Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrewbranch opened this issue Feb 20, 2020 · 1 comment · Fixed by #36925
Closed

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

andrewbranch opened this issue Feb 20, 2020 · 1 comment · Fixed by #36925
Assignees
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging

Comments

@andrewbranch
Copy link
Member

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

@DanielRosenwasser
Copy link
Member

Thanks @a-tarasyuk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants