undefined does not match field "name": string of type Identifier when running @mui/x-codemod v6.0.0/preset-safe

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

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 (&lt;anonymous&gt;)
at Function.identifier (/home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/ast-types/lib/types.js:467:35)
at NodePath.&lt;anonymous&gt; (/home/dcutting/.npm/_npx/a9b616de167a2c5b/node_modules/@mui/x-codemod/v6.0.0/pickers/view-components-rename/index.js:81:93)
at NodePath.&lt;anonymous&gt; (/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 (&lt;anonymous&gt;)
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 &#39;react&#39;
import { Table } from &#39;@devexpress/dx-react-grid-material-ui&#39;
import { DateTime } from &#39;luxon&#39;

const DeliveryTimeCell = ({ value, ...props }) =&gt; {
  const formattedDate = DateTime.fromISO(value, { zone: &#39;utc&#39; }).toLocaleString(
    DateTime.DATETIME_MED_WITH_SECONDS
  )

  return (
    &lt;Table.Cell title={formattedDate} {...props}&gt;
      {formattedDate}
    &lt;/Table.Cell&gt;
  )
}

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.

huangapple
  • 本文由 发表于 2023年4月4日 05:15:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75923832.html
匿名

发表评论

匿名网友

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

确定