Typescript: Export default on interface not allowed

Created on 18 May 2015  ·  5Comments  ·  Source: microsoft/TypeScript

Raised on SO. The following is an error:

export default interface Foo {
}

By design or bug?

By Design

Most helpful comment

It's by design. You can accomplish the exact same effect with

interface Foo {
    // stuff
}
export default Foo;

More discussion in #3095.

All 5 comments

It's by design. You can accomplish the exact same effect with

interface Foo {
    // stuff
}
export default Foo;

More discussion in #3095.

I'm OK with leaving it as is if the reasoning is that interfaces, et al, are not vaid EcmaScript and #3917 is implemented.

hi all,

i unexpectedly encountered this too.

@ahejlsberg, can you clarify on your remarks further? the discussion in #3095 seems to be focusing more on the declaration collisions, which is all said and good.

@clavecoder, i don't fully see the rationale you point to. Interfaces aren't valid ecmascript either, so why shed convention?

these remarks are (of course) stated in a cordial tone. however, this decision feels very counterintuitive to me

Allowing export default + [interface / abstract class / enum / namespace / type ] is tracked by https://github.com/Microsoft/TypeScript/issues/3792

oh i see! thanks. i'll follow on over there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blendsdk picture blendsdk  ·  3Comments

Antony-Jones picture Antony-Jones  ·  3Comments

weswigham picture weswigham  ·  3Comments

kyasbal-1994 picture kyasbal-1994  ·  3Comments

fwanicka picture fwanicka  ·  3Comments