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
When a function is typed to return an object of a certain type, the properties of the object can be expanded, meaning extra properties can be added to the ones described in the type or interface.
🔎 Search Terms
function return object type
🕗 Version & Regression Information
This is observable on the playground in all available versions.
This is not a bug. The return type is not specified, so it's inferred. The inferred return type is then checked for compatibility, and it's compatible. This comes up pretty often, e.g. #41850.
Bug Report
When a function is typed to return an object of a certain type, the properties of the object can be expanded, meaning extra properties can be added to the ones described in the type or interface.
🔎 Search Terms
function return object type
🕗 Version & Regression Information
This is observable on the playground in all available versions.
Couldn't find anything I understood to be relevant in https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs
⏯ Playground Link
Buggy example on
@next
💻 Code
🙁 Actual behavior
Extra properties in the returned object, which aren't defined in the interface or type, do not raise an error.
🙂 Expected behavior
Extra properties in the returned object, which aren't defined in the interface or type, should raise an error.
The text was updated successfully, but these errors were encountered: