NativeBase components cannot be resolved in IDE (PhpStorm/WebStorm)

Created on 19 Jul 2017  路  13Comments  路  Source: GeekyAnts/NativeBase

react-native, react and native-base version

RN: 0.45.1 React: 16.0.0-alpha.12 NativeBase: 2.2.0

Expected behaviour

Since NativeBase has its type definitions file within it (node_modules/native-base/index.d.ts) my IDE should be able to resolve imported components. All of my other dependencies can be resolved by PhpStorm without any problem, like: React, React-Native, Redux, propTypes etc.

Actual behaviour

When I use following statement in my IDE (phpStorm)

import { connectStyle, Button, Text } from 'native-base';

I get: Cannot resolve symbol error for all the components imported.

Steps to reproduce (code snippet or screenshot)

Create a new project on PhpStorm with React, ReactNative and NativeBase. Then add the following import statement to any JS file.

import { connectStyle, Button, Text } from 'native-base';

Screenshot of emulator/device

N/A

Is the bug present in both ios and android or in any one of them?

N/A

Any other additional info which would help us debug the issue quicker.

N/A

Most helpful comment

For a temporary fix.

In \node_modules\native-base\index.d.ts: comment the imports:

//import * as React from "react";
//import * as ReactNative from "react-native";

declare module "native-base" {

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000489950-JavaScript-Modules-with-Namespaces-Cannot-resolve-symbol

All 13 comments

+1

+1

+1

For a temporary fix.

In \node_modules\native-base\index.d.ts: comment the imports:

//import * as React from "react";
//import * as ReactNative from "react-native";

declare module "native-base" {

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000489950-JavaScript-Modules-with-Namespaces-Cannot-resolve-symbol

@darkopetrovic Thank you so much. This worked.

It works, thx

thanks, works

Any updates? The solution, as is says, is "temporary". Every time yarn / npm runs the fix is removed from the file.

Edit; or is this an Intellij / Webstorm / Phpstorm /... issue?

@darkopetrovic It works!

This temporary fix might be a PR ;)

@darkopetrovic thanks a lot. I fix it finally, that confuced me a lot before.

https://github.com/GeekyAnts/NativeBase/issues/1075#issuecomment-321543488

Actually, this fix does not fix the problem fully. Imports begin working, but instead it breaks ability of IDE to suggest properties that inherited from base ReactNative components

Guys, any progress here?
This is really annoying bug.

Fixed with NB 2.3.10

Was this page helpful?
0 / 5 - 0 ratings