samchon / typia

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

[Question] When using typia in generate mode, how to prevent importing template file? #986

Closed damischa1 closed 4 weeks ago

damischa1 commented 6 months ago

Hello,

thanks for great type checking tool.

I am starting to use typia with NextJS. I was wondering if there is some fresh idea how to prevent co-developers from importing the functions from the template file instead of the generation result?

I have tried moving the template file out of the hierarchy for the project, but ide still seems to give two suggestions: the template file and the actual implementation generated from template... Just worried of what happens if someone is using the version from template file.

samchon commented 6 months ago

What about making an independent npm module with transformation mode, and make NestJS to import it?

damischa1 commented 6 months ago

I can try something like this. Not tried yet. Anyways it seems a little backwards, since the template file and (and the generated file) are using the types defined in the NextJS project. So the typia-module would have to have access to the source tree of the NextJS ptoject.

damischa1 commented 6 months ago

I was actually thinking something like this would be usefult.

More limited template file, with only typia function generator invocations. In template file nothing would be exported. But the generator would add export keywords to the generated file.

Then there would be nothing to import from the template file and not possible to have such issues.

samchon commented 6 months ago

Add the template path to the exclude of the tsconfig.json.

damischa1 commented 6 months ago

Tried adding exclude in tsconfig.json.

IntelliJ Idea is suggesting still the two options: the template export and generated export.

This might be intended behaviour from the IDE, because the exclude does not exclude files from build if they are explicitly included from some another file. So importing from excluded files is perfectly valid: https://www.typescriptlang.org/tsconfig#exclude

ryoppippi commented 1 month ago

@damischa1 how about using unpluin-typia

ryoppippi commented 4 weeks ago

We can close this issue because we have unpluin-typia