英文:
undefined does not match field "name": string of type Identifier when running @mui/x-codemod v6.0.0/preset-safe
问题
我正尝试从 v5 迁移到 v6 的 mui-x,运行 npx @mui/x-codemod v6.0.0/preset-safe 时,在 27 个文件上出现以下错误:
错误:undefined 与类型为 Identifier 的 "name" 字段不匹配
在 /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/ast-types/lib/types.js:446:27 处添加参数
在 /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/ast-types/lib/types.js:469:25 处
在 Array.forEach (
在 /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/ast-types/lib/types.js:467:35 处调用 Function.identifier
在 /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/v6.0.0/pickers/view-components-rename/index.js:81:93 处的 NodePath.
在 /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/node_modules/jscodeshift/src/collections/Node.js:142:47 处的 NodePath.
在 /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/node_modules/jscodeshift/src/Collection.js:75:36 处
在 Array.forEach (
在 /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/node_modules/jscodeshift/src/Collection.js:74:18 处
在 /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/node_modules/jscodeshift/src/collections/Node.js:140:17 处的 Collection.replaceWith
我将 package.json 中 @mui/x-date-pickers 的版本设置为 6.0.0,并运行了运行 codemod 脚本的命令。错误似乎与我的代码无关。例如,这是一个错误的代码文件:
import React from 'react'
import { Table } from '@devexpress/dx-react-grid-material-ui'
import { DateTime } from 'luxon'
const DeliveryTimeCell = ({ value, ...props }) => {
const formattedDate = DateTime.fromISO(value, { zone: 'utc' }).toLocaleString(
DateTime.DATETIME_MED_WITH_SECONDS
)
return (
<Table.Cell title={formattedDate} {...props}>
{formattedDate}
</Table.Cell>
)
}
export default DeliveryTimeCell
英文:
I'm attempting to migrate from v5 to v6 for mui-x and I'm getting the following on 27 files when I run npx @mui/x-codemod v6.0.0/preset-safe .:
Error: undefined does not match field "name": string of type Identifier
at addParam (/home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/ast-types/lib/types.js:446:27)
at /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/ast-types/lib/types.js:469:25
at Array.forEach (<anonymous>)
at Function.identifier (/home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/ast-types/lib/types.js:467:35)
at NodePath.<anonymous> (/home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/v6.0.0/pickers/view-components-rename/index.js:81:93)
at NodePath.<anonymous> (/home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/node_modules/jscodeshift/src/collections/Node.js:142:47)
at /home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/node_modules/jscodeshift/src/Collection.js:75:36
at Array.forEach (<anonymous>)
at Collection.forEach (/home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/node_modules/jscodeshift/src/Collection.js:74:18)
at Collection.replaceWith (/home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/node_modules/jscodeshift/src/collections/Node.js:140:17)
I set my package.json version for @mui/x-date-pickers to 6.0.0 and ran the command to run the codemod scripts. The errors don't appear to reference anything specific regarding my code. For example, here is the code file for one of the errors:
import React from 'react'
import { Table } from '@devexpress/dx-react-grid-material-ui'
import { DateTime } from 'luxon'
const DeliveryTimeCell = ({ value, ...props }) => {
const formattedDate = DateTime.fromISO(value, { zone: 'utc' }).toLocaleString(
DateTime.DATETIME_MED_WITH_SECONDS
)
return (
<Table.Cell title={formattedDate} {...props}>
{formattedDate}
</Table.Cell>
)
}
export default DeliveryTimeCell
答案1
得分: 1
已解决 - 请参阅 此GitHub问题 以及相关PR以获取详细信息。将于2023年4月20日发布。
英文:
Update for anyone else facing this: it is now fixed - see this Github issue and related PR for details. Will be released on April 20th, 2023.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论