JavaScript Modules with Namespaces - Cannot resolve symbol

After upgrading to native-base 2.3.1 i'm now seeing that none of the exported components can be resolved. It appears they are all within the NativeBase namespace. The app compiles fine, but i'm getting warnings in every file.

if i change the import statement to be

'import * as NativeBase from 'native-base'

and then proceed to reference the components as NativeBase.Button etc, i receive no errors.

I'm using eslint 4.3.0 and my JavaScript language version in WebStorm is set to React JSX

1
2 comments

the issue occur because of the way the module is declared in \node_modules\native-base\index.d.ts:

 

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

declare module "native-base" {

if both an import statement and declare module statement are there, the module is considered an augmentation module. See https://youtrack.jetbrains.com/issue/WEB-27065#comment=27-2185731 for explanation

as a workaround, you can comment out both import statements in \index.d.ts:

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

declare module "native-base" {

Completion/resolving will work fine then

 

1
Avatar
Permanently deleted user

Thanks for the explanation Elena.

The workaround worked.

0

Please sign in to leave a comment.