-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: up to ts 2.4, fix compile error, refactor rn styles interface #1573
Conversation
@paranoidjk, thanks for your PR! By analyzing the history of the files in this pull request, we identified @chinalife, @yiminghe and @yesmeck to be potential reviewers. |
@silentcloud 参考 ccc2122 RN 的 styles 和 props 的 ts 定义都需要改下,不然 ts compile error |
在我这显示的都是 react-native 同一类型的错误 yarn compile
yarn compile
yarn compile v0.27.5
$ BABEL_ENV=dist antd-tools run compile
antd-tools run compile
components/card/index.tsx(10,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/card/index.tsx(10,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/card/index.tsx(10,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/checkbox/AgreeItem.tsx(9,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/checkbox/AgreeItem.tsx(9,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/checkbox/AgreeItem.tsx(9,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/checkbox/Checkbox.tsx(10,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/checkbox/Checkbox.tsx(10,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/checkbox/Checkbox.tsx(10,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/checkbox/CheckboxItem.tsx(11,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/checkbox/CheckboxItem.tsx(11,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/checkbox/CheckboxItem.tsx(11,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/date-picker/index.tsx(12,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/date-picker/index.tsx(12,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/date-picker/index.tsx(12,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/image-picker/index.tsx(17,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/image-picker/index.tsx(17,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/image-picker/index.tsx(17,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/modal/PromptContainer.tsx(24,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/modal/PromptContainer.tsx(24,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/modal/PromptContainer.tsx(24,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/notice-bar/index.tsx(7,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/notice-bar/index.tsx(7,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/notice-bar/index.tsx(7,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/pagination/index.tsx(12,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/pagination/index.tsx(12,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/pagination/index.tsx(12,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/picker/index.tsx(5,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/picker/index.tsx(5,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/picker/index.tsx(5,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/radio/Radio.tsx(8,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/radio/Radio.tsx(8,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/radio/Radio.tsx(8,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/radio/RadioItem.tsx(12,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/radio/RadioItem.tsx(12,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/radio/RadioItem.tsx(12,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/result/index.tsx(9,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/result/index.tsx(9,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/result/index.tsx(9,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/segmented-control/segmented.android.tsx(7,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/segmented-control/segmented.android.tsx(7,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/segmented-control/segmented.android.tsx(7,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/steps/index.tsx(19,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/steps/index.tsx(19,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/steps/index.tsx(19,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/tab-bar/tabbar.android.tsx(8,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/tab-bar/tabbar.android.tsx(8,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/tab-bar/tabbar.android.tsx(8,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/tag/index.tsx(7,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/tag/index.tsx(7,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/tag/index.tsx(7,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/textarea-item/index.tsx(17,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/textarea-item/index.tsx(17,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/textarea-item/index.tsx(17,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/toast/ToastContainer.tsx(22,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ImageStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/toast/ToastContainer.tsx(22,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'TextStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
components/toast/ToastContainer.tsx(22,3): error TS4026: Public static property 'defaultProps' of exported class has or is using name 'ViewStyle' from external module "/Users/colder/Documents/Git/ant-design-mobile/node_modules/@types/react-native/index" but cannot be named.
[15:05:20] TypeScript: 57 declaration errors
[15:05:20] TypeScript: 57 emit errors
[15:05:20] TypeScript: emit failed
error Command failed with exit code 1.
☃ ant-design-mobile git:(pr/1573) cat node_modules/@types/react/package.json| grep version
"version": "15.0.38",
☃ ant-design-mobile git:(pr/1573) cat node_modules/@types/react-native/package.json | grep version
"version": "0.46.2",
☃ ant-design-mobile git:(pr/1573) cat node_modules/typescript/package.json | grep version
"version": "2.4.1", |
Codecov Report
@@ Coverage Diff @@
## master #1573 +/- ##
=======================================
Coverage 66.47% 66.47%
=======================================
Files 230 230
Lines 2303 2303
Branches 706 706
=======================================
Hits 1531 1531
Misses 771 771
Partials 1 1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1573 +/- ##
==========================================
+ Coverage 66.47% 66.49% +0.01%
==========================================
Files 230 228 -2
Lines 2303 2301 -2
Branches 706 706
==========================================
- Hits 1531 1530 -1
+ Misses 771 770 -1
Partials 1 1
Continue to review full report at Codecov.
|
components/date-picker/index.tsx
Outdated
@@ -1,7 +1,7 @@ | |||
import React from 'react'; | |||
import PropTypes from 'prop-types'; | |||
import PopupDatePicker from 'rmc-date-picker/lib/Popup'; | |||
import PopupStyles from '../picker/styles'; | |||
import '../picker/styles'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@silentcloud 看下这行代码的改动,没看懂 rn 是如何处理 less 的?
components/picker/index.tsx
Outdated
@@ -1,8 +1,8 @@ | |||
import AbstractPicker, { getDefaultProps } from './AbstractPicker'; | |||
import styles from './styles'; | |||
import './styles'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@silentcloud 同上, picker 和 date-picker 这两个组件的 rn 版样式处理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..... 看错了.... 这里的文件路径竟然不是在 styles 下面....
之前我查看 List native props 类型的时候,发现有个问题。 rn styles 属性都是对象,比如这个 我看到这个 pr 所有 NativeProps.styles 都成了必选的,但其实都是有默认值的。 |
@cncolder rn 的 |
@paranoidjk 但是 props.styles.xxx,有些可选有些则必选,这里非常麻烦。 所有 RN 组件都没有合并默认 styles 和用户 styles 的代码。 |
理论上全部是可选,因为组件都有默认样式,只是允许用户传入来自定义。 你发现哪些是必选的? |
@paranoidjk 我对 RN 不太了解,你可以随便选一个组件 就比如 List,如果用户指定 styles.Body,那是不是其他所有样式全丢了? styles 是可选的,但是一旦指定其中一个,其他的子样式就全是必选的了。 |
@silentcloud rn build error,貌似 master 也是跑不起来的,你空了看下吧 |
@paranoidjk 当成另一个问题解决吧。 还是那个疑问,真的有人在用RN吗?,还是说他们都不改 styles 只用默认值? |
有人在用的... 看issue label rn |
…nt-design#1573) * feat: up to ts 2.4, fix compile error * fix: badge native ts * fix: ts compile * feat: revert rn version * test: update snapshot * fix: picker rn style * fix: rn styles is optional
…nt-design#1573) * feat: up to ts 2.4, fix compile error * fix: badge native ts * fix: ts compile * feat: revert rn version * test: update snapshot * fix: picker rn style * fix: rn styles is optional
Wait for #1576
props.styles
typescript interface definition@types/react-native
typescript
First of all, thank you for your contribution! :-)
Please makes sure that these checkboxes are checked before submitting your PR, thank you!
npm run lint
and fix those errors before submitting in order to keep consistent code style.Extra checklist:
if isBugFix :
elif isNewFeature :
This change is