deepkit-framework icon indicating copy to clipboard operation
deepkit-framework copied to clipboard

Improve type-compiler handing of `extends` field in tsconfig

Open lionelhorn opened this issue 1 year ago • 0 comments

TLDR : when "extends" is an array in tsconfig, type-compiler crashes.

While using deepkit vite plugin like that

// vite.config.ts

export default defineConfig({
  [...]
    plugins: [
        deepkitType({
            tsConfig: resolve(__dirname, "tsconfig.json"),
            compilerOptions: {
                "sourceMap": true,
            }
        }),
    // [...]
    ],
})

// tsconfig.json

{
    "include": ["**/*.ts", "**/*.tsx"],
    "extends": ["@epic-web/config/typescript"],
    "compilerOptions": {
        "paths": {
            "#app/*": ["./app/*"],
            "#tests/*": ["./tests/*"],
            "@/icon-name": [
                "./app/components/ui/icons/name.d.ts",
                "./types/icon-name.d.ts"
            ]
        }
    },
    "reflection": "true"
}

https://github.com/deepkit/deepkit-framework/blob/1e0d489dfcf5e18cd3903719ce944930ad3c900f/packages/type-compiler/src/config.ts#L289

Will crash with TypeError: The "path" argument must be of type string. Received an instance of Array

According to https://www.typescriptlang.org/tsconfig/#extends it's supposed to be a string. According to the tsconfig-schema.json and the "intellisense" like highlight in my IDE, it can be array | string.

lionelhorn avatar Jul 11 '24 16:07 lionelhorn