[TS] Escape keywords in typescript object names (#7137)

* Add Object to the list of reserved keywords.
* Properly escape keywords in type names.
* Properly escape keywords in enum names.
* Properly escape keywords in enum field names.
This commit is contained in:
James Kuszmaul
2022-03-05 09:39:59 -08:00
committed by GitHub
parent 9ed1323044
commit 8db2fef3f7
4 changed files with 47 additions and 22 deletions

View File

@@ -25,6 +25,7 @@ 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
fi
tsc
node -r esm JavaScriptTest

View File

@@ -14,7 +14,9 @@
},
"include": [
"monster_test.ts",
"typescript_keywords.ts",
"my-game/**/*.ts",
"typescript/**/*.ts",
"optional_scalars/**/*.ts",
"namespace_test/**/*.ts",
"union_vector/**/*.ts"

View File

@@ -0,0 +1,15 @@
// This file includes a variety of keywords meant to deliberately interfere
// with typescript keywords.
namespace typescript;
enum class: int {
new,
instanceof,
}
table Object {
return:int;
if:int;
switch:int;
enum:class;
}