Skip to content

Tweak UMD / global semantics - #8678

Merged
Ryan Cavanaugh (RyanCavanaugh) merged 2 commits into
microsoft:masterfrom
RyanCavanaugh:fix8255
May 23, 2016
Merged

Ryan Cavanaugh (RyanCavanaugh) merged 2 commits into
microsoft:masterfrom
RyanCavanaugh:fix8255

Conversation

@RyanCavanaugh

Copy link
Copy Markdown
Member

The behavior for UMD declarations is now that you cannot use UMD symbols from external modules. This removes the confusing concept of "was this file referenced or not?".

I've also renamed GlobalModuleExportDeclaration to NamespaceExportDeclaration because it was confusing.

Fixes #8255

"category": "Error",
"code": 2685
},
"Identifier '{0}' must be imported from a module": {

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) May 19, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that isn't specifically the solution. The problem is that you're using something intended to be used as a global. Importing an identifier by that name from a module might not work at all. Importing the module as that name would work.

A better message might be

The namespace '{0}' declared in '{1}' is not accessible within a module. Did you mean to import the file instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a good way right now to generate {1} in that message (since we'd basically have to reverse-engineer a module name that would successfully resolve from the containing file).

How about

Global identifier {0} cannot be used from a module. Did you mean to import this from its module?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about getting the path relative to the project root?

@DanielRosenwasser

Copy link
Copy Markdown
Member

I've also renamed GlobalModuleExportDeclaration to NamespaceExportDeclaration because it was confusing.

Still confusing, but better. 😄

@RyanCavanaugh

Copy link
Copy Markdown
Member Author

Any other comments?

@mhegazy

Copy link
Copy Markdown
Contributor

Fixes #7843

@mhegazy

Copy link
Copy Markdown
Contributor

The message is a bit vague, and can be enhanced, other than that 👍

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.

4 participants