typescript没有抱怨没有在构造函数中声明类型
我是typescript的新手,我希望typescript会因为没有为我的构造函数声明类型而抛出一个错误,但不幸的是我没有 所以我很好奇为什么我没有出错 这就是我正在做的typescript没有抱怨没有在构造函数中声明类型,typescript,Typescript,我是typescript的新手,我希望typescript会因为没有为我的构造函数声明类型而抛出一个错误,但不幸的是我没有 所以我很好奇为什么我没有出错 这就是我正在做的 export interface BaseConfig { app: express.Application, routePermission: number, context: any } export class BaseConfig implements BaseConfig { co
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
) {
//intitalize Express App
this.routePermission = authenticatedRoute
this.context = context
this.app = express()
这是我的配置
nomplicitany应设置为true。如果为false,则表示接受隐式any,并且声明的没有类型的变量因此隐式地具有类型any。noImplicitAny应设置为true。如果为false,则表示接受implicit any,因此未声明类型的变量隐式地具有类型any。身份验证和authenticatedRoute参数类型是从默认值推断出来的,但默认情况下上下文具有任何类型,因为您在编译器选项中将noImplicitAny设置为false。有关编译器标志的详细信息,请参阅。身份验证和authenticatedRoute参数类型是从默认值推断出来的,但默认情况下上下文具有任何类型,因为您在编译器选项中将noImplicitAny设置为false。有关编译器标志的更多信息,请参阅
{
"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"]
}