[TypeScript] Type Definitions and Modules
Posted answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[TypeScript] Type Definitions and Modules相关的知识,希望对你有一定的参考价值。
For example you are building your own module, the same as Lodash:
my-lodash.d.ts
declare module "lodash" {
declare interface FirstFunction {
(data: any[]) :any;
}
declare interface Lodash {
first: FirstFunction;
}
export const _: Lodash:
}
Normally you can install @types for popluar 3rd-party libs, if you have to build your own, you need to remember export type defination aas well for Typescript.
以上是关于[TypeScript] Type Definitions and Modules的主要内容,如果未能解决你的问题,请参考以下文章
Type[keyof Type] 函数参数的 Typescript 类型保护
[TypeScript] Create Explicit and Readable Type Declarations with TypeScript mapped Type Modifiers(代码
[TypeScript] type、typeof、keyof
[TypeScript] Union Types and Type Aliases in TypeScript
[TypeScript] Define Custom Type Guard Functions in TypeScript
[TypeScript] Use TypeScript’s never Type for Exhaustiveness Checking