question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@types not working

See original GitHub issue

Let’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:open
  • Created 7 years ago
  • Reactions:6
  • Comments:10

github_iconTop GitHub Comments

9reactions
duydaocommented, Oct 4, 2016

I got it to work by setting a custom typescript version in the user settings (Command Palette -> Preferences: Settings) as a temporary workaround:

"typescript_tsdk": "/absolute/path/to/node_modules/typescript/lib",

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

4reactions
rafaelbitencommented, Oct 13, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found