Merge branch 'master' into strictChecks

This commit is contained in:
Anders Hejlsberg
2017-03-05 16:31:22 -08:00
47 changed files with 288 additions and 154 deletions
+8 -6
View File
@@ -143,7 +143,7 @@ namespace ts {
getAugmentedPropertiesOfType,
getRootSymbols,
getContextualType: node => {
node = getParseTreeNode(node, isExpression)
node = getParseTreeNode(node, isExpression);
return node ? getContextualType(node) : undefined;
},
getFullyQualifiedName,
@@ -16133,7 +16133,7 @@ namespace ts {
}
function checkDeclarationInitializer(declaration: VariableLikeDeclaration) {
const type = checkExpressionCached(declaration.initializer);
const type = getTypeOfExpression(declaration.initializer, /*cache*/ true);
return getCombinedNodeFlags(declaration) & NodeFlags.Const ||
getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration) ||
isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type);
@@ -16206,10 +16206,12 @@ namespace ts {
// Returns the type of an expression. Unlike checkExpression, this function is simply concerned
// with computing the type and may not fully check all contained sub-expressions for errors.
function getTypeOfExpression(node: Expression) {
// A cache argument of true indicates that if the function performs a full type check, it is ok
// to cache the result.
function getTypeOfExpression(node: Expression, cache?: boolean) {
// Optimize for the common case of a call to a function with a single non-generic call
// signature where we can just fetch the return type without checking the arguments.
if (node.kind === SyntaxKind.CallExpression && (<CallExpression>node).expression.kind !== SyntaxKind.SuperKeyword) {
if (node.kind === SyntaxKind.CallExpression && (<CallExpression>node).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(node, /*checkArgumentIsStringLiteral*/true)) {
const funcType = checkNonNullExpression((<CallExpression>node).expression);
const signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
@@ -16219,7 +16221,7 @@ namespace ts {
// Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions
// should have a parameter that indicates whether full error checking is required such that
// we can perform the optimizations locally.
return checkExpression(node);
return cache ? checkExpressionCached(node) : checkExpression(node);
}
// Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
@@ -20676,7 +20678,7 @@ namespace ts {
}
if (potentialNewTargetCollisions.length) {
forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope)
forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
potentialNewTargetCollisions.length = 0;
}
+2 -2
View File
@@ -84,7 +84,7 @@ namespace ts {
this.index++;
return { value: this.selector(this.data, this.keys[index]), done: false };
}
return { value: undefined as never, done: true }
return { value: undefined as never, done: true };
}
}
@@ -140,7 +140,7 @@ namespace ts {
action(this.data[key], key);
}
}
}
};
}
export function createFileMap<T>(keyMapper?: (key: string) => string): FileMap<T> {
+1 -1
View File
@@ -1164,7 +1164,7 @@ namespace ts {
emitTypeParameters(node.typeParameters);
const baseTypeNode = getClassExtendsHeritageClauseElement(node);
if (baseTypeNode) {
node.name
node.name;
emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false);
}
emitHeritageClause(node.name, getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true);
+2 -2
View File
@@ -675,7 +675,7 @@ namespace ts {
}
export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations {
return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false);
return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /*jsOnly*/ false);
}
/* @internal */
@@ -962,7 +962,7 @@ namespace ts {
const result = cache && cache.get(containingDirectory);
if (result) {
if (traceEnabled) {
trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName)
trace(host, Diagnostics.Resolution_for_module_0_was_found_in_cache, moduleName);
}
return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension } };
}
+2 -2
View File
@@ -121,13 +121,13 @@ namespace ts {
enableEmitNotification,
isSubstitutionEnabled,
isEmitNotificationEnabled,
get onSubstituteNode() { return onSubstituteNode },
get onSubstituteNode() { return onSubstituteNode; },
set onSubstituteNode(value) {
Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed.");
Debug.assert(value !== undefined, "Value must not be 'undefined'");
onSubstituteNode = value;
},
get onEmitNode() { return onEmitNode },
get onEmitNode() { return onEmitNode; },
set onEmitNode(value) {
Debug.assert(state < TransformationState.Initialized, "Cannot modify transformation hooks after initialization has completed.");
Debug.assert(value !== undefined, "Value must not be 'undefined'");
+1 -1
View File
@@ -2690,7 +2690,7 @@ namespace ts {
if (loopOutParameters.length) {
copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements);
}
addRange(statements, lexicalEnvironment)
addRange(statements, lexicalEnvironment);
loopBody = createBlock(statements, /*multiline*/ true);
}
+1 -1
View File
@@ -1152,7 +1152,7 @@ namespace ts {
createIdentifier("__esModule"),
createLiteral(true)
)
)
);
}
else {
statement = createStatement(
+1 -1
View File
@@ -3297,7 +3297,7 @@
}
export interface PluginImport {
name: string
name: string;
}
export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[];