Skip to content
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

UMD support #7264

Merged
merged 11 commits into from
Mar 10, 2016
Merged

UMD support #7264

merged 11 commits into from
Mar 10, 2016

Conversation

RyanCavanaugh
Copy link
Member

Fixes #7125

@RyanCavanaugh RyanCavanaugh changed the title Prototype UMD support UMD support Mar 1, 2016
@@ -4604,6 +4609,7 @@ namespace ts {
case SyntaxKind.EnumKeyword:
return parseEnumDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.GlobalKeyword:
return parseModuleDeclaration(fullStart, decorators, modifiers);
Copy link
Member

Choose a reason for hiding this comment

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

You can let this fall through again.

if (parent.externalModuleIndicator && !parent.isDeclarationFile) {
error(node, Diagnostics.Global_module_exports_may_only_appear_in_declaration_files);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Spoke offline with @vladima. Add all of this to the binder.

@RyanCavanaugh
Copy link
Member Author

Any other comments?

@@ -981,6 +981,10 @@ namespace ts {
return getExternalModuleMember(<ImportDeclaration>node.parent.parent.parent, node);
}

function getTargetOfGlobalModuleExportDeclaration(node: GlobalModuleExportDeclaration): Symbol {
return node.parent.symbol;
Copy link
Contributor

Choose a reason for hiding this comment

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

can this symbol be merged with anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hrm, yes. You could have a module jquery.d.ts and then an augmentation of it in another file. I assume that has some impact here?

Copy link
Contributor

Choose a reason for hiding this comment

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

use getMergedSymbol

@RyanCavanaugh
Copy link
Member Author

@vladima added support for export =. Can you look at the diff and comment on whether or not this is the right approach?

function getTargetOfGlobalModuleExportDeclaration(node: GlobalModuleExportDeclaration): Symbol {
const moduleSymbol = node.parent.symbol;
if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) {
return moduleSymbol.exports["export="].exportSymbol;
Copy link
Member

Choose a reason for hiding this comment

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

Does this account for module augmentations? Will you need to get the "merged" symbol in that case?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it does, but I don't know how to make it work either. Any ideas?

@RyanCavanaugh
Copy link
Member Author

Added tests for module augmentation; any other comments?

else {
const parent = node.parent as SourceFile;

if (!isExternalModule(<SourceFile>node.parent)) {
Copy link
Member

Choose a reason for hiding this comment

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

Use parent here

@DanielRosenwasser
Copy link
Member

Can you add a test that uses an export = whose RHS is a function, as well as one with a class?

@RyanCavanaugh
Copy link
Member Author

✔️

@DanielRosenwasser
Copy link
Member

@RyanCavanaugh umd7.ts has a function used as the export = declaration, but I'd like to see how something with a type space translates in these cases. In other words, if you export = a class, can you use it in type position? What is the type of an instantiation of the namespace export?

TL;DR: Can you add an example that uses export = on a class?

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