Skip to content

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

Description

@jwbay

TypeScript Version: 3.0.0-dev.20180601

Search Terms: declaration import types

Code
src/one/two/export.ts:

import*asCSSfrom'csstype';exportconstuse=(f: CSS.Properties['fontWeight'])=>f;

src/one/two/consumer.ts:

import{use}from"./export";exportconstasdf=use;

Expected behavior:
consumer.d.ts has something like

exportdeclareconstasdf: (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.

exportdeclareconstasdf: (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

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