TypeScript tsc not recognizing valid dotted notation types in strict mode while Angular...

Discussão em 'Angular' iniciado por Sai Satwik Kuppili, Outubro 22, 2024.

  1. I'm using Angular with a custom TypeScript utility type NestedKeyOf to extract nested keys from objects in a dotted notation format.

    Here's my NestedKeyOf type definition:

    type NestedKeyOf<T> = T extends object
    ? {
    [K in keyof T & string]: T[K] extends object
    ? K | `${K}.${NestedKeyOf<T[K]>}`
    : K;
    }[keyof T & string]
    : never;


    This type works as expected during Angular's compilation (ng serve, ng build), and it allows me to access properties using dot notation (e.g., property.nestedProperty). However, when I run tsc directly with strict mode enabled, the dotted notation is not recognized as a valid type.

    Here is the TypeScript compilation command I use:

    tsc -p ./tsconfig.app.json --noEmit --skipLibCheck --strict


    Why is tsc not recognizing valid dotted notation types that work fine during Angular compilation? Is there any configuration or workaround to make tsc handle these types similarly to how Angular does?

    Note: Ensured that both Angular and tsc use the same TypeScript version.

    Continue reading...

Compartilhe esta Página