Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add new files. #1006

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [20.x, 21.x]

steps:
- uses: actions/checkout@v4
Expand Down
Binary file added integration/extension-import/base.bin
Binary file not shown.
79 changes: 79 additions & 0 deletions integration/extension-import/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* eslint-disable */
import _m0 from "protobufjs/minimal";

export interface Extendable {
field: string;
}

function createBaseExtendable(): Extendable {
return { field: "" };
}

export const Extendable = {
encode(message: Extendable, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.field !== "") {
writer.uint32(10).string(message.field);
}
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): Extendable {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseExtendable();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}

message.field = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},

fromJSON(object: any): Extendable {
return { field: isSet(object.field) ? globalThis.String(object.field) : "" };
},

toJSON(message: Extendable): unknown {
const obj: any = {};
if (message.field !== "") {
obj.field = message.field;
}
return obj;
},

create<I extends Exact<DeepPartial<Extendable>, I>>(base?: I): Extendable {
return Extendable.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Extendable>, I>>(object: I): Extendable {
const message = createBaseExtendable();
message.field = object.field ?? "";
return message;
},
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

type DeepPartial<T> = T extends Builtin ? T
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
4 changes: 2 additions & 2 deletions integration/extension-import/extension-import-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import * as path from "node:path";
import * as fs from "node:fs";
import * as ts from "typescript";

describe('extension-only-files', () => {
describe("extension-only-files", () => {
it("generate as external module", () => {
const generatedPath = path.join(__dirname, "extension.ts");
const generatedCode = fs.readFileSync(generatedPath, "utf8");
const source = ts.createSourceFile(generatedPath, generatedCode, ts.ScriptTarget.ES2018);

expect(ts.isExternalModule(source)).toBe(true);
})
});
});
Binary file added integration/extension-import/extension.bin
Binary file not shown.
4 changes: 4 additions & 0 deletions integration/extension-import/index.foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable */

export * from "./base";
export * from "./extension";
3 changes: 3 additions & 0 deletions integration/extension-import/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* eslint-disable */

export * as foo from "./index.foo";
3 changes: 2 additions & 1 deletion integration/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"exclude": [
"angular",
"batching-with-context-esModuleInterop",
"extension-import/*.ts",
"import-mapping/mapping.ts",
"simple-esmodule-interop"
]
}
}
1 change: 1 addition & 0 deletions integration/tsconfig.proto.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"codegen.ts",
"angular",
"batching-with-context-esModuleInterop",
"extension-import/*.ts",
"import-mapping/mapping.ts",
"simple-esmodule-interop"
]
Expand Down
2 changes: 1 addition & 1 deletion protoc.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Docker image for protoc
FROM node:current-slim
FROM node:20-slim
ARG PROTOC_VERSION="3.19.1"
ARG ARCH="x86_64"

Expand Down
Loading