Why the limitation on exporting an interface by default in TypeScript?

后端 未结 2 749
离开以前
离开以前 2021-02-06 20:33

I\'m using TypeScript 1.5 beta, and I\'m trying to export an interface as the default export. The following code causes an error in both Visual Studio and WebStorm:



        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-06 21:06

    TypeScript v2.4.0 allows export default interface. Here is the pull-request that introduced the change.

    We can now do both of these:

    // Foo.ts
    export interface Foo { }
    
    // Bar.ts
    export default interface Bar { }    
    
    // Baz.ts
    import { Foo } from "./foo";
    import Bar from "./bar";
    
    export class Baz implements Foo, Bar 
    {
    
    }
    

提交回复
热议问题