Closed timsuchanek closed 5 years ago
The problem here is that {}
is a valid Params
, so we think this is just a call to obj.paramsIdentityInline<{}>
and the correct suggestion list is therefore empty. From a type system perspective, that's justifiable.
This doesn't happen when there's a required property because the inference fails to produce a successful call, so we defer to the constraint for error reporting purposes and the constraint does have the properties. Notice that once the required property is present, we go back to showing the completions from the inferred type:
The "fix" is probably just a bunch more special-casing in the services layer.
Is this issue likely to be picked up by the TypeScript core team @RyanCavanaugh? :)
Not soon, no.
Does TypeScript have a bounty program in case someone wants to pick it up? Any thoughts on how much effort a fix for this would be?
This kind of issue also degrades a a bit the development experience for me.
created a reproduction at TypeScript Playground and added another case. The function being a property on an object doesn't change the auto-complete outcome at all.
Assuming I'm to fix this issue, is there any pointers where this kind of functionality is to be implemented?
Considering it provides autocomplete on error, even on the generic ones, there should be a way to reuse that code path, or am I missing something here?
Opened a PR to fix this https://github.com/microsoft/TypeScript/pull/32100
As #30212 has been closed incorrectly (it's not a duplicate) and the comments there are not reacted on anymore, I reopen the issue here.
Steps to Reproduce:
Open a TypeScript file with this content:
When you have a type which only consists of optional properties and use it in a generic context as a type parameter, the autocompletion doesn't work, while it works when you use that type directly without being generic in the function signature. However, as soon as at least one of the properties on that type is non-optional, the autocompletion works, even for the optional properties.
Does this issue occur when all extensions are disabled?: Yes
As @hediet correctly notes, the referenced fix doesn't work for this bug. Please see #30212 for more infos.
Ping @mjbvz