Skip to content

Replace import React with import * as React#1346

Merged
jgonet merged 1 commit intomasterfrom
@kuba/import-react
Feb 10, 2021
Merged

Replace import React with import * as React#1346
jgonet merged 1 commit intomasterfrom
@kuba/import-react

Conversation

@jgonet
Copy link
Copy Markdown
Member

@jgonet jgonet commented Feb 10, 2021

Description

React doesn't have a default import so we should import it as all import.

This came up when writing PR adding constants to Platform in RN types.

Error: 1> node_modules/react-native-gesture-handler/dist/src/components/DrawerLayout.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/components/GestureButtons.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/components/GestureComponents.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/components/Swipeable.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/components/touchables/TouchableWithoutFeedback.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/gestureHandlerRootHOC.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/handlers/createNativeWrapper.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag
Error: 1> node_modules/react-native-gesture-handler/dist/src/handlers/gestureHandlers.d.ts(1,8): error TS1259: Module '"/home/runner/work/DefinitelyTyped/DefinitelyTyped/types/react/index"' can only be default-imported using the 'esModuleInterop' flag

@jgonet jgonet self-assigned this Feb 10, 2021
@jgonet jgonet requested a review from WoLewicki February 10, 2021 16:02
Copy link
Copy Markdown
Member

@WoLewicki WoLewicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Is it necessary to do it if we use the esModuleInterop flag?

@jgonet
Copy link
Copy Markdown
Member Author

jgonet commented Feb 10, 2021

I thought it was unnecessary but seems like it's not picked up or the error message is misleading.

@jgonet jgonet merged commit 34afd6e into master Feb 10, 2021
@jgonet jgonet deleted the @kuba/import-react branch February 10, 2021 17:46
mrousavy pushed a commit to mrousavy/react-native-gesture-handler that referenced this pull request Feb 11, 2021
braincore pushed a commit to braincore/react-native-gesture-handler that referenced this pull request Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants