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

Where can you specify typeRoots? #2

Closed
mickdekkers opened this issue Nov 9, 2017 · 2 comments
Closed

Where can you specify typeRoots? #2

mickdekkers opened this issue Nov 9, 2017 · 2 comments

Comments

@mickdekkers
Copy link

Hey, thanks for making this example project. It's been really helpful.

There's a package I'm trying to work with (execa), but some of the typings are incorrect. I'd like to override the @types/execa typings with my own types in a /package/foo/types folder, at least temporarily. From what I understand, this should be possible through setting the typeRoots property in tsconfig like this:

"typeRoots": [
  "./node_modules/@types",
  "./types/"
]

But I'm not sure which tsconfig file this should be put in. I think I've tried all of them (and restarted vscode in between) but the types in my types folder aren't being picked up. Where can I place the typeRoots property so it can be picked up by vscode and tsc when building?

@Quramy
Copy link
Owner

Quramy commented Nov 9, 2017

Hi.

But I'm not sure which tsconfig file this should be put in.

Do you try put typeRoots to <project_root>/tsconfig.base.json?
And you can re-structure your project directory such as :

<project_root>
 + node_modules/
 |  | @types
 |  :  + execa/
 + packages/
 |  + foo
 |  \ bar
 + types/ 
 |  + xxx.d.ts 
 |  + yyy.d.ts
 |   :
 + tsconfig.base.json    <-- put typeRoots entry to this file

@mickdekkers
Copy link
Author

Hi, thanks for your reply.

I tried restructuring the project directory as you suggested and putting typeRoots in <project_root>/tsconfig.base.json, but it turns out I misunderstood and typeRoots are only used to resolve /// <reference types=".." /> directives.
I used the workaround described here by putting that into <project_root>/tsconfig.json, and my types are detected correctly now 🎉

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

No branches or pull requests

2 participants