Skip to content

Declaration file non-exported types are importable #38592

@mheiber

Description

@mheiber

TypeScript Version: 3.9.2, 3.8.3, 3.1.6 3.0.3 (and likely more)

Search Terms:

declaration file export, non-exported types, implicit export, dts, .d.ts, es-modules declaration

Code

module.d.ts

export declare const explicitlyExported: {};
declare const implicitlyExported: {};

importer.d.ts

import { implicitlyExported } from "./module"; // no error, is usable import

Expected behavior:

Error: Module '"./module"' has no exported member 'implicitlyExported'.

Actual behavior:

No error.

Even thought it wasn't exported, implicitlyExported is available for import.

Playground Link:

n/a (declaration file issue)

Related Issues:

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions