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

chore: Extract SwitchChangeEventHandler and SwitchSize #17331

Merged
merged 1 commit into from Jun 27, 2019

Conversation

Projects
None yet
3 participants
@yesmeck
Copy link
Member

commented Jun 27, 2019

With this change, we can define a change handler more convenience:

Before:

const handleChange = (checked: boolean, event: MouseEvent) => {
  ...
}

After:

const handleChange: SwitchChangeEventHandler = (checked, event) => {
  ...
}

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

👻 What's the background?

💡 Solution

📝 Changelog

Language Changelog
🇺🇸 English Improve type definitions of Switch
🇨🇳 Chinese 改进 Switch 的类型定义

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed
Extract SwitchChangeEventHandler and SwitchSize
With this change, we can define change handler more convenience:

Before:

```javascript
const handleChange = (checked: boolean, event: MouseEvent) => {
  ...
}
```

After:

```javascript
const handleChange: SwitchChangeEventHandler = (checked, event) => {
  ...
}
```

@pr-triage pr-triage bot added the PR: unreviewed label Jun 27, 2019

@netlify

This comment has been minimized.

Copy link

commented Jun 27, 2019

Deploy preview for ant-design ready!

Built with commit 87afda5

https://deploy-preview-17331--ant-design.netlify.com

export interface SwitchProps {
prefixCls?: string;
size?: 'small' | 'default';

This comment has been minimized.

Copy link
@afc163

afc163 Jun 27, 2019

Member

这种有没有更好的声明方式,Enum 能用不?

This comment has been minimized.

Copy link
@yesmeck

yesmeck Jun 27, 2019

Author Member
export enum SwitchSize {
  SMALL = 'small';
  DEFAUL = 'default';
}
import { SwitchSize } from 'antd/es/switch';

<Switch size={SwitchSize.SMALL} />

This comment has been minimized.

Copy link
@afc163

afc163 Jun 27, 2019

Member

这样就改使用方式了。

目前看来最好的方式是:#7965 (comment)

This comment has been minimized.

Copy link
@ztplz

ztplz Jun 27, 2019

Collaborator

他那种assert不推荐的,毕竟assert能少用就少用。如果值A是B类型,你应该直接声明A是B类型,而不是把A里的类型都assert成B里的属性然后通过ts的类型检查。

@afc163 afc163 changed the title Extract SwitchChangeEventHandler and SwitchSize chore: Extract SwitchChangeEventHandler and SwitchSize Jun 27, 2019

@afc163 afc163 merged commit c391515 into master Jun 27, 2019

25 of 27 checks passed

Header rules - ant-design No header rules processed
Details
Pages changed - ant-design 216 new files uploaded
Details
DEP All dependencies are resolved
LGTM analysis: JavaScript No new or fixed alerts
Details
License Compliance All checks passed.
Details
Mixed content - ant-design No mixed content detected
Details
Redirect rules - ant-design 18 redirect rules processed
Details
Semantic Pull Request ready to be squashed
Details
WIP Ready for review
Details
ant-design.ant-design #ant design succeeded
Details
buildsize No change
Details
ci/circleci: compile Your tests passed on CircleCI!
Details
ci/circleci: dist Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: setup Your tests passed on CircleCI!
Details
ci/circleci: test_dist Your tests passed on CircleCI!
Details
ci/circleci: test_dist_15 Your tests passed on CircleCI!
Details
ci/circleci: test_dom Your tests passed on CircleCI!
Details
ci/circleci: test_dom_15 Your tests passed on CircleCI!
Details
ci/circleci: test_es Your tests passed on CircleCI!
Details
ci/circleci: test_es_15 Your tests passed on CircleCI!
Details
ci/circleci: test_lib Your tests passed on CircleCI!
Details
ci/circleci: test_lib_15 Your tests passed on CircleCI!
Details
ci/circleci: test_node Your tests passed on CircleCI!
Details
ci/circleci: test_node_15 Your tests passed on CircleCI!
Details
netlify/ant-design/deploy-preview Deploy preview ready!
Details
security/snyk - package.json (paranoidjk) No manifest changes detected

@pr-triage pr-triage bot added PR: merged and removed PR: unreviewed labels Jun 27, 2019

@delete-merged-branch delete-merged-branch bot deleted the improve-swicth-types branch Jun 27, 2019

@afc163 afc163 referenced this pull request Jun 29, 2019

Closed

add 3.20.0 changelog #17362

5 of 14 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.