Skip to content
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

(feat) use satisfies operator if possible #1770

Merged
merged 3 commits into from
Dec 11, 2022

Conversation

dummdidumm
Copy link
Member

when creating SvelteKit files

@dummdidumm dummdidumm merged commit c7fe395 into sveltejs:master Dec 11, 2022
@dummdidumm dummdidumm deleted the ts-satisfies branch December 11, 2022 09:38
@aradalvand
Copy link

aradalvand commented Dec 11, 2022

@dummdidumm I'm curious as to what the rationale behind this change was. Why is the satisfies operator preferable?
It seems like this is just more verbose and more exotic than the simple e.g. export load: PageLoad = .... What's the advantage?

@dummdidumm
Copy link
Member Author

dummdidumm commented Dec 11, 2022

The advantage is that for the generated ./$types we have to generate the types only once and not regenerate them if you update your load function. Also once we persuade the TypeScript team to implement this for functions, too (microsoft/TypeScript#51556), it will look way nicer.

export function load (..) {
  ..
} satisfied PageLoad

It's exotic to you right now, because this is a new feature, but I'm sure you'll get used to it in no time.

@aradalvand
Copy link

aradalvand commented Dec 11, 2022

The advantage is that for the generated ./$types we have to generate the types only once and not regenerate them if you update your load function

Ah okay, that makes sense, thanks.

Also once we persuade the TypeScript team to implement this for functions, too (microsoft/TypeScript#51556), it will look way nicer.

Yeah, that would make it look a lot better.

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.

2 participants