typescript - TypeScript: Exclude external types from the build output
问题描述
I'm creating a firebase functions with TypeScript and I have the following folder structure in the project:
- functions
--- src
------ auth.ts
- types
--- authResponse.ts
Inside my auth.ts
file, I import the type from 'authResponse.ts`.
And
as the result, when I build the code inside functions
directory, I get the following output in the functions/lib
directory:
-- lib
---- src
------- auth.js
---- types
------- authResponse.js
But I need the full output inside the lib
directory like this:
-- lib
---- auth.js
I understand that it's caused by the fact that I'm importing types
from the outside.
Is there any way to prevent it from appearing inside the lib folder? I've tried excluding it from tsconfig, but no luck.
解决方案
根据您的问题,我假设您使用predeploy hook进行编译。
如果是,请重命名authResponse.ts
为authResponse.d.ts
. 代表定义,所以Typescriptd
转译器会知道它不应该被转译。
查看本指南以编写定义文件。
推荐阅读
- python - 成功处理第一个输入后,Snakemake 规则以“MissingOutputException”停止
- jbpm - 如何从工作项处理程序执行 jbpm 业务流程
- database - 如何在 postgresql 11 中启用 pg_audit 扩展
- ip - 我的网络是否由于暴露的 Minecraft 端口而易受攻击?
- html - html画布不会填满firefox mobile上的整个页面
- python - 遍历找到的标签中的所有标签
- python - 熊猫为索引旋转多个值
- azure - 临时禁用 azure 活动日志警报
- java - 扫描仪输入的Netbeans java平台shell问题
- flutter - 根据键值之一从映射中检索条目