then it will show only one error message: "Property 'x' does not exist on type '{}'" but I expected to get different error like "Property 'toLowercase' does not exist on type 'string'" as was described in https://devblogs.microsoft.com/typescript/announcing-typescript-3-2/#objectdefineproperty-declarations-in-javascript
7条答案
按热度按时间at0kjp5o1#
Unfortunately it doesn't work in
TS
as well,if you run this in
TS
playground (I guess it has the latestTS
version)then it will show only one error message:
"Property 'x' does not exist on type '{}'"
but I expected to get different error like
"Property 'toLowercase' does not exist on type 'string'"
as was described in https://devblogs.microsoft.com/typescript/announcing-typescript-3-2/#objectdefineproperty-declarations-in-javascriptlf5gs5x22#
@DanielRosenwasser See #14650
uhry853o3#
这是关于JavaScript分析的,而不是TypeScript。
voj3qocg4#
我遇到了这个问题。有人知道解决方法吗?
chhkpiq45#
n/m,上述问题的解决方法如下:
smdnsysy6#
你需要为属性 'x: string' 添加确定性Assert赋值。
1zmg4dgp7#
我认为在这个问题中,源代码被假定为JavaScript,而且据我所知,没有明确的赋值Assert语法。