I'm facing an issue here. Typescript keeps throwing this error:
TS4060: Return type of exported function has or is using private name 'class' Student
test.ts
export default function EXPORTMODULE(GreetingText:string) {
class Student {
name: string;
constructor(name: string) {
this.name = name;
}
greet() {
return `"${GreetingText}, " + this.greeting`;
}
}
class Teacher {
name: string;
constructor(name: string) {
this.name = name;
}
greet() {
return `"${GreetingText}, " + this.greeting`;
}
}
class Professor {
name: string;
constructor(name: string) {
this.name = name;
}
greet() {
return `"${GreetingText}, " + this.greeting`;
}
}
return {Professor, Student, Teacher}
}
Even though I paste the same code on Typescript Playground, it compiles without any errors.
To replicate:
usage.ts
console.log('hello world app')
import module from './test';
const moduleES = module('Holla')
const moduleFR = module('Salut')
const moduleEN = module('Hello')
const greeterESStudent = new moduleES.Student("world");
console.log(greeterESStudent.greet())
const greeterFRStudent = new moduleES.Student("world");
console.log(greeterFRStudent.greet())
const greeterESTeacher= new moduleFR.Teacher("world");
console.log(greeterESTeacher.greet())
const greeterFRTeacher= new moduleFR.Student("world");
console.log(greeterFRTeacher.greet())