Skip to content

Using switch cases for log leveling leads to ts-error #754

Description

@FrBoehle

Hey,

in 0.9.x, it seems that the level "warn" was changed to "warning".
Whenever i try to process the validation levels with a switch like so, it throws a ts-error:

const parser = new DOMParser({
      onError: (level, msg, context) => {
        switch (level) {
          case 'warning':
            ...
            break
          case 'error':
            ...
            break
          case 'fatalError':
            ...
            break
          default:
            break
        }
      },
    })

The error reads:
Type '"warning"' is not comparable to type '"warn" | "error" | "fatalError"'.ts(2678)

Workaround:
use // @ts-expect-error

The old one ("warn") does NOT throw a ts-error.
I'm assuming that somewhere you are still using "warn" instead of "warning" in your code?
Maybe here?:

* {'warn' | 'error' | 'fatalError'}

xmldom version: 0.9.3
typescript version: 5.6.2
If you need further information, im happy to help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp-wantedExternal contributions welcometypesAnything regarding Typescript

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions