samchon / typia

Super-fast/easy runtime validators and serializers via transformation
https://typia.io/
MIT License
4.45k stars 153 forks source link

How I can setup typia with vite and avoid typecheking? #472

Closed search654321 closed 1 year ago

search654321 commented 1 year ago

I'm setting up typia with vite and when I run the recommended config I see TypeScript warnings on my console like this:

9:27:56 AM [vite] warning: @rollup/plugin-typescript TS2722: Cannot invoke an object which is possibly 'undefined'.

  46             <IconButton icon="Close" onClick={() => onClose()} size={24} />

I have an external command to check types and I want to avoid doing type checking on the bundler, for compilation speed reasons and to avoid cluttering the console.

How I can turn off type checking when running vite but keep typia working?

This is my current config for the @rollup/plugin-typescript

typescript({
  typescript: ttsc,
  cacheDir: '.tscache',
})
samchon commented 1 year ago

Have any idea not to use validator function only when release mode?

search654321 commented 1 year ago

Right now I'm just using assert. I'm not sure how typia works but the only thing I want from this extension is to do runtime validation of types, but avoid running type checking. I'm not sure if that is a limitation of rollup plugin, but at least turning off warnings will be fine...

I use assert both in development and release mode

samchon commented 1 year ago

I think the error message has been occured because the onClose function can be undefined.

It seems not problem of typia.

search654321 commented 1 year ago

Oh, the error message is not typia, what I mean is that I don't wan't to see typescript errors when running the vite server

samchon commented 1 year ago

You mean not to compile TypeScript type, but transpile only? Then using typia is not possible because it requires TypeScript type info.

In that case, I recommend you to compile typia using code independently and import the compiled code from main vite developed project.

search654321 commented 1 year ago

But could be possible to silence typescript errors in the vite console? With webpack that is possible

samchon commented 1 year ago

Not possible in vite. What about solving the TypeScript errors?

search654321 commented 1 year ago

I'm working in a legacy project and fixing them all will take a year

samchon commented 1 year ago

Then should compile from independently and import it