Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue 3 vite ignore errors during build

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.

like image 815
Anekdotin Avatar asked Oct 15 '25 15:10

Anekdotin


1 Answers

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

like image 93
tony19 Avatar answered Oct 17 '25 10:10

tony19