Skip to content

tsc 2.9.x generating incorrect type definitions for import types #25278

Closed

Description

@jrf0110

tldr; when using the new import types feature of tsc 2.9, there are certain circumstances where the import( part is missing.

Version: 3.0.0-dev.20180626

Code

See https://github.com/jrf0110/tsc-declaration-bug/blob/master/workspaces/button-consumer/dist/index.d.ts#L2 for a full example

import { MyButton } from "@cloudflare/button-thing";
export const Something = MyButton;

Expected behavior:

/// <reference path="../../../types/component-button.d.ts" />
export declare const Something: typeof import('@cloudflare/component-button').Button;

Actual behavior:

/// <reference path="../../../types/component-button.d.ts" />
export declare const Something: typeof '@cloudflare/component-button'.Button;

Playground Link: https://github.com/jrf0110/tsc-declaration-bug

Additional Info

We saw this come up using yarn workspaces. I'm not exactly sure if using yarn workspaces is required to reproduce. Nonetheless, this definitely seems like a bug with tsc itself.

I suspect this has something to do with importing from .d.ts files that declare a module, as is the case in the linked example.

Metadata

Metadata

Labels

BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions