ts-migrate icon indicating copy to clipboard operation
ts-migrate copied to clipboard

tsc does not pass after running reignore

Open NickHeiner opened this issue 4 years ago • 7 comments

I ran ts-migrate reignore . on my codebase. When I run tsc, I get a bunch of errors. I made sure that the version of tsc I'm using matches what ts-migrate bundles.

The 126 errors are in this gist.

I manually removed one of the error TS2578: Unused '@ts-expect-error' directive errors, and there was no problem on that line on a subsequent tsc run.

NickHeiner avatar Jan 27 '21 00:01 NickHeiner

The TS2578: Unused '@ts-expect-error' directive are caused by https://github.com/dsherret/ts-morph/issues/925.

NickHeiner avatar Jan 29 '21 19:01 NickHeiner

@NickHeiner ts-migrate 0.1.18 has been released with the latest @ts-morph/bootstrap, which should contain a fix for the upstream issue. Are you able to confirm whether it fixes this issue? I don't think there's quite enough information here for me to easily figure it out for myself.

edsrzf avatar Apr 27 '21 04:04 edsrzf

Yes, I'll get back to this hopefully over the next few weeks, and I'll let you know.

NickHeiner avatar Apr 27 '21 15:04 NickHeiner

Any news here? I'm facing the same issue. I have a cypress test doing cy.text().includes, somehow te-migrate doesn't know that .text() returns a string

It might not be too hard to parse tsc errors and do some simple string replacement "codemod", to remove unused @ts-expect-error

devinrhode2 avatar Nov 03 '21 14:11 devinrhode2

I'm evening seeing things like:

interface FOO {
  // @ts-expect-error ts-migrate(2304) FIXME: Cannot find name 'Array'.
  emails: Array<{
    email: string
    label: string
    type: 'primary' | 'secondary'
  }>
  
  // @ts-expect-error ts-migrate(2304) FIXME: Cannot find name 'Record'.
  selectedPreferences: Record<number, boolean>
}

devinrhode2 avatar Nov 03 '21 18:11 devinrhode2

And, with a very strict tsconfig.json compilerOptions, there are tons of other errors that are completely un-touched, when they should have a // @ts-expect-error comment added above them.

devinrhode2 avatar Nov 03 '21 21:11 devinrhode2

false alarm! Using latest ts-migrate (0.1.26) and this command:

yarn ts-migrate migrate . --plugin ts-ignore --sources="node_modules/**/*.d.ts" --sources="node_modules/@types/**/*.{ts,tsx}" --sources="apps/**/*.{ts,tsx}" --sources="libs/**/*.{ts,tsx}"

Seems to create proper @ts-expect-error comments if the --sources are set correctly...

devinrhode2 avatar Nov 03 '21 23:11 devinrhode2