compile thexcript使用.ts in inoct fornode

问题描述 投票:0回答:2

我该如何编译? TSC命令不起作用,因为我的tsconfig.json是:

{
  "compilerOptions": {
    "allowImportingTsExtensions": true,
    "noEmit": true,
    "strict": true
  }
}

(能够使用允许importingtsextensions我需要noemit)

	
the Transpiles毫无问题,它不会发出任何转移文件,因为正如Documenation/公告时,AllowImportingTsextensions flag是针对您有一个Bundler转换项目文件的情况。

typescript compilation compiler-optimization tsconfig tsc
2个回答
1
投票

节点规格要求您使用.js文件扩展名来用于所有导入和导出。这是决定的,以便像./foo.js这样的相对导入路径在节点和浏览器中都可以工作。 马特·波克克在这里很好地解释了推理

https://www.totaltypescript.com/relative-import-paths-need-need-plaper-file-file-file-file-mentensions-in-ecmascript-imports

0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.