Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kit): update generated tsconfig.json with improved defaults #27485

Merged
merged 5 commits into from
Jun 7, 2024

Conversation

danielroe
Copy link
Member

🔗 Linked issue

resolves #25789

📚 Description

This improves types for Nuxt apps (and also within the monorepo), in many cases following recommendations from https://www.totaltypescript.com/tsconfig-cheat-sheet.

The most potentially disruptive changes is enabling noUncheckedIndexedAccess. I've marked that it only be enabled for v4 but would be willing to revisit that. It will likely throw up a lot of type warnings, but can easily be disabled, and is a better choice for a new project.

As the diff in the PR is a bit messy (tidying up the options by topic/section), here's a simplified version:

    compilerOptions: {
      forceConsistentCasingInFileNames: true,
      jsx: 'preserve',
      jsxImportSource: 'vue',
-     target: 'ESNext',
-     module: 'ESNext',
      target: 'es2022',
      module: 'preserve',
      moduleDetection: 'force',
      moduleResolution: nuxt.options.future?.typescriptBundlerResolution || (nuxt.options.experimental as any)?.typescriptBundlerResolution ? 'Bundler' : 'Node',
      skipLibCheck: true,
      isolatedModules: true,
      useDefineForClassFields: true,
      strict: nuxt.options.typescript?.strict ?? true,
      noUncheckedIndexedAccess: nuxt.options.future.compatibilityVersion === 4,
      noImplicitOverride: true,
      lib: [
        'es2022',
        'dom',
        'dom.iterable'
      ],
      noImplicitThis: true,
      esModuleInterop: true,
      types: [],
      verbatimModuleSyntax: true,
      allowJs: true,
      noEmit: true,
      resolveJsonModule: true,
      allowSyntheticDefaultImports: true,
      paths: {},
    }

@pi0 are you up for a similar PR to nitro?

Copy link

stackblitz bot commented Jun 7, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add noUncheckedIndexedAccess to tsconfig.server.json and tsconfig.json
1 participant