mskelton / ratchet

Codemod to convert React PropTypes to TypeScript types.
https://mskelton.dev/ratchet
ISC License
138 stars 14 forks source link

Transform error. Error: undefined does not match field "name": string of type Identifier #41

Closed joshunger closed 2 years ago

joshunger commented 2 years ago

Navigate to https://mskelton.dev/ratchet

Enter the following -

import PropTypes from "prop-types"
import React from "react"

export function MyComponent(props) {
  return <span />
}

MyComponent.propTypes = {
  bar: PropTypes.string.isRequired,
  'dashed-prop': PropTypes.number,
}

Error:

Transform error. Error: undefined does not match field "name": string of type Identifier
    at n (main.ab6196fd287e15dd275b.js:2:101878)
    at main.ab6196fd287e15dd275b.js:2:102196
    at Array.forEach (<anonymous>)
    at Function.i [as identifier] (main.ab6196fd287e15dd275b.js:2:102169)
    at V (main.ab6196fd287e15dd275b.js:2:2677597)
    at Array.map (<anonymous>)
    at te (main.ab6196fd287e15dd275b.js:2:2680210)
    at e.<anonymous> (main.ab6196fd287e15dd275b.js:2:2680262)
    at main.ab6196fd287e15dd275b.js:2:2537682
    at Array.forEach (<anonymous>)
a @ main.ab6196fd287e15dd275b.js:2
(anonymous) @ main.ab6196fd287e15dd275b.js:2
(anonymous) @ main.ab6196fd287e15dd275b.js:2
(anonymous) @ main.ab6196fd287e15dd275b.js:2
(anonymous) @ main.ab6196fd287e15dd275b.js:2
setTimeout (async)
(anonymous) @ main.ab6196fd287e15dd275b.js:2
(anonymous) @ main.ab6196fd287e15dd275b.js:2
(anonymous) @ main.ab6196fd287e15dd275b.js:2
(anonymous) @ main.ab6196fd287e15dd275b.js:2
Vn.t @ main.ab6196fd287e15dd275b.js:2
Vn @ main.ab6196fd287e15dd275b.js:2
(anonymous) @ main.ab6196fd287e15dd275b.js:2
mskelton commented 2 years ago

Thanks for the report! I've just pushed a fix that will resolve this issue.

joshunger commented 2 years ago

@mskelton thank you! Ratchet has been a huge help really appreciate it.