We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I still playing with arktype and found this issue while emiting d.ts
import { scope } from "arktype"; // Scopes are collections of types that can reference each other. export const types = scope({ package: { name: "string", "dependencies?": "package[]", "contributors?": "contributor[]", }, contributor: { // Subtypes like 'email' are inferred like 'string' but provide additional validation at runtime. email: "string.email", "packages?": "package[]", }, }).export(); // Cyclic types are inferred to arbitrary depth... export type Package = typeof types.package.infer; // And can validate cyclic data. const packageData: Package = { name: "arktype", dependencies: [{ name: "typescript" }], contributors: [{ email: "david@sharktypeio" }], }; packageData.dependencies![0].dependencies = [packageData]; export const out = types.package(packageData);
d.ts result
export declare const types: import("arktype").Module<{ package: { name: string; dependencies?: any[]; contributors?: { email: string & { " arkConstrained": import("arktype/out/keywords/inference").Branded<"email">; }; packages?: any[]; }[]; }; contributor: { email: string & { " arkConstrained": import("arktype/out/keywords/inference").Branded<"email">; }; packages?: any[]; }; }>; export type Package = typeof types.package.infer; export declare const out: { name: string; dependencies?: any[]; contributors?: { email: string; packages?: any[]; }[]; } | import("arktype").ArkErrors;
tsconfig.json
{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", "target": "ESNext", "skipLibCheck": true, "strict": true, "exactOptionalPropertyTypes": true, "declaration": true, "emitDeclarationOnly": true, "declarationDir": "./type" } }
The text was updated successfully, but these errors were encountered:
It seems like you need moduleResolution: "NodeNext" to get TS to output the correct paths. Here is the config I used to test it:
moduleResolution: "NodeNext"
{ "compilerOptions": { "module": "NodeNext", "target": "ESNext", "moduleResolution": "NodeNext", "lib": ["ESNext"], "skipLibCheck": true, "declaration": true, "strict": true, "verbatimModuleSyntax": true, "esModuleInterop": true, "types": ["node"] }, "include": ["src"] }
That said, it seems like a limitation of TS that anonymous cyclic types can't be output as .d.ts, as I notice this was my output:
export declare const out: { name: string; dependencies?: any[] | undefined; contributors?: { email: string; packages?: any[] | undefined; }[] | undefined; } | import("arktype").ArkErrors;
It makes sense they're not serializable directly, but may be worth opening an issue on the TS repo to see if there's another way.
Sorry, something went wrong.
I still found Argument of type 'string' is not assignable to parameter of type '(string & { " of": { base: string; attributes: MoreThanLength<7>; }; }) | (string & { " of": { base: string; attributes: MoreThanLength<7>; }; }) | (string & { ...; }) | (string & { ...; }) | undefined'.
Argument of type 'string' is not assignable to parameter of type '(string & { " of": { base: string; attributes: MoreThanLength<7>; }; }) | (string & { " of": { base: string; attributes: MoreThanLength<7>; }; }) | (string & { ...; }) | (string & { ...; }) | undefined'.
But seems same issue with #1116 , so please refers to #1116 to maintain the issue solving
ssalbdivad
No branches or pull requests
I still playing with arktype and found this issue while emiting d.ts
d.ts result
tsconfig.json
The text was updated successfully, but these errors were encountered: