Skip to content

tsc not recognizing typings in node_modules/@types #11109

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

Closed
bmurali31 opened this issue Sep 23, 2016 · 2 comments
Closed

tsc not recognizing typings in node_modules/@types #11109

bmurali31 opened this issue Sep 23, 2016 · 2 comments

Comments

@bmurali31
Copy link

bmurali31 commented Sep 23, 2016

TypeScript Version: 2.0.3

Code
tsconfig.json
{
"compilerOptions": {
"target": "es2015",
"jsx": "react",
"module" :"es2015",
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"experimentalDecorators": true,
"preserveConstEnums": true,
"sourceMap": true,
"typeRoots": [
"node_modules/@types"
]
},
"compileOnSave": true,
"exclude": [
"node_modules"
]
}

tsc could not locate the typings from node_modules/@types folder.
It works if I install typings using "typings install"

// A *self-contained* demonstration of the problem follows...
tsc command fails with the following message. 

index.android.tsx(9,24): error TS2307: Cannot find module 'react'.                                                                       
index.android.tsx(19,8): error TS2307: Cannot find module 'react-native'.                                                                
node_modules/@types/react-native/index.d.ts(19,24): error TS2307: Cannot find module 'react'.                                            
node_modules/@types/react-native/index.d.ts(222,28): error TS2304: Cannot find name 'Component'.

**index.android.tsx** file content

import * as React from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  FlexAlignType,
  ViewStyle,
  TextStyle,
  fetch
} from 'react-native';

Expected behavior:
tsc should compile without any errors
Actual behavior:

@bmurali31
Copy link
Author

@joselee I am guessing it is something to do with the my tsconfig.json setting. The same tsconfig works fine if I install the typings using "typings install".

@ghost
Copy link

ghost commented Sep 23, 2016

Duplicate of #11103

@ghost ghost closed this as completed Sep 23, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant