mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-05 08:47:05 +00:00
Improve TS types to support isolatedModules and isolatedDeclarations
This commit is contained in:
21
tests/ts/relative_imports/transit/one/info.d.ts
vendored
Normal file
21
tests/ts/relative_imports/transit/one/info.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as flatbuffers from 'flatbuffers';
|
||||
export declare class Info implements flatbuffers.IUnpackableObject<InfoT> {
|
||||
bb: flatbuffers.ByteBuffer | null;
|
||||
bb_pos: number;
|
||||
__init(i: number, bb: flatbuffers.ByteBuffer): Info;
|
||||
static getRootAsInfo(bb: flatbuffers.ByteBuffer, obj?: Info): Info;
|
||||
static getSizePrefixedRootAsInfo(bb: flatbuffers.ByteBuffer, obj?: Info): Info;
|
||||
timestamp(): bigint;
|
||||
static getFullyQualifiedName(): "Transit.One.Info";
|
||||
static startInfo(builder: flatbuffers.Builder): void;
|
||||
static addTimestamp(builder: flatbuffers.Builder, timestamp: bigint): void;
|
||||
static endInfo(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
static createInfo(builder: flatbuffers.Builder, timestamp: bigint): flatbuffers.Offset;
|
||||
unpack(): InfoT;
|
||||
unpackTo(_o: InfoT): void;
|
||||
}
|
||||
export declare class InfoT implements flatbuffers.IGeneratedObject {
|
||||
timestamp: bigint;
|
||||
constructor(timestamp?: bigint);
|
||||
pack(builder: flatbuffers.Builder): flatbuffers.Offset;
|
||||
}
|
||||
57
tests/ts/relative_imports/transit/one/info.js
Normal file
57
tests/ts/relative_imports/transit/one/info.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 Info {
|
||||
constructor() {
|
||||
this.bb = null;
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
__init(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
static getRootAsInfo(bb, obj) {
|
||||
return (obj || new Info()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
static getSizePrefixedRootAsInfo(bb, obj) {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Info()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
timestamp() {
|
||||
const offset = this.bb.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb.readUint64(this.bb_pos + offset) : BigInt('0');
|
||||
}
|
||||
static getFullyQualifiedName() {
|
||||
return 'Transit.One.Info';
|
||||
}
|
||||
static startInfo(builder) {
|
||||
builder.startObject(1);
|
||||
}
|
||||
static addTimestamp(builder, timestamp) {
|
||||
builder.addFieldInt64(0, timestamp, BigInt('0'));
|
||||
}
|
||||
static endInfo(builder) {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
static createInfo(builder, timestamp) {
|
||||
Info.startInfo(builder);
|
||||
Info.addTimestamp(builder, timestamp);
|
||||
return Info.endInfo(builder);
|
||||
}
|
||||
unpack() {
|
||||
return new InfoT(this.timestamp());
|
||||
}
|
||||
unpackTo(_o) {
|
||||
_o.timestamp = this.timestamp();
|
||||
}
|
||||
}
|
||||
export class InfoT {
|
||||
constructor(timestamp = BigInt('0')) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
pack(builder) {
|
||||
return Info.createInfo(builder, this.timestamp);
|
||||
}
|
||||
}
|
||||
78
tests/ts/relative_imports/transit/one/info.ts
Normal file
78
tests/ts/relative_imports/transit/one/info.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 Info implements flatbuffers.IUnpackableObject<InfoT> {
|
||||
bb: flatbuffers.ByteBuffer|null = null;
|
||||
bb_pos: number = 0;
|
||||
__init(i:number, bb:flatbuffers.ByteBuffer):Info {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
}
|
||||
|
||||
static getRootAsInfo(bb:flatbuffers.ByteBuffer, obj?:Info):Info {
|
||||
return (obj || new Info()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
static getSizePrefixedRootAsInfo(bb:flatbuffers.ByteBuffer, obj?:Info):Info {
|
||||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
||||
return (obj || new Info()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
}
|
||||
|
||||
timestamp():bigint {
|
||||
const offset = this.bb!.__offset(this.bb_pos, 4);
|
||||
return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
|
||||
}
|
||||
|
||||
static getFullyQualifiedName(): "Transit.One.Info" {
|
||||
return 'Transit.One.Info';
|
||||
}
|
||||
|
||||
static startInfo(builder:flatbuffers.Builder):void {
|
||||
builder.startObject(1);
|
||||
}
|
||||
|
||||
static addTimestamp(builder:flatbuffers.Builder, timestamp:bigint):void {
|
||||
builder.addFieldInt64(0, timestamp, BigInt('0'));
|
||||
}
|
||||
|
||||
static endInfo(builder:flatbuffers.Builder):flatbuffers.Offset {
|
||||
const offset = builder.endObject();
|
||||
return offset;
|
||||
}
|
||||
|
||||
static createInfo(builder:flatbuffers.Builder, timestamp:bigint):flatbuffers.Offset {
|
||||
Info.startInfo(builder);
|
||||
Info.addTimestamp(builder, timestamp);
|
||||
return Info.endInfo(builder);
|
||||
}
|
||||
|
||||
unpack(): InfoT {
|
||||
return new InfoT(
|
||||
this.timestamp()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
unpackTo(_o: InfoT): void {
|
||||
_o.timestamp = this.timestamp();
|
||||
}
|
||||
}
|
||||
|
||||
export class InfoT implements flatbuffers.IGeneratedObject {
|
||||
constructor(
|
||||
public timestamp: bigint = BigInt('0')
|
||||
){}
|
||||
|
||||
|
||||
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
|
||||
return Info.createInfo(builder,
|
||||
this.timestamp
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user