Skip to content

24542 - bad error message for import *-ing an export=#25445

Merged
DanielRosenwasser merged 11 commits intomicrosoft:masterfrom
a-tarasyuk:bug/24542-bad-error-message-for-import-ing-an-export
Jan 9, 2019
Merged

24542 - bad error message for import *-ing an export=#25445
DanielRosenwasser merged 11 commits intomicrosoft:masterfrom
a-tarasyuk:bug/24542-bad-error-message-for-import-ing-an-export

Conversation

@a-tarasyuk
Copy link
Copy Markdown
Contributor

Fixes #24542

@a-tarasyuk a-tarasyuk changed the title 24542 - bad error message for import ing an export 24542 - bad error message for import *-ing an export= Jul 5, 2018
@a-tarasyuk a-tarasyuk force-pushed the bug/24542-bad-error-message-for-import-ing-an-export branch 3 times, most recently from d0dabbc to 44a7350 Compare July 5, 2018 09:02
@a-tarasyuk a-tarasyuk force-pushed the bug/24542-bad-error-message-for-import-ing-an-export branch from 44a7350 to 2c7b39a Compare July 5, 2018 09:12
@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jul 5, 2018

@DanielRosenwasser can you please review this change.

Comment thread tests/baselines/reference/es6ExportEqualsInterop.errors.txt Outdated
@DanielRosenwasser
Copy link
Copy Markdown
Member

@mhegazy @weswigham what about

When writing ECMAScript imports, callable/constructable 'export ='-style modules can only be imported by turning on the 'esModuleInterop' flag and using a default import.

@weswigham
Copy link
Copy Markdown
Member

weswigham commented Jul 5, 2018

@DanielRosenwasser we can equally point people to import a = require when not targeting esnext and is usually a less error-prone change than turning on esModuleInterop; which is why the original message was "cannot be imported using this construct".

… bug/24542-bad-error-message-for-import-ing-an-export
@a-tarasyuk
Copy link
Copy Markdown
Contributor Author

@DanielRosenwasser @weswigham Should I change the message to

When writing ECMAScript imports, callable/constructable 'export ='-style modules can only be imported by turning on the 'esModuleInterop' flag and using a default import.

?

Maybe the message should rely on module type(es2015, cjs), what do you think?

@DanielRosenwasser
Copy link
Copy Markdown
Member

Hey @a-tarasyuk - I think you're right, but in those circumstances we need to just recommend people use allowSyntheticDefaultImports, not esModuleInterop. Does that sound right @weswigham?

@a-tarasyuk
Copy link
Copy Markdown
Contributor Author

@DanielRosenwasser thanks for your answer, will wait for the answer from @weswigham in order to understand which message should I use for this case as the message from Expected section - #24542 is not right.

@weswigham
Copy link
Copy Markdown
Member

Hey @a-tarasyuk - I think you're right, but in those circumstances we need to just recommend people use allowSyntheticDefaultImports, not esModuleInterop

If module < es2015, esModuleInterop, otherwise alliwSyntheticDefaultImports.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jul 11, 2018

@DanielRosenwasser can you take a look.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jul 16, 2018

@DanielRosenwasser mentioned he had some comments offline. @DanielRosenwasser can u please comment

@a-tarasyuk a-tarasyuk closed this Jul 24, 2018
… bug/24542-bad-error-message-for-import-ing-an-export
@a-tarasyuk a-tarasyuk reopened this Sep 7, 2018
@a-tarasyuk a-tarasyuk closed this Sep 12, 2018
@a-tarasyuk a-tarasyuk reopened this Sep 12, 2018
@RyanCavanaugh RyanCavanaugh added this to the Community milestone Sep 17, 2018
… bug/24542-bad-error-message-for-import-ing-an-export
Comment thread tests/baselines/reference/es6ExportEqualsInterop.errors.txt Outdated
Comment thread tests/baselines/reference/es6ExportEqualsInterop.errors.txt Outdated
@DanielRosenwasser DanielRosenwasser merged commit 6bfb935 into microsoft:master Jan 9, 2019
@DanielRosenwasser
Copy link
Copy Markdown
Member

Thank you for the PR and your patience!

@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants