Skip to content

d.ts with import statement exports types that are not marked exported #19545

Closed
@evmar

Description

@evmar

TypeScript Version: [email protected] (also 2.4 and 2.5)

Code

// extra.ts
export var x = 3;

// iface.d.ts
import {x} from './extra';
// note: this next line is *not* exported
declare interface Foo { bar: string; }

// user.ts
import {Foo} from './iface';

Expected behavior:
This should fail to compile, because iface.d.ts did not export the Foo type. Error message should be

 error TS2305: Module ... has no exported member 'Foo'.

Actual behavior:
It compiles.

Extra notes:

  1. if iface.d.ts has no import statement, but instead uses export {} to become a module, then expected error is produced
  2. if you remove import/export statements from iface.d.ts, then as expected you get the 'is not a module' error
  3. if you rename iface.d.ts to iface.ts, then expected error is produced

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions