I am facing a situation where I expected TypeScript to give me an error for not specifying types in my constructor, but to my surprise, I did not encounter any errors.
This got me wondering why the error was not being thrown.
This is the code snippet in question:
export interface BaseConfig {
app: express.Application,
routePermission: number,
context: any
}
export class BaseConfig implements BaseConfig {
constructor(
context,
authentication = false,
authenticatedRoute = USER_TYPE.LOGGED_IN_NORMAL_USER
) {
// Initialize Express App
this.routePermission = authenticatedRoute
this.context = context
this.app = express()
Below is my tsconfig
:
{
"compilerOptions": {
"moduleResolution": "node",
"experimentalDecorators": true,
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017",
"resolveJsonModule": true,
"esModuleInterop": true,
"noImplicitAny": false
},
"compileOnSave": true,
"include": [
"src"
],
"exclude": ["node_modules"]
}