use of com.google.javascript.jscomp.modules.Module in project closure-compiler by google.
the class TypeCheck method visitModuleBody.
/**
* Validates the implicit assignment to the global for a legacy goog.module
*/
private void visitModuleBody(NodeTraversal t, Node moduleBody) {
Module associatedModule = ModuleImportResolver.getModuleFromScopeRoot(compiler.getModuleMap(), (b) -> t.getInput(), moduleBody);
if (!associatedModule.metadata().isLegacyGoogModule()) {
return;
}
QualifiedName moduleName = QualifiedName.of(associatedModule.closureNamespace());
Node googModuleCall = moduleBody.getFirstChild();
if (moduleName.isSimple()) {
TypedVar globalVar = topScope.getVar(moduleName.join());
validator.expectCanAssignTo(googModuleCall, moduleBody.getJSType(), globalVar.getType(), "legacy goog.module export");
} else {
JSType parentType = topScope.lookupQualifiedName(moduleName.getOwner());
ObjectType parentObjectType = parentType != null ? parentType.toMaybeObjectType() : null;
if (parentObjectType == null) {
return;
}
validator.expectCanAssignToPropertyOf(googModuleCall, moduleBody.getJSType(), parentObjectType.getPropertyType(moduleName.getComponent()), parentObjectType, () -> moduleName.getOwner().join(), moduleName.getComponent());
}
}
Aggregations