0
外部庫提供接口Foo
與許多可選的屬性克隆接口:一些性質非可選
interface Foo {
propertyA?: string;
propertyB?: string;
}
我的代碼接受Foo
並且在一些屬性的填充。後面的代碼要求這個部分填充的Foo
。
interface FooWithA {
propertyA: string;
propertyB?: string;
}
我可以使用哪些類型的註釋表示:「這是一個Foo
與性能的X,Y,Z非可選」,使strictNullChecks
停止抱怨?
我可以在不對propertyA的屬性類型進行硬編碼的情況下執行此操作嗎?聲明'FooWithA.propertyA'與'Foo.propertyA'具有相同的類型? – spiffytech
我不認爲這是可能的。看看['! '非空斷言運算符](https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#non-null-assertion-operator)這可能解決您的問題'strictNullChecks'。 – Saravana