samchon / typia

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

How to use typia with tsx? #1265

Open victor314159 opened 1 week ago

victor314159 commented 1 week ago

Big fan of typia here, thanks for this amazing lib !

I'm trying to use typiawhen starting my backend in development mode with tsx

I use tsx because it allows very easy hot reloading when developping.

    "scripts": {
        "serve": "tsx watch ./lib/index.ts",
    },

Long story short, typia works fin in production mode (with tsc), but I don't know how to make it work with tsx

Is it possible ?

samchon commented 1 week ago

No way, use ts-node instead.

jairmedeiros commented 1 week ago

https://github.com/TypeStrong/ts-node/issues/2133 😭

victor314159 commented 1 week ago

This is how I fixed it:

 "serve": "tsx watch --inspect=0.0.0.0:9229 ./lib/index.ts", // stop using tsx
 "serve": "npx concurrently \"tsc --watch\" \"nodemon -L --inspect=0.0.0.0:9229 ./dist/index.js\"", // use tsc --watch option, so Typia works fine

because I'm running in a docker container, the node --watch wouldn't work, so I've used nodemon

Also added it to tsconfig.json (because tsc --wtach wouldn't work otherwise because of the container running on Windows.)

    "watchOptions": {
        "watchFile": "dynamicPriorityPolling"
    }