Skip to content

Incorrect parameter type checking for omitted parameters #2720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Jojoshua opened this issue Mar 20, 2025 · 2 comments
Closed

Incorrect parameter type checking for omitted parameters #2720

Jojoshua opened this issue Mar 20, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@Jojoshua
Copy link
Contributor

Describe the bug

I'm not exactly sure how to phrase the title of this bug report so please update if it doesn't make sense. While trying to workaround/create a concept so that a set of components could follow a strict pattern and enforce an abstract class (sveltejs/svelte#15552), I found this issue.

The doSomething method requires a data parameter of type number. The type checker got it right when the parameter was passed in (S1.svelte and S3.svelte) but not when it was simply left out (S2.svelte)

Image

Reproduction

See https://github.com/Jojoshua/svelte5-issue1/tree/master/src/Specialty

Expected behaviour

I expect an error to be shown for S2.svelte where it requires a parameter of type number to be passed into the component prop

System Info

  • OS: [e.g. Windows]
  • IDE: [e.g. VSCode, Atom]

Which package is the issue about?

No response

Additional Information, eg. Screenshots

No response

@Jojoshua Jojoshua added the bug Something isn't working label Mar 20, 2025
@jasonlyu123
Copy link
Member

This is controlled by TypeScript and is considered as "working as intended" https://github.com/microsoft/TypeScript/wiki/FAQ#parameter-arity-variance-is-correct. I don't know any workaround to force TypeScript to error on this either, unfortunately.

@Jojoshua
Copy link
Contributor Author

This is controlled by TypeScript and is considered as "working as intended" https://github.com/microsoft/TypeScript/wiki/FAQ#parameter-arity-variance-is-correct. I don't know any workaround to force TypeScript to error on this either, unfortunately.

Thanks for finding the reference...I've never heard of that. I will close this since it appears to be a TS design decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants