Vscode-react-native: React Native IntelliSense Not Work

Created on 12 Oct 2016  ·  11Comments  ·  Source: microsoft/vscode-react-native

Actual Behavior

qq20161012-0 2x

qq20161012-1 2x

Software versions

  • React-Native VS Code extension version: 0.2.0
  • VSCode version: 1.6.0
  • OS platform and version: macOS 10.12
  • React Native version: 0.34.1
bug

Most helpful comment

I've created a new project with

react-native init foobar
cd foobar
code .

and the extension is not working. It's not even recognizing that the language is Javascript React.
My tsconfig.json is
{"compilerOptions":{"allowJs":true},"exclude":["node_modules"]}

I've tried the following from the project root:

  • cp -R .vscode/typings .vscode/react;
  • cp -R .vscode/typings .
  • cp -R .vscode/typings .vscode/.react (no dice, vscode will delete it);

I don't have a .vscode/react/typings but I have .vscode/typings/react-native/react-native.d.ts

Oh, by the way, the README still mentions VSCode 0.11, which seems just a little outdated since we are at 1.6.

All 11 comments

Me too

If you look in the bottom right of the VS Code window, what language service does it show?

capture

Also have you referenced import { AppRegistry } from 'react-native'; ?

我也遇到了这个问题,用typescript可以结局,但是需要手动安装@types/react-native

@MSLaguana JavaScript, no JavaScript React. I am sure referenced import { AppRegistry } from 'react-native';

just copy srcRootDir/.vscode/typings to srcRootDir/typings , and it works.

don't know why, but work.

Do you have a jsconfig.json or a tsconfig.json file in your root folder, which specifies either a files element or an excludes element? If you do, that may be excluding the .vscode/typings folder which would mean intellisense does not consider them.

@MSLaguana My tsconfig.json

{
    "compilerOptions": {
        "allowJs": true
    },
    "exclude": [
        "node_modules"
    ]
}

Do not have jsconfig.json.

That shouldn't cause issues then. Could you please check that .vscode/react/typings exists and has react-native.d.ts in it?

exist……

I've created a new project with

react-native init foobar
cd foobar
code .

and the extension is not working. It's not even recognizing that the language is Javascript React.
My tsconfig.json is
{"compilerOptions":{"allowJs":true},"exclude":["node_modules"]}

I've tried the following from the project root:

  • cp -R .vscode/typings .vscode/react;
  • cp -R .vscode/typings .
  • cp -R .vscode/typings .vscode/.react (no dice, vscode will delete it);

I don't have a .vscode/react/typings but I have .vscode/typings/react-native/react-native.d.ts

Oh, by the way, the README still mentions VSCode 0.11, which seems just a little outdated since we are at 1.6.

By the way, I've managed to have auto completion by installing the "Typings" extension as described in this blog post: https://medium.com/react-weekly/react-native-and-typescript-ad57b7413ead#.lqkkadkkt

I'm just starting with this technology, so bear with me if I'm doing a bit of cargo-culting... :)

Was this page helpful?
0 / 5 - 0 ratings