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

Use the unknown type in typescript 3.0 to improve defintions #14044

Closed
Zzzen opened this issue Jan 2, 2019 · 4 comments

Comments

Projects
None yet
5 participants
@Zzzen
Copy link
Contributor

commented Jan 2, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

Let's take Table.Column for an example:

export interface ColumnProps<T> {
    // ...
    render?: (text: any, record: T, index: number) => React.ReactNode;
    onFilter?: (value: any, record: T) => boolean;
}

It's very easy to mistake text as record and write down <Column render={item => item.prop}/>

What does the proposed API look like?

Replace any with unknown when it makes sense.
Definition of render should be render?: (text: unknown, record: T, index: number) => React.ReactNode;

Note: unknown is a breaking change to TS 2.x users.

@ztplz

This comment has been minimized.

Copy link
Collaborator

commented Jan 2, 2019

Sounds great, but it shouldn’t be a break change when 3.x is not yet popular.

@afc163

This comment has been minimized.

Copy link
Member

commented Apr 30, 2019

PR is welcome~ @Zzzen

@Zzzen

This comment has been minimized.

Copy link
Contributor Author

commented Jun 15, 2019

Working on it 🏃‍♂

Zzzen added a commit to Zzzen/ant-design that referenced this issue Jun 16, 2019

afc163 added a commit that referenced this issue Jun 21, 2019

Merge pull request #17120 from Zzzen/master
refactor: eliminate `any` type in exported interfaces.#14044

@afc163 afc163 closed this Jun 21, 2019

@afc163

This comment has been minimized.

Copy link
Member

commented Jun 23, 2019

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.