I'm trying to convert a javascript code to typescript. I have a class which used to work properly in js
class Model {
constructor(input, alias) {
this.tableName = input;
this.alias = alias;
}
}
but now I get two errors saying Property 'tableName' does not exist on type 'Model'
and Property 'alias' does not exist on type 'Model'
also this is my tsconfig settings :
{
"compilerOptions": {
"module": "CommonJS",
"target": "ES6",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"moduleResolution": "Node",
"noImplicitAny": false,
"strict": false,
"outDir": "./dist"
},
"include": ["controllers", "models", "module","routes","./app.ts"],
"ts-node": {
"transpileOnly": true
}
}
I'm kinda new to typescript and don't know much about it.
any help will be appreciated
You must define the property
class Model {
tableName:string;
alias:string;
constructor(input, alias) {
this.tableName = input;
this.alias = alias;
}
}