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
1 task done
Zzzen opened this issue Jan 2, 2019 · 4 comments · Fixed by #17120
Closed
1 task done

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

Zzzen opened this issue Jan 2, 2019 · 4 comments · Fixed by #17120
Assignees
Labels
help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request. Inactive

Comments

@Zzzen
Copy link
Contributor

Zzzen 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
Copy link
Contributor

ztplz commented Jan 2, 2019

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

@afc163 afc163 added the help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request. label Apr 30, 2019
@afc163
Copy link
Member

afc163 commented Apr 30, 2019

PR is welcome~ @Zzzen

@Zzzen
Copy link
Contributor Author

Zzzen 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
refactor: eliminate `any` type in exported interfaces.#14044
@afc163 afc163 closed this as completed Jun 21, 2019
@afc163
Copy link
Member

afc163 commented Jun 23, 2019

#17245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted The suggestion or request has been accepted, we need you to help us by sending a pull request. Inactive
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants