-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Intellisense, navigation (ctrl+click) stops working for react-native projects #8528
Comments
I haven't looked at |
As @basarat noted, {
"compilerOptions": {
"paths": { "@whatever/*" : [ "node_modules/components/*" ] }
}
} Documentation for |
I might be wrong, but from #5039 I read |
sorry about that. {
"compilerOptions": {
"baseUrl" : "./",
"paths": { "@whatever/*": [ "node_modules/components/*" ] }
}
} |
Maybe I'm doing something wrong. This is for a react-native app. My {
"compilerOptions": {
"allowJs": true,
"paths": {
"baseUrl": "./",
"app/*": [
"./*"
]
}
},
"exclude": [
"node_modules"
]
} Then I have the following structure:
Then in import { getSettingsType } from 'app/components/settings'; It still doesn't work: cmd+click not working, neither intellisense. |
(I've also tried to place |
@miqmago you have the config wrong. |
runnign tsc on teh provided tsconfig.json i get: c:\ts2>tsc --v
Version 1.9.0-dev.20160518-1.0
c:\ts2>tsc --p ./tsconfig.json
error TS5060: Option 'paths' cannot be used without specifying '--baseUrl' option.
error TS5063: Substitutions for pattern 'baseUrl' should be an array. |
@basarat thanks, this is not working anyway (cmd+hover doesn't find the definition, cmd+click not working): app/tsconfig.json {
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"paths": {
"app/*": [
"./*"
]
}
},
"exclude": [
"node_modules"
]
} app/components/settings/index.js import t from 'tcomb-form-native';
export function getSettingsType(options) {
const Settings = {
isShowHelp: t.Boolean,
};
return t.struct(Settings);
} app/selectors/settings.json import { getSettingsType } from 'app/components/settings'; Also tried the following cases with the same result:
The only working is |
Do not think this path mapping arguemtn males sense in the given example. you are saying if you see something that has a prefix this works for me: c:\test\8528>tree /F
Folder PATH listing for volume OSDisk
Volume serial number is 00000090 9E6D:383F
C:.
│ tsconfig.json
│
└───app
├───components
│ └───settings
│ index.js
│
└───selectors
settings.js
c:\test\8528>type tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "./",
"outDir": "built"
},
"exclude": [
"node_modules",
"built"
]
}
c:\test\8528>type app\components\settings\index.js
import t from 'tcomb-form-native';
export function getSettingsType(options) {
const Settings = {
isShowHelp: t.Boolean,
};
return t.struct(Settings);
}
c:\test\8528>type app\selectors\settings.js
import { getSettingsType } from 'app/components/settings';
c:\test\8528>tsc --v
Version 1.9.0-dev.20160518-1.0
c:\test\8528>tsc one helpful tool to use is
======== Resolving module 'app/components/settings' from 'c:/test/8528/app/selectors/settings.js'. ========
Module resolution kind is not specified, using 'NodeJs'.
'baseUrl' option is set to 'c:/test/8528', using this value to resolve non-relative module name 'app/components/settings'
'paths' option is specified, looking for a pattern to match module name 'app/components/settings'.
Module name 'app/components/settings', matched pattern 'app/*'.
Trying substitution './*', candidate module location: './components/settings'.
Loading module as file / folder, candidate module location 'c:/test/8528/components/settings'.
File 'c:/test/8528/components/settings.ts' does not exist.
File 'c:/test/8528/components/settings.tsx' does not exist.
File 'c:/test/8528/components/settings.d.ts' does not exist.
File 'c:/test/8528/components/settings.js' does not exist.
File 'c:/test/8528/components/settings.jsx' does not exist.
File 'c:/test/8528/components/settings/package.json' does not exist.
File 'c:/test/8528/components/settings/index.ts' does not exist.
File 'c:/test/8528/components/settings/index.tsx' does not exist.
File 'c:/test/8528/components/settings/index.d.ts' does not exist.
File 'c:/test/8528/components/settings/index.js' does not exist.
File 'c:/test/8528/components/settings/index.jsx' does not exist.
.....
======== Module name 'app/components/settings' was not resolved. ======== |
@mhegazy Thanks. When running
Also I've just tried the structure that you propose, moving all files inside declare module Settings {
function getSettingsType(options);
}
export = Settings; But it neither works. This is very frustrating 😢 |
what version of tsc are you using? |
I've just updated to 1.8.10 right now and the behavior is the same:
Visual Code: Versió 1.1.1-insider (1.1.1-insider) |
Also tried this command and maybe here it is the problem:
tsconfig.json: {
"compilerOptions": {
"allowJs": true,
"baseUrl": "./"
},
"exclude": [
"node_modules"
]
} After removing |
all these features are TS 2.0 features. so the version you are using does not support them. i would not expect them to work. you can get the latest drops of TypeScript through |
Did you mean 1.9?
Also https://github.com/Microsoft/TypeScript/blob/master/package.json#L5: "version": "1.9.0", Now
Is this feature really developed? (Meaning |
Also noted that react-native is unable to resolve
(Debugging with Visual Code) |
I think this is not only a question, but a bug/feature and maybe it could be reopened: |
yes. the version says 1.9, we pump the version when we ship. so this is what is going to be TS 2.0. I should have been more explicit.
This has nothing to do with
the correct flag name is
This error is not one that the compiler emits, so this is a runtime error. I do not have enough context to be able to help you here.
Can you provide a project i can look at, i might be able to help better this way, |
Please see https://github.com/miqmago/RNVSTest repo for a demo project. In this project, you can see that This project is the result of creating the project with
|
I think i see the probelm. baseURL is a new feature that was not in TS 1.8, and is not in the latest VSCode. you can update your VSCode installation to use a later version of TS (see details here). to do that, you need to install Doing so makes this sample work fine for me using vscode 1.1.1: |
@mhegazy the solution you propose solves the problem of intellisense in visual studio, but this won't run in react-native:
If changing to
|
facebook/react-native#3099 (comment) seems to work, I've commited the changes |
From @miqmago on April 30, 2016 11:15
In a react-native project, in this issue facebook/react-native#3099 (comment) it is suggested to follow this steps in order to avoid
../../../../..
paths in requires:package.json:
(or without
@
it works too)Then in your files you can load a package like this:
The problem with this is that navigation (ctrl+click), intellisense, etc. stops working
Copied from original issue: microsoft/vscode#6015
The text was updated successfully, but these errors were encountered: