Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Incorrect Type Definition for popover Attribute in SvelteKit #2688

@karanravindra

Description

@karanravindra

Describe the bug

Description:
The popover attribute does not have the correct type definition in SvelteKit's typings. According to the MDN documentation, the popover attribute is a boolean attribute when used without a value. When present without a value, it should default to "auto" instead of requiring an explicit value.

Example Code

This code should be valid, but TypeScript reports an error:

<button popovertarget="popover-div">Click me</button>
<div popover id="popover-div">
	...
</div>

Error Message

Type 'true' is not assignable to type '"" | "auto" | "manual" | null | undefined'.ts(2322)
(property) popover?: "" | "auto" | "manual" | null | undefined

Expected Behavior

  • The popover attribute should allow popover={true} as valid, reflecting its boolean HTML attribute behavior.
  • If popover is present without a value, it should default to "auto" rather than throwing a TypeScript error.

Suggested Fix

Update the type definition in SvelteKit’s typings to:

  • Accept true, allowing popover={true}.
  • Default to "auto" when popover is used without a value.

Reproduction

<button popovertarget="popover-div">Click me</button>
<div popover id="popover-div">
	...
</div>

Logs

System Info

System:
    OS: macOS 15.3
    CPU: (11) arm64 Apple M3 Pro
    Memory: 183.48 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.config/.nvm/versions/node/v22.12.0/bin/node
    npm: 10.9.0 - ~/.config/.nvm/versions/node/v22.12.0/bin/npm
    pnpm: 9.15.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 133.0.6943.53
    Safari: 18.3

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions