AngiusA
Denoβ€’10mo agoβ€’
1 reply
Angius

`ts-match` unable to infer types properly

I'm using the ts-match library to do some pattern matching on an object, and it seems unable to infer most types properly. Perhaps someone has experience with it.
My code is https://pastie.io/htxtti.ts and I'm seeing errors left, right, and center.

* 1: Type 'unknown' is not assignable to type '[typeString: string | undefined, skipImport: boolean]'
* 9: Object literal may only specify known properties, and 'enum' does not exist in type 'Matcher<never, unknown, any, any, unknown>'
* 10: Property 'enum' does not exist on type 'never'
* 10: Parameter 'e' implicitly has an 'any' type
* 13: Object literal may only specify known properties, and 'oneOf' does not exist in type 'Matcher<never, unknown, any, any, unknown>'
* 15: Property 'oneOf' does not exist on type 'never'
* 24: Object literal may only specify known properties, and 'properties' does not exist in type 'Matcher<never, unknown, any, any, unknown>
* 26: Property 'properties' does not exist on type 'never'
* 27: Argument of type 'unknown' is not assignable to parameter of type 'Type'
* 35: Object literal may only specify known properties, and 'type' does not exist in type 'Matcher<never, unknown, any, any, unknown>'
* 36: Property 'type' does not exist on type 'never'

For reference, the type I'm matching on is
export interface Type {
    type: string;
    enum?: string[] | undefined;
    format?: string | undefined;
    nullable?: boolean | undefined;
    properties?: Record<string, Type> | undefined;
    items: Type;
    oneOf?: Type[] | undefined;
    $ref?: string | undefined;
}
Was this page helpful?