Skip to content

Conversation

islandryu
Copy link
Contributor

Fixes #47076

I fix error term of declaration in modules.

  • "An import declaration can only be used in a namespace or module." →

    • When the node is in JS file, "An import declaration can only be used at the top level of a module."
    • Otherwise, "An import declaration can only be used at the top level of a namespace or module."
  • "An export declaration can only be used in a module." →

    • "An export declaration can only be used at the top level of a module."
  • "A namespace declaration is only allowed in a namespace or module." →

    • "A namespace declaration is only allowed at the top level of a module."

@ghost
Copy link

ghost commented Dec 9, 2021

CLA assistant check
All CLA requirements met.

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Dec 9, 2021
@islandryu islandryu changed the title Fix error term of declaration in modules fix(47076):Fix error term of declaration in modules Dec 21, 2021
@DanielRosenwasser
Copy link
Member

Why isn't it

A namespace declaration is only allowed at the top level of a namespace or module.

?

@islandryu
Copy link
Contributor Author

@DanielRosenwasser
Indeed, it should be that way.
Fixed.

@sandersn sandersn merged commit 95c22d1 into microsoft:main Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Improve non-top-level import/export error, especially for JS
4 participants