Skip to content

Import types in d.ts files contain relative paths to node_modules #24599

Closed
@jwbay

Description

@jwbay

TypeScript Version: 3.0.0-dev.20180601

Search Terms: declaration import types

Code
src/one/two/export.ts:

import * as CSS from 'csstype';
export const use = (f: CSS.Properties['fontWeight']) => f;

src/one/two/consumer.ts:

import { use } from "./export";
export const asdf = use ;

Expected behavior:
consumer.d.ts has something like

export declare const asdf: (f: import("csstype/index").FontWeightProperty) => import("csstype/index").FontWeightProperty;

Actual behavior:
It has relative paths to node_modules, based on the source file's location at compile time. This places an assumption on the location of the d.ts file when it's consumed externally.

export declare const asdf: (f: import("../../../node_modules/csstype/index").FontWeightProperty) => import("../../../node_modules/csstype/index").FontWeightProperty;

Playground Link: N/A

Related Issues: #24556, but csstype does specify a types key in package.json

Metadata

Metadata

Assignees

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