Fix up a bunch of typescript issues
These came to light with the typescript compiler upgrade that is
coming up soon with the bazel upgrade.
A lot of the changes in this patch arose from the changes in the
imports. For some reason we can no longer import modules the way we
used to. I'm not really sure how it ever worked. The upstream
documentation agrees with the changes we had to make here. It's
possible that the old version of typescript simply did things
differently when it comes to importing modules.
Change-Id: I054b5269c90cc94276e9f856d8cd79c8de2946f2
diff --git a/third_party/flatbuffers/BUILD b/third_party/flatbuffers/BUILD
index 346f9a6..3114495 100644
--- a/third_party/flatbuffers/BUILD
+++ b/third_party/flatbuffers/BUILD
@@ -8,13 +8,14 @@
exports_files([
"LICENSE",
+ "tsconfig.json",
])
# Public flatc library to compile flatbuffer files at runtime.
cc_library(
name = "flatbuffers",
- copts = ["-Wno-cast-align"],
hdrs = ["//:public_headers"],
+ copts = ["-Wno-cast-align"],
linkstatic = 1,
strip_include_prefix = "/include",
deps = ["//src:flatbuffers"],
@@ -82,6 +83,7 @@
linkstatic = 1,
strip_include_prefix = "/include",
)
+
py_library(
name = "flatpy",
srcs = glob(["python/flatbuffers/*.py"]),
diff --git a/third_party/flatbuffers/ts/BUILD b/third_party/flatbuffers/ts/BUILD
new file mode 100644
index 0000000..ad59551
--- /dev/null
+++ b/third_party/flatbuffers/ts/BUILD
@@ -0,0 +1,16 @@
+load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
+
+ts_library(
+ name = "flatbuffers_ts",
+ srcs = [
+ "builder.ts",
+ "byte-buffer.ts",
+ "constants.ts",
+ "encoding.ts",
+ "flatbuffers.ts",
+ "long.ts",
+ "types.ts",
+ "utils.ts",
+ ],
+ visibility = ["//visibility:public"],
+)
diff --git a/third_party/flatbuffers/ts/builder.ts b/third_party/flatbuffers/ts/builder.ts
index 6be72fb..137031e 100644
--- a/third_party/flatbuffers/ts/builder.ts
+++ b/third_party/flatbuffers/ts/builder.ts
@@ -604,7 +604,7 @@
* @returns list of offsets of each non null object
*/
createObjectOffsetList(list: string[]): Offset[] {
- const ret = [];
+ const ret: number[] = [];
for(let i = 0; i < list.length; ++i) {
const val = list[i];
@@ -625,4 +625,4 @@
this.createObjectOffsetList(list);
return this.endVector();
}
- }
\ No newline at end of file
+ }
diff --git a/third_party/flatbuffers/tsconfig.json b/third_party/flatbuffers/tsconfig.json
index 9af4075..d480e1b 100644
--- a/third_party/flatbuffers/tsconfig.json
+++ b/third_party/flatbuffers/tsconfig.json
@@ -1,16 +1,12 @@
{
"compilerOptions": {
- "target": "ES5",
- "module": "commonjs",
- "lib": ["ES2015", "ES2020.BigInt", "DOM"],
- "declaration": true,
- "outDir": "./js",
+ "experimentalDecorators": true,
"strict": true,
- "esModuleInterop": true,
- "skipLibCheck": true,
- "forceConsistentCasingInFileNames": true
+ "noImplicitAny": false,
+ "target": "es6",
+ "lib": ["es6", "dom"]
},
- "include": [
- "ts/**/*.ts"
- ]
+ "bazelOptions": {
+ "workspaceName": "flatbuffers"
+ }
}