简体   繁体   English

在哪里找到@ types / node的源代码

[英]Where to find the source code of @types/node

According to the instructions online, I installed Node for Typescript via the following command. 根据在线说明,我通过以下命令安装了Node for Typescript。

npm install @types/node --save-dev

I found that there were some new files in the directory node_modules after running the above command. 运行上述命令后,我发现目录node_modules中有一些新文件。

node_modules
    @types
        node
            index.d.ts
            package.json
            README.md
            types-metadata.json

If I recall correctly, Node.js was written in JS instead of Typescript, so I need to use those JS source codes to invoke Node.js api, instead of just the Typescript definition file shown above, but where can I find those files? 如果我没记错的话,Node.js是用JS而不是Typescript编写的,所以我需要使用那些JS源代码来调用Node.js api,而不仅仅是上面显示的Typescript定义文件,但是在哪里可以找到这些文件? What's the default location to store those JS files when I run npm install @types/whateveritis ? 当我运行npm install @types/whateveritis时,存储那些JS文件的默认位置是npm install @types/whateveritis

The JS files that make up a module aren't handled by TS. TS不会处理组成模块的JS文件。 Node is part of the runtime environment, so it's always available. 节点是运行时环境的一部分,因此它始终可用。 Other packages would be bound in node_modules. 其他软件包将绑定在node_modules中。 The type information is married with the actual module code when you do an import -- the TS compiler will find the appropriate type declaration for a module name (potentially from @types) and bring that in. 导入时,类型信息与实际的模块代码结合在一起-TS编译器将找到模块名称的适当类型声明(可能来自@types)并将其引入。

Keep in mind that TS never explicitly does anything with the modules you import, it just applies the proper type info for the compiler's own bookkeeping. 请记住,TS永远不会对导入的模块显式执行任何操作,它只会为编译器自己的簿记应用正确的类型信息。 Nothing is actually imported until you execute your generated javascript code and typescript is no longer relevant at that point. 在执行生成的javascript代码之前, 实际上不会导入任何内容,并且此时打字稿不再相关。

Note that you did not install node by doing that, you will still need to install any modules separately through NPM. 请注意,您这样做并不是安装节点,您仍然需要通过NPM单独安装所有模块。 See earlier point of node always being available. 请参阅节点的早期点始终可用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 需要自定义 Node Red Editor Client CSS 和 JS,在哪里可以找到有关 node-red-editor 源代码的文档? - Need to customize Node Red Editor Client CSS and JS, where to find documentation about source code of node-red-editor? 在哪里可以找到 Javascript `typeof` 运算符的源代码? - Where can I find the source code for the Javascript `typeof` operator? 如何在 github 上找到节点 package 的旧版本源代码? - How to find the older versions of source code for a node package on github? 我在哪里可以看到Node.js中JavaScript方法的源代码,例如hasOwnProperty? - Where can I see the source code for JavaScript methods, such as hasOwnProperty, in Node.js? 在哪里可以找到我的代码中模型“ Item”的路径“ _id”的值“ create”的Cast to ObjectId的源失败 - Where can I find the source of Cast to ObjectId failed for value “create” at path “_id” for model “Item” in my code 我在哪里可以找到 deepEqual() 函数的源代码,它在特定参数中返回 true? - Where I can find source code of deepEqual() function, that returns true in specific arguments? 找出Node在哪里冻结? - Find out where Node is freezing? Firefox源代码中的主事件循环在哪里? - Where is the main event loop in the Firefox source code? Node.js源代码的require()函数 - Node.js source code of require() function 如果我有应用程序的源代码和 macOS 和 Windows 安装程序,我如何才能找到用于构建应用程序的 Node.js 版本? - if I have source code and macOS and Windows installers for an app, how can I find what version of Node.js was used to build the app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM