I would like to know the difference between creating a class and exporting it later and creating a class with the keyword export at the beginning
First use case:
class Foo {
constructor() {
}
// ...
}
export = Foo;
Second use case:
export class Foo {
constructor() {
}
// ...
}
The reason I am asking is that when I use the first approach, I always have to import the class in another module like this:
import Foo = require("./Foo");
and when I use the second approach, I can import it like this:
import {Foo} from "./Foo";
I have two questions: Whats the difference between these two approaches? and is there a way to export the class to import a class without using require
while keeping the first approach ?