Appearance
使用核心类型
¥Using Core Types
使用核心类型和 zodern:types
¥Using core types with zodern:types
对于 MeteorJS 2.8.1 版本,我们在核心包中引入了与 zodern:types 包的集成。此软件包允许你在 TypeScript 代码或 JavaScript 代码中使用 Meteor 核心软件包的 TypeScript 类型。为了使用你需要的类型,请通过运行命令来安装软件包:
¥For MeteorJS in its version 2.8.1 we have introduced to our core packages an integration with the zodern:types package. This package allows you to use the TypeScript types for the Meteor core packages in your TypeScript code or JavaScript code. in order to use the types you need to install the package by running the command:
bash
meteor add zodern:types
并将以下行添加到你的 tsconfig.json
文件(如果你没有,请创建一个并添加下面的代码):
¥And add the following line to your tsconfig.json
file (if you do not have one, create one and add the code bellow):
json
{
"compilerOptions": {
"preserveSymlinks": true,
"paths": {
"meteor/*": [
"node_modules/@types/meteor/*",
".meteor/local/types/packages.d.ts"
]
}
}
}
然后运行命令:
¥then run the command:
bash
meteor lint
这将在你的 .meteor 文件夹中创建一个文件,其中包含核心包的类型。你可以像以前一样继续使用代码,但现在即使使用 JavaScript,你也可以使用核心包的类型。
¥this will create a file within your .meteor folder that will have your types for the core packages. You can continue to use your code as you did before, but now you can use the types for the core packages even if you are in JavaScript.
有关该软件包的更多信息,请访问 zodern:types。
¥for more information about the package please visit the zodern:types.