Skip to content
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

Merged
merged 7 commits into from
Jul 18, 2017

Conversation

paranoidjk
Copy link
Contributor

@paranoidjk paranoidjk commented Jul 17, 2017

Wait for #1576

  • 修复 react-native 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!

  • Make sure that you follow antd's code convention.
  • Run npm run lint and fix those errors before submitting in order to keep consistent code style.
  • Rebase before creating a PR to keep commit history clear.
  • Add some descriptions and refer relative issues for you PR.

Extra checklist:

if isBugFix :

  • Make sure that you add at least one unit test for the bug which you had fixed.

elif isNewFeature :

  • Update API docs for the component.
  • Update/Add demo to demonstrate new feature.
  • Update TypeScript definition for the component.
  • Add unit tests for the feature.

This change is Reviewable

@mention-bot
Copy link

@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.

@paranoidjk
Copy link
Contributor Author

@silentcloud 参考 ccc2122 RN 的 styles 和 props 的 ts 定义都需要改下,不然 ts compile error

@cncolder
Copy link
Contributor

cncolder commented Jul 17, 2017

在我这显示的都是 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",

@paranoidjk
Copy link
Contributor Author

@cncolder 是的,参考 ccc2122 这个就可以修复了,同类问题

@codecov
Copy link

codecov bot commented Jul 17, 2017

Codecov Report

Merging #1573 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#rn 81.3% <ø> (ø) ⬆️
#web 65.75% <100%> (ø) ⬆️
Impacted Files Coverage Δ
components/accordion/index.tsx 100% <ø> (ø) ⬆️
components/badge/index.tsx 100% <ø> (ø) ⬆️
components/result/index.tsx 100% <ø> (ø) ⬆️
components/list/index.tsx 100% <ø> (ø) ⬆️
components/activity-indicator/index.tsx 100% <ø> (ø) ⬆️
components/action-sheet/AndroidContainer.tsx 100% <ø> (ø) ⬆️
components/input-item/Input.web.tsx 40.62% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 987ce7a...e52637c. Read the comment docs.

@codecov
Copy link

codecov bot commented Jul 17, 2017

Codecov Report

Merging #1573 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#rn 81.13% <ø> (-0.18%) ⬇️
#web 65.78% <100%> (+0.02%) ⬆️
Impacted Files Coverage Δ
components/textarea-item/index.tsx 100% <ø> (ø) ⬆️
components/toast/ToastContainer.tsx 100% <ø> (ø) ⬆️
components/image-picker/index.tsx 100% <ø> (ø) ⬆️
components/tag/index.tsx 100% <ø> (ø) ⬆️
components/radio/Radio.tsx 100% <ø> (ø) ⬆️
components/badge/index.tsx 100% <ø> (ø) ⬆️
components/radio/RadioItem.tsx 100% <ø> (ø) ⬆️
components/list/index.tsx 100% <ø> (ø) ⬆️
components/activity-indicator/index.tsx 100% <ø> (ø) ⬆️
components/checkbox/CheckboxItem.tsx 100% <ø> (ø) ⬆️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb057b0...60a42c1. Read the comment docs.

@paranoidjk paranoidjk changed the title [WIP] feat: up to ts 2.4, fix compile error feat: up to ts 2.4, fix compile error Jul 17, 2017
@@ -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';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@silentcloud 看下这行代码的改动,没看懂 rn 是如何处理 less 的?

@@ -1,8 +1,8 @@
import AbstractPicker, { getDefaultProps } from './AbstractPicker';
import styles from './styles';
import './styles';
Copy link
Contributor Author

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 版样式处理

Copy link
Contributor Author

Choose a reason for hiding this comment

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

..... 看错了.... 这里的文件路径竟然不是在 styles 下面....

@cncolder
Copy link
Contributor

之前我查看 List native props 类型的时候,发现有个问题。

rn styles 属性都是对象,比如这个 TBadgeStyle 类型有8个属性,哪些是可选的哪些是必选的,要参考源码才能看明白。

我看到这个 pr 所有 NativeProps.styles 都成了必选的,但其实都是有默认值的。

@paranoidjk
Copy link
Contributor Author

@cncolder rn 的 props.styles 都是可选,我会改回来

@cncolder
Copy link
Contributor

cncolder commented Jul 17, 2017

@paranoidjk 但是 props.styles.xxx,有些可选有些则必选,这里非常麻烦。

所有 RN 组件都没有合并默认 styles 和用户 styles 的代码。

@paranoidjk
Copy link
Contributor Author

理论上全部是可选,因为组件都有默认样式,只是允许用户传入来自定义。

你发现哪些是必选的?

@cncolder
Copy link
Contributor

cncolder commented Jul 17, 2017

@paranoidjk 我对 RN 不太了解,你可以随便选一个组件 <Comp styles={{}}/> 验证一下。

就比如 List,如果用户指定 styles.Body,那是不是其他所有样式全丢了?

styles 是可选的,但是一旦指定其中一个,其他的子样式就全是必选的了。

@paranoidjk
Copy link
Contributor Author

@silentcloud rn build error,貌似 master 也是跑不起来的,你空了看下吧

@cncolder
Copy link
Contributor

@paranoidjk 当成另一个问题解决吧。

还是那个疑问,真的有人在用RN吗?,还是说他们都不改 styles 只用默认值?

@paranoidjk
Copy link
Contributor Author

有人在用的... 看issue label rn

@paranoidjk paranoidjk changed the title feat: up to ts 2.4, fix compile error WIP feat: up to ts 2.4, fix compile error Jul 18, 2017
@paranoidjk paranoidjk changed the title WIP feat: up to ts 2.4, fix compile error feat: up to ts 2.4, fix compile error Jul 18, 2017
@paranoidjk paranoidjk changed the title feat: up to ts 2.4, fix compile error feat: up to ts 2.4, fix compile error, refactor rn styles interface Jul 18, 2017
@paranoidjk paranoidjk merged commit 0bd98af into master Jul 18, 2017
@paranoidjk paranoidjk deleted the ts-2.4 branch July 18, 2017 06:18
plowsirius pushed a commit to koubei-fe/ant-design-mobile that referenced this pull request Jul 24, 2017
…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
lixiaoyang1992 pushed a commit to lixiaoyang1992/ant-design-mobile that referenced this pull request Apr 26, 2018
…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
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.

3 participants