Skip to content

Instantly share code, notes, and snippets.

@ParkinT
Last active November 11, 2020 14:03
Show Gist options
  • Save ParkinT/b8cbf777b609fd606b40f6afb32126bc to your computer and use it in GitHub Desktop.
Save ParkinT/b8cbf777b609fd606b40f6afb32126bc to your computer and use it in GitHub Desktop.
Clarification of Typescript syntax specifically related to export and import

This table associates different export statement forms with the expected export name and local names:

For importing, though...

  • If you are importing a default export, you have to explicitly name the import. Default exports will not automatically have a local name after importing. Example: import express from "express". The local name does not matter. Could as well be import banana from "express".
  • If you are importing a named export, by default, the local name will be the same as the exported name. Example: If you have export const x = 2, then, you should import it as import { x } from "module". You can also rename the import like this: `import { x as y } from "module".

From this StackOverflow entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment