Skip to content

[ts5.8.2+node16] error TS2307: Cannot find module 'trusted-types/lib' or its corresponding type declarations #4943

@AviVahl

Description

@AviVahl

Which package(s) are affected?

Lit Core (lit / lit-html / lit-element / reactive-element)

Description

Upgrading to typescript@5.8.2, on a project that uses node16 module/moduleResolution, results in the following error:

> tsc

node_modules/lit-html/development/lit-html.d.ts:7:34 - error TS2307: Cannot find module 'trusted-types/lib' or its corresponding type declarations.

7 import type { TrustedHTML } from 'trusted-types/lib';
                                   ~~~~~~~~~~~~~~~~~~~


Found 1 error in node_modules/lit-html/development/lit-html.d.ts:7

Reproduction

mkdir lit-type-issue
cd lit-type-issue
npm init -y
npm i typescript lit
npx tsc --init --skipLibCheck false --module node16 --moduleResolution node16
echo "import * as lit from 'lit'; console.log(lit);" > index.ts
npx tsc --noEmit

Workaround

  1. turn on skipLibCheck to avoid type-checking .d.ts files
  2. avoid using the newest typescript version
  3. avoid node16 moduleResolution

Is this a regression?

Yes. This used to work, but now it doesn't.

Affected versions

failing with typescript 5.8.2, passes with 5.7.3

Browser/OS/Node environment

Browser: irrelevant
OS: Fedora 41
Node: 22.14.0
npm: 10.9.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions