This is a test project to demonstrate a bug in the TypeScript compiler when using JavaScript. See microsoft/TypeScript#51622
When creating types from a ts
source file it keeps the import pathes as is. (which is expected)
👉 Source: src/ElementA.ts
import { LitElement } from "lit";
export class ElementA extends LitElement {}
👉 Output: dist-types/src/ElementA.d.ts
import { LitElement } from "lit";
export declare class ElementA extends LitElement {}
When creating types from "the exact same file" but as a js
it changes the import pathes by "resolving" them.
👉 Source: src/ElementB.js
import { LitElement } from "lit";
export class ElementB extends LitElement {}
export class ElementB extends LitElement {}
import { LitElement } from "lit-element/lit-element.js";
👉 Output: dist-types/src/ElementB.d.ts
export class ElementB extends LitElement {}
import { LitElement } from "lit";
Because of the miss match between the "location" of LitElement
TS believes those are different LitElement types.
- Clone this repo
- Run
npm install
- Run
npm run types
- Inspect the output in
dist-types
- Node 18
- TypeScript 4.9.3