简体   繁体   中英

What's the difference between export interface and export default interface in typescript declaration merging?

What's the difference between export interface and export default interface in declaration merging ?

I think export interface just extend, export default interface will override old interface completely.

declare module 'react-intl' {
  export interface MessageDescriptor {
    // error: ts(2717), id's type must be string
    id: 'test' | 'test2';
  }
}

if I use :

declare module 'react-intl' {
  export default interface MessageDescriptor {
    // ok
    id: 'test' | 'test2';
  }
}

当您导出接口时,它将仅导出类中的特定对象,但是当您导出默认接口时,它将导出所有对象并覆盖先前导出的类实例的行为。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM