【问题标题】:TypeScript re-export interface from a core library inside namespaceTypeScript 从命名空间内的核心库重新导出接口
【发布时间】:2018-09-11 03:54:35
【问题描述】:

我想声明一个命名空间GraphQLScalars,它现在应该只包含一个导出,Date,它应该与在es5 lib中找到的本机Date接口的类型相同。

我使用以下 sn-p 尝试此操作失败:

declare namespace GraphQLScalars {
    export type Date = Date
}

【问题讨论】:

    标签: typescript typescript-typings


    【解决方案1】:

    在外部捕获全局类型以防止内部名称冲突。例如:

    declare type __date = Date;
    declare namespace GraphQLScalars {
        export type Date = __date;
    }
    

    【讨论】:

      猜你喜欢
      • 2018-05-21
      • 1970-01-01
      • 2019-03-18
      • 2022-08-18
      • 2021-05-20
      • 2019-06-29
      • 2013-03-29
      • 1970-01-01
      • 2017-02-16
      相关资源
      最近更新 更多