英文:
VS Code missing docs/intellisense for version 6.5.0 of @mui/x-date-pickers
问题
使用 "@mui/x-date-pickers": "^5.0.20"
:
显示此面板以显示有用的信息,以及其他 TypeScript 类型和内容。
使用 "@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"
:
Shows this panel with useful info, and other typescript types and stuff.
With "@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 中消失了。
根据文件历史记录,我只能看到如下的详细信息:
- https://github.com/mui/mui-x/blob/e8e92cffaeb9f257b3ddc808bd1446e0d9e5237f/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx 仍然存在
- https://github.com/mui/mui-x/blob/94e9e4061c9468db35d9b2bd5e785a283db7aae1/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx 已经不存在。
我不知道为什么删除了文档注释。在您提给维护者的问题中,他们说:
> 感谢您创建问题并指出了这个不一致性/退化!
> 在我们的 v6 迁移期间可能被遗忘了,期间我们暂时拥有了新旧变体的重复选择器组件,然后在这个过程中丢失了它。
> 经过一些调查,似乎这是核心功能,我们在 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<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:
- https://github.com/mui/mui-x/blob/e8e92cffaeb9f257b3ddc808bd1446e0d9e5237f/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx still there
- https://github.com/mui/mui-x/blob/94e9e4061c9468db35d9b2bd5e785a283db7aae1/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx gone.
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:
> 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.
> 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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论