Ant-design-mobile: error TS2307: Cannot find module 'react-native'

Created on 14 Jun 2017  ·  3Comments  ·  Source: ant-design/ant-design-mobile

Version

1.2.0

Environment

Web project on TypeScript, antd-mobile >= 1.1.4-beta.0

Reproduction link

https://github.com/ant-design/ant-design-mobile/pull/1280/files

Steps to reproduce

  1. git clone https://github.com/ant-design/antd-mobile-samples.git
  2. cd ./antd-mobile-samples/web-typescript
  3. yarn
  4. yarn upgrade [email protected]
  5. yarn start

What is expected?

No TypeScript compile error

What is actually happening?

TypeScript compile error

node_modules/antd-mobile/lib/baseType.d.ts(3,27): error TS2307: Cannot find module 'react-native'.
2:51:05 PM - Compilation complete. Watching for file changes.

This compile error starts from PR https://github.com/ant-design/ant-design-mobile/pull/1280/files

bug

All 3 comments

screenshot from 2018-05-06 00-39-33

I got same error from modal props type
is it intended one? (= which means that i should install react-native package even if i use only for web?)

my workaround:

  1. yarn add -D @types/react-native // don't need react-native itself,
  2. killglobals ed -s ./node_modules/@types/react-native/index.d.ts <<< $',s/declare global/declare namespace FuckGlobals/g\nw'
    you can execute above script @ package.json > scripts > postintsall
Was this page helpful?
0 / 5 - 0 ratings