Skip to content

exactOptionalPropertyTypes type issues #1176

@macmillen

Description

@macmillen

Describe the bug
When the exactOptionalPropertyTypes flag is set to true in tsconfig.json I get errors when passing values to HTML elements which are possibly undefined which (presumably) shouldn't be happening.

To Reproduce
Steps to reproduce the behavior:

  1. Example:
<button on:click>Button</button>
Type 'undefined' is not assignable to type 'MouseEventHandler<HTMLButtonElement>'.ts(2322)
(JSX attribute) svelte.JSX.DOMAttributes<HTMLButtonElement>.onclick?: svelte.JSX.MouseEventHandler<HTMLButtonElement>
  1. Example
<script lang="ts">
  let placeholder: string | undefined;
</script>

<input {placeholder} />
Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.ts(2322)

Expected behavior
All HTML properties should accept an undefined value. (?)

Screenshots
image

System (please complete the following information):

  • OS: Linux
  • IDE: VSCode
  • Plugin/Package: Svelte for VSCode

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