Skip to content

bug: components.d.ts resolves inherited types to wrong import paths #6687

@alexischarp

Description

@alexischarp

Prerequisites

Stencil Version

4.43.3

Current Behavior

The issue:
The auto-generated components.d.ts resolves the Validator type import to the consuming component's directory instead of the shared directory where it actually lives:

// What Stencil generates (wrong):
import { Validator } from "./components/data-entry/checkbox/input.types";

The file at dist/types/components/data-entry/checkbox/input.types.d.ts doesn't exist — the type only exists at dist/types/components/shared/input/input.types.d.ts. This breaks type resolution for consumers who import type { Validator } from 'my-package'.

The individual component .d.ts files resolve correctly (they properly reference ../../shared/input/...), so the issue is specifically in how components.d.ts resolves import paths for types inherited through base classes.

It looks like this issue happens when there is more than 1 extend.

Expected Behavior

// What Stencil generates (wrong):
import { Validator } from "./components/data-entry/checkbox/input.types";

// What it should be:
import { Validator } from "./components/shared/input/input.types";

System Info

Steps to Reproduce

  • Shared base classes in src/components/shared/input/ that import a Validator type from a sibling input.types.ts file
  • Concrete components (e.g. checkbox, input-text, select, etc.) in src/components/data-entry/ that extend a class that extends this base class

Code Reproduction URL

https://codesandbox.io/p/github/johnjenkins/stencil-starter/csb-yx4ntc/draft/exciting-wave?file=%2Fdist%2Ftypes%2Fcomponents.d.ts%3A11%2C28

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions