diff options
author | Björn Harrtell <bjornharrtell@users.noreply.github.com> | 2022-09-30 00:03:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-29 15:03:35 -0700 |
commit | d243b904cc5866eb2089c898412f4aba7a0eaf61 (patch) | |
tree | 93f19b0acc31f0312e06d6c9ee291cb14dcb37d5 /tests/ts | |
parent | 374f8fb5fbd698c2e5719076c82224fe06542d18 (diff) | |
download | flatbuffers-d243b904cc5866eb2089c898412f4aba7a0eaf61.tar.gz flatbuffers-d243b904cc5866eb2089c898412f4aba7a0eaf61.tar.bz2 flatbuffers-d243b904cc5866eb2089c898412f4aba7a0eaf61.zip |
[TS] Make strict compliant and improve typings (#7549)
* [TS] Make strict compliant and improve typings
* clang-format
* Code gen harmonize
Co-authored-by: Derek Bailey <derekbailey@google.com>
Diffstat (limited to 'tests/ts')
34 files changed, 235 insertions, 234 deletions
diff --git a/tests/ts/TypeScriptTest.py b/tests/ts/TypeScriptTest.py index c95ed722..0b42bc63 100755 --- a/tests/ts/TypeScriptTest.py +++ b/tests/ts/TypeScriptTest.py @@ -61,7 +61,7 @@ check_call(["npm", "install", "--silent"]) print("Invoking flatc...") flatc( - options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], + options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], schema="../monster_test.fbs", include="../include_test", ) @@ -74,18 +74,18 @@ flatc( ) flatc( - options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], + options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], schema="../union_vector/union_vector.fbs", prefix="union_vector", ) flatc( - options=["--ts", "--gen-name-strings"], + options=["--ts", "--reflect-names", "--gen-name-strings"], schema="../optional_scalars.fbs", ) flatc( - options=["--ts", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], + options=["--ts", "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api"], schema=[ "typescript_keywords.fbs", "test_dir/typescript_include.fbs", @@ -98,6 +98,7 @@ flatc( flatc( options=[ "--ts", + "--reflect-names", "--gen-name-strings", "--gen-mutable", "--gen-object-api", diff --git a/tests/ts/my-game/example/ability.ts b/tests/ts/my-game/example/ability.ts index 36b0eb81..b0bea8fe 100644 --- a/tests/ts/my-game/example/ability.ts +++ b/tests/ts/my-game/example/ability.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class Ability { +export class Ability implements flatbuffers.IUnpackableObject<AbilityT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Ability { @@ -61,7 +61,7 @@ unpackTo(_o: AbilityT): void { } } -export class AbilityT { +export class AbilityT implements flatbuffers.IGeneratedObject { constructor( public id: number = 0, public distance: number = 0 diff --git a/tests/ts/my-game/example/monster.js b/tests/ts/my-game/example/monster.js index e4ef970a..397d0d9b 100644 --- a/tests/ts/my-game/example/monster.js +++ b/tests/ts/my-game/example/monster.js @@ -889,19 +889,19 @@ export class Monster { } unpack() { return new MonsterT((this.pos() !== null ? this.pos().unpack() : null), this.mana(), this.hp(), this.name(), this.bb.createScalarList(this.inventory.bind(this), this.inventoryLength()), this.color(), this.testType(), (() => { - let temp = unionToAny(this.testType(), this.test.bind(this)); + const temp = unionToAny(this.testType(), this.test.bind(this)); if (temp === null) { return null; } return temp.unpack(); })(), this.bb.createObjList(this.test4.bind(this), this.test4Length()), this.bb.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), this.bb.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), (this.enemy() !== null ? this.enemy().unpack() : null), this.bb.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), (this.testempty() !== null ? this.testempty().unpack() : null), this.testbool(), this.testhashs32Fnv1(), this.testhashu32Fnv1(), this.testhashs64Fnv1(), this.testhashu64Fnv1(), this.testhashs32Fnv1a(), this.testhashu32Fnv1a(), this.testhashs64Fnv1a(), this.testhashu64Fnv1a(), this.bb.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), this.testf(), this.testf2(), this.testf3(), this.bb.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), this.bb.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), this.bb.createScalarList(this.flex.bind(this), this.flexLength()), this.bb.createObjList(this.test5.bind(this), this.test5Length()), this.bb.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), this.bb.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), (this.parentNamespaceTest() !== null ? this.parentNamespaceTest().unpack() : null), this.bb.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), this.singleWeakReference(), this.bb.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), this.bb.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), this.coOwningReference(), this.bb.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), this.nonOwningReference(), this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), this.anyUniqueType(), (() => { - let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); if (temp === null) { return null; } return temp.unpack(); })(), this.anyAmbiguousType(), (() => { - let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + const temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); if (temp === null) { return null; } @@ -917,7 +917,7 @@ export class Monster { _o.color = this.color(); _o.testType = this.testType(); _o.test = (() => { - let temp = unionToAny(this.testType(), this.test.bind(this)); + const temp = unionToAny(this.testType(), this.test.bind(this)); if (temp === null) { return null; } @@ -959,7 +959,7 @@ export class Monster { _o.vectorOfNonOwningReferences = this.bb.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()); _o.anyUniqueType = this.anyUniqueType(); _o.anyUnique = (() => { - let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); if (temp === null) { return null; } @@ -967,7 +967,7 @@ export class Monster { })(); _o.anyAmbiguousType = this.anyAmbiguousType(); _o.anyAmbiguous = (() => { - let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + const temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); if (temp === null) { return null; } diff --git a/tests/ts/my-game/example/monster.ts b/tests/ts/my-game/example/monster.ts index 63e5768e..4e84c62f 100644 --- a/tests/ts/my-game/example/monster.ts +++ b/tests/ts/my-game/example/monster.ts @@ -20,7 +20,7 @@ import { InParentNamespace, InParentNamespaceT } from '../../my-game/in-parent-n /** * an example documentation comment: "monster object" */ -export class Monster { +export class Monster implements flatbuffers.IUnpackableObject<MonsterT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Monster { @@ -1153,19 +1153,19 @@ unpack(): MonsterT { this.mana(), this.hp(), this.name(), - this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength()), + this.bb!.createScalarList<number>(this.inventory.bind(this), this.inventoryLength()), this.color(), this.testType(), (() => { - let temp = unionToAny(this.testType(), this.test.bind(this)); + const temp = unionToAny(this.testType(), this.test.bind(this)); if(temp === null) { return null; } return temp.unpack() })(), - this.bb!.createObjList(this.test4.bind(this), this.test4Length()), - this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()), - this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), + this.bb!.createObjList<Test, TestT>(this.test4.bind(this), this.test4Length()), + this.bb!.createScalarList<string>(this.testarrayofstring.bind(this), this.testarrayofstringLength()), + this.bb!.createObjList<Monster, MonsterT>(this.testarrayoftables.bind(this), this.testarrayoftablesLength()), (this.enemy() !== null ? this.enemy()!.unpack() : null), - this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), + this.bb!.createScalarList<number>(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()), (this.testempty() !== null ? this.testempty()!.unpack() : null), this.testbool(), this.testhashs32Fnv1(), @@ -1176,41 +1176,41 @@ unpack(): MonsterT { this.testhashu32Fnv1a(), this.testhashs64Fnv1a(), this.testhashu64Fnv1a(), - this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), + this.bb!.createScalarList<boolean>(this.testarrayofbools.bind(this), this.testarrayofboolsLength()), this.testf(), this.testf2(), this.testf3(), - this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), - this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), - this.bb!.createScalarList(this.flex.bind(this), this.flexLength()), - this.bb!.createObjList(this.test5.bind(this), this.test5Length()), - this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), - this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), + this.bb!.createScalarList<string>(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()), + this.bb!.createObjList<Ability, AbilityT>(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()), + this.bb!.createScalarList<number>(this.flex.bind(this), this.flexLength()), + this.bb!.createObjList<Test, TestT>(this.test5.bind(this), this.test5Length()), + this.bb!.createScalarList<bigint>(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()), + this.bb!.createScalarList<number>(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()), (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null), - this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), + this.bb!.createObjList<Referrable, ReferrableT>(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()), this.singleWeakReference(), - this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), - this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), + this.bb!.createScalarList<bigint>(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()), + this.bb!.createObjList<Referrable, ReferrableT>(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()), this.coOwningReference(), - this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), + this.bb!.createScalarList<bigint>(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()), this.nonOwningReference(), - this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), + this.bb!.createScalarList<bigint>(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()), this.anyUniqueType(), (() => { - let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); if(temp === null) { return null; } return temp.unpack() })(), this.anyAmbiguousType(), (() => { - let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + const temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); if(temp === null) { return null; } return temp.unpack() })(), - this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), + this.bb!.createScalarList<Color>(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()), this.signedEnum(), - this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), - this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()), + this.bb!.createScalarList<number>(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()), + this.bb!.createObjList<Stat, StatT>(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()), (this.nativeInline() !== null ? this.nativeInline()!.unpack() : null), this.longEnumNonEnumDefault(), this.longEnumNormalDefault() @@ -1223,19 +1223,19 @@ unpackTo(_o: MonsterT): void { _o.mana = this.mana(); _o.hp = this.hp(); _o.name = this.name(); - _o.inventory = this.bb!.createScalarList(this.inventory.bind(this), this.inventoryLength()); + _o.inventory = this.bb!.createScalarList<number>(this.inventory.bind(this), this.inventoryLength()); _o.color = this.color(); _o.testType = this.testType(); _o.test = (() => { - let temp = unionToAny(this.testType(), this.test.bind(this)); + const temp = unionToAny(this.testType(), this.test.bind(this)); if(temp === null) { return null; } return temp.unpack() })(); - _o.test4 = this.bb!.createObjList(this.test4.bind(this), this.test4Length()); - _o.testarrayofstring = this.bb!.createScalarList(this.testarrayofstring.bind(this), this.testarrayofstringLength()); - _o.testarrayoftables = this.bb!.createObjList(this.testarrayoftables.bind(this), this.testarrayoftablesLength()); + _o.test4 = this.bb!.createObjList<Test, TestT>(this.test4.bind(this), this.test4Length()); + _o.testarrayofstring = this.bb!.createScalarList<string>(this.testarrayofstring.bind(this), this.testarrayofstringLength()); + _o.testarrayoftables = this.bb!.createObjList<Monster, MonsterT>(this.testarrayoftables.bind(this), this.testarrayoftablesLength()); _o.enemy = (this.enemy() !== null ? this.enemy()!.unpack() : null); - _o.testnestedflatbuffer = this.bb!.createScalarList(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()); + _o.testnestedflatbuffer = this.bb!.createScalarList<number>(this.testnestedflatbuffer.bind(this), this.testnestedflatbufferLength()); _o.testempty = (this.testempty() !== null ? this.testempty()!.unpack() : null); _o.testbool = this.testbool(); _o.testhashs32Fnv1 = this.testhashs32Fnv1(); @@ -1246,48 +1246,48 @@ unpackTo(_o: MonsterT): void { _o.testhashu32Fnv1a = this.testhashu32Fnv1a(); _o.testhashs64Fnv1a = this.testhashs64Fnv1a(); _o.testhashu64Fnv1a = this.testhashu64Fnv1a(); - _o.testarrayofbools = this.bb!.createScalarList(this.testarrayofbools.bind(this), this.testarrayofboolsLength()); + _o.testarrayofbools = this.bb!.createScalarList<boolean>(this.testarrayofbools.bind(this), this.testarrayofboolsLength()); _o.testf = this.testf(); _o.testf2 = this.testf2(); _o.testf3 = this.testf3(); - _o.testarrayofstring2 = this.bb!.createScalarList(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()); - _o.testarrayofsortedstruct = this.bb!.createObjList(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()); - _o.flex = this.bb!.createScalarList(this.flex.bind(this), this.flexLength()); - _o.test5 = this.bb!.createObjList(this.test5.bind(this), this.test5Length()); - _o.vectorOfLongs = this.bb!.createScalarList(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()); - _o.vectorOfDoubles = this.bb!.createScalarList(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()); + _o.testarrayofstring2 = this.bb!.createScalarList<string>(this.testarrayofstring2.bind(this), this.testarrayofstring2Length()); + _o.testarrayofsortedstruct = this.bb!.createObjList<Ability, AbilityT>(this.testarrayofsortedstruct.bind(this), this.testarrayofsortedstructLength()); + _o.flex = this.bb!.createScalarList<number>(this.flex.bind(this), this.flexLength()); + _o.test5 = this.bb!.createObjList<Test, TestT>(this.test5.bind(this), this.test5Length()); + _o.vectorOfLongs = this.bb!.createScalarList<bigint>(this.vectorOfLongs.bind(this), this.vectorOfLongsLength()); + _o.vectorOfDoubles = this.bb!.createScalarList<number>(this.vectorOfDoubles.bind(this), this.vectorOfDoublesLength()); _o.parentNamespaceTest = (this.parentNamespaceTest() !== null ? this.parentNamespaceTest()!.unpack() : null); - _o.vectorOfReferrables = this.bb!.createObjList(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()); + _o.vectorOfReferrables = this.bb!.createObjList<Referrable, ReferrableT>(this.vectorOfReferrables.bind(this), this.vectorOfReferrablesLength()); _o.singleWeakReference = this.singleWeakReference(); - _o.vectorOfWeakReferences = this.bb!.createScalarList(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()); - _o.vectorOfStrongReferrables = this.bb!.createObjList(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()); + _o.vectorOfWeakReferences = this.bb!.createScalarList<bigint>(this.vectorOfWeakReferences.bind(this), this.vectorOfWeakReferencesLength()); + _o.vectorOfStrongReferrables = this.bb!.createObjList<Referrable, ReferrableT>(this.vectorOfStrongReferrables.bind(this), this.vectorOfStrongReferrablesLength()); _o.coOwningReference = this.coOwningReference(); - _o.vectorOfCoOwningReferences = this.bb!.createScalarList(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()); + _o.vectorOfCoOwningReferences = this.bb!.createScalarList<bigint>(this.vectorOfCoOwningReferences.bind(this), this.vectorOfCoOwningReferencesLength()); _o.nonOwningReference = this.nonOwningReference(); - _o.vectorOfNonOwningReferences = this.bb!.createScalarList(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()); + _o.vectorOfNonOwningReferences = this.bb!.createScalarList<bigint>(this.vectorOfNonOwningReferences.bind(this), this.vectorOfNonOwningReferencesLength()); _o.anyUniqueType = this.anyUniqueType(); _o.anyUnique = (() => { - let temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); + const temp = unionToAnyUniqueAliases(this.anyUniqueType(), this.anyUnique.bind(this)); if(temp === null) { return null; } return temp.unpack() })(); _o.anyAmbiguousType = this.anyAmbiguousType(); _o.anyAmbiguous = (() => { - let temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); + const temp = unionToAnyAmbiguousAliases(this.anyAmbiguousType(), this.anyAmbiguous.bind(this)); if(temp === null) { return null; } return temp.unpack() })(); - _o.vectorOfEnums = this.bb!.createScalarList(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()); + _o.vectorOfEnums = this.bb!.createScalarList<Color>(this.vectorOfEnums.bind(this), this.vectorOfEnumsLength()); _o.signedEnum = this.signedEnum(); - _o.testrequirednestedflatbuffer = this.bb!.createScalarList(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()); - _o.scalarKeySortedTables = this.bb!.createObjList(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()); + _o.testrequirednestedflatbuffer = this.bb!.createScalarList<number>(this.testrequirednestedflatbuffer.bind(this), this.testrequirednestedflatbufferLength()); + _o.scalarKeySortedTables = this.bb!.createObjList<Stat, StatT>(this.scalarKeySortedTables.bind(this), this.scalarKeySortedTablesLength()); _o.nativeInline = (this.nativeInline() !== null ? this.nativeInline()!.unpack() : null); _o.longEnumNonEnumDefault = this.longEnumNonEnumDefault(); _o.longEnumNormalDefault = this.longEnumNormalDefault(); } } -export class MonsterT { +export class MonsterT implements flatbuffers.IGeneratedObject { constructor( public pos: Vec3T|null = null, public mana: number = 150, diff --git a/tests/ts/my-game/example/referrable.ts b/tests/ts/my-game/example/referrable.ts index ec029800..52603629 100644 --- a/tests/ts/my-game/example/referrable.ts +++ b/tests/ts/my-game/example/referrable.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class Referrable { +export class Referrable implements flatbuffers.IUnpackableObject<ReferrableT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Referrable { @@ -81,7 +81,7 @@ unpackTo(_o: ReferrableT): void { } } -export class ReferrableT { +export class ReferrableT implements flatbuffers.IGeneratedObject { constructor( public id: bigint = BigInt('0') ){} diff --git a/tests/ts/my-game/example/stat.ts b/tests/ts/my-game/example/stat.ts index e4525995..c1597b2a 100644 --- a/tests/ts/my-game/example/stat.ts +++ b/tests/ts/my-game/example/stat.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class Stat { +export class Stat implements flatbuffers.IUnpackableObject<StatT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Stat { @@ -118,7 +118,7 @@ unpackTo(_o: StatT): void { } } -export class StatT { +export class StatT implements flatbuffers.IGeneratedObject { constructor( public id: string|Uint8Array|null = null, public val: bigint = BigInt('0'), diff --git a/tests/ts/my-game/example/struct-of-structs-of-structs.ts b/tests/ts/my-game/example/struct-of-structs-of-structs.ts index 52efc120..fa17939b 100644 --- a/tests/ts/my-game/example/struct-of-structs-of-structs.ts +++ b/tests/ts/my-game/example/struct-of-structs-of-structs.ts @@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers'; import { StructOfStructs, StructOfStructsT } from '../../my-game/example/struct-of-structs.js'; -export class StructOfStructsOfStructs { +export class StructOfStructsOfStructs implements flatbuffers.IUnpackableObject<StructOfStructsOfStructsT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructsOfStructs { @@ -55,7 +55,7 @@ unpackTo(_o: StructOfStructsOfStructsT): void { } } -export class StructOfStructsOfStructsT { +export class StructOfStructsOfStructsT implements flatbuffers.IGeneratedObject { constructor( public a: StructOfStructsT|null = null ){} diff --git a/tests/ts/my-game/example/struct-of-structs.ts b/tests/ts/my-game/example/struct-of-structs.ts index 749a73cb..10d3607f 100644 --- a/tests/ts/my-game/example/struct-of-structs.ts +++ b/tests/ts/my-game/example/struct-of-structs.ts @@ -6,7 +6,7 @@ import { Ability, AbilityT } from '../../my-game/example/ability.js'; import { Test, TestT } from '../../my-game/example/test.js'; -export class StructOfStructs { +export class StructOfStructs implements flatbuffers.IUnpackableObject<StructOfStructsT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs { @@ -67,7 +67,7 @@ unpackTo(_o: StructOfStructsT): void { } } -export class StructOfStructsT { +export class StructOfStructsT implements flatbuffers.IGeneratedObject { constructor( public a: AbilityT|null = null, public b: TestT|null = null, diff --git a/tests/ts/my-game/example/test-simple-table-with-enum.ts b/tests/ts/my-game/example/test-simple-table-with-enum.ts index cfca00b4..903ab99c 100644 --- a/tests/ts/my-game/example/test-simple-table-with-enum.ts +++ b/tests/ts/my-game/example/test-simple-table-with-enum.ts @@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers'; import { Color } from '../../my-game/example/color.js'; -export class TestSimpleTableWithEnum { +export class TestSimpleTableWithEnum implements flatbuffers.IUnpackableObject<TestSimpleTableWithEnumT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):TestSimpleTableWithEnum { @@ -82,7 +82,7 @@ unpackTo(_o: TestSimpleTableWithEnumT): void { } } -export class TestSimpleTableWithEnumT { +export class TestSimpleTableWithEnumT implements flatbuffers.IGeneratedObject { constructor( public color: Color = Color.Green ){} diff --git a/tests/ts/my-game/example/test.ts b/tests/ts/my-game/example/test.ts index b3d84eec..7484f2c1 100644 --- a/tests/ts/my-game/example/test.ts +++ b/tests/ts/my-game/example/test.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class Test { +export class Test implements flatbuffers.IUnpackableObject<TestT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Test { @@ -62,7 +62,7 @@ unpackTo(_o: TestT): void { } } -export class TestT { +export class TestT implements flatbuffers.IGeneratedObject { constructor( public a: number = 0, public b: number = 0 diff --git a/tests/ts/my-game/example/type-aliases.ts b/tests/ts/my-game/example/type-aliases.ts index 805c8cf3..93262d70 100644 --- a/tests/ts/my-game/example/type-aliases.ts +++ b/tests/ts/my-game/example/type-aliases.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class TypeAliases { +export class TypeAliases implements flatbuffers.IUnpackableObject<TypeAliasesT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):TypeAliases { @@ -344,8 +344,8 @@ unpack(): TypeAliasesT { this.u64(), this.f32(), this.f64(), - this.bb!.createScalarList(this.v8.bind(this), this.v8Length()), - this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length()) + this.bb!.createScalarList<number>(this.v8.bind(this), this.v8Length()), + this.bb!.createScalarList<number>(this.vf64.bind(this), this.vf64Length()) ); } @@ -361,12 +361,12 @@ unpackTo(_o: TypeAliasesT): void { _o.u64 = this.u64(); _o.f32 = this.f32(); _o.f64 = this.f64(); - _o.v8 = this.bb!.createScalarList(this.v8.bind(this), this.v8Length()); - _o.vf64 = this.bb!.createScalarList(this.vf64.bind(this), this.vf64Length()); + _o.v8 = this.bb!.createScalarList<number>(this.v8.bind(this), this.v8Length()); + _o.vf64 = this.bb!.createScalarList<number>(this.vf64.bind(this), this.vf64Length()); } } -export class TypeAliasesT { +export class TypeAliasesT implements flatbuffers.IGeneratedObject { constructor( public i8: number = 0, public u8: number = 0, diff --git a/tests/ts/my-game/example/vec3.ts b/tests/ts/my-game/example/vec3.ts index bc4c4733..84516e09 100644 --- a/tests/ts/my-game/example/vec3.ts +++ b/tests/ts/my-game/example/vec3.ts @@ -6,7 +6,7 @@ import { Color } from '../../my-game/example/color.js'; import { Test, TestT } from '../../my-game/example/test.js'; -export class Vec3 { +export class Vec3 implements flatbuffers.IUnpackableObject<Vec3T> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Vec3 { @@ -112,7 +112,7 @@ unpackTo(_o: Vec3T): void { } } -export class Vec3T { +export class Vec3T implements flatbuffers.IGeneratedObject { constructor( public x: number = 0.0, public y: number = 0.0, diff --git a/tests/ts/my-game/example2/monster.ts b/tests/ts/my-game/example2/monster.ts index 7240476b..07144869 100644 --- a/tests/ts/my-game/example2/monster.ts +++ b/tests/ts/my-game/example2/monster.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class Monster { +export class Monster implements flatbuffers.IUnpackableObject<MonsterT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Monster { @@ -56,7 +56,7 @@ unpack(): MonsterT { unpackTo(_o: MonsterT): void {} } -export class MonsterT { +export class MonsterT implements flatbuffers.IGeneratedObject { constructor(){} diff --git a/tests/ts/my-game/in-parent-namespace.ts b/tests/ts/my-game/in-parent-namespace.ts index 0de94df5..0e2f4128 100644 --- a/tests/ts/my-game/in-parent-namespace.ts +++ b/tests/ts/my-game/in-parent-namespace.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class InParentNamespace { +export class InParentNamespace implements flatbuffers.IUnpackableObject<InParentNamespaceT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):InParentNamespace { @@ -56,7 +56,7 @@ unpack(): InParentNamespaceT { unpackTo(_o: InParentNamespaceT): void {} } -export class InParentNamespaceT { +export class InParentNamespaceT implements flatbuffers.IGeneratedObject { constructor(){} diff --git a/tests/ts/reflection/enum-val.ts b/tests/ts/reflection/enum-val.ts index 85278327..2364dab2 100644 --- a/tests/ts/reflection/enum-val.ts +++ b/tests/ts/reflection/enum-val.ts @@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers'; import { Type, TypeT } from '../reflection/type.js'; -export class EnumVal { +export class EnumVal implements flatbuffers.IUnpackableObject<EnumValT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):EnumVal { @@ -111,7 +111,7 @@ unpack(): EnumValT { this.name(), this.value(), (this.unionType() !== null ? this.unionType()!.unpack() : null), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()) ); } @@ -120,11 +120,11 @@ unpackTo(_o: EnumValT): void { _o.name = this.name(); _o.value = this.value(); _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); } } -export class EnumValT { +export class EnumValT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public value: bigint = BigInt('0'), diff --git a/tests/ts/reflection/enum.ts b/tests/ts/reflection/enum.ts index 7bba354f..34d13775 100644 --- a/tests/ts/reflection/enum.ts +++ b/tests/ts/reflection/enum.ts @@ -7,7 +7,7 @@ import { KeyValue, KeyValueT } from '../reflection/key-value.js'; import { Type, TypeT } from '../reflection/type.js'; -export class Enum { +export class Enum implements flatbuffers.IUnpackableObject<EnumT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Enum { @@ -179,11 +179,11 @@ static endEnum(builder:flatbuffers.Builder):flatbuffers.Offset { unpack(): EnumT { return new EnumT( this.name(), - this.bb!.createObjList(this.values.bind(this), this.valuesLength()), + this.bb!.createObjList<EnumVal, EnumValT>(this.values.bind(this), this.valuesLength()), this.isUnion(), (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), this.declarationFile() ); } @@ -191,16 +191,16 @@ unpack(): EnumT { unpackTo(_o: EnumT): void { _o.name = this.name(); - _o.values = this.bb!.createObjList(this.values.bind(this), this.valuesLength()); + _o.values = this.bb!.createObjList<EnumVal, EnumValT>(this.values.bind(this), this.valuesLength()); _o.isUnion = this.isUnion(); _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); _o.declarationFile = this.declarationFile(); } } -export class EnumT { +export class EnumT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public values: (EnumValT)[] = [], diff --git a/tests/ts/reflection/field.ts b/tests/ts/reflection/field.ts index 48c1bed1..9734fbab 100644 --- a/tests/ts/reflection/field.ts +++ b/tests/ts/reflection/field.ts @@ -6,7 +6,7 @@ import { KeyValue, KeyValueT } from '../reflection/key-value.js'; import { Type, TypeT } from '../reflection/type.js'; -export class Field { +export class Field implements flatbuffers.IUnpackableObject<FieldT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Field { @@ -308,8 +308,8 @@ unpack(): FieldT { this.deprecated(), this.required(), this.key(), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), this.optional(), this.padding() ); @@ -326,14 +326,14 @@ unpackTo(_o: FieldT): void { _o.deprecated = this.deprecated(); _o.required = this.required(); _o.key = this.key(); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); _o.optional = this.optional(); _o.padding = this.padding(); } } -export class FieldT { +export class FieldT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public type: TypeT|null = null, diff --git a/tests/ts/reflection/key-value.ts b/tests/ts/reflection/key-value.ts index 736766b9..93262f42 100644 --- a/tests/ts/reflection/key-value.ts +++ b/tests/ts/reflection/key-value.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class KeyValue { +export class KeyValue implements flatbuffers.IUnpackableObject<KeyValueT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):KeyValue { @@ -79,7 +79,7 @@ unpackTo(_o: KeyValueT): void { } } -export class KeyValueT { +export class KeyValueT implements flatbuffers.IGeneratedObject { constructor( public key: string|Uint8Array|null = null, public value: string|Uint8Array|null = null diff --git a/tests/ts/reflection/object.ts b/tests/ts/reflection/object.ts index 1e14f039..fbe70061 100644 --- a/tests/ts/reflection/object.ts +++ b/tests/ts/reflection/object.ts @@ -6,7 +6,7 @@ import { Field, FieldT } from '../reflection/field.js'; import { KeyValue, KeyValueT } from '../reflection/key-value.js'; -export class Object_ { +export class Object_ implements flatbuffers.IUnpackableObject<Object_T> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Object_ { @@ -220,12 +220,12 @@ static createObject(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, unpack(): Object_T { return new Object_T( this.name(), - this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()), + this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength()), this.isStruct(), this.minalign(), this.bytesize(), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), this.declarationFile() ); } @@ -233,17 +233,17 @@ unpack(): Object_T { unpackTo(_o: Object_T): void { _o.name = this.name(); - _o.fields = this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()); + _o.fields = this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength()); _o.isStruct = this.isStruct(); _o.minalign = this.minalign(); _o.bytesize = this.bytesize(); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); _o.declarationFile = this.declarationFile(); } } -export class Object_T { +export class Object_T implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public fields: (FieldT)[] = [], diff --git a/tests/ts/reflection/rpccall.ts b/tests/ts/reflection/rpccall.ts index 151d7b1b..320de516 100644 --- a/tests/ts/reflection/rpccall.ts +++ b/tests/ts/reflection/rpccall.ts @@ -6,7 +6,7 @@ import { KeyValue, KeyValueT } from '../reflection/key-value.js'; import { Object_, Object_T } from '../reflection/object.js'; -export class RPCCall { +export class RPCCall implements flatbuffers.IUnpackableObject<RPCCallT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):RPCCall { @@ -129,8 +129,8 @@ unpack(): RPCCallT { this.name(), (this.request() !== null ? this.request()!.unpack() : null), (this.response() !== null ? this.response()!.unpack() : null), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()) ); } @@ -139,12 +139,12 @@ unpackTo(_o: RPCCallT): void { _o.name = this.name(); _o.request = (this.request() !== null ? this.request()!.unpack() : null); _o.response = (this.response() !== null ? this.response()!.unpack() : null); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); } } -export class RPCCallT { +export class RPCCallT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public request: Object_T|null = null, diff --git a/tests/ts/reflection/schema-file.ts b/tests/ts/reflection/schema-file.ts index e1f50357..eda23ded 100644 --- a/tests/ts/reflection/schema-file.ts +++ b/tests/ts/reflection/schema-file.ts @@ -9,7 +9,7 @@ import * as flatbuffers from 'flatbuffers'; * Symbols declared within a file may be recovered by iterating over all * symbols and examining the `declaration_file` field. */ -export class SchemaFile { +export class SchemaFile implements flatbuffers.IUnpackableObject<SchemaFileT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile { @@ -96,18 +96,18 @@ static createSchemaFile(builder:flatbuffers.Builder, filenameOffset:flatbuffers. unpack(): SchemaFileT { return new SchemaFileT( this.filename(), - this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()) + this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength()) ); } unpackTo(_o: SchemaFileT): void { _o.filename = this.filename(); - _o.includedFilenames = this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); + _o.includedFilenames = this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength()); } } -export class SchemaFileT { +export class SchemaFileT implements flatbuffers.IGeneratedObject { constructor( public filename: string|Uint8Array|null = null, public includedFilenames: (string)[] = [] diff --git a/tests/ts/reflection/schema.ts b/tests/ts/reflection/schema.ts index d1839c7c..c9965222 100644 --- a/tests/ts/reflection/schema.ts +++ b/tests/ts/reflection/schema.ts @@ -8,7 +8,7 @@ import { SchemaFile, SchemaFileT } from '../reflection/schema-file.js'; import { Service, ServiceT } from '../reflection/service.js'; -export class Schema { +export class Schema implements flatbuffers.IUnpackableObject<SchemaT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Schema { @@ -215,31 +215,31 @@ static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbu unpack(): SchemaT { return new SchemaT( - this.bb!.createObjList(this.objects.bind(this), this.objectsLength()), - this.bb!.createObjList(this.enums.bind(this), this.enumsLength()), + this.bb!.createObjList<Object_, Object_T>(this.objects.bind(this), this.objectsLength()), + this.bb!.createObjList<Enum, EnumT>(this.enums.bind(this), this.enumsLength()), this.fileIdent(), this.fileExt(), (this.rootTable() !== null ? this.rootTable()!.unpack() : null), - this.bb!.createObjList(this.services.bind(this), this.servicesLength()), + this.bb!.createObjList<Service, ServiceT>(this.services.bind(this), this.servicesLength()), this.advancedFeatures(), - this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()) + this.bb!.createObjList<SchemaFile, SchemaFileT>(this.fbsFiles.bind(this), this.fbsFilesLength()) ); } unpackTo(_o: SchemaT): void { - _o.objects = this.bb!.createObjList(this.objects.bind(this), this.objectsLength()); - _o.enums = this.bb!.createObjList(this.enums.bind(this), this.enumsLength()); + _o.objects = this.bb!.createObjList<Object_, Object_T>(this.objects.bind(this), this.objectsLength()); + _o.enums = this.bb!.createObjList<Enum, EnumT>(this.enums.bind(this), this.enumsLength()); _o.fileIdent = this.fileIdent(); _o.fileExt = this.fileExt(); _o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null); - _o.services = this.bb!.createObjList(this.services.bind(this), this.servicesLength()); + _o.services = this.bb!.createObjList<Service, ServiceT>(this.services.bind(this), this.servicesLength()); _o.advancedFeatures = this.advancedFeatures(); - _o.fbsFiles = this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); + _o.fbsFiles = this.bb!.createObjList<SchemaFile, SchemaFileT>(this.fbsFiles.bind(this), this.fbsFilesLength()); } } -export class SchemaT { +export class SchemaT implements flatbuffers.IGeneratedObject { constructor( public objects: (Object_T)[] = [], public enums: (EnumT)[] = [], diff --git a/tests/ts/reflection/service.ts b/tests/ts/reflection/service.ts index c083cae0..c0ad8adb 100644 --- a/tests/ts/reflection/service.ts +++ b/tests/ts/reflection/service.ts @@ -6,7 +6,7 @@ import { KeyValue, KeyValueT } from '../reflection/key-value.js'; import { RPCCall, RPCCallT } from '../reflection/rpccall.js'; -export class Service { +export class Service implements flatbuffers.IUnpackableObject<ServiceT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Service { @@ -156,9 +156,9 @@ static createService(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, unpack(): ServiceT { return new ServiceT( this.name(), - this.bb!.createObjList(this.calls.bind(this), this.callsLength()), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.bb!.createObjList<RPCCall, RPCCallT>(this.calls.bind(this), this.callsLength()), + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), this.declarationFile() ); } @@ -166,14 +166,14 @@ unpack(): ServiceT { unpackTo(_o: ServiceT): void { _o.name = this.name(); - _o.calls = this.bb!.createObjList(this.calls.bind(this), this.callsLength()); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.calls = this.bb!.createObjList<RPCCall, RPCCallT>(this.calls.bind(this), this.callsLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); _o.declarationFile = this.declarationFile(); } } -export class ServiceT { +export class ServiceT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public calls: (RPCCallT)[] = [], diff --git a/tests/ts/reflection/type.ts b/tests/ts/reflection/type.ts index e831e21d..37316959 100644 --- a/tests/ts/reflection/type.ts +++ b/tests/ts/reflection/type.ts @@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers'; import { BaseType } from '../reflection/base-type.js'; -export class Type { +export class Type implements flatbuffers.IUnpackableObject<TypeT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Type { @@ -195,7 +195,7 @@ unpackTo(_o: TypeT): void { } } -export class TypeT { +export class TypeT implements flatbuffers.IGeneratedObject { constructor( public baseType: BaseType = BaseType.None, public element: BaseType = BaseType.None, diff --git a/tests/ts/reflection_generated.ts b/tests/ts/reflection_generated.ts index 4bb12220..ec17d64b 100644 --- a/tests/ts/reflection_generated.ts +++ b/tests/ts/reflection_generated.ts @@ -35,7 +35,7 @@ export enum AdvancedFeatures { DefaultVectorsAndStrings = '8' } -export class Type { +export class Type implements flatbuffers.IUnpackableObject<TypeT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Type { @@ -225,7 +225,7 @@ unpackTo(_o: TypeT): void { } } -export class TypeT { +export class TypeT implements flatbuffers.IGeneratedObject { constructor( public baseType: BaseType = BaseType.None, public element: BaseType = BaseType.None, @@ -248,7 +248,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { } } -export class KeyValue { +export class KeyValue implements flatbuffers.IUnpackableObject<KeyValueT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):KeyValue { @@ -323,7 +323,7 @@ unpackTo(_o: KeyValueT): void { } } -export class KeyValueT { +export class KeyValueT implements flatbuffers.IGeneratedObject { constructor( public key: string|Uint8Array|null = null, public value: string|Uint8Array|null = null @@ -341,7 +341,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { } } -export class EnumVal { +export class EnumVal implements flatbuffers.IUnpackableObject<EnumValT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):EnumVal { @@ -447,7 +447,7 @@ unpack(): EnumValT { this.name(), this.value(), (this.unionType() !== null ? this.unionType()!.unpack() : null), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()) ); } @@ -456,11 +456,11 @@ unpackTo(_o: EnumValT): void { _o.name = this.name(); _o.value = this.value(); _o.unionType = (this.unionType() !== null ? this.unionType()!.unpack() : null); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); } } -export class EnumValT { +export class EnumValT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public value: bigint = BigInt('0'), @@ -484,7 +484,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { } } -export class Enum { +export class Enum implements flatbuffers.IUnpackableObject<EnumT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Enum { @@ -656,11 +656,11 @@ static endEnum(builder:flatbuffers.Builder):flatbuffers.Offset { unpack(): EnumT { return new EnumT( this.name(), - this.bb!.createObjList(this.values.bind(this), this.valuesLength()), + this.bb!.createObjList<EnumVal, EnumValT>(this.values.bind(this), this.valuesLength()), this.isUnion(), (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), this.declarationFile() ); } @@ -668,16 +668,16 @@ unpack(): EnumT { unpackTo(_o: EnumT): void { _o.name = this.name(); - _o.values = this.bb!.createObjList(this.values.bind(this), this.valuesLength()); + _o.values = this.bb!.createObjList<EnumVal, EnumValT>(this.values.bind(this), this.valuesLength()); _o.isUnion = this.isUnion(); _o.underlyingType = (this.underlyingType() !== null ? this.underlyingType()!.unpack() : null); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); _o.declarationFile = this.declarationFile(); } } -export class EnumT { +export class EnumT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public values: (EnumValT)[] = [], @@ -710,7 +710,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { } } -export class Field { +export class Field implements flatbuffers.IUnpackableObject<FieldT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Field { @@ -1012,8 +1012,8 @@ unpack(): FieldT { this.deprecated(), this.required(), this.key(), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), this.optional(), this.padding() ); @@ -1030,14 +1030,14 @@ unpackTo(_o: FieldT): void { _o.deprecated = this.deprecated(); _o.required = this.required(); _o.key = this.key(); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); _o.optional = this.optional(); _o.padding = this.padding(); } } -export class FieldT { +export class FieldT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public type: TypeT|null = null, @@ -1080,7 +1080,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { } } -export class Object_ { +export class Object_ implements flatbuffers.IUnpackableObject<Object_T> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Object_ { @@ -1294,12 +1294,12 @@ static createObject(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, unpack(): Object_T { return new Object_T( this.name(), - this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()), + this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength()), this.isStruct(), this.minalign(), this.bytesize(), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), this.declarationFile() ); } @@ -1307,17 +1307,17 @@ unpack(): Object_T { unpackTo(_o: Object_T): void { _o.name = this.name(); - _o.fields = this.bb!.createObjList(this.fields.bind(this), this.fieldsLength()); + _o.fields = this.bb!.createObjList<Field, FieldT>(this.fields.bind(this), this.fieldsLength()); _o.isStruct = this.isStruct(); _o.minalign = this.minalign(); _o.bytesize = this.bytesize(); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); _o.declarationFile = this.declarationFile(); } } -export class Object_T { +export class Object_T implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public fields: (FieldT)[] = [], @@ -1350,7 +1350,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { } } -export class RPCCall { +export class RPCCall implements flatbuffers.IUnpackableObject<RPCCallT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):RPCCall { @@ -1473,8 +1473,8 @@ unpack(): RPCCallT { this.name(), (this.request() !== null ? this.request()!.unpack() : null), (this.response() !== null ? this.response()!.unpack() : null), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()) + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()) ); } @@ -1483,12 +1483,12 @@ unpackTo(_o: RPCCallT): void { _o.name = this.name(); _o.request = (this.request() !== null ? this.request()!.unpack() : null); _o.response = (this.response() !== null ? this.response()!.unpack() : null); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); } } -export class RPCCallT { +export class RPCCallT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public request: Object_T|null = null, @@ -1516,7 +1516,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { } } -export class Service { +export class Service implements flatbuffers.IUnpackableObject<ServiceT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Service { @@ -1666,9 +1666,9 @@ static createService(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, unpack(): ServiceT { return new ServiceT( this.name(), - this.bb!.createObjList(this.calls.bind(this), this.callsLength()), - this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()), - this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()), + this.bb!.createObjList<RPCCall, RPCCallT>(this.calls.bind(this), this.callsLength()), + this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()), + this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()), this.declarationFile() ); } @@ -1676,14 +1676,14 @@ unpack(): ServiceT { unpackTo(_o: ServiceT): void { _o.name = this.name(); - _o.calls = this.bb!.createObjList(this.calls.bind(this), this.callsLength()); - _o.attributes = this.bb!.createObjList(this.attributes.bind(this), this.attributesLength()); - _o.documentation = this.bb!.createScalarList(this.documentation.bind(this), this.documentationLength()); + _o.calls = this.bb!.createObjList<RPCCall, RPCCallT>(this.calls.bind(this), this.callsLength()); + _o.attributes = this.bb!.createObjList<KeyValue, KeyValueT>(this.attributes.bind(this), this.attributesLength()); + _o.documentation = this.bb!.createScalarList<string>(this.documentation.bind(this), this.documentationLength()); _o.declarationFile = this.declarationFile(); } } -export class ServiceT { +export class ServiceT implements flatbuffers.IGeneratedObject { constructor( public name: string|Uint8Array|null = null, public calls: (RPCCallT)[] = [], @@ -1715,7 +1715,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { * Symbols declared within a file may be recovered by iterating over all * symbols and examining the `declaration_file` field. */ -export class SchemaFile { +export class SchemaFile implements flatbuffers.IUnpackableObject<SchemaFileT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):SchemaFile { @@ -1802,18 +1802,18 @@ static createSchemaFile(builder:flatbuffers.Builder, filenameOffset:flatbuffers. unpack(): SchemaFileT { return new SchemaFileT( this.filename(), - this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()) + this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength()) ); } unpackTo(_o: SchemaFileT): void { _o.filename = this.filename(); - _o.includedFilenames = this.bb!.createScalarList(this.includedFilenames.bind(this), this.includedFilenamesLength()); + _o.includedFilenames = this.bb!.createScalarList<string>(this.includedFilenames.bind(this), this.includedFilenamesLength()); } } -export class SchemaFileT { +export class SchemaFileT implements flatbuffers.IGeneratedObject { constructor( public filename: string|Uint8Array|null = null, public includedFilenames: (string)[] = [] @@ -1831,7 +1831,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { } } -export class Schema { +export class Schema implements flatbuffers.IUnpackableObject<SchemaT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Schema { @@ -2038,31 +2038,31 @@ static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbu unpack(): SchemaT { return new SchemaT( - this.bb!.createObjList(this.objects.bind(this), this.objectsLength()), - this.bb!.createObjList(this.enums.bind(this), this.enumsLength()), + this.bb!.createObjList<Object_, Object_T>(this.objects.bind(this), this.objectsLength()), + this.bb!.createObjList<Enum, EnumT>(this.enums.bind(this), this.enumsLength()), this.fileIdent(), this.fileExt(), (this.rootTable() !== null ? this.rootTable()!.unpack() : null), - this.bb!.createObjList(this.services.bind(this), this.servicesLength()), + this.bb!.createObjList<Service, ServiceT>(this.services.bind(this), this.servicesLength()), this.advancedFeatures(), - this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()) + this.bb!.createObjList<SchemaFile, SchemaFileT>(this.fbsFiles.bind(this), this.fbsFilesLength()) ); } unpackTo(_o: SchemaT): void { - _o.objects = this.bb!.createObjList(this.objects.bind(this), this.objectsLength()); - _o.enums = this.bb!.createObjList(this.enums.bind(this), this.enumsLength()); + _o.objects = this.bb!.createObjList<Object_, Object_T>(this.objects.bind(this), this.objectsLength()); + _o.enums = this.bb!.createObjList<Enum, EnumT>(this.enums.bind(this), this.enumsLength()); _o.fileIdent = this.fileIdent(); _o.fileExt = this.fileExt(); _o.rootTable = (this.rootTable() !== null ? this.rootTable()!.unpack() : null); - _o.services = this.bb!.createObjList(this.services.bind(this), this.servicesLength()); + _o.services = this.bb!.createObjList<Service, ServiceT>(this.services.bind(this), this.servicesLength()); _o.advancedFeatures = this.advancedFeatures(); - _o.fbsFiles = this.bb!.createObjList(this.fbsFiles.bind(this), this.fbsFilesLength()); + _o.fbsFiles = this.bb!.createObjList<SchemaFile, SchemaFileT>(this.fbsFiles.bind(this), this.fbsFilesLength()); } } -export class SchemaT { +export class SchemaT implements flatbuffers.IGeneratedObject { constructor( public objects: (Object_T)[] = [], public enums: (EnumT)[] = [], diff --git a/tests/ts/typescript/object.ts b/tests/ts/typescript/object.ts index 041b6609..5baf6ed3 100644 --- a/tests/ts/typescript/object.ts +++ b/tests/ts/typescript/object.ts @@ -8,7 +8,7 @@ import { Schema, SchemaT } from '../reflection/schema.js'; import { class_ } from '../typescript/class.js'; -export class Object_ { +export class Object_ implements flatbuffers.IUnpackableObject<Object_T> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Object_ { @@ -193,7 +193,7 @@ unpackTo(_o: Object_T): void { } } -export class Object_T { +export class Object_T implements flatbuffers.IGeneratedObject { constructor( public return_: number = 0, public if_: number = 0, diff --git a/tests/ts/typescript_keywords_generated.ts b/tests/ts/typescript_keywords_generated.ts index 42724253..bcc61102 100644 --- a/tests/ts/typescript_keywords_generated.ts +++ b/tests/ts/typescript_keywords_generated.ts @@ -11,7 +11,7 @@ export enum class_ { instanceof_ = 1 } -export class Object_ { +export class Object_ implements flatbuffers.IUnpackableObject<Object_T> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Object_ { @@ -196,7 +196,7 @@ unpackTo(_o: Object_T): void { } } -export class Object_T { +export class Object_T implements flatbuffers.IGeneratedObject { constructor( public return_: number = 0, public if_: number = 0, diff --git a/tests/ts/union_vector/attacker.ts b/tests/ts/union_vector/attacker.ts index 6b3fc0fc..0d3ca4be 100644 --- a/tests/ts/union_vector/attacker.ts +++ b/tests/ts/union_vector/attacker.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class Attacker { +export class Attacker implements flatbuffers.IUnpackableObject<AttackerT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Attacker { @@ -73,7 +73,7 @@ unpackTo(_o: AttackerT): void { } } -export class AttackerT { +export class AttackerT implements flatbuffers.IGeneratedObject { constructor( public swordAttackDamage: number = 0 ){} diff --git a/tests/ts/union_vector/book-reader.ts b/tests/ts/union_vector/book-reader.ts index 7a312781..29a9b501 100644 --- a/tests/ts/union_vector/book-reader.ts +++ b/tests/ts/union_vector/book-reader.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class BookReader { +export class BookReader implements flatbuffers.IUnpackableObject<BookReaderT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):BookReader { @@ -49,7 +49,7 @@ unpackTo(_o: BookReaderT): void { } } -export class BookReaderT { +export class BookReaderT implements flatbuffers.IGeneratedObject { constructor( public booksRead: number = 0 ){} diff --git a/tests/ts/union_vector/falling-tub.ts b/tests/ts/union_vector/falling-tub.ts index b32f99d0..eeb9f721 100644 --- a/tests/ts/union_vector/falling-tub.ts +++ b/tests/ts/union_vector/falling-tub.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class FallingTub { +export class FallingTub implements flatbuffers.IUnpackableObject<FallingTubT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):FallingTub { @@ -49,7 +49,7 @@ unpackTo(_o: FallingTubT): void { } } -export class FallingTubT { +export class FallingTubT implements flatbuffers.IGeneratedObject { constructor( public weight: number = 0 ){} diff --git a/tests/ts/union_vector/hand-fan.ts b/tests/ts/union_vector/hand-fan.ts index f90b4dd3..dd687baa 100644 --- a/tests/ts/union_vector/hand-fan.ts +++ b/tests/ts/union_vector/hand-fan.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class HandFan { +export class HandFan implements flatbuffers.IUnpackableObject<HandFanT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):HandFan { @@ -73,7 +73,7 @@ unpackTo(_o: HandFanT): void { } } -export class HandFanT { +export class HandFanT implements flatbuffers.IGeneratedObject { constructor( public length: number = 0 ){} diff --git a/tests/ts/union_vector/movie.js b/tests/ts/union_vector/movie.js index 0245a438..53374ebd 100644 --- a/tests/ts/union_vector/movie.js +++ b/tests/ts/union_vector/movie.js @@ -107,7 +107,7 @@ export class Movie { } unpack() { return new MovieT(this.mainCharacterType(), (() => { - let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); if (temp === null) { return null; } @@ -116,13 +116,13 @@ export class Movie { } return temp.unpack(); })(), this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), (() => { - let ret = []; + const ret = []; for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { - let targetEnum = this.charactersType(targetEnumIndex); + const targetEnum = this.charactersType(targetEnumIndex); if (targetEnum === null || Character[targetEnum] === 'NONE') { continue; } - let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); if (temp === null) { continue; } @@ -138,7 +138,7 @@ export class Movie { unpackTo(_o) { _o.mainCharacterType = this.mainCharacterType(); _o.mainCharacter = (() => { - let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); if (temp === null) { return null; } @@ -149,13 +149,13 @@ export class Movie { })(); _o.charactersType = this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()); _o.characters = (() => { - let ret = []; + const ret = []; for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { - let targetEnum = this.charactersType(targetEnumIndex); + const targetEnum = this.charactersType(targetEnumIndex); if (targetEnum === null || Character[targetEnum] === 'NONE') { continue; } - let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); if (temp === null) { continue; } diff --git a/tests/ts/union_vector/movie.ts b/tests/ts/union_vector/movie.ts index 6edeb53c..1f6ca378 100644 --- a/tests/ts/union_vector/movie.ts +++ b/tests/ts/union_vector/movie.ts @@ -8,7 +8,7 @@ import { Character, unionToCharacter, unionListToCharacter } from './character.j import { Rapunzel, RapunzelT } from './rapunzel.js'; -export class Movie { +export class Movie implements flatbuffers.IUnpackableObject<MovieT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Movie { @@ -139,19 +139,19 @@ unpack(): MovieT { return new MovieT( this.mainCharacterType(), (() => { - let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); if(temp === null) { return null; } if(typeof temp === 'string') { return temp; } return temp.unpack() })(), - this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), + this.bb!.createScalarList<Character>(this.charactersType.bind(this), this.charactersTypeLength()), (() => { - let ret = []; + const ret = []; for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { - let targetEnum = this.charactersType(targetEnumIndex); + const targetEnum = this.charactersType(targetEnumIndex); if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } - let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); if(temp === null) { continue; } if(typeof temp === 'string') { ret.push(temp); continue; } ret.push(temp.unpack()); @@ -165,19 +165,19 @@ unpack(): MovieT { unpackTo(_o: MovieT): void { _o.mainCharacterType = this.mainCharacterType(); _o.mainCharacter = (() => { - let temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); + const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this)); if(temp === null) { return null; } if(typeof temp === 'string') { return temp; } return temp.unpack() })(); - _o.charactersType = this.bb!.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()); + _o.charactersType = this.bb!.createScalarList<Character>(this.charactersType.bind(this), this.charactersTypeLength()); _o.characters = (() => { - let ret = []; + const ret = []; for(let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) { - let targetEnum = this.charactersType(targetEnumIndex); + const targetEnum = this.charactersType(targetEnumIndex); if(targetEnum === null || Character[targetEnum!] === 'NONE') { continue; } - let temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); + const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex); if(temp === null) { continue; } if(typeof temp === 'string') { ret.push(temp); continue; } ret.push(temp.unpack()); @@ -187,7 +187,7 @@ unpackTo(_o: MovieT): void { } } -export class MovieT { +export class MovieT implements flatbuffers.IGeneratedObject { constructor( public mainCharacterType: Character = Character.NONE, public mainCharacter: AttackerT|BookReaderT|RapunzelT|string|null = null, diff --git a/tests/ts/union_vector/rapunzel.ts b/tests/ts/union_vector/rapunzel.ts index e1dc63dd..20ca4971 100644 --- a/tests/ts/union_vector/rapunzel.ts +++ b/tests/ts/union_vector/rapunzel.ts @@ -4,7 +4,7 @@ import * as flatbuffers from 'flatbuffers'; -export class Rapunzel { +export class Rapunzel implements flatbuffers.IUnpackableObject<RapunzelT> { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; __init(i:number, bb:flatbuffers.ByteBuffer):Rapunzel { @@ -49,7 +49,7 @@ unpackTo(_o: RapunzelT): void { } } -export class RapunzelT { +export class RapunzelT implements flatbuffers.IGeneratedObject { constructor( public hairLength: number = 0 ){} |