我正在使用 WebStorm 构建 Node.js 应用程序。我正在使用 TypeScript。
当我使用“require”语句时,我收到此警告:
unresolved function or method require
它只发生在 TypeScript 文件中。在js文件中没有问题。代码有效,顺便说一句,这只是一个警告。
我发现了很多关于这个警告的问题,但它们都是关于 JavaScript 的,在我的项目中,js 文件对“require”语句没有问题,只有 ts 文件。
任何帮助将不胜感激!
最佳答案
I've found many questions about this warning but they all about JavaScript, and in my project js files have no problem with the "require" statement, just the ts files.
在 TypeScript 中,您需要声明您正在使用的所有内容,以防止出现拼写错误。
从 DefinitelyTyped 获取 node.d.ts
:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts
更多
https://basarat.gitbooks.io/typescript/content/docs/types/migrating.html
关于node.js - Unresolved 功能或方法要求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35543616/