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

How about using typeRoots instead of types in tsconfig.json? #38

Closed
iwata opened this issue Mar 22, 2019 · 4 comments
Closed

How about using typeRoots instead of types in tsconfig.json? #38

iwata opened this issue Mar 22, 2019 · 4 comments
Labels
transfered Issue transfered from nuxt main repo

Comments

@iwata
Copy link

iwata commented Mar 22, 2019

What problem does this feature solve?

I think it is better to use typeRoots than types.
That's because if you use types, you have to add it to types explicitly when you add @types/xxx as your dependency.

What does the proposed changes look like?

Specifically, you should write the following in defaultTsJsonConfig:

export const defaultTsJsonConfig = {
  compilerOptions: {
    target: 'esnext',
    module: 'esnext',
    moduleResolution: 'node',
    lib: [
      'esnext',
      'esnext.asynciterable',
      'dom'
    ],
    esModuleInterop: true,
    experimentalDecorators: true,
    allowJs: true,
    sourceMap: true,
    strict: true,
    noImplicitAny: false,
    noEmit: true,
    baseUrl: '.',
    paths: {
      '~/*': [
        './*'
      ],
      '@/*': [
        './*'
      ]
    },
    typeRoots: [
      './node_modules/@types',
      './node_modules/@nuxt/vue-app/types'
    ]
  }
}
This feature request is available on Nuxt community (#c8889)
@iwata iwata changed the title Use typeRoots instead of types in tsconfig.json How about using typeRoots instead of types in tsconfig.json? Mar 22, 2019
@kevinmarrec
Copy link
Contributor

@iwata Thanks for your proposal, I will closely check if it better fits for the next major TS change (which should switch back to the extends way instead of overriding tsconfig.json when Nuxt is starting)

@kevinmarrec
Copy link
Contributor

@iwata The issue with typeRoots is that it needs relative path, and people might have their node_modules not in current folder where is running nuxt.

See
https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types

I suggest keeping types for now.

I'm working on changes which will only create tsconfig.json with these values only if the file is missing. So then people can change and use typeRoots (they already can do) if they really need it.

@iwata
Copy link
Author

iwata commented Mar 25, 2019

@kevinmarrec
Thanks your prompt reply.

I'm working on changes which will only create tsconfig.json with these values only if the file is missing.

That's great.
It's related by this second question.
https://cmty.app/nuxt/nuxt.js/issues/c8891

@kevinmarrec
Copy link
Contributor

@iwata Everything you mentioned won't be longer issues with nuxt/nuxt#5367

And yes, @nuxt/typescript should be installed as dependency and not devDependency to prevent error in production to be able to use nuxt start. See docs PR linked to the link above, I changed it so it tells user to install it as dependency.

It will also be in released notes when it will be released.

@pi0 pi0 transferred this issue from nuxt/nuxt Aug 10, 2019
@kevinmarrec kevinmarrec added the transfered Issue transfered from nuxt main repo label Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transfered Issue transfered from nuxt main repo
Projects
None yet
Development

No branches or pull requests

2 participants