VS Code缺少@mui/x-date-pickers版本6.5.0的文档/智能感知。

huangapple go评论77阅读模式
英文:

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

问题

使用 "@mui/x-date-pickers": "^5.0.20"VS Code缺少@mui/x-date-pickers版本6.5.0的文档/智能感知。

显示此面板以显示有用的信息,以及其他 TypeScript 类型和内容。

使用 "@mui/x-date-pickers": "^6.5.0"VS Code缺少@mui/x-date-pickers版本6.5.0的文档/智能感知。

不显示任何内容,并且我收到与 TypeScript 相关的错误,就好像该包实际上没有安装。为什么?

我已经尝试过多次安装和重新安装,使用 VS Code 中的 Developer > Reload Window,甚至删除整个 /node_modules 目录,然后再次运行 pnpm install。似乎问题与版本号有关(还尝试了 6.4.0,出现了相同的问题,没有尝试其他版本)

为什么会这样?我该如何修复它?与 '@mui/material' 等其他包没有类似的问题。

英文:

With "@mui/x-date-pickers": "^5.0.20":VS Code缺少@mui/x-date-pickers版本6.5.0的文档/智能感知。

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

With "@mui/x-date-pickers": "^6.5.0":VS Code缺少@mui/x-date-pickers版本6.5.0的文档/智能感知。

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'.

答案1

得分: 1

这似乎是因为在某个特定时间点之后,这些相同的文档内容未被保留的原因。从我的研究来看,MUI中的日期选择器在历史上经历了许多变化。请查看 https://github.com/mui/material-ui-pickers/issues/2157

以下是您在 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>,
) {

而在 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>,
) {
  ...

如果您查看 v5.13.0 版本,您将在以下链接中看到文档: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>,
) {
  ...

github.com/mui/material-ui v5.6 和 v5.7 中存在一个奇怪的缺口,该文件不存在,然后在 github.com/mui/material-ui v5.8 中以"@ignore - do not document." 形式重新出现。

但在 https://github.com/mui/mui-x/blob/v5.8.0/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx#L28 中,它带有文档注释,并且您可以看到它一直保留到 https://github.com/mui/mui-x/blob/v5.17.26/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx#L51,但在 https://github.com/mui/mui-x/blob/v6.0.0/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx#L23 中消失了。

根据文件历史记录,我只能看到如下的详细信息:

我不知道为什么删除了文档注释。在您提给维护者的问题中,他们说:

@LukasTy:

> 感谢您创建问题并指出了这个不一致性/退化!
> 在我们的 v6 迁移期间可能被遗忘了,期间我们暂时拥有了新旧变体的重复选择器组件,然后在这个过程中丢失了它。

@alexfauqette:

> 经过一些调查,似乎这是核心功能,我们在 X 上不支持。
>
> 这些装饰是在运行 yarn docs:api 时自动生成的,感谢 这个 AST 分析器
>
> 但它依赖于元素以 export default 导出以及可能其他内容。而在 X 上,我们使用 export

英文:

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&lt;TDate&gt;(
  inProps: MobileDatePickerProps&lt;TDate&gt;,
  ref: React.Ref&lt;HTMLDivElement&gt;,
) {

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&lt;TDate&gt;(
  inProps: MobileDatePickerProps&lt;TDate&gt;,
  ref: React.Ref&lt;HTMLDivElement&gt;,
) {
  ...

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&lt;TDate&gt;(
  props: MobileDatePickerProps&lt;TDate&gt;,
  ref: React.Ref&lt;any&gt;,
) {
  ...

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.

<strike>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.</strike>

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.

huangapple
  • 本文由 发表于 2023年5月31日 23:08:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76374943.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定