【问题标题】:What is the scope of a type alias?类型别名的范围是什么?
【发布时间】:2015-10-30 12:38:55
【问题描述】:

打字稿类型别名的范围是什么? 我有这个别名,我想我可能想以某种方式在全球范围内声明它:

type ResouceResult<T> = T & {
    $promise: ng.IPromise<T>,
    $resolved: boolean
};

【问题讨论】:

    标签: typescript typescript1.6


    【解决方案1】:

    Typescript 1.5 语言规范第 3.9 节:http://www.typescriptlang.org/Content/TypeScript%20Language%20Specification.pdf

    3.9 类型别名

    类型别名声明在包含模块中引入类型别名

    模块

    【讨论】:

      【解决方案2】:

      全局声明

      如果您的文件是全局的,则类型别名是全局的。如果是模块,则类型别名为模块。

      更多信息:https://basarat.gitbook.io/typescript/project/modules

      【讨论】:

      • 您的链接已损坏。
      • 谢谢。固定?
      猜你喜欢
      • 2010-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-05
      • 2012-10-23
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      相关资源
      最近更新 更多