mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 12:44:25 +00:00
[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>
This commit is contained in:
@@ -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'),
|
||||
|
||||
@@ -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)[] = [],
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)[] = [],
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)[] = []
|
||||
|
||||
@@ -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)[] = [],
|
||||
|
||||
@@ -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)[] = [],
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user