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

@sveltejs/kit@1.20.4 and svelte@4.0.0 building component library generates d.ts files with deprecated SvelteComponentTyped #10223

Closed
nstuyvesant opened this issue Jun 22, 2023 · 3 comments · Fixed by #10328
Labels
pkg:svelte-package Issues related to svelte-package
Milestone

Comments

@nstuyvesant
Copy link
Contributor

Describe the bug

Upgraded component library package in monorepo to use svelte@4.0.0. It uses @sveltejs/kit@1.20.4 to "bundle" the component library to dist/.

When svelte-package is run, it creates all the files in the dist/ directory as it did with previous versions of svelte including type declarations.

The problem is that these type declarations import the deprecated SvelteComponentTyped like this...

import { SvelteComponentTyped } from "svelte";
import { AlluvialChart as AlluvialChartCore, type AlluvialChartOptions, type ChartTabularData } from '@carbon/charts';
declare const __propDef: {
    props: {
        [x: string]: any;
        chart: AlluvialChartCore;
        options: AlluvialChartOptions;
        data: ChartTabularData;
        ref: HTMLDivElement;
    };
    events: {
        load: CustomEvent<any>;
        update: CustomEvent<any>;
        destroy: CustomEvent<any>;
    } & {
        [evt: string]: CustomEvent<any>;
    };
    slots: {};
};
export type AlluvialChartProps = typeof __propDef.props;
export type AlluvialChartEvents = typeof __propDef.events;
export type AlluvialChartSlots = typeof __propDef.slots;
export default class AlluvialChart extends SvelteComponentTyped<AlluvialChartProps, AlluvialChartEvents, AlluvialChartSlots> {
}
export {};

Reproduction

git clone https://github.com/nstuyvesant/carbon-charts.git
cd carbon-charts
git checkout pr-1554
git pull
yarn install
yarn build

then look at d.ts files in packages/svelte/dist/.

Logs

No response

System Info

System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 4.76 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.1 - /opt/homebrew/bin/node
    Yarn: 3.5.1 - /opt/homebrew/bin/yarn
    npm: 9.7.2 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 114.0.5735.133
    Firefox: 114.0.1
    Safari: 16.5.1
  npmPackages:
    @sveltejs/adapter-auto: ^2.1.0 => 2.1.0 
    @sveltejs/kit: ^1.20.4 => 1.20.4 
    @sveltejs/package: ^2.0.2 => 2.0.2 
    svelte: ^4.0.0 => 4.0.0 
    vite: ^4.3.9 => 4.3.9

Severity

annoyance

Additional Information

Just seems like svelte-package needs to check the version of svelte and output the type declarations accordingly.

@dummdidumm
Copy link
Member

It does this, and I'm a bit unsure if we want to really change that. The reason is that if we generate it with SvelteComponentTyped that means your library is also compatible with Svelte 3. Maybe we can check the peerDependencies and dependencies for Svelte versions and if only 4 shows up then use SvelteComponent.

@dummdidumm dummdidumm added the pkg:svelte-package Issues related to svelte-package label Jun 22, 2023
@dummdidumm dummdidumm added this to the soon milestone Jun 22, 2023
@nstuyvesant
Copy link
Contributor Author

Yeah the backwards compatibility is super-important especially for a component library right now.

@jacob-8
Copy link
Contributor

jacob-8 commented Jun 23, 2023

I'm going to just comment here instead of create a new issue as I'm assuming the presence of this issue means everyone is aware that @sveltejs/package is throwing an unmet peer dependency error when trying to be used with Svelte 4.

dummdidumm added a commit that referenced this issue Jul 6, 2023
When the (peer)dependency states that only Svelte 4 is allowed, invoke the dts generation script with the Svelte 4 shims instead of the Svelte 3 shims. The noticable difference is that then SvelteComponent instead of the deprecated SvelteComponentTyped will be used to declare the component typings.
closes #10223
dummdidumm added a commit that referenced this issue Jul 7, 2023
…10328)

When the (peer)dependency states that only Svelte 4 is allowed, invoke the dts generation script with the Svelte 4 shims instead of the Svelte 3 shims. The noticable difference is that then SvelteComponent instead of the deprecated SvelteComponentTyped will be used to declare the component typings.
closes #10223
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:svelte-package Issues related to svelte-package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants