Add common types to their own file/export w/outputIndex option
In each ts file generated there is
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
export 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;
export 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;
}
The biggest problem I have with this is that they are exported (so I can't use export * from './protofile.ts')
Is there a way to have them imported from a shared file in each ts file and to not export them?
https://github.com/stephenh/ts-proto/pull/821/files
Seems there is an exportCommonSymbols option which solves the problem at hand, but I will leave open for the other improvement which is to output those types in a separate file and import them
Hi @Tofandel , you're right we don't have an option to put the common types in a shared package, and export that from the index file. We could probably just do that if outputIndex=true was enabled.
If you'd like to submit a PR for that, that'd be great! Thank you!