typescriptvisual-studio-codeintellisensepnpmmui-x-date-picker

VS Code missing docs/intellisense for version 6.5.0 of @mui/x-date-pickers


With "@mui/x-date-pickers": "^5.0.20":enter image description here

Shows this panel with useful info, and other typescript types and stuff.

With "@mui/x-date-pickers": "^6.5.0":enter image description here

Shows nothing, and I get typescript-related errors as if the package isn't really installed. Why?

I've already tried installing and re-installing numerous times, using Developer > Reload Window in VS Code, and even deleting the entire /node_modules directory and doing pnpm install again. It seems to be specific to the version number (also tried 6.4.0 with the same problems, didn't try any other versions)

Why is this? How do I fix it? There's no such problems with any of the other packages like '@mui/material'.


Solution

  • It seems to be that the reason is simply that those same docs were not kept after a certain point. From my digging, the date pickers in MUI have had a pretty crazy history with lots and lots of moving around. Just take a look at https://github.com/mui/material-ui-pickers/issues/2157.

    Here's the source code with the docs you're seeing for v5.0.2: https://github.com/mui/material-ui/blob/v5.0.2/packages/mui-lab/src/MobileDatePicker/MobileDatePicker.tsx#L27 :

    /**
     *
     * Demos:
     *
     * - [Date Picker](https://mui.com/components/date-picker/)
     *
     * API:
     *
     * - [MobileDatePicker API](https://mui.com/api/mobile-date-picker/)
     */
    const MobileDatePicker = React.forwardRef(function MobileDatePicker<TDate>(
      inProps: MobileDatePickerProps<TDate>,
      ref: React.Ref<HTMLDivElement>,
    ) {
    

    And the source code without those same docs in v6.5.0: https://github.com/mui/mui-x/blob/v6.5.0/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx#L18 :

    const MobileDatePicker = React.forwardRef(function MobileDatePicker<TDate>(
      inProps: MobileDatePickerProps<TDate>,
      ref: React.Ref<HTMLDivElement>,
    ) {
      ...
    

    If you look at v5.13.0, you'll see https://github.com/mui/material-ui/blob/v5.13.3/packages/mui-lab/src/MobileDatePicker/MobileDatePicker.tsx#LL27C1-L33C4 :

    /**
     * @ignore - do not document.
     */
    const MobileDatePicker = React.forwardRef(function DeprecatedMobileDatePicker<TDate>(
      props: MobileDatePickerProps<TDate>,
      ref: React.Ref<any>,
    ) {
      ...
    

    There's a weird hole in github.com/mui/material-ui v5.6 and v5.7 where the file doesn't exist, and then it comes back in github.com/mui/material-ui v5.8 with "@ignore - do not document.".

    But in https://github.com/mui/mui-x/blob/v5.8.0/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx#L28 it appears with the doc comment and you can see it stays until https://github.com/mui/mui-x/blob/v5.17.26/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx#L51, but is gone in https://github.com/mui/mui-x/blob/v6.0.0/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx#L23.

    As fine grained as I can see from the file history:

    I don't know if there was a particular reason the doc comment was removed.

    This is probably as far as my shoddy investigation can go. You might need to contact the maintainers to know why they removed the doc comment. If you do talk with them in some public channel, please comment here with a link to it.

    In the issue ticket that you raised to the maintainers, they said:

    @LukasTy:

    Thank you for creating the issue and pointing out this inconsistency/regression! It must have been forgotten during our v6 migration, where we temporarily had duplicate pickers components for the new and old variants and it got lost during the process.

    @alexfauqette:

    After some investigation, it seems this is a feature from core we don't support on X.

    Those decorations are auto-generated when running yarn docs:api thanks to this AST analyser

    But it relies on the fact that elements are exported with export default and probably other stuff. Whereas in X we use export.