export vs. default export in typescript

I was just playing around with aurelia todo-app and realized that TypeScript indicated an error while i was importing another module in the app module.

Simply adding the export keyword in the todo class fixed the error however I did not know why!

Took a look at the TypeScript documentation and it says one file can have just one default export and several others as well (no analogy exists for the .cs files here :) ) and while the default export can simply be included with

 import default-export from './module.ts'

others have to be explicit via

import {non-default-export} from './module.ts'

i am not sure what made the ECMAScript or TypeScript design team guys to decide in this convention but it makes for one more syntactic thing to remember.

Comments are closed