Skip to content

breaking: remove Component type, keep using SvelteComponent instead #9413

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

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/small-papayas-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

breaking: remove Component type, keep using SvelteComponent instead
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Please note that [the Svelte codebase is currently being rewritten for Svelte 5]

If your PR concerns Svelte 4 (including updates to [svelte.dev.docs](https://svelte.dev/docs)), please ensure the base branch is `svelte-4` and not `main`.


### Before submitting the PR, please make sure you do the following

- [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ await createBundle({
[`${pkg.name}/animate`]: `${dir}/src/animate/public.d.ts`,
[`${pkg.name}/compiler`]: `${dir}/src/compiler/index.js`,
[`${pkg.name}/easing`]: `${dir}/src/easing/index.js`,
[`${pkg.name}/legacy`]: `${dir}/src/legacy/public.d.ts`,
[`${pkg.name}/legacy`]: `${dir}/src/legacy/legacy-client.js`,
[`${pkg.name}/motion`]: `${dir}/src/motion/public.d.ts`,
[`${pkg.name}/server`]: `${dir}/src/server/index.js`,
[`${pkg.name}/store`]: `${dir}/src/store/public.d.ts`,
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/internal/client/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -3020,7 +3020,7 @@ export function unwrap(value) {
* @template {Record<string, any>} Props
* @template {Record<string, any> | undefined} Exports
* @template {Record<string, any>} Events
* @param {import('../../main/public.js').Component<Props, Exports, Events>} component
* @param {import('../../main/public.js').SvelteComponent<Props, Events>} component
* @param {{
* target: Node;
* props?: Props;
Expand Down Expand Up @@ -3139,7 +3139,7 @@ export function createRoot(component, options) {
* @template {Record<string, any>} Props
* @template {Record<string, any> | undefined} Exports
* @template {Record<string, any>} Events
* @param {import('../../main/public.js').Component<Props, Exports, Events>} component
* @param {import('../../main/public.js').SvelteComponent<Props, Events>} component
* @param {{
* target: Node;
* props?: Props;
Expand Down
12 changes: 6 additions & 6 deletions packages/svelte/src/legacy/legacy-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import * as $ from '../internal/index.js';
* @template {Record<string, any>} Events
* @template {Record<string, any>} Slots
*
* @param {import('./public.js').ComponentConstructorOptions<Props> & {
* component: import('../main/public.js').Component<Props, Exports, Events, Slots>;
* @param {import('../main/public.js').ComponentConstructorOptions<Props> & {
* component: import('../main/public.js').SvelteComponent<Props, Events, Slots>;
* immutable?: boolean;
* recover?: false;
* }} options
* @returns {import('./public.js').SvelteComponent<Props & Exports, Events, Slots>}
* @returns {import('../main/public.js').SvelteComponent<Props, Events, Slots> & Exports}
*/
export function createClassComponent(options) {
// @ts-expect-error $$prop_def etc are not actually defined
Expand All @@ -33,8 +33,8 @@ export function createClassComponent(options) {
* @template {Record<string, any>} Events
* @template {Record<string, any>} Slots
*
* @param {import('../main/public.js').Component<Props, Exports, Events, Slots>} component
* @returns {typeof import('./public.js').SvelteComponent<Props & Exports, Events, Slots>}
* @param {import('../main/public.js').SvelteComponent<Props, Events, Slots>} component
* @returns {typeof import('../main/public.js').SvelteComponent<Props, Events, Slots> & Exports}
*/
export function asClassComponent(component) {
// @ts-expect-error $$prop_def etc are not actually defined
Expand All @@ -57,7 +57,7 @@ class Svelte4Component {
#instance;

/**
* @param {import('./public.js').ComponentConstructorOptions & {
* @param {import('../main/public.js').ComponentConstructorOptions & {
* component: any;
* immutable?: boolean;
* recover?: false;
Expand Down
9 changes: 5 additions & 4 deletions packages/svelte/src/legacy/legacy-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { render } from '../internal/server/index.js';
export { createClassComponent };

/**
* Takes the component function and returns a Svelte 4 compatible component constructor.
* Takes a Svelte 5 component and returns a Svelte 4 compatible component constructor.
*
* @deprecated Use this only as a temporary solution to migrate your imperative component code to Svelte 5.
*
Expand All @@ -15,8 +15,8 @@ export { createClassComponent };
* @template {Record<string, any>} Events
* @template {Record<string, any>} Slots
*
* @param {import('../main/public.js').Component<Props, Exports, Events, Slots>} component
* @returns {typeof import('./public.js').SvelteComponent<Props & Exports, Events, Slots>}
* @param {import('../main/public.js').SvelteComponent<Props, Events, Slots>} component
* @returns {typeof import('../main/public.js').SvelteComponent<Props, Events, Slots> & Exports}
*/
export function asClassComponent(component) {
const component_constructor = as_class_component(component);
Expand All @@ -30,8 +30,9 @@ export function asClassComponent(component) {
html: result.html
};
};
// @ts-expect-error this is present for SSR
// this is present for SSR
component_constructor.render = _render;

// @ts-ignore
return component_constructor;
}
93 changes: 0 additions & 93 deletions packages/svelte/src/legacy/public.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/svelte/src/main/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module '*.svelte' {
export { Component as default } from 'svelte';
export { SvelteComponent as default } from 'svelte';
}

/**
Expand Down
Loading