ThomasAribart / json-schema-to-ts

Infer TS types from JSON schemas 📝
MIT License
1.43k stars 30 forks source link

VSCode syntax checking slow #154

Open yoshi-68 opened 1 year ago

yoshi-68 commented 1 year ago

Importing FromSchema slows VSCode's syntax check.

ThomasAribart commented 8 months ago

@yoshi-68 Can you provide more details on your issue ? How did you use FromSchema ? What version ? etc.

Seancheey commented 6 months ago

experiencing same issue with generics:

Here is an example:


export class ApiSchema<IN extends JSONSchema, OUT extends JSONSchema> {
    readonly path: string;
    readonly requestSchema: IN;
    readonly responseSchema: OUT;
    readonly requestValidate;

    constructor(path: string, requestSchema: IN, responseSchema: OUT) {
        this.path = path;
        this.requestSchema = requestSchema;
        this.responseSchema = responseSchema;
        this.requestValidate = ajv.compile(requestSchema);
    }

    buildPostApi(
        handle: (requestBody: FromSchema<IN>, request: RequestEvent) => Promise<FromSchema<OUT>>
    ): (event: RequestEventAny) => Response | Promise<Response> {
       ...
    }
}
fermuch commented 4 months ago

@Seancheey this might be a bit old and maybe you've moved from it, but the docs in here helped me solve this: https://github.com/ThomasAribart/json-schema-to-ts/blob/main/documentation/FAQs/applying-from-schema-on-generics.md

They should be displayed more promptly!