@@ -4271,10 +4271,13 @@ var ts;
42714271 (node.name.kind === 9 || isGlobalScopeAugmentation(node));
42724272 }
42734273 ts.isAmbientModule = isAmbientModule;
4274+ function isShorthandAmbientModuleSymbol(moduleSymbol) {
4275+ return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
4276+ }
4277+ ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol;
42744278 function isShorthandAmbientModule(node) {
42754279 return node.kind === 225 && (!node.body);
42764280 }
4277- ts.isShorthandAmbientModule = isShorthandAmbientModule;
42784281 function isBlockScopedContainerTopLevel(node) {
42794282 return node.kind === 256 ||
42804283 node.kind === 225 ||
@@ -13316,6 +13319,7 @@ var ts;
1331613319 var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
1331713320 var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false);
1331813321 var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false);
13322+ var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false);
1331913323 var enumNumberIndexInfo = createIndexInfo(stringType, true);
1332013324 var globals = ts.createMap();
1332113325 var patternAmbientModules;
@@ -13410,6 +13414,7 @@ var ts;
1341013414 var assignableRelation = ts.createMap();
1341113415 var comparableRelation = ts.createMap();
1341213416 var identityRelation = ts.createMap();
13417+ var enumRelation = ts.createMap();
1341313418 var _displayBuilder;
1341413419 var builtinGlobals = ts.createMap();
1341513420 builtinGlobals[undefinedSymbol.name] = undefinedSymbol;
@@ -13843,7 +13848,7 @@ var ts;
1384313848 checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
1384413849 }
1384513850 }
13846- if (result && isInExternalModule) {
13851+ if (result && isInExternalModule && (meaning & 107455) === 107455 ) {
1384713852 var decls = result.declarations;
1384813853 if (decls && decls.length === 1 && decls[0].kind === 228) {
1384913854 error(errorLocation, ts.Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
@@ -13943,7 +13948,7 @@ var ts;
1394313948 function getTargetOfImportClause(node) {
1394413949 var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier);
1394513950 if (moduleSymbol) {
13946- var exportDefaultSymbol = ts.isShorthandAmbientModule (moduleSymbol.valueDeclaration ) ?
13951+ var exportDefaultSymbol = ts.isShorthandAmbientModuleSymbol (moduleSymbol) ?
1394713952 moduleSymbol :
1394813953 moduleSymbol.exports["export="] ?
1394913954 getPropertyOfType(getTypeOfSymbol(moduleSymbol.exports["export="]), "default") :
@@ -13998,7 +14003,7 @@ var ts;
1399814003 if (targetSymbol) {
1399914004 var name_10 = specifier.propertyName || specifier.name;
1400014005 if (name_10.text) {
14001- if (ts.isShorthandAmbientModule (moduleSymbol.valueDeclaration )) {
14006+ if (ts.isShorthandAmbientModuleSymbol (moduleSymbol)) {
1400214007 return moduleSymbol;
1400314008 }
1400414009 var symbolFromVariable = void 0;
@@ -14787,8 +14792,13 @@ var ts;
1478714792 buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags);
1478814793 }
1478914794 else if (!(flags & 512) && type.flags & (2097152 | 1572864) && type.aliasSymbol) {
14790- var typeArguments = type.aliasTypeArguments;
14791- writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
14795+ if (type.flags & 2097152 || !(flags & 1024)) {
14796+ var typeArguments = type.aliasTypeArguments;
14797+ writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
14798+ }
14799+ else {
14800+ writeUnionOrIntersectionType(type, nextFlags);
14801+ }
1479214802 }
1479314803 else if (type.flags & 1572864) {
1479414804 writeUnionOrIntersectionType(type, nextFlags);
@@ -15483,7 +15493,9 @@ var ts;
1548315493 if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 2048)) {
1548415494 type = getTypeWithFacts(type, 131072);
1548515495 }
15486- return type;
15496+ return declaration.initializer ?
15497+ getUnionType([type, checkExpressionCached(declaration.initializer)], true) :
15498+ type;
1548715499 }
1548815500 function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) {
1548915501 var jsDocType = getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration);
@@ -15771,7 +15783,7 @@ var ts;
1577115783 function getTypeOfFuncClassEnumModule(symbol) {
1577215784 var links = getSymbolLinks(symbol);
1577315785 if (!links.type) {
15774- if (symbol.valueDeclaration.kind === 225 && ts.isShorthandAmbientModule (symbol.valueDeclaration )) {
15786+ if (symbol.valueDeclaration.kind === 225 && ts.isShorthandAmbientModuleSymbol (symbol)) {
1577515787 links.type = anyType;
1577615788 }
1577715789 else {
@@ -18123,8 +18135,14 @@ var ts;
1812318135 if (source === target) {
1812418136 return true;
1812518137 }
18126- if (source.symbol.name !== target.symbol.name || !(source.symbol.flags & 256) || !(target.symbol.flags & 256)) {
18127- return false;
18138+ var id = source.id + "," + target.id;
18139+ if (enumRelation[id] !== undefined) {
18140+ return enumRelation[id];
18141+ }
18142+ if (source.symbol.name !== target.symbol.name ||
18143+ !(source.symbol.flags & 256) || !(target.symbol.flags & 256) ||
18144+ (source.flags & 524288) !== (target.flags & 524288)) {
18145+ return enumRelation[id] = false;
1812818146 }
1812918147 var targetEnumType = getTypeOfSymbol(target.symbol);
1813018148 for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(source.symbol)); _i < _a.length; _i++) {
@@ -18135,11 +18153,11 @@ var ts;
1813518153 if (errorReporter) {
1813618154 errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, property.name, typeToString(target, undefined, 128));
1813718155 }
18138- return false;
18156+ return enumRelation[id] = false;
1813918157 }
1814018158 }
1814118159 }
18142- return true;
18160+ return enumRelation[id] = true;
1814318161 }
1814418162 function isSimpleTypeRelatedTo(source, target, relation, errorReporter) {
1814518163 if (target.flags & 8192)
@@ -18163,10 +18181,19 @@ var ts;
1816318181 if (relation === assignableRelation || relation === comparableRelation) {
1816418182 if (source.flags & 1)
1816518183 return true;
18166- if (source.flags & (4 | 64) && target.flags & 16)
18184+ if ((source.flags & 4 | source.flags & 64) && target.flags & 272)
18185+ return true;
18186+ if (source.flags & 256 &&
18187+ target.flags & 256 &&
18188+ source.text === target.text &&
18189+ isEnumTypeRelatedTo(source.baseType, target.baseType, errorReporter)) {
1816718190 return true;
18168- if (source.flags & 64 && target.flags & 256 && source.text === target.text)
18191+ }
18192+ if (source.flags & 256 &&
18193+ target.flags & 16 &&
18194+ isEnumTypeRelatedTo(target, source.baseType, errorReporter)) {
1816918195 return true;
18196+ }
1817018197 }
1817118198 return false;
1817218199 }
@@ -20051,6 +20078,9 @@ var ts;
2005120078 return type;
2005220079 }
2005320080 function narrowTypeByEquality(type, operator, value, assumeTrue) {
20081+ if (type.flags & 1) {
20082+ return type;
20083+ }
2005420084 if (operator === 31 || operator === 33) {
2005520085 assumeTrue = !assumeTrue;
2005620086 }
@@ -20164,7 +20194,7 @@ var ts;
2016420194 }
2016520195 }
2016620196 var targetType = type.flags & 16384 ? getApparentType(type) : type;
20167- return isTypeSubtypeOf(candidate, targetType ) ? candidate :
20197+ return isTypeSubtypeOf(candidate, type ) ? candidate :
2016820198 isTypeAssignableTo(type, candidate) ? type :
2016920199 isTypeAssignableTo(candidate, targetType) ? candidate :
2017020200 getIntersectionType([type, candidate]);
@@ -20336,13 +20366,14 @@ var ts;
2033620366 var isParameter = ts.getRootDeclaration(declaration).kind === 142;
2033720367 var declarationContainer = getControlFlowContainer(declaration);
2033820368 var flowContainer = getControlFlowContainer(node);
20369+ var isOuterVariable = flowContainer !== declarationContainer;
2033920370 while (flowContainer !== declarationContainer &&
2034020371 (flowContainer.kind === 179 || flowContainer.kind === 180) &&
2034120372 (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) {
2034220373 flowContainer = getControlFlowContainer(flowContainer);
2034320374 }
2034420375 var assumeInitialized = !strictNullChecks || (type.flags & 1) !== 0 || isParameter ||
20345- flowContainer !== declarationContainer || ts.isInAmbientContext(declaration);
20376+ isOuterVariable || ts.isInAmbientContext(declaration);
2034620377 var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer);
2034720378 if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) {
2034820379 error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
@@ -22572,16 +22603,16 @@ var ts;
2257222603 function getResolvedSignature(node, candidatesOutArray) {
2257322604 var links = getNodeLinks(node);
2257422605 var cached = links.resolvedSignature;
22575- if (cached && cached !== anySignature && !candidatesOutArray) {
22606+ if (cached && cached !== resolvingSignature && !candidatesOutArray) {
2257622607 return cached;
2257722608 }
22578- links.resolvedSignature = anySignature ;
22609+ links.resolvedSignature = resolvingSignature ;
2257922610 var result = resolveSignature(node, candidatesOutArray);
2258022611 links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
2258122612 return result;
2258222613 }
2258322614 function getResolvedOrAnySignature(node) {
22584- return getNodeLinks(node).resolvedSignature === anySignature ? anySignature : getResolvedSignature(node);
22615+ return getNodeLinks(node).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(node);
2258522616 }
2258622617 function getInferredClassType(symbol) {
2258722618 var links = getSymbolLinks(symbol);
@@ -23533,7 +23564,7 @@ var ts;
2353323564 return maybeTypeOfKind(contextualType, (64 | 256));
2353423565 }
2353523566 if (type.flags & 8) {
23536- return maybeTypeOfKind(contextualType, 128) && !isTypeAssignableTo(booleanType, contextualType) ;
23567+ return maybeTypeOfKind(contextualType, 128);
2353723568 }
2353823569 if (type.flags & 16) {
2353923570 return typeContainsLiteralFromEnum(contextualType, type);
@@ -27119,7 +27150,7 @@ var ts;
2711927150 }
2712027151 function moduleExportsSomeValue(moduleReferenceExpression) {
2712127152 var moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
27122- if (!moduleSymbol) {
27153+ if (!moduleSymbol || ts.isShorthandAmbientModuleSymbol(moduleSymbol) ) {
2712327154 return true;
2712427155 }
2712527156 var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
@@ -29013,7 +29044,7 @@ var ts;
2901329044 }
2901429045 else {
2901529046 errorNameNode = declaration.name;
29016- resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer);
29047+ resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024 , writer);
2901729048 errorNameNode = undefined;
2901829049 }
2901929050 }
@@ -29025,7 +29056,7 @@ var ts;
2902529056 }
2902629057 else {
2902729058 errorNameNode = signature.name;
29028- resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer);
29059+ resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 | 1024 , writer);
2902929060 errorNameNode = undefined;
2903029061 }
2903129062 }
@@ -29218,7 +29249,7 @@ var ts;
2921829249 write(tempVarName);
2921929250 write(": ");
2922029251 writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
29221- resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer);
29252+ resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 | 1024 , writer);
2922229253 write(";");
2922329254 writeLine();
2922429255 write(node.isExportEquals ? "export = " : "export default ");
@@ -29623,7 +29654,7 @@ var ts;
2962329654 }
2962429655 else {
2962529656 writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError;
29626- resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2, writer);
29657+ resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024 , writer);
2962729658 }
2962829659 function getHeritageClauseVisibilityError(symbolAccessibilityResult) {
2962929660 var diagnosticMessage;
@@ -36533,9 +36564,8 @@ var ts;
3653336564})(ts || (ts = {}));
3653436565var ts;
3653536566(function (ts) {
36536- ts.version = "2.0.2 ";
36567+ ts.version = "2.0.3 ";
3653736568 var emptyArray = [];
36538- var defaultTypeRoots = ["node_modules/@types"];
3653936569 function findConfigFile(searchPath, fileExists) {
3654036570 while (true) {
3654136571 var fileName = ts.combinePaths(searchPath, "tsconfig.json");
@@ -36668,11 +36698,27 @@ var ts;
3666836698 else if (host.getCurrentDirectory) {
3666936699 currentDirectory = host.getCurrentDirectory();
3667036700 }
36671- if (!currentDirectory) {
36672- return undefined;
36701+ return currentDirectory && getDefaultTypeRoots(currentDirectory, host);
36702+ }
36703+ function getDefaultTypeRoots(currentDirectory, host) {
36704+ if (!host.directoryExists) {
36705+ return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)];
36706+ }
36707+ var typeRoots;
36708+ while (true) {
36709+ var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes);
36710+ if (host.directoryExists(atTypes)) {
36711+ (typeRoots || (typeRoots = [])).push(atTypes);
36712+ }
36713+ var parent_15 = ts.getDirectoryPath(currentDirectory);
36714+ if (parent_15 === currentDirectory) {
36715+ break;
36716+ }
36717+ currentDirectory = parent_15;
3667336718 }
36674- return ts.map(defaultTypeRoots, function (d) { return ts.combinePaths(currentDirectory, d); }) ;
36719+ return typeRoots ;
3667536720 }
36721+ var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types");
3667636722 function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) {
3667736723 var traceEnabled = isTraceEnabled(options, host);
3667836724 var moduleResolutionState = {
0 commit comments