[TS] Add single-file ts codegen & bazel rule for typescript (#7161)

The headline here is adding a flatbuffer_ts_library rule for generating
typescript code in bazel. This entails some non-trivial other changes,
but ideally none are user-visible.

In particular:
* Added a --ts-flat-file flag that generates a single *_generated.ts
  file instead of separate files for each typescript type. This makes
  bazel much happier.
* Import the bazel rules_nodejs stuff needed to support building
  typescript in bazel
* Move flatbuffers.ts to index.ts because I wasn't sure how to make
  bazel comprehend the "main" attribute of the package.json. Happy
  to take another stab at figuring that out if really needed.
* Fix another couple keyword escaping spots in typescript...
This commit is contained in:
James Kuszmaul
2022-03-10 10:08:13 -08:00
committed by GitHub
parent 2f84c60385
commit e5f331db99
19 changed files with 1549 additions and 39 deletions

View File

@@ -25,7 +25,8 @@ if [ -x ../flatc ]; then
../flatc --gen-object-api -b -I include_test monster_test.fbs unicode_test.json
../flatc --ts --gen-name-strings --gen-mutable --gen-object-api -o union_vector union_vector/union_vector.fbs
../flatc --ts --gen-name-strings optional_scalars.fbs
../flatc --ts --gen-name-strings --gen-object-api --gen-mutable typescript_keywords.fbs
../flatc --ts --gen-name-strings --gen-object-api --gen-mutable -I ../ ./typescript_keywords.fbs test_dir/typescript_include.fbs test_dir/typescript_transitive_include.fbs ../reflection/reflection.fbs
../flatc --ts --gen-name-strings --gen-object-api --gen-mutable --ts-flat-files -I ../ ./typescript_keywords.fbs test_dir/typescript_include.fbs test_dir/typescript_transitive_include.fbs ../reflection/reflection.fbs
fi
tsc
node -r esm JavaScriptTest