Reputation: 1273
There are different syntaxes of export and import statements in typescript. I can write something like that:
export class MyClass {}
Then include that class in other file:
import {MyClass} from "./fileName"
But there are another way to write the same thing. Export:
class MyClass {}
export = MyClass;
Import:
import MyClass = require("./fileName");
My question is: which one of these methods I should use? Which one is more appropriate?
Upvotes: 1
Views: 49
Reputation: 276353
But there are another way to write the same thing. Export:
Module systems have existed before ES6. For example nodejs style commonjs
and requirejs style amd
. TypeScript supports these by providing its own syntax extensions specifically the import =
and export =
style import/exports.
For modern code prefer the ES6 style import / export i.e individual exports and import / from
style syntax.
Upvotes: 2