-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat: add ComponentExports utility type
#13441
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
Conversation
🦋 Changeset detectedLatest commit: 46a0488 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note that some previous change (which may be the one being referred to here) broke @testing-library/svelte's TypeScript support. I mention this here because perhaps it could be verified. |
|
Very cool, so much nicer to code with. I get this warning in VS code, does this have to be suppressed globally or is there a better way to avoid it?
Update: I believe it's required to ignore the above warning. See my comment here for my use case and the related discussion: #13104 (comment) |
If I understand correctly this is not related to this PR, this is just a utility type, to type the |
I tried to say it was just a use case connection (adoption friction for bind:this) for context if anyone was prioritising/triaging, so not technical/code related to this PR specifically. Apologies if it was unhelpful. |
dummdidumm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
commit: |
This reverts commit d93ad3b.
|
Thank you — we decided against releasing this in favour of making |
This reverts commit d93ad3b.
With the type change for
bind:thison components (related issues are this language-tools issue and 13430).Recommended way is to do this (per this comment):
Since we currently have the
Componenttype exported by svelte that has theExportswe can rely on that and do this instead:<script lang="ts"> import CloneWorkflowDialog from './dialogs/CloneWorkflowDialog.svelte'; // in a utility type, preferably provided by Svelte package itself. + type ComponentExports<TComponent extends Component<any, any>> = + TComponent extends Component<any, infer TExports> ? TExports : never; - let cloneWorkflowDialog : ReturnType<typeof CloneWorkflowDialog>; + let cloneWorkflowDialog : ComponentExports<typeof CloneWorkflowDialog>; </script>Whats the problem with using
ReturnType?This is the safer/forward-compatibale way that the svelte can decide on the type.
Svelte 5 rewrite
Please note that the Svelte codebase is currently being rewritten for Svelte 5. Changes should target Svelte 5, which lives on the default branch (
main).If your PR concerns Svelte 4 (including updates to svelte.dev.docs), please ensure the base branch is
svelte-4and notmain.Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.Tests and linting
pnpm testand lint the project withpnpm lint