Skip to content

Different Declaration output for same code from js and ts fileΒ #51622

@daKmoR

Description

@daKmoR

Bug Report

πŸ”Ž Search Terms

  • declaration import rewrite
  • declaration import change

πŸ•— Version & Regression Information

  • Probably has always been like that (verified it in 4.9, 4.8, 4.7)

⏯ Playground Link

Sadly not possible as it's about importing of "nested" dependencies.

So I created a reproduction repository

  1. Clone https://github.com/daKmoR/tsbug-declaration-output
  2. Run npm install
  3. Run npm run types
  4. Inspect the output in dist-types

πŸ’» Code

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 {}

πŸ™ Actual behavior

πŸ‘‰ Output: dist-types/src/ElementB.d.ts

export class ElementB extends LitElement {}
import { LitElement } from "lit-element/lit-element.js";

πŸ™‚ Expected behavior

export class ElementB extends LitElement {}
import { LitElement } from "lit";

Consequences

Because of the miss match between the "location" of LitElement TS believes those are different LitElement types.

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions