Why does Typescript compiler not change .ts to .js?

喜欢而已 提交于 2019-12-06 02:50:32

For starters, you have to remove the .ts extension from the import. TypeScript says that it treats it as a static string and won't change it.

Second, out of experience, I guess using a .d.ts file may solve your module not found error. I have solved many times by using this small hack. You can reference it using /// <reference path="tools/typeScriptImports.d.ts" />. Imagine .d.ts as the header file for TypeScript.

Lastly, try and make the path relative to the server.js file. So: ./tools/typeScriptImports.

You are not supposed to write extension .ts in import commands.

Corresponding documentation: http://www.typescriptlang.org/Handbook#modules-going-external

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!