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

前后端共享dto类型 #1

Open
Tzdy opened this issue Dec 29, 2022 · 3 comments
Open

前后端共享dto类型 #1

Tzdy opened this issue Dec 29, 2022 · 3 comments

Comments

@Tzdy
Copy link
Owner

Tzdy commented Dec 29, 2022

No description provided.

@Tzdy
Copy link
Owner Author

Tzdy commented Dec 29, 2022

后端将类型输出

tsc src/dto/**/*.ts --outDir dtoTypeOut --declaration  --emitDeclarationOnly

然后将类型文件复制到前端项目中。

自己的项目可以这么做,但是要共享的话,还得用其他方法。

@Tzdy
Copy link
Owner Author

Tzdy commented Dec 29, 2022

--declaration --emitDeclarationOnly输出类型。
需要保证dto文件不能引入文件外的模块,否则就不好复制了。
一般dto中会有许多装饰器。就会导致报错。
但是仍然可以正常输出.d.ts

@Tzdy
Copy link
Owner Author

Tzdy commented Dec 29, 2022

需要一种方法,把这些装饰器,和引入装饰器模块的代码去掉。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant