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

tsc generating wrong .d.ts for tsx generated by svelte2tsx #2546

Open
NaviTheCoderboi opened this issue Oct 26, 2024 · 3 comments
Open

tsc generating wrong .d.ts for tsx generated by svelte2tsx #2546

NaviTheCoderboi opened this issue Oct 26, 2024 · 3 comments

Comments

@NaviTheCoderboi
Copy link

guys i am using svelte2tsx for transforming svelte to tsx for gneerating .d.ts

        const tsx = s2x.svelte2tsx(content, {
            filename: file,
            isTsFile: isTsScript(content),
            emitOnTemplateError: false,
            version: svelte.VERSION,
            mode: 'dts'
        });

i get such output

import { SvelteComponentTyped } from "svelte"

;function render() {
;type $$ComponentProps =  {
        name: string;
    };
    const {
        name
    }:/*Ωignore_startΩ*/$$ComponentProps/*Ωignore_endΩ*/ = $props(); 
;
async () => {

 { svelteHTML.createElement("h1", {});
     name;
 }

 { svelteHTML.createElement("h2", {}); }
};
return { props: {} as any as $$ComponentProps, exports: {}, bindings: __sveltets_$$bindings(''), slots: {}, events: {} }}
const Foo = __sveltets_2_fn_component(render());
export default Foo;

when i use typescript on it , i t gives me such .d.ts file, how do i fix it?

declare const Foo: any;
export default Foo;

my code: https://github.com/NaviTheCoderboi/foo

@jasonlyu123
Copy link
Member

svelte2tsx also has an emitDts mode you can use. https://github.com/sveltejs/language-tools/blob/master/packages/svelte2tsx/src/emitDts.ts. You can also reference the implementation If you have a specific reason for not using it,

@NaviTheCoderboi
Copy link
Author

NaviTheCoderboi commented Oct 26, 2024

@jasonlyu123 i have written my code from that only, but i am not getting expected output

@dummdidumm
Copy link
Member

Please provide a proper reproduction (the link is a 404)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants