If we specify the default export:
export class Foo {} export default Foo;
then we can omit the curly braces during import (as indicated in this answer ):
import { Foo } from "foo"; // becomes: import Foo from "foo";
This is fine, but are there any non-stylistic reasons to prefer each other in some cases? For example, is there some kind of agreement or is it incompatible with certain instruments or has a different meaning?
(Based on this discussion and others, I understand that export default could come about as a way to handle the export of a single primary object (for example, $ ), which is now processed by import * as foo from "foo" . import * as foo from "foo" Also, it seems that the import syntax by the default does not provide consistent naming ( import fooAlias from "foo" ), while the standard import import { fooAlias } from "foo" will be compiled except that the alias was explicit ( Foo as fooAlias ). In addition, I could not find much information on when I should use one over the other.)
source share