我不小心得到了这个,它似乎起作用了:
export interface ITestBlockOpts {
desc: string,
title: string,
opts: Object,
suman: ISuman,
gracefulExit,
handleBeforesAndAfters,
notifyParent
}
对于线路:
gracefulExit,
handleBeforesAndAfters,
notifyParent
这个语法是的缩写吗
gracefulExit: any
handleBeforesAndAfters: any
notifyParent: any
是。TypeScript编译器具有一个选项来假定未类型化的变量应被类型化为CCD_ 1。这是默认情况下为false
的noImplicitAny
选项。
它的存在主要是为了更容易地从JavaScript转换(其中TypeScript是的严格超集,即当noImplicitAny == false
时,所有有效的JavaAscript都是有效的TypeScript(。
如果您在绿地或所有TypeScript项目中使用TypeScript,那么您应该使用noImplicitAny == true
来确保始终使用类型化变量和字段。
请注意,在TypeScript中,如果接口成员具有any
类型(无论是否隐式(,则它与可选(undefined
(成员不是一回事。
因此这些接口是等价的:
interface Foo {
a: any // explicit `any` type
}
interface Bar {
a // implicit 'any' type
}
但这些接口并不等同:
interface Foo {
a: any
}
interface Baz {
a?: any // explicit `any` type, but `a` can also be `undefined`
}
interface Qux {
a? // implicit `any`, but `a` can also be `undefined`
}