Skip to content

Type merging for imported types only works if the type is imported from "node_modules/@types/" dir #39691

@ezsh

Description

@ezsh

Consider the following example.

In typings_module:
vars.d.ts:

interface UserProperties {
}

declare global {
    const variable: UserProperties;
}

index.d.ts:

export as namespace ModuleNamespace;
export * from "./vars"

Now, we want to specify properties for the UserProperties interface.
a_project_file.d.ts:

declare module "typings_module" {
	export interface UserProperties {
		test: number;
	}
}

export {}

The bug is the type merging works only if the "typings_module" files are inside "node_modules/@types/" and does not work if the same files are referenced from another location via the "typeRoots" TSC option in "tsconfig.json".

TypeScript Version: 3.9.6

Search Terms: "type merging", "declaration files"

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions