mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-11 23:40:57 +00:00
[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:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
15
tests/typescript_keywords.fbs
Normal file
15
tests/typescript_keywords.fbs
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user