Skip to content

Wrong error message when trying to named-import an export= (or CJS) export #36909

Closed
@andrewbranch

Description

@andrewbranch

TypeScript Version: 3.8 RC – nightly

Search Terms: declares locally but not exported

Code

// a.ts
class Foo {}
export = Foo;

// b.ts
import { Foo } from './a';

Expected behavior:
Module "./a" has no exported member 'Foo' (pre-3.8 message), or better yet, using context to pick between one of these specialized messages:

  • TS, module kind < es2015, allowSynthetic off: 'Foo' can only be imported by using 'import Foo = require(...)' or by turning on the 'allowSyntheticDefaultImports' flag and using a default import.
  • TS, module kind < es2015, allowSynthetic on: 'Foo' can only be imported by using 'import Foo = require(...)' or a default import.
  • TS or JS, module kind >= es2015, allowSynthetic off: 'Foo' can only be imported by turning on the 'allowSyntheticDefaultImports' flag and using a default import.
  • TS or JS, module kind >= es2015, allowSynthetic on: 'Foo' can only be imported by using a default import.
  • JS, module kind < es2015, allowSynthetic off: 'Foo' can only be imported by using a 'require' call or by turning on the 'allowSyntheticDefaultImports' flag and using a default import.
  • JS, module kind < es2015, allowSynthetic on: `'Foo' can only be imported by using a 'require' call or by using a default import.'

Actual behavior:

Module '"./a"' declares 'Foo' locally, but it is not exported.

Playground Link: https://www.typescriptlang.org/play/?ts=Nightly#code/CYUwxgNghgTiAEBbA9sArhBByKX4G8AoASBAA8AHZGAFwPgF8TIoBnV+AMWWXqdMrU6AXi48A3ISaFQLOElQZsAIzxFiAeg3wAsoszwsAIihG8s6HA5ZuyPBGRgoECAE8ANPGVo6ASz8cAHbIdORUtCDAAHQkvojhdPhivAzwAGYwyIiGuJJMQA

Related Issues: PR: #36187

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Error MessagesThe issue relates to error messaging

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions