tsconfig / bases

Hosts TSConfigs to extend in a TypeScript app, tuned to a particular runtime environment
MIT License
6.41k stars 240 forks source link

Help Me #201

Open ageha734 opened 1 year ago

ageha734 commented 1 year ago

Error1

tsconfig:

{
  "extends": "@tsconfig/next/tsconfig.json",
  "compilerOptions": {
    "paths": {
      "lib/*": [
        "lib/*"
      ]
    }
  }
}

TypeScript 5 have the following error: TypeError: Cannot read properties of undefined (reading 'push') at writeConfigurationDefaults (/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js:227:30) at async verifyTypeScriptSetup (/node_modules/next/dist/lib/verifyTypeScriptSetup.js:120:9) at async DevServer.verifyTypeScript (/node_modules/next/dist/server/dev/next-dev-server.js:648:34) at async DevServer.prepareImpl (/node_modules/next/dist/server/dev/next-dev-server.js:672:9) at async NextServer.prepare /node_modules/next/dist/server/next.js:165:13) at async Server.<anonymous> (/next/dist/server/lib/render-server.js:123:17) { type: 'TypeError' }

Error2

tsconfig:

{
  "extends": "node_modules/@tsconfig/next/tsconfig.json",
  "compilerOptions": {
    "paths": {
      "lib/*": [
        "lib/*"
      ]
    }
  }
}

TypeScript 5 have the following error: error TS6053: File 'node_modules/@tsconfig/next/tsconfig.json' not found.

Development environment

List of commands executed

summary

I can't build with an error even after changing the path to the Extended Settings file and re-installing.

orta commented 1 year ago

Did you install the packages?

ageha734 commented 1 year ago

Yes. Installed and used.

orta commented 1 year ago

I'm unsure, maybe next does something strange to the paths but that seems unlikely

ageha734 commented 1 year ago

I think the proper setting is

"extends":"@tsconfig/next/tsconfig.json"

but is there any other place to set it?

orta commented 1 year ago

Nope that goes in your tsconfig

emkman commented 1 year ago

@ageha734 the issue is with Next.js. It expects an include key in your tsconfig.json. Instead of

{
  "extends": "@tsconfig/next/tsconfig.json"
}

you need something like this

{
  "extends": "@tsconfig/next/tsconfig.json",
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

Generally, it seems like this package doesn't play that well with Next.js expectations which does a lot of checks and automatic injection into your tsconfig.json and so it's probably better to just copy and paste from https://github.com/tsconfig/bases/blob/main/bases/next.json manually.