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

[pickers] Declaration files don't type-check with TypeScript 4.8 #6134

Closed
2 tasks done
Methuselah96 opened this issue Sep 12, 2022 · 6 comments
Closed
2 tasks done

[pickers] Declaration files don't type-check with TypeScript 4.8 #6134

Methuselah96 opened this issue Sep 12, 2022 · 6 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! typescript

Comments

@Methuselah96
Copy link
Contributor

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

The declaration files currently have a error with TypeScript 4.8:

ERROR in node_modules/@mui/x-date-pickers/internals/models/muiPickersAdapter.d.ts:2:55
TS2344: Type 'TDate' does not satisfy the constraint 'ExtendableDateType'.
    1 | import { IUtils } from '@date-io/core/IUtils';
  > 2 | export declare type MuiPickersAdapter<TDate> = IUtils<TDate>;
      |                                                       ^^^^^
    3 | export declare type MuiDateSectionName = 'day' | 'month' | 'year' | 'hour' | 'minute' | 'second' | 'am-pm';
    4 | export declare type MuiFormatTokenMap = {
    5 |     [formatToken: string]: MuiDateSectionName;

Expected behavior 🤔

The declaration files should not have an error with TypeScript 4.8.

Steps to reproduce 🕹

Create TypeScript 4.8 project with @mui/x-date-pickers with skipLibCheck turned off.

Context 🔦

I noticed this was addressed in #5935, but wanted to make sure that the fix made it into v5 since the release notes for the latest v5 release mentioned that this was the last scheduled regular release for v5.

Your environment 🌎

N/A

Order ID 💳 (optional)

No response

@Methuselah96 Methuselah96 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 12, 2022
@flaviendelangle
Copy link
Member

Fixed by #5935

@flaviendelangle flaviendelangle added typescript component: pickers This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 13, 2022
@flaviendelangle flaviendelangle changed the title Declaration files don't type-check with TypeScript 4.8 [pickers] Declaration files don't type-check with TypeScript 4.8 Sep 13, 2022
@Orforio
Copy link

Orforio commented Sep 20, 2022

Thanks for the update, but I've just updated my project to use "@mui/x-date-pickers": "^5.0.2" and "typescript": "^4.8.3" but I'm still getting the exact same error:

> [email protected] typecheck
> tsc --noEmit

node_modules/@mui/x-date-pickers/internals/models/muiPickersAdapter.d.ts:2:55 - error TS2344: Type 'TDate' does not satisfy the constraint 'ExtendableDateType'.

2 export declare type MuiPickersAdapter<TDate> = IUtils<TDate>;
                                                        ~~~~~

  node_modules/@mui/x-date-pickers/internals/models/muiPickersAdapter.d.ts:2:39
    2 export declare type MuiPickersAdapter<TDate> = IUtils<TDate>;
                                            ~~~~~
    This type parameter might need an `extends ExtendableDateType` constraint.


Found 1 error in node_modules/@mui/x-date-pickers/internals/models/muiPickersAdapter.d.ts:2

This is currently blocking our build, so I'm going to have to turn on skipLibCheck for now...

@flaviendelangle
Copy link
Member

There is an ongoing discussion on #6136
I'm trying to figure out why the fix did not make it to the published declaration files.

@Orforio
Copy link

Orforio commented Sep 20, 2022

@flaviendelangle Aha, thanks for the update!

@Methuselah96
Copy link
Contributor Author

Methuselah96 commented Sep 20, 2022

@flaviendelangle The fix does not work because @ts-ignore comments don't get copied to declaration files (see microsoft/TypeScript#38628), so the original TypeScript source code will type-check sucessfully, but the built declaration files will not.

Maybe we should re-open this issue until it gets resolved?

@flaviendelangle
Copy link
Member

Yes I know that we loose the @ts-ignore / @ts-expect-error during the build.
It seems however that if I rename the file muiPickersAdapter.d.ts it works...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! typescript
Projects
None yet
Development

No branches or pull requests

3 participants