josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
816 stars 108 forks source link

Interface declaration in index.d.ts causes npm run build to fail #349

Closed hybridwebdev closed 7 months ago

hybridwebdev commented 7 months ago

image

As you can see in the image, webpack fails to build. It's caused by this code:

interface RenderValueComponentDescription {
    component: typeof SvelteComponent<RenderValuePropsOptional>;
    props: Record<string, unknown>;
}

if you change it to this:

interface RenderValueComponentDescription {
    component: typeof SvelteComponent;
    props: Record<string, unknown>;
}

Then the build succeeds.

For clarification, I am using vanilla-jsoneditor in VUE 3 using webpack.

josdejong commented 7 months ago

If this is invalid TypeScript I would expect errors already when bundling the library itself, but that is not the case 🤔.

What version of TypeScript and Webpack are you using in your project? How can we reproduce this issue?

hybridwebdev commented 7 months ago

I am running webpack 5.75.0 and my project is using typescript ~4.5.5. As for a reproduction environment, your library is part of a very large and proprietary codebase I can't publish here. I can say I'm basically using your library very generically. Just importing type declarations and AJV to create an editor instance in VUE as per your demos. Standard stuff, and I highly doubt my implementation is the issue.

I see your library is using typescript 5.3.2 so it is a possibility that I need to update my version. Looking at the code to me it does look like the syntax in question is invalid. However, I could be wrong as my knowledge of typescript isn't as strong as it could be.

I will give updating my typescript a go and report back.

The weird issue is, this only occurs when building. In dev mode, I don't see any errors in VSC, console or anywhere.

hybridwebdev commented 7 months ago

Okay, so I updated my typescript to 4.9.5 (that was the highest I could go based on other dependencies in my library) and it resolved the issue. Seems my typescript version was indeed the culprit.

josdejong commented 6 months ago

That's good news 🎉, thanks for letting me know!