@types not working
See original GitHub issueLet’s suppose I installed @types/react
and added compilerOptions.types["react"]
to the tsconfig.json
. Then I’m trying to do import * as React from 'react'
and sublime says: module react is not found.
Same goes if I install types with typings
and add them via include["typings/index.d.ts"]
. The only way which works is to manually do /// <reference path="typings/index.d.ts" />
.
What is going on? I’m using TypeScript 2.0.3 both locally and globally. Executing tsc
on a project doesn’t produce any such errors.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:10
Top Results From Across the Web
typeRoots and types not working · Issue #37708 - GitHub
In my project root, I got package.json, package-lock.json, main.ts(empty one), tsconfig.json . tsconfig.json contains the above code.
Read more >TypeScript 2 - @types not recognized - Stack Overflow
It sounds like the compiler can't actually find the module. The compiler is looking for both the module and the definition file for...
Read more >Troubleshooting Handbook: Types
Facing weird type errors? You aren't alone. This is the hardest part of using TypeScript with React. Be patient - you are learning...
Read more >Surviving the TypeScript Ecosystem — Part 4 - Medium
Cool, that's not too bad. But how did TypeScript know how to find the newly downloaded type definition? When loading a JavaScript module...
Read more >Typescript Type System: How Does it Really Work? Type ...
Error:(54, 6) TS2339:Property 'name' does not exist on type '{}'. So what is going here? We have defined an empty object first and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I got it to work by setting a custom typescript version in the user settings (Command Palette -> Preferences: Settings) as a temporary workaround:
after adding the setting, restart sublime text and the @types will be recognized.
For more infos about the setting, visit https://github.com/Microsoft/TypeScript-Sublime-Plugin#note-using-different-versions-of-typescript
Just a quick note for future users: on mac, that path will normally be:
"typescript_tsdk": "/usr/local/lib/node_modules/typescript/lib/"
. And thanks! I was about to give up and move back to Babel all together =P I also agree that this should work out-of-the-box.