isolated modules typescript code example
Example 1: module.exports in typescript
class Person {
private firstName: string;
private lastName: string;
constructor(firstName: string, lastName: string) {
this.firstName = firstName;
this.lastName = lastName;
}
public getFullName() {
return `${this.firstName} ${this.lastName}`;
}
}
export = Person;
Example 2: create npm module typescript
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"allowJs": true,
"strict": true,
"outDir": "./lib",
"esModuleInterop": true
},
"include": ["src"],
"exclude": ["node_modules"]
}