You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After replacing the ?? operator with older-style code I still get an error (TS4.9.5):
constko_result=ko();constassert_some_obj=ko_result===null ? {} : ko_result;// same for `ko_result || {}`const{ oid, pid }=assert_some_obj;// Property 'pid' does not exist on type '{}'. ts(2339)
This is correct, isn't it?
With the same rewrite this also gives no error in the case of the ok() function though. But I'd rather expect an error in both cases and ideally with the union type boiled down to the second union member:
π Expected behavior
Error Property does not exist on type '{}' (2339) in both examples.
PS:
const{ pid }={};// Initializer provides no value for this binding element and the binding element has no default value. ts(2525)// Binding element 'pid' implicitly has an 'any' type. ts(7031)
So this does not look like fully sane code anyway.
// this issue is specifically triggered by index signaturesdeclareconstmaybeIndexable: {[key: string]: string}|undefinedconst{ anyThing }=maybeIndexable??{};console.log(anyThing.toLowerCase());// runtime error!
Bug Report
π Search Terms
2339 Property does not exist on type empty object
π Version & Regression Information
Tested on 4.2.3 (version we use on our project) and 4.8.4 (latest available in playground)
β― Playground Link
Playground link with relevant code
π» Code
This is a simplified test case. I did encounter error while using @reach/router useMatch hook API
π Actual behavior
Error
Property does not exist on type '{ [param: string]: string; uri: string; path: string; } | {}' (2339)
π Expected behavior
No error expected
The text was updated successfully, but these errors were encountered: