mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-04 20:41:09 +00:00
Improve TS types to support isolatedModules and isolatedDeclarations
This commit is contained in:
21
tests/ts/relative_imports/transit/two/identity.d.ts
vendored
Normal file
21
tests/ts/relative_imports/transit/two/identity.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export declare class Identity implements flatbuffers.IUnpackableObject<IdentityT> {
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): Identity;
|
||||
static getRootAsIdentity(bb: flatbuffers.ByteBuffer, obj?: Identity): Identity;
|
||||
static getSizePrefixedRootAsIdentity(bb: flatbuffers.ByteBuffer, obj?: Identity): Identity;
|
||||
id(): number;
|
||||
static getFullyQualifiedName(): "Transit.Two.Identity";
|
||||
static startIdentity(builder: flatbuffers.Builder): void;
|
||||
static addId(builder: flatbuffers.Builder, id: number): void;
|
||||
static endIdentity(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createIdentity(builder: flatbuffers.Builder, id: number): flatbuffers.Offset;
|
||||
unpack(): IdentityT;
|
||||
unpackTo(_o: IdentityT): void;
|
||||
}
|
||||
export declare class IdentityT implements flatbuffers.IGeneratedObject {
|
||||
id: number;
|
||||
constructor(id?: number);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
}
|
||||
57
tests/ts/relative_imports/transit/two/identity.js
Normal file
57
tests/ts/relative_imports/transit/two/identity.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export class Identity {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsIdentity(bb, obj) {
|
||||
return (obj || new Identity()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsIdentity(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Identity()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
id() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readUint32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'Transit.Two.Identity';
|
||||
}
|
||||
static startIdentity(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addId(builder, id) {
|
||||
builder.addFieldInt32(0, id, 0);
|
||||
}
|
||||
static endIdentity(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createIdentity(builder, id) {
|
||||
Identity.startIdentity(builder);
|
||||
Identity.addId(builder, id);
|
||||
return Identity.endIdentity(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new IdentityT(this.id());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.id = this.id();
|
||||
}
|
||||
}
|
||||
export class IdentityT {
|
||||
constructor(id = 0) {
|
||||
this.id = id;
|
||||
}
|
||||
pack(builder) {
|
||||
return Identity.createIdentity(builder, this.id);
|
||||
}
|
||||
}
|
||||
78
tests/ts/relative_imports/transit/two/identity.ts
Normal file
78
tests/ts/relative_imports/transit/two/identity.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
|
||||
|
||||
|
||||
export class Identity implements flatbuffers.IUnpackableObject<IdentityT> {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos: number = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Identity {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsIdentity(bb:flatbuffers.ByteBuffer, obj?:Identity):Identity {
|
||||
return (obj || new Identity()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsIdentity(bb:flatbuffers.ByteBuffer, obj?:Identity):Identity {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Identity()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
id():number {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
|
||||
}
|
||||
|
||||
static getFullyQualifiedName(): "Transit.Two.Identity" {
|
||||
return 'Transit.Two.Identity';
|
||||
}
|
||||
|
||||
static startIdentity(builder:flatbuffers.Builder):void {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
static addId(builder:flatbuffers.Builder, id:number):void {
|
||||
builder.addFieldInt32(0, id, 0);
|
||||
}
|
||||
|
||||
static endIdentity(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createIdentity(builder:flatbuffers.Builder, id:number):flatbuffers.Offset {
|
||||
Identity.startIdentity(builder);
|
||||
Identity.addId(builder, id);
|
||||
return Identity.endIdentity(builder);
|
||||
}
|
||||
|
||||
unpack(): IdentityT {
|
||||
return new IdentityT(
|
||||
this.id()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: IdentityT): void {
|
||||
_o.id = this.id();
|
||||
}
|
||||
}
|
||||
|
||||
export class IdentityT implements flatbuffers.IGeneratedObject {
|
||||
constructor(
|
||||
public id: number = 0
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return Identity.createIdentity(builder,
|
||||
this.id
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user