Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
damischa1 opened this issue Mar 2, 2024 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@damischa1
Copy link

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.

@damischa1 damischa1 changed the title When using typia in generate mode, how to prevent importing template file? [Question] When using typia in generate mode, how to prevent importing template file? Mar 2, 2024
@samchon
Copy link
Owner

samchon commented Mar 2, 2024

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

@samchon samchon self-assigned this Mar 2, 2024
@samchon samchon added the question Further information is requested label Mar 2, 2024
@damischa1
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

samchon commented Mar 2, 2024

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

@damischa1
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants