本文介绍了如何管理未通过打字下载的类型定义文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Angular 应用程序,我在其中使用 npmtypings 来管理下拉我的类型定义文件 .d.ts 用于 TypeScript.但是,我有一些 .d.ts 文件在 typings 中不存在,它们要么是手工制作的,要么是手动从其他来源下载的.

I have an Angular app where I'm using npm and typings to manage pulling down my type definition files .d.ts for TypeScript. However I have a few .d.ts files that don't exist in typings and are either hand rolled or downloaded from an alternate source manually.

从项目结构的角度来看,我应该如何管理项目中的这些局外人类型定义文件?将它们手动添加到 typings/global 文件夹中,然后添加对 index.d.ts 的引用是否正确,或者这是有问题的,应该放置这些与 typings 管理的文件分开放在一个隔离的地方?

From a project structure perspective, how should I manage these outsider type definition files in the project? Is it correct to just add them manually to the typings/global folder, and then add a reference to index.d.ts, or is this problematic and these should be placed separately in a segregated spot away from the files managed by typings?

推荐答案

其中一个选项是将 typings.json 指向您的自定义定义文件.例如具有以下文件夹结构:

One of the options would be pointing typings.json to your custom definitions file. For example having the following folder structure:

/typings
    /custom
        hand-rolled.d.ts
    /global
        ...

typings.json 将有指向文件系统的引用:

typings.json will have reference pointing to file system:

"globalDependencies": {
    "hand-rolled": "file:typings/custom/hand-rolled.d.ts"
}

您无需手动添加对 index.d.ts 的引用.您可以将 typings/custom 签入源代码管理.

You'll not need manually add a reference to index.d.ts. And you can check in typings/custom into source control.

这篇关于如何管理未通过打字下载的类型定义文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 20:58