有没有办法使用Typescript内联设置编译器选项

时间:2017-03-30 04:32:24

标签: typescript compiler-construction options

在我的tsconfig中,我将strictNullChecks设置为true。

我刚刚报告了ProxyHandler.getOwnPropertyDescriptor()定义的问题,该定义被错误地声明为返回PropertyDescriptorPropertyDescriptor | undefined

我正在尝试编写自己的ProxyHandler,并实现getOwnPropertyDescriptor():PropertyDescriptor(以完成类型定义中的当前合约)。但我不能,因为当我尝试将内部PropertyDescriptor | undefined结果强制转换为PropertyDescriptor

时,编译器报告错误
getOwnPropertyDescriptor(target: T, p: PropertyKey): PropertyDescriptor {
    let res: PropertyDescriptor | undefined = undefined
    //... compute result
    return res as PropertyDescriptor; 
       // FAILS : [ts] Type 'undefined' cannot be converted to type 'PropertyDescriptor'.
}

有没有人知道如何使用特殊注释来禁用我的方法中的strictNullChecks(我想保留对所有其他文件的检查)?

0 个答案:

没有答案