Skip to content

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

@stemcstudio

Description

@stemcstudio

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerChanges relating to the compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions