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

append_styles s/b typed as an optional parameter in function init(...) #7200

Closed
stemcstudio opened this issue Jan 28, 2022 · 0 comments · Fixed by #9118
Closed

append_styles s/b typed as an optional parameter in function init(...) #7200

stemcstudio opened this issue Jan 28, 2022 · 0 comments · Fixed by #9118
Labels
compiler Changes relating to the compiler

Comments

@stemcstudio
Copy link

Describe the bug

If the generated JavaScript code (for the simplest Hello World case) is given a .ts extension and analyzed by the TypeScript compiler, the error is "Expected 7-8 arguments, but got 6." This is because the current prototype of the init function in Component.ts requires append_styles.

Reproduction

You can see this in my STEMCstudio browser-based application (an online coding environment for education that supports Svelt).

https://stemcstudio.com/gists/078c883495d81d6976ae798c9e243b76

Selecting the "Workspace Settings" menu (cog wheel) and the "Show Intermediate (TypeScript) Code" menu item shows that the call to init has six arguments. The append_styles parameter is not required (as evidence in the Svelt source code).

The fix would be to change the append_styles type in src/runtime/internal/Component.ts to something like:

append_styles?: (root: Element | ShadowRoot) => void,

OR

append_styles?: (root: Node) => void

I'm not quite sure which is best or what the intent is.

I can make a recommendation if rectifying this issue is given favorable consideration.

Logs

No response

System Info

Version 3.46.3 of Svelte and below.

Severity

annoyance

@stemcstudio stemcstudio changed the title append_styles is typed as a required parameter in function init(...) append_styles s/b typed as an optional parameter in function init(...) Jan 28, 2022
@Conduitry Conduitry added the compiler Changes relating to the compiler label Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Changes relating to the compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants