Skip to content

docs(typescript): clarify excess property checks in computed<T>() typing - #3466

Open
wjs-tech wants to merge 1 commit into
vuejs:mainfrom
wjs-tech:fix/3286-computed-typing
Open

wjs-tech wants to merge 1 commit into
vuejs:mainfrom
wjs-tech:fix/3286-computed-typing

Conversation

@wjs-tech

Copy link
Copy Markdown
Contributor

A generic argument such as computed<Foo>(...) only checks that the getter's return value is assignable to Foo. Because TypeScript does not run excess property checks when inferring into a generic, returning an object with extra properties is silently allowed — which can surprise users who expect strict shape checking.

This adds a tip to the "Typing computed()" section showing:

  • the loose behavior with a generic argument
  • the stricter alternative using a return type annotation
  • the satisfies operator as a concise way to enforce an exact shape

close #3286

A generic argument such as computed<Foo>(...) only requires the getter's return value to be assignable to Foo. Because TypeScript does not run excess property checks when inferring into a generic, returning an object with extra properties is silently allowed.

Add a tip to the Typing computed() section showing the loose generic behavior, the stricter return-type-annotation alternative, and the satisfies operator as a concise way to enforce an exact shape.

close vuejs#3286
@netlify

netlify Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit 6785194
🔍 Latest deploy log https://app.netlify.com/projects/vuejs/deploys/6aaf5662c68bff0008ef8e74
😎 Deploy Preview https://deploy-preview-3466--vuejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion: Clarify typing with computed<T> vs return annotation (excess property checks)

1 participant