I am getting the error "TS2322: Type 'number' is not assignable to type 'string'."
I wanted to just disable this rather than fix it in the code. I am using "vue-tsc --noEmit && vite build" for my build in package.json
Currently running vue 3 / vite with latest in a Dockerfile.
If you're unable to fix the code for some reason, you could suppress the error with a preceding comment, containing @ts-expect-error
:
// @ts-expect-error
const s: string = 123
Or @ts-ignore
:
// @ts-ignore
const s: string = 123
From @ts-ignore
or @ts-expect-error
?:
Pick
ts-expect-error
if:
- you’re writing test code where you actually want the type system to error on an operation
- you expect a fix to be coming in fairly quickly and you just need a quick workaround
- you’re in a reasonably-sized project with a proactive team that wants to remove suppression comments as soon affected code is valid again
Pick
ts-ignore
if:
- you have a larger project and new errors have appeared in code with no clear owner
- you are in the middle of an upgrade between two different versions of TypeScript, and a line of code errors in one version but not another.
- you honestly don’t have the time to decide which of these options is better.
demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With