diff options
author | José Luis Millán <jmillan@aliax.net> | 2023-03-03 08:35:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-02 23:35:59 -0800 |
commit | 3e778aca4d7ab763835a8130b909554f44f844df (patch) | |
tree | 04b30218e307b6d13150d1f29ee162792ac166bd | |
parent | 01f41386180ddc6f251a13ad11889bf9ce7b9e00 (diff) | |
download | flatbuffers-3e778aca4d7ab763835a8130b909554f44f844df.tar.gz flatbuffers-3e778aca4d7ab763835a8130b909554f44f844df.tar.bz2 flatbuffers-3e778aca4d7ab763835a8130b909554f44f844df.zip |
TS/JS: Export object based classes on entry (#7822)
* TS/JS: Export object based classes on entry
Along with the non object ones, for consistency. This is a regression
introduced recently.
Before:
`export { UpdateSettingsRequest } from './worker/update-settings-request.js';`
Now:
`export { UpdateSettingsRequest, UpdateSettingsRequestT } from './worker/update-settings-request.js';`
* only export object based classes for structs
Enums are not elegible.
---------
Co-authored-by: Björn Harrtell <bjornharrtell@users.noreply.github.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
29 files changed, 187 insertions, 113 deletions
diff --git a/src/idl_gen_ts.cpp b/src/idl_gen_ts.cpp index a3e1f127..af0836ac 100644 --- a/src/idl_gen_ts.cpp +++ b/src/idl_gen_ts.cpp @@ -255,7 +255,6 @@ class TsGenerator : public BaseGenerator { for (const auto &it : ns_defs_) { code = "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n"; - // export all definitions in ns entry point module int export_counter = 0; for (const auto &def : it.second.definitions) { @@ -281,7 +280,14 @@ class TsGenerator : public BaseGenerator { base_name_rel += base_file_name; auto ts_file_path_rel = base_name_rel + ".ts"; auto type_name = def.first; - code += "export { " + type_name + " } from '"; + auto fully_qualified_type_name = + it.second.ns->GetFullyQualifiedName(type_name); + auto is_struct = parser_.structs_.Lookup(fully_qualified_type_name); + code += "export { " + type_name; + if (parser_.opts.generate_object_based_api && is_struct) { + code += ", " + type_name + parser_.opts.object_suffix; + } + code += " } from '"; std::string import_extension = parser_.opts.ts_no_import_ext ? "" : ".js"; code += base_name_rel + import_extension + "';\n"; diff --git a/tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs b/tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs index 35f3db73..ec2df633 100644 --- a/tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs +++ b/tests/ts/arrays_test_complex/arrays_test_complex_generated.cjs @@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => { return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); @@ -27,10 +31,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru var example_exports = {}; __export(example_exports, { ArrayStruct: () => ArrayStruct, + ArrayStructT: () => ArrayStructT, ArrayTable: () => ArrayTable, + ArrayTableT: () => ArrayTableT, InnerStruct: () => InnerStruct, + InnerStructT: () => InnerStructT, NestedStruct: () => NestedStruct, + NestedStructT: () => NestedStructT, OuterStruct: () => OuterStruct, + OuterStructT: () => OuterStructT, TestEnum: () => TestEnum }); module.exports = __toCommonJS(example_exports); diff --git a/tests/ts/arrays_test_complex/my-game/example.d.ts b/tests/ts/arrays_test_complex/my-game/example.d.ts index 93eb5251..a3c1a81e 100644 --- a/tests/ts/arrays_test_complex/my-game/example.d.ts +++ b/tests/ts/arrays_test_complex/my-game/example.d.ts @@ -1,6 +1,6 @@ -export { ArrayStruct } from './example/array-struct.js'; -export { ArrayTable } from './example/array-table.js'; -export { InnerStruct } from './example/inner-struct.js'; -export { NestedStruct } from './example/nested-struct.js'; -export { OuterStruct } from './example/outer-struct.js'; +export { ArrayStruct, ArrayStructT } from './example/array-struct.js'; +export { ArrayTable, ArrayTableT } from './example/array-table.js'; +export { InnerStruct, InnerStructT } from './example/inner-struct.js'; +export { NestedStruct, NestedStructT } from './example/nested-struct.js'; +export { OuterStruct, OuterStructT } from './example/outer-struct.js'; export { TestEnum } from './example/test-enum.js'; diff --git a/tests/ts/arrays_test_complex/my-game/example.js b/tests/ts/arrays_test_complex/my-game/example.js index bc149dab..78d5ab69 100644 --- a/tests/ts/arrays_test_complex/my-game/example.js +++ b/tests/ts/arrays_test_complex/my-game/example.js @@ -1,7 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { ArrayStruct } from './example/array-struct.js'; -export { ArrayTable } from './example/array-table.js'; -export { InnerStruct } from './example/inner-struct.js'; -export { NestedStruct } from './example/nested-struct.js'; -export { OuterStruct } from './example/outer-struct.js'; +export { ArrayStruct, ArrayStructT } from './example/array-struct.js'; +export { ArrayTable, ArrayTableT } from './example/array-table.js'; +export { InnerStruct, InnerStructT } from './example/inner-struct.js'; +export { NestedStruct, NestedStructT } from './example/nested-struct.js'; +export { OuterStruct, OuterStructT } from './example/outer-struct.js'; export { TestEnum } from './example/test-enum.js'; diff --git a/tests/ts/arrays_test_complex/my-game/example.ts b/tests/ts/arrays_test_complex/my-game/example.ts index 9643b93b..da121608 100644 --- a/tests/ts/arrays_test_complex/my-game/example.ts +++ b/tests/ts/arrays_test_complex/my-game/example.ts @@ -1,8 +1,8 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { ArrayStruct } from './example/array-struct.js'; -export { ArrayTable } from './example/array-table.js'; -export { InnerStruct } from './example/inner-struct.js'; -export { NestedStruct } from './example/nested-struct.js'; -export { OuterStruct } from './example/outer-struct.js'; +export { ArrayStruct, ArrayStructT } from './example/array-struct.js'; +export { ArrayTable, ArrayTableT } from './example/array-table.js'; +export { InnerStruct, InnerStructT } from './example/inner-struct.js'; +export { NestedStruct, NestedStructT } from './example/nested-struct.js'; +export { OuterStruct, OuterStructT } from './example/outer-struct.js'; export { TestEnum } from './example/test-enum.js'; diff --git a/tests/ts/monster_test.d.ts b/tests/ts/monster_test.d.ts index b8d81d45..e89d898e 100644 --- a/tests/ts/monster_test.d.ts +++ b/tests/ts/monster_test.d.ts @@ -1,2 +1,2 @@ -export { TableA } from './table-a.js'; +export { TableA, TableAT } from './table-a.js'; export * as MyGame from './my-game.js'; diff --git a/tests/ts/monster_test.js b/tests/ts/monster_test.js index da2897c6..a378544c 100644 --- a/tests/ts/monster_test.js +++ b/tests/ts/monster_test.js @@ -1,3 +1,3 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { TableA } from './table-a.js'; +export { TableA, TableAT } from './table-a.js'; export * as MyGame from './my-game.js'; diff --git a/tests/ts/monster_test.ts b/tests/ts/monster_test.ts index 771db3b3..7aebadfe 100644 --- a/tests/ts/monster_test.ts +++ b/tests/ts/monster_test.ts @@ -1,4 +1,4 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { TableA } from './table-a.js'; +export { TableA, TableAT } from './table-a.js'; export * as MyGame from './my-game.js'; diff --git a/tests/ts/monster_test_generated.cjs b/tests/ts/monster_test_generated.cjs index eafb6a4a..8eb338e6 100644 --- a/tests/ts/monster_test_generated.cjs +++ b/tests/ts/monster_test_generated.cjs @@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => { return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); @@ -27,7 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru var monster_test_exports = {}; __export(monster_test_exports, { MyGame: () => my_game_exports, - TableA: () => TableA + TableA: () => TableA, + TableAT: () => TableAT }); module.exports = __toCommonJS(monster_test_exports); @@ -167,6 +172,7 @@ __export(my_game_exports, { Example: () => example_exports, Example2: () => example2_exports, InParentNamespace: () => InParentNamespace, + InParentNamespaceT: () => InParentNamespaceT, OtherNameSpace: () => other_name_space_exports }); @@ -227,21 +233,31 @@ var InParentNamespaceT = class { var example_exports = {}; __export(example_exports, { Ability: () => Ability, + AbilityT: () => AbilityT, Any: () => Any, AnyAmbiguousAliases: () => AnyAmbiguousAliases, AnyUniqueAliases: () => AnyUniqueAliases, Color: () => Color, LongEnum: () => LongEnum, Monster: () => Monster2, + MonsterT: () => MonsterT2, Race: () => Race, Referrable: () => Referrable, + ReferrableT: () => ReferrableT, Stat: () => Stat, + StatT: () => StatT, StructOfStructs: () => StructOfStructs, StructOfStructsOfStructs: () => StructOfStructsOfStructs, + StructOfStructsOfStructsT: () => StructOfStructsOfStructsT, + StructOfStructsT: () => StructOfStructsT, Test: () => Test, TestSimpleTableWithEnum: () => TestSimpleTableWithEnum, + TestSimpleTableWithEnumT: () => TestSimpleTableWithEnumT, + TestT: () => TestT, TypeAliases: () => TypeAliases, - Vec3: () => Vec3 + TypeAliasesT: () => TypeAliasesT, + Vec3: () => Vec3, + Vec3T: () => Vec3T }); // my-game/example/ability.js @@ -916,6 +932,10 @@ var Monster2 = class { const offset = this.bb.__offset(this.bb_pos, 24); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } + /** + * an example documentation comment: this will end up in the generated code + * multiline too + */ testarrayoftables(index, obj) { const offset = this.bb.__offset(this.bb_pos, 26); return offset ? (obj || new Monster2()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; @@ -2502,7 +2522,8 @@ var TypeAliasesT = class { // my-game/example2.js var example2_exports = {}; __export(example2_exports, { - Monster: () => Monster + Monster: () => Monster, + MonsterT: () => MonsterT }); // my-game/other-name-space.js @@ -2510,7 +2531,9 @@ var other_name_space_exports = {}; __export(other_name_space_exports, { FromInclude: () => FromInclude, TableB: () => TableB, - Unused: () => Unused + TableBT: () => TableBT, + Unused: () => Unused, + UnusedT: () => UnusedT }); // my-game/other-name-space/from-include.js diff --git a/tests/ts/my-game.d.ts b/tests/ts/my-game.d.ts index b7f6e9d3..e82f8a31 100644 --- a/tests/ts/my-game.d.ts +++ b/tests/ts/my-game.d.ts @@ -1,4 +1,4 @@ -export { InParentNamespace } from './my-game/in-parent-namespace.js'; +export { InParentNamespace, InParentNamespaceT } from './my-game/in-parent-namespace.js'; export * as Example from './my-game/example.js'; export * as Example2 from './my-game/example2.js'; export * as OtherNameSpace from './my-game/other-name-space.js'; diff --git a/tests/ts/my-game.js b/tests/ts/my-game.js index 9db431c1..75f45820 100644 --- a/tests/ts/my-game.js +++ b/tests/ts/my-game.js @@ -1,5 +1,5 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { InParentNamespace } from './my-game/in-parent-namespace.js'; +export { InParentNamespace, InParentNamespaceT } from './my-game/in-parent-namespace.js'; export * as Example from './my-game/example.js'; export * as Example2 from './my-game/example2.js'; export * as OtherNameSpace from './my-game/other-name-space.js'; diff --git a/tests/ts/my-game.ts b/tests/ts/my-game.ts index 01779164..8981f325 100644 --- a/tests/ts/my-game.ts +++ b/tests/ts/my-game.ts @@ -1,6 +1,6 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { InParentNamespace } from './my-game/in-parent-namespace.js'; +export { InParentNamespace, InParentNamespaceT } from './my-game/in-parent-namespace.js'; export * as Example from './my-game/example.js'; export * as Example2 from './my-game/example2.js'; export * as OtherNameSpace from './my-game/other-name-space.js'; diff --git a/tests/ts/my-game/example.d.ts b/tests/ts/my-game/example.d.ts index 076bdf58..a09b7f84 100644 --- a/tests/ts/my-game/example.d.ts +++ b/tests/ts/my-game/example.d.ts @@ -1,16 +1,16 @@ -export { Ability } from './example/ability.js'; +export { Ability, AbilityT } from './example/ability.js'; export { Any } from './example/any.js'; export { AnyAmbiguousAliases } from './example/any-ambiguous-aliases.js'; export { AnyUniqueAliases } from './example/any-unique-aliases.js'; export { Color } from './example/color.js'; export { LongEnum } from './example/long-enum.js'; -export { Monster } from './example/monster.js'; +export { Monster, MonsterT } from './example/monster.js'; export { Race } from './example/race.js'; -export { Referrable } from './example/referrable.js'; -export { Stat } from './example/stat.js'; -export { StructOfStructs } from './example/struct-of-structs.js'; -export { StructOfStructsOfStructs } from './example/struct-of-structs-of-structs.js'; -export { Test } from './example/test.js'; -export { TestSimpleTableWithEnum } from './example/test-simple-table-with-enum.js'; -export { TypeAliases } from './example/type-aliases.js'; -export { Vec3 } from './example/vec3.js'; +export { Referrable, ReferrableT } from './example/referrable.js'; +export { Stat, StatT } from './example/stat.js'; +export { StructOfStructs, StructOfStructsT } from './example/struct-of-structs.js'; +export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './example/struct-of-structs-of-structs.js'; +export { Test, TestT } from './example/test.js'; +export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './example/test-simple-table-with-enum.js'; +export { TypeAliases, TypeAliasesT } from './example/type-aliases.js'; +export { Vec3, Vec3T } from './example/vec3.js'; diff --git a/tests/ts/my-game/example.js b/tests/ts/my-game/example.js index e0236541..d7e502db 100644 --- a/tests/ts/my-game/example.js +++ b/tests/ts/my-game/example.js @@ -1,17 +1,17 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { Ability } from './example/ability.js'; +export { Ability, AbilityT } from './example/ability.js'; export { Any } from './example/any.js'; export { AnyAmbiguousAliases } from './example/any-ambiguous-aliases.js'; export { AnyUniqueAliases } from './example/any-unique-aliases.js'; export { Color } from './example/color.js'; export { LongEnum } from './example/long-enum.js'; -export { Monster } from './example/monster.js'; +export { Monster, MonsterT } from './example/monster.js'; export { Race } from './example/race.js'; -export { Referrable } from './example/referrable.js'; -export { Stat } from './example/stat.js'; -export { StructOfStructs } from './example/struct-of-structs.js'; -export { StructOfStructsOfStructs } from './example/struct-of-structs-of-structs.js'; -export { Test } from './example/test.js'; -export { TestSimpleTableWithEnum } from './example/test-simple-table-with-enum.js'; -export { TypeAliases } from './example/type-aliases.js'; -export { Vec3 } from './example/vec3.js'; +export { Referrable, ReferrableT } from './example/referrable.js'; +export { Stat, StatT } from './example/stat.js'; +export { StructOfStructs, StructOfStructsT } from './example/struct-of-structs.js'; +export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './example/struct-of-structs-of-structs.js'; +export { Test, TestT } from './example/test.js'; +export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './example/test-simple-table-with-enum.js'; +export { TypeAliases, TypeAliasesT } from './example/type-aliases.js'; +export { Vec3, Vec3T } from './example/vec3.js'; diff --git a/tests/ts/my-game/example.ts b/tests/ts/my-game/example.ts index fbfb45d5..80ddc487 100644 --- a/tests/ts/my-game/example.ts +++ b/tests/ts/my-game/example.ts @@ -1,18 +1,18 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { Ability } from './example/ability.js'; +export { Ability, AbilityT } from './example/ability.js'; export { Any } from './example/any.js'; export { AnyAmbiguousAliases } from './example/any-ambiguous-aliases.js'; export { AnyUniqueAliases } from './example/any-unique-aliases.js'; export { Color } from './example/color.js'; export { LongEnum } from './example/long-enum.js'; -export { Monster } from './example/monster.js'; +export { Monster, MonsterT } from './example/monster.js'; export { Race } from './example/race.js'; -export { Referrable } from './example/referrable.js'; -export { Stat } from './example/stat.js'; -export { StructOfStructs } from './example/struct-of-structs.js'; -export { StructOfStructsOfStructs } from './example/struct-of-structs-of-structs.js'; -export { Test } from './example/test.js'; -export { TestSimpleTableWithEnum } from './example/test-simple-table-with-enum.js'; -export { TypeAliases } from './example/type-aliases.js'; -export { Vec3 } from './example/vec3.js'; +export { Referrable, ReferrableT } from './example/referrable.js'; +export { Stat, StatT } from './example/stat.js'; +export { StructOfStructs, StructOfStructsT } from './example/struct-of-structs.js'; +export { StructOfStructsOfStructs, StructOfStructsOfStructsT } from './example/struct-of-structs-of-structs.js'; +export { Test, TestT } from './example/test.js'; +export { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from './example/test-simple-table-with-enum.js'; +export { TypeAliases, TypeAliasesT } from './example/type-aliases.js'; +export { Vec3, Vec3T } from './example/vec3.js'; diff --git a/tests/ts/my-game/example2.d.ts b/tests/ts/my-game/example2.d.ts index 6d0d7508..4aebab97 100644 --- a/tests/ts/my-game/example2.d.ts +++ b/tests/ts/my-game/example2.d.ts @@ -1 +1 @@ -export { Monster } from './example2/monster.js'; +export { Monster, MonsterT } from './example2/monster.js'; diff --git a/tests/ts/my-game/example2.js b/tests/ts/my-game/example2.js index edab044c..796233a3 100644 --- a/tests/ts/my-game/example2.js +++ b/tests/ts/my-game/example2.js @@ -1,2 +1,2 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { Monster } from './example2/monster.js'; +export { Monster, MonsterT } from './example2/monster.js'; diff --git a/tests/ts/my-game/example2.ts b/tests/ts/my-game/example2.ts index faf5b638..bc48a5cb 100644 --- a/tests/ts/my-game/example2.ts +++ b/tests/ts/my-game/example2.ts @@ -1,3 +1,3 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { Monster } from './example2/monster.js'; +export { Monster, MonsterT } from './example2/monster.js'; diff --git a/tests/ts/my-game/other-name-space.d.ts b/tests/ts/my-game/other-name-space.d.ts index d6cab69e..3152eff5 100644 --- a/tests/ts/my-game/other-name-space.d.ts +++ b/tests/ts/my-game/other-name-space.d.ts @@ -1,3 +1,3 @@ export { FromInclude } from './other-name-space/from-include.js'; -export { TableB } from './other-name-space/table-b.js'; -export { Unused } from './other-name-space/unused.js'; +export { TableB, TableBT } from './other-name-space/table-b.js'; +export { Unused, UnusedT } from './other-name-space/unused.js'; diff --git a/tests/ts/my-game/other-name-space.js b/tests/ts/my-game/other-name-space.js index 12e8e5a6..bc3afbfb 100644 --- a/tests/ts/my-game/other-name-space.js +++ b/tests/ts/my-game/other-name-space.js @@ -1,4 +1,4 @@ // automatically generated by the FlatBuffers compiler, do not modify export { FromInclude } from './other-name-space/from-include.js'; -export { TableB } from './other-name-space/table-b.js'; -export { Unused } from './other-name-space/unused.js'; +export { TableB, TableBT } from './other-name-space/table-b.js'; +export { Unused, UnusedT } from './other-name-space/unused.js'; diff --git a/tests/ts/my-game/other-name-space.ts b/tests/ts/my-game/other-name-space.ts index ea4a261f..eb3679fb 100644 --- a/tests/ts/my-game/other-name-space.ts +++ b/tests/ts/my-game/other-name-space.ts @@ -1,5 +1,5 @@ // automatically generated by the FlatBuffers compiler, do not modify export { FromInclude } from './other-name-space/from-include.js'; -export { TableB } from './other-name-space/table-b.js'; -export { Unused } from './other-name-space/unused.js'; +export { TableB, TableBT } from './other-name-space/table-b.js'; +export { Unused, UnusedT } from './other-name-space/unused.js'; diff --git a/tests/ts/reflection.d.ts b/tests/ts/reflection.d.ts index f296e54f..5e1f8769 100644 --- a/tests/ts/reflection.d.ts +++ b/tests/ts/reflection.d.ts @@ -1,12 +1,12 @@ export { AdvancedFeatures } from './reflection/advanced-features.js'; export { BaseType } from './reflection/base-type.js'; -export { Enum } from './reflection/enum.js'; -export { EnumVal } from './reflection/enum-val.js'; -export { Field } from './reflection/field.js'; -export { KeyValue } from './reflection/key-value.js'; +export { Enum, EnumT } from './reflection/enum.js'; +export { EnumVal, EnumValT } from './reflection/enum-val.js'; +export { Field, FieldT } from './reflection/field.js'; +export { KeyValue, KeyValueT } from './reflection/key-value.js'; export { Object_ } from './reflection/object.js'; -export { RPCCall } from './reflection/rpccall.js'; -export { Schema } from './reflection/schema.js'; -export { SchemaFile } from './reflection/schema-file.js'; -export { Service } from './reflection/service.js'; -export { Type } from './reflection/type.js'; +export { RPCCall, RPCCallT } from './reflection/rpccall.js'; +export { Schema, SchemaT } from './reflection/schema.js'; +export { SchemaFile, SchemaFileT } from './reflection/schema-file.js'; +export { Service, ServiceT } from './reflection/service.js'; +export { Type, TypeT } from './reflection/type.js'; diff --git a/tests/ts/reflection.js b/tests/ts/reflection.js index 881519a2..b3239724 100644 --- a/tests/ts/reflection.js +++ b/tests/ts/reflection.js @@ -1,13 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify export { AdvancedFeatures } from './reflection/advanced-features.js'; export { BaseType } from './reflection/base-type.js'; -export { Enum } from './reflection/enum.js'; -export { EnumVal } from './reflection/enum-val.js'; -export { Field } from './reflection/field.js'; -export { KeyValue } from './reflection/key-value.js'; +export { Enum, EnumT } from './reflection/enum.js'; +export { EnumVal, EnumValT } from './reflection/enum-val.js'; +export { Field, FieldT } from './reflection/field.js'; +export { KeyValue, KeyValueT } from './reflection/key-value.js'; export { Object_ } from './reflection/object.js'; -export { RPCCall } from './reflection/rpccall.js'; -export { Schema } from './reflection/schema.js'; -export { SchemaFile } from './reflection/schema-file.js'; -export { Service } from './reflection/service.js'; -export { Type } from './reflection/type.js'; +export { RPCCall, RPCCallT } from './reflection/rpccall.js'; +export { Schema, SchemaT } from './reflection/schema.js'; +export { SchemaFile, SchemaFileT } from './reflection/schema-file.js'; +export { Service, ServiceT } from './reflection/service.js'; +export { Type, TypeT } from './reflection/type.js'; diff --git a/tests/ts/reflection.ts b/tests/ts/reflection.ts index 8440332d..d62f1dcf 100644 --- a/tests/ts/reflection.ts +++ b/tests/ts/reflection.ts @@ -2,13 +2,13 @@ export { AdvancedFeatures } from './reflection/advanced-features.js'; export { BaseType } from './reflection/base-type.js'; -export { Enum } from './reflection/enum.js'; -export { EnumVal } from './reflection/enum-val.js'; -export { Field } from './reflection/field.js'; -export { KeyValue } from './reflection/key-value.js'; +export { Enum, EnumT } from './reflection/enum.js'; +export { EnumVal, EnumValT } from './reflection/enum-val.js'; +export { Field, FieldT } from './reflection/field.js'; +export { KeyValue, KeyValueT } from './reflection/key-value.js'; export { Object_ } from './reflection/object.js'; -export { RPCCall } from './reflection/rpccall.js'; -export { Schema } from './reflection/schema.js'; -export { SchemaFile } from './reflection/schema-file.js'; -export { Service } from './reflection/service.js'; -export { Type } from './reflection/type.js'; +export { RPCCall, RPCCallT } from './reflection/rpccall.js'; +export { Schema, SchemaT } from './reflection/schema.js'; +export { SchemaFile, SchemaFileT } from './reflection/schema-file.js'; +export { Service, ServiceT } from './reflection/service.js'; +export { Type, TypeT } from './reflection/type.js'; diff --git a/tests/ts/typescript_keywords_generated.cjs b/tests/ts/typescript_keywords_generated.cjs index 65601436..5e2e1a87 100644 --- a/tests/ts/typescript_keywords_generated.cjs +++ b/tests/ts/typescript_keywords_generated.cjs @@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => { return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); @@ -50,15 +54,24 @@ __export(reflection_exports, { AdvancedFeatures: () => AdvancedFeatures, BaseType: () => BaseType, Enum: () => Enum, + EnumT: () => EnumT, EnumVal: () => EnumVal, + EnumValT: () => EnumValT, Field: () => Field, + FieldT: () => FieldT, KeyValue: () => KeyValue, + KeyValueT: () => KeyValueT, Object_: () => Object_, RPCCall: () => RPCCall, + RPCCallT: () => RPCCallT, Schema: () => Schema, SchemaFile: () => SchemaFile, + SchemaFileT: () => SchemaFileT, + SchemaT: () => SchemaT, Service: () => Service, - Type: () => Type + ServiceT: () => ServiceT, + Type: () => Type, + TypeT: () => TypeT }); // reflection/advanced-features.js @@ -237,6 +250,9 @@ var Type = class { this.bb.writeUint16(this.bb_pos + offset, value); return true; } + /** + * The size (octets) of the `base_type` field. + */ baseSize() { const offset = this.bb.__offset(this.bb_pos, 12); return offset ? this.bb.readUint32(this.bb_pos + offset) : 4; @@ -249,6 +265,9 @@ var Type = class { this.bb.writeUint32(this.bb_pos + offset, value); return true; } + /** + * The size (octets) of the `element` field, if present. + */ elementSize() { const offset = this.bb.__offset(this.bb_pos, 14); return offset ? this.bb.readUint32(this.bb_pos + offset) : 0; @@ -770,6 +789,9 @@ var Field = class { this.bb.writeInt8(this.bb_pos + offset, +value); return true; } + /** + * Number of padding octets to always add after this field. Structs only. + */ padding() { const offset = this.bb.__offset(this.bb_pos, 28); return offset ? this.bb.readUint16(this.bb_pos + offset) : 0; @@ -1542,6 +1564,10 @@ var Schema = class { this.bb.writeUint64(this.bb_pos + offset, value); return true; } + /** + * All the files used in this compilation. Files are relative to where + * flatc was invoked. + */ fbsFiles(index, obj) { const offset = this.bb.__offset(this.bb_pos, 18); return offset ? (obj || new SchemaFile()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; diff --git a/tests/ts/union_vector/union_vector.d.ts b/tests/ts/union_vector/union_vector.d.ts index 3e2be4f4..ebd93797 100644 --- a/tests/ts/union_vector/union_vector.d.ts +++ b/tests/ts/union_vector/union_vector.d.ts @@ -1,8 +1,8 @@ -export { Attacker } from './attacker.js'; -export { BookReader } from './book-reader.js'; +export { Attacker, AttackerT } from './attacker.js'; +export { BookReader, BookReaderT } from './book-reader.js'; export { Character } from './character.js'; -export { FallingTub } from './falling-tub.js'; +export { FallingTub, FallingTubT } from './falling-tub.js'; export { Gadget } from './gadget.js'; -export { HandFan } from './hand-fan.js'; -export { Movie } from './movie.js'; -export { Rapunzel } from './rapunzel.js'; +export { HandFan, HandFanT } from './hand-fan.js'; +export { Movie, MovieT } from './movie.js'; +export { Rapunzel, RapunzelT } from './rapunzel.js'; diff --git a/tests/ts/union_vector/union_vector.js b/tests/ts/union_vector/union_vector.js index 29b895f5..3e9b22bd 100644 --- a/tests/ts/union_vector/union_vector.js +++ b/tests/ts/union_vector/union_vector.js @@ -1,9 +1,9 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { Attacker } from './attacker.js'; -export { BookReader } from './book-reader.js'; +export { Attacker, AttackerT } from './attacker.js'; +export { BookReader, BookReaderT } from './book-reader.js'; export { Character } from './character.js'; -export { FallingTub } from './falling-tub.js'; +export { FallingTub, FallingTubT } from './falling-tub.js'; export { Gadget } from './gadget.js'; -export { HandFan } from './hand-fan.js'; -export { Movie } from './movie.js'; -export { Rapunzel } from './rapunzel.js'; +export { HandFan, HandFanT } from './hand-fan.js'; +export { Movie, MovieT } from './movie.js'; +export { Rapunzel, RapunzelT } from './rapunzel.js'; diff --git a/tests/ts/union_vector/union_vector.ts b/tests/ts/union_vector/union_vector.ts index 22209859..79401d2b 100644 --- a/tests/ts/union_vector/union_vector.ts +++ b/tests/ts/union_vector/union_vector.ts @@ -1,10 +1,10 @@ // automatically generated by the FlatBuffers compiler, do not modify -export { Attacker } from './attacker.js'; -export { BookReader } from './book-reader.js'; +export { Attacker, AttackerT } from './attacker.js'; +export { BookReader, BookReaderT } from './book-reader.js'; export { Character } from './character.js'; -export { FallingTub } from './falling-tub.js'; +export { FallingTub, FallingTubT } from './falling-tub.js'; export { Gadget } from './gadget.js'; -export { HandFan } from './hand-fan.js'; -export { Movie } from './movie.js'; -export { Rapunzel } from './rapunzel.js'; +export { HandFan, HandFanT } from './hand-fan.js'; +export { Movie, MovieT } from './movie.js'; +export { Rapunzel, RapunzelT } from './rapunzel.js'; diff --git a/tests/ts/union_vector/union_vector_generated.cjs b/tests/ts/union_vector/union_vector_generated.cjs index 0677b137..b63140cd 100644 --- a/tests/ts/union_vector/union_vector_generated.cjs +++ b/tests/ts/union_vector/union_vector_generated.cjs @@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => { return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); @@ -27,13 +31,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru var union_vector_exports = {}; __export(union_vector_exports, { Attacker: () => Attacker, + AttackerT: () => AttackerT, BookReader: () => BookReader, + BookReaderT: () => BookReaderT, Character: () => Character, FallingTub: () => FallingTub, + FallingTubT: () => FallingTubT, Gadget: () => Gadget, HandFan: () => HandFan, + HandFanT: () => HandFanT, Movie: () => Movie, - Rapunzel: () => Rapunzel + MovieT: () => MovieT, + Rapunzel: () => Rapunzel, + RapunzelT: () => RapunzelT }); module.exports = __toCommonJS(union_vector_exports); |