mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into object-spread
This commit is contained in:
+3
-3
@@ -725,16 +725,16 @@ declare module "convert-source-map" {
|
||||
}
|
||||
|
||||
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
|
||||
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "built/local/bundle.js" }, /*useBuiltCompiler*/ true));
|
||||
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "../../built/local/bundle.js" }, /*useBuiltCompiler*/ true));
|
||||
return testProject.src()
|
||||
.pipe(newer("built/local/bundle.js"))
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(testProject)
|
||||
.pipe(testProject())
|
||||
.pipe(through2.obj((file, enc, next) => {
|
||||
const originalMap = file.sourceMap;
|
||||
const prebundledContent = file.contents.toString();
|
||||
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
|
||||
originalMap.sources = originalMap.sources.map(s => path.resolve("src", s));
|
||||
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
|
||||
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
|
||||
originalMap.file = "built/local/_stream_0.js";
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
|
||||
'/// <reference path="types.ts" />\r\n' +
|
||||
'/* @internal */\r\n' +
|
||||
'namespace ts {\r\n' +
|
||||
' export var Diagnostics = {\r\n';
|
||||
' export const Diagnostics = {\r\n';
|
||||
var names = Utilities.getObjectKeys(messageTable);
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
var name = names[i];
|
||||
|
||||
@@ -18,8 +18,13 @@ class TypeOperatorSpacingWalker extends Lint.RuleWalker {
|
||||
for (let i = 1; i < types.length; i++) {
|
||||
const currentType = types[i];
|
||||
if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) {
|
||||
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
|
||||
this.addFailure(failure);
|
||||
const sourceFile = currentType.getSourceFile();
|
||||
const previousTypeEndPos = sourceFile.getLineAndCharacterOfPosition(types[i - 1].end);
|
||||
const currentTypeStartPos = sourceFile.getLineAndCharacterOfPosition(currentType.pos);
|
||||
if (previousTypeEndPos.line === currentTypeStartPos.line) {
|
||||
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
|
||||
this.addFailure(failure);
|
||||
}
|
||||
}
|
||||
expectedStart = currentType.end + 2;
|
||||
}
|
||||
|
||||
+23
-8
@@ -355,11 +355,24 @@ namespace ts {
|
||||
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
||||
: Diagnostics.Duplicate_identifier_0;
|
||||
|
||||
forEach(symbol.declarations, declaration => {
|
||||
if (hasModifier(declaration, ModifierFlags.Default)) {
|
||||
if (symbol.declarations && symbol.declarations.length) {
|
||||
// If the current node is a default export of some sort, then check if
|
||||
// there are any other default exports that we need to error on.
|
||||
// We'll know whether we have other default exports depending on if `symbol` already has a declaration list set.
|
||||
if (isDefaultExport) {
|
||||
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
|
||||
}
|
||||
});
|
||||
else {
|
||||
// This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration.
|
||||
// Error on multiple export default in the following case:
|
||||
// 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default
|
||||
// 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers)
|
||||
if (symbol.declarations && symbol.declarations.length &&
|
||||
(isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(<ExportAssignment>node).isExportEquals))) {
|
||||
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forEach(symbol.declarations, declaration => {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));
|
||||
@@ -1114,7 +1127,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
forEachChild(node, bind);
|
||||
if (node.operator === SyntaxKind.PlusEqualsToken || node.operator === SyntaxKind.MinusMinusToken) {
|
||||
if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) {
|
||||
bindAssignmentTargetFlow(node.operand);
|
||||
}
|
||||
}
|
||||
@@ -1363,7 +1376,7 @@ namespace ts {
|
||||
function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean {
|
||||
const body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
|
||||
if (body && (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock)) {
|
||||
for (const stat of (<Block>body).statements) {
|
||||
for (const stat of (<BlockLike>body).statements) {
|
||||
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
|
||||
return true;
|
||||
}
|
||||
@@ -1948,12 +1961,15 @@ namespace ts {
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node));
|
||||
}
|
||||
else {
|
||||
// An export default clause with an expression exports a value
|
||||
// We want to exclude both class and function here, this is necessary to issue an error when there are both
|
||||
// default export-assignment and default export function and class declaration.
|
||||
const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(<ExportAssignment>node)
|
||||
// An export default clause with an EntityNameExpression exports all meanings of that identifier
|
||||
? SymbolFlags.Alias
|
||||
// An export default clause with any other expression exports a value
|
||||
: SymbolFlags.Property;
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.Property | SymbolFlags.AliasExcludes | SymbolFlags.Class | SymbolFlags.Function);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2436,8 +2452,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// If the parameter's name is 'this', then it is TypeScript syntax.
|
||||
if (subtreeFlags & TransformFlags.ContainsDecorators
|
||||
|| (name && isIdentifier(name) && name.originalKeywordKind === SyntaxKind.ThisKeyword)) {
|
||||
if (subtreeFlags & TransformFlags.ContainsDecorators || isThisIdentifier(name)) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
|
||||
+122
-64
@@ -121,6 +121,7 @@ namespace ts {
|
||||
const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__");
|
||||
|
||||
const anyType = createIntrinsicType(TypeFlags.Any, "any");
|
||||
const autoType = createIntrinsicType(TypeFlags.Any, "any");
|
||||
const unknownType = createIntrinsicType(TypeFlags.Any, "unknown");
|
||||
const undefinedType = createIntrinsicType(TypeFlags.Undefined, "undefined");
|
||||
const undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsWideningType, "undefined");
|
||||
@@ -2166,7 +2167,7 @@ namespace ts {
|
||||
? "any"
|
||||
: (<IntrinsicType>type).intrinsicName);
|
||||
}
|
||||
else if (type.flags & TypeFlags.ThisType) {
|
||||
else if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) {
|
||||
if (inObjectTypeLiteral) {
|
||||
writer.reportInaccessibleThisError();
|
||||
}
|
||||
@@ -2184,9 +2185,14 @@ namespace ts {
|
||||
// The specified symbol flags need to be reinterpreted as type flags
|
||||
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags);
|
||||
}
|
||||
else if (!(flags & TypeFormatFlags.InTypeAlias) && type.flags & (TypeFlags.Anonymous | TypeFlags.UnionOrIntersection) && type.aliasSymbol &&
|
||||
else if (!(flags & TypeFormatFlags.InTypeAlias) && ((type.flags & TypeFlags.Anonymous && !(<AnonymousType>type).target) || type.flags & TypeFlags.UnionOrIntersection) && type.aliasSymbol &&
|
||||
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) {
|
||||
// Only write out inferred type with its corresponding type-alias if type-alias is visible
|
||||
// We emit inferred type as type-alias at the current localtion if all the following is true
|
||||
// the input type is has alias symbol that is accessible
|
||||
// the input type is a union, intersection or anonymous type that is fully instantiated (if not we want to keep dive into)
|
||||
// e.g.: export type Bar<X, Y> = () => [X, Y];
|
||||
// export type Foo<Y> = Bar<any, Y>;
|
||||
// export const y = (x: Foo<string>) => 1 // we want to emit as ...x: () => [any, string])
|
||||
const typeArguments = type.aliasTypeArguments;
|
||||
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
|
||||
}
|
||||
@@ -3092,6 +3098,11 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isAutoVariableInitializer(initializer: Expression) {
|
||||
const expr = initializer && skipParentheses(initializer);
|
||||
return !expr || expr.kind === SyntaxKind.NullKeyword || expr.kind === SyntaxKind.Identifier && getResolvedSymbol(<Identifier>expr) === undefinedSymbol;
|
||||
}
|
||||
|
||||
function addOptionality(type: Type, optional: boolean): Type {
|
||||
return strictNullChecks && optional ? includeFalsyTypes(type, TypeFlags.Undefined) : type;
|
||||
}
|
||||
@@ -3130,6 +3141,14 @@ namespace ts {
|
||||
return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality);
|
||||
}
|
||||
|
||||
// Use control flow type inference for non-ambient, non-exported var or let variables with no initializer
|
||||
// or a 'null' or 'undefined' initializer.
|
||||
if (declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) &&
|
||||
!(getCombinedNodeFlags(declaration) & NodeFlags.Const) && !(getCombinedModifierFlags(declaration) & ModifierFlags.Export) &&
|
||||
!isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) {
|
||||
return autoType;
|
||||
}
|
||||
|
||||
if (declaration.kind === SyntaxKind.Parameter) {
|
||||
const func = <FunctionLikeDeclaration>declaration.parent;
|
||||
// For a parameter of a set accessor, use the type of the get accessor if one is present
|
||||
@@ -3220,7 +3239,7 @@ namespace ts {
|
||||
result.pattern = pattern;
|
||||
}
|
||||
if (hasComputedProperties) {
|
||||
result.flags |= TypeFlags.ObjectLiteralPatternWithComputedProperties;
|
||||
result.isObjectLiteralPatternWithComputedProperties = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -3807,7 +3826,8 @@ namespace ts {
|
||||
(<GenericType>type).instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
|
||||
(<GenericType>type).target = <GenericType>type;
|
||||
(<GenericType>type).typeArguments = type.typeParameters;
|
||||
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
|
||||
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
|
||||
type.thisType.isThisType = true;
|
||||
type.thisType.symbol = symbol;
|
||||
type.thisType.constraint = type;
|
||||
}
|
||||
@@ -3927,7 +3947,7 @@ namespace ts {
|
||||
if (!links.declaredType) {
|
||||
const enumType = <EnumType>getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
|
||||
links.declaredType = enumType.flags & TypeFlags.Union ?
|
||||
enumType.memberTypes[getEnumMemberValue(<EnumDeclaration>symbol.valueDeclaration)] :
|
||||
enumType.memberTypes[getEnumMemberValue(<EnumMember>symbol.valueDeclaration)] :
|
||||
enumType;
|
||||
}
|
||||
return links.declaredType;
|
||||
@@ -5108,7 +5128,7 @@ namespace ts {
|
||||
|
||||
function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean {
|
||||
let checked: Type[];
|
||||
while (type && !(type.flags & TypeFlags.ThisType) && type.flags & TypeFlags.TypeParameter && !contains(checked, type)) {
|
||||
while (type && type.flags & TypeFlags.TypeParameter && !((type as TypeParameter).isThisType) && !contains(checked, type)) {
|
||||
if (type === target) {
|
||||
return true;
|
||||
}
|
||||
@@ -5471,7 +5491,8 @@ namespace ts {
|
||||
type.instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
|
||||
type.target = <GenericType>type;
|
||||
type.typeArguments = type.typeParameters;
|
||||
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
|
||||
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
|
||||
type.thisType.isThisType = true;
|
||||
type.thisType.constraint = type;
|
||||
type.declaredProperties = properties;
|
||||
type.declaredCallSignatures = emptyArray;
|
||||
@@ -5584,7 +5605,26 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isSetOfLiteralsFromSameEnum(types: TypeSet): boolean {
|
||||
const first = types[0];
|
||||
if (first.flags & TypeFlags.EnumLiteral) {
|
||||
const firstEnum = getParentOfSymbol(first.symbol);
|
||||
for (let i = 1; i < types.length; i++) {
|
||||
const other = types[i];
|
||||
if (!(other.flags & TypeFlags.EnumLiteral) || (firstEnum !== getParentOfSymbol(other.symbol))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeSubtypes(types: TypeSet) {
|
||||
if (types.length === 0 || isSetOfLiteralsFromSameEnum(types)) {
|
||||
return;
|
||||
}
|
||||
let i = types.length;
|
||||
while (i > 0) {
|
||||
i--;
|
||||
@@ -6244,7 +6284,7 @@ namespace ts {
|
||||
return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow;
|
||||
}
|
||||
|
||||
function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | MethodDeclaration {
|
||||
function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration {
|
||||
return (isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func);
|
||||
}
|
||||
|
||||
@@ -6881,7 +6921,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
|
||||
if (!(target.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties) && maybeTypeOfKind(target, TypeFlags.ObjectType)) {
|
||||
if (maybeTypeOfKind(target, TypeFlags.ObjectType) &&
|
||||
(!(target.flags & TypeFlags.ObjectType) || !(target as ObjectType).isObjectLiteralPatternWithComputedProperties)) {
|
||||
for (const prop of getPropertiesOfObjectType(source)) {
|
||||
if (!isKnownProperty(target, prop.name)) {
|
||||
if (reportErrors) {
|
||||
@@ -8667,7 +8708,9 @@ namespace ts {
|
||||
if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) {
|
||||
return declaredType;
|
||||
}
|
||||
const initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, TypeFlags.Undefined);
|
||||
const initialType = assumeInitialized ? declaredType :
|
||||
declaredType === autoType ? undefinedType :
|
||||
includeFalsyTypes(declaredType, TypeFlags.Undefined);
|
||||
const visitedFlowStart = visitedFlowCount;
|
||||
const result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
|
||||
visitedFlowCount = visitedFlowStart;
|
||||
@@ -8741,9 +8784,12 @@ namespace ts {
|
||||
// Assignments only narrow the computed type if the declared type is a union type. Thus, we
|
||||
// only need to evaluate the assigned type if the declared type is a union type.
|
||||
if (isMatchingReference(reference, node)) {
|
||||
const isIncrementOrDecrement = node.parent.kind === SyntaxKind.PrefixUnaryExpression || node.parent.kind === SyntaxKind.PostfixUnaryExpression;
|
||||
return declaredType.flags & TypeFlags.Union && !isIncrementOrDecrement ?
|
||||
getAssignmentReducedType(<UnionType>declaredType, getInitialOrAssignedType(node)) :
|
||||
if (node.parent.kind === SyntaxKind.PrefixUnaryExpression || node.parent.kind === SyntaxKind.PostfixUnaryExpression) {
|
||||
const flowType = getTypeAtFlowNode(flow.antecedent);
|
||||
return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
|
||||
}
|
||||
return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) :
|
||||
declaredType.flags & TypeFlags.Union ? getAssignmentReducedType(<UnionType>declaredType, getInitialOrAssignedType(node)) :
|
||||
declaredType;
|
||||
}
|
||||
// We didn't have a direct match. However, if the reference is a dotted name, this
|
||||
@@ -9187,7 +9233,7 @@ namespace ts {
|
||||
if (isRightSideOfQualifiedNameOrPropertyAccess(location)) {
|
||||
location = location.parent;
|
||||
}
|
||||
if (isExpression(location) && !isAssignmentTarget(location)) {
|
||||
if (isPartOfExpression(location) && !isAssignmentTarget(location)) {
|
||||
const type = checkExpression(<Expression>location);
|
||||
if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
|
||||
return type;
|
||||
@@ -9358,13 +9404,23 @@ namespace ts {
|
||||
// We only look for uninitialized variables in strict null checking mode, and only when we can analyze
|
||||
// the entire control flow graph from the variable's declaration (i.e. when the flow container and
|
||||
// declaration container are the same).
|
||||
const assumeInitialized = !strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isParameter ||
|
||||
isOuterVariable || isInAmbientContext(declaration);
|
||||
const assumeInitialized = isParameter || isOuterVariable ||
|
||||
type !== autoType && (!strictNullChecks || (type.flags & TypeFlags.Any) !== 0) ||
|
||||
isInAmbientContext(declaration);
|
||||
const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer);
|
||||
// A variable is considered uninitialized when it is possible to analyze the entire control flow graph
|
||||
// from declaration to use, and when the variable's declared type doesn't include undefined but the
|
||||
// control flow based type does include undefined.
|
||||
if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) {
|
||||
if (type === autoType) {
|
||||
if (flowType === autoType) {
|
||||
if (compilerOptions.noImplicitAny) {
|
||||
error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol));
|
||||
error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType));
|
||||
}
|
||||
return anyType;
|
||||
}
|
||||
}
|
||||
else if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) {
|
||||
error(node, Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
|
||||
// Return the declared type to reduce follow-on errors
|
||||
return type;
|
||||
@@ -9478,7 +9534,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function findFirstSuperCall(n: Node): Node {
|
||||
if (isSuperCallExpression(n)) {
|
||||
if (isSuperCall(n)) {
|
||||
return n;
|
||||
}
|
||||
else if (isFunctionLike(n)) {
|
||||
@@ -9585,7 +9641,7 @@ namespace ts {
|
||||
captureLexicalThis(node, container);
|
||||
}
|
||||
if (isFunctionLike(container) &&
|
||||
(!isInParameterInitializerBeforeContainingFunction(node) || getFunctionLikeThisParameter(container))) {
|
||||
(!isInParameterInitializerBeforeContainingFunction(node) || getThisParameter(container))) {
|
||||
// Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated.
|
||||
|
||||
// If this is a function in a JS file, it might be a class method. Check if it's the RHS
|
||||
@@ -9987,7 +10043,7 @@ namespace ts {
|
||||
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
||||
if (functionDecl.type ||
|
||||
functionDecl.kind === SyntaxKind.Constructor ||
|
||||
functionDecl.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<AccessorDeclaration>getDeclarationOfKind(functionDecl.symbol, SyntaxKind.SetAccessor))) {
|
||||
functionDecl.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<SetAccessorDeclaration>getDeclarationOfKind(functionDecl.symbol, SyntaxKind.SetAccessor))) {
|
||||
return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl));
|
||||
}
|
||||
|
||||
@@ -10256,7 +10312,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression {
|
||||
function isFunctionExpressionOrArrowFunction(node: Node): node is FunctionExpression | ArrowFunction {
|
||||
return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction;
|
||||
}
|
||||
|
||||
@@ -10267,7 +10323,7 @@ namespace ts {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForFunctionLikeDeclaration(node: FunctionExpression | MethodDeclaration) {
|
||||
function getContextualTypeForFunctionLikeDeclaration(node: FunctionExpression | ArrowFunction | MethodDeclaration) {
|
||||
return isObjectLiteralMethod(node) ?
|
||||
getContextualTypeForObjectLiteralMethod(node) :
|
||||
getApparentTypeOfContextualType(node);
|
||||
@@ -10278,7 +10334,7 @@ namespace ts {
|
||||
// If the contextual type is a union type, get the signature from each type possible and if they are
|
||||
// all identical ignoring their return type, the result is same signature but with return type as
|
||||
// union type of return types from these signatures
|
||||
function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature {
|
||||
function getContextualSignature(node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature {
|
||||
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
|
||||
const type = getContextualTypeForFunctionLikeDeclaration(node);
|
||||
if (!type) {
|
||||
@@ -10550,7 +10606,8 @@ namespace ts {
|
||||
patternWithComputedProperties = true;
|
||||
}
|
||||
}
|
||||
else if (contextualTypeHasPattern && !(contextualType.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties)) {
|
||||
else if (contextualTypeHasPattern &&
|
||||
!(contextualType.flags & TypeFlags.ObjectType && (contextualType as ObjectType).isObjectLiteralPatternWithComputedProperties)) {
|
||||
// If object literal is contextually typed by the implied type of a binding pattern, and if the
|
||||
// binding pattern specifies a default value for the property, make the property optional.
|
||||
const impliedProp = getPropertyOfType(contextualType, member.name);
|
||||
@@ -10642,7 +10699,10 @@ namespace ts {
|
||||
const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined;
|
||||
const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral;
|
||||
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags) | (patternWithComputedProperties ? TypeFlags.ObjectLiteralPatternWithComputedProperties : 0);
|
||||
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
|
||||
if (patternWithComputedProperties) {
|
||||
result.isObjectLiteralPatternWithComputedProperties = true;
|
||||
}
|
||||
if (inDestructuringPattern) {
|
||||
result.pattern = node;
|
||||
}
|
||||
@@ -11214,7 +11274,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
// An instance property must be accessed through an instance of the enclosing class
|
||||
if (type.flags & TypeFlags.ThisType) {
|
||||
if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) {
|
||||
// get the original type -- represented as the type constraint of the 'this' type
|
||||
type = getConstraintOfTypeParameter(<TypeParameter>type);
|
||||
}
|
||||
@@ -11264,7 +11324,7 @@ namespace ts {
|
||||
const prop = getPropertyOfType(apparentType, right.text);
|
||||
if (!prop) {
|
||||
if (right.text && !checkAndReportErrorForExtendingInterface(node)) {
|
||||
reportNonexistentProperty(right, type.flags & TypeFlags.ThisType ? apparentType : type);
|
||||
reportNonexistentProperty(right, type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ? apparentType : type);
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
@@ -11664,7 +11724,7 @@ namespace ts {
|
||||
argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature);
|
||||
}
|
||||
else {
|
||||
const callExpression = <CallExpression>node;
|
||||
const callExpression = <CallExpression | NewExpression>node;
|
||||
if (!callExpression.arguments) {
|
||||
// This only happens when we have something of the form: 'new C'
|
||||
Debug.assert(callExpression.kind === SyntaxKind.NewExpression);
|
||||
@@ -11675,7 +11735,7 @@ namespace ts {
|
||||
argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
|
||||
|
||||
// If we are missing the close paren, the call is incomplete.
|
||||
callIsIncomplete = (<CallExpression>callExpression).arguments.end === callExpression.end;
|
||||
callIsIncomplete = callExpression.arguments.end === callExpression.end;
|
||||
|
||||
typeArguments = callExpression.typeArguments;
|
||||
spreadArgIndex = getSpreadArgumentIndex(args);
|
||||
@@ -12762,7 +12822,7 @@ namespace ts {
|
||||
* @param node The call/new expression to be checked.
|
||||
* @returns On success, the expression's signature's return type. On failure, anyType.
|
||||
*/
|
||||
function checkCallExpression(node: CallExpression): Type {
|
||||
function checkCallExpression(node: CallExpression | NewExpression): Type {
|
||||
// Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true
|
||||
checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments);
|
||||
|
||||
@@ -13012,7 +13072,10 @@ namespace ts {
|
||||
if (!contextualSignature) {
|
||||
reportErrorsFromWidening(func, type);
|
||||
}
|
||||
if (isUnitType(type) && !(contextualSignature && isLiteralContextualType(getReturnTypeOfSignature(contextualSignature)))) {
|
||||
if (isUnitType(type) &&
|
||||
!(contextualSignature &&
|
||||
isLiteralContextualType(
|
||||
contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) {
|
||||
type = getWidenedLiteralType(type);
|
||||
}
|
||||
|
||||
@@ -13217,7 +13280,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) {
|
||||
if (produceDiagnostics && node.kind !== SyntaxKind.MethodDeclaration) {
|
||||
checkCollisionWithCapturedSuperVariable(node, (<FunctionExpression>node).name);
|
||||
checkCollisionWithCapturedThisVariable(node, (<FunctionExpression>node).name);
|
||||
}
|
||||
@@ -14679,7 +14742,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function containsSuperCall(n: Node): boolean {
|
||||
if (isSuperCallExpression(n)) {
|
||||
if (isSuperCall(n)) {
|
||||
return true;
|
||||
}
|
||||
else if (isFunctionLike(n)) {
|
||||
@@ -14735,7 +14798,7 @@ namespace ts {
|
||||
let superCallStatement: ExpressionStatement;
|
||||
|
||||
for (const statement of statements) {
|
||||
if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((<ExpressionStatement>statement).expression)) {
|
||||
if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCall((<ExpressionStatement>statement).expression)) {
|
||||
superCallStatement = <ExpressionStatement>statement;
|
||||
break;
|
||||
}
|
||||
@@ -15803,10 +15866,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function parameterIsThisKeyword(parameter: ParameterDeclaration) {
|
||||
return parameter.name && (<Identifier>parameter.name).originalKeywordKind === SyntaxKind.ThisKeyword;
|
||||
}
|
||||
|
||||
function parameterNameStartsWithUnderscore(parameter: ParameterDeclaration) {
|
||||
return parameter.name && parameter.name.kind === SyntaxKind.Identifier && (<Identifier>parameter.name).text.charCodeAt(0) === CharacterCodes._;
|
||||
}
|
||||
@@ -16148,6 +16207,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function convertAutoToAny(type: Type) {
|
||||
return type === autoType ? anyType : type;
|
||||
}
|
||||
|
||||
// Check variable, parameter, or property declaration
|
||||
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
|
||||
checkDecorators(node);
|
||||
@@ -16198,7 +16261,7 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
const symbol = getSymbolOfNode(node);
|
||||
const type = getTypeOfVariableOrParameterOrProperty(symbol);
|
||||
const type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol));
|
||||
if (node === symbol.valueDeclaration) {
|
||||
// Node is the primary declaration of the symbol, just validate the initializer
|
||||
// Don't validate for-in initializer as it is already an error
|
||||
@@ -16210,7 +16273,7 @@ namespace ts {
|
||||
else {
|
||||
// Node is a secondary declaration, check that type is identical to primary declaration and check that
|
||||
// initializer is consistent with type associated with the node
|
||||
const declarationType = getWidenedTypeForVariableLikeDeclaration(node);
|
||||
const declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
|
||||
if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) {
|
||||
error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(type), typeToString(declarationType));
|
||||
}
|
||||
@@ -16699,7 +16762,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isGetAccessorWithAnnotatedSetAccessor(node: FunctionLikeDeclaration) {
|
||||
return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<AccessorDeclaration>getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor)));
|
||||
return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(<SetAccessorDeclaration>getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor)));
|
||||
}
|
||||
|
||||
function isUnwrappedReturnTypeVoidOrAny(func: FunctionLikeDeclaration, returnType: Type): boolean {
|
||||
@@ -17693,9 +17756,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
checkCollisionWithCapturedThisVariable(node, node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
if (isIdentifier(node.name)) {
|
||||
checkCollisionWithCapturedThisVariable(node, node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
}
|
||||
|
||||
checkExportsOnMergedDeclarations(node);
|
||||
const symbol = getSymbolOfNode(node);
|
||||
|
||||
@@ -18703,6 +18769,9 @@ namespace ts {
|
||||
(<ImportDeclaration>node.parent).moduleSpecifier === node)) {
|
||||
return resolveExternalModuleName(node, <LiteralExpression>node);
|
||||
}
|
||||
if (isInJavaScriptFile(node) && isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) {
|
||||
return resolveExternalModuleName(node, <LiteralExpression>node);
|
||||
}
|
||||
// Fall through
|
||||
|
||||
case SyntaxKind.NumericLiteral:
|
||||
@@ -19314,7 +19383,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isLiteralConstDeclaration(node: VariableDeclaration): boolean {
|
||||
function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean {
|
||||
if (isConst(node)) {
|
||||
const type = getTypeOfSymbol(getSymbolOfNode(node));
|
||||
return !!(type.flags & TypeFlags.StringOrNumberLiteral && type.flags & TypeFlags.FreshLiteral);
|
||||
@@ -19322,7 +19391,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function writeLiteralConstValue(node: VariableDeclaration, writer: SymbolWriter) {
|
||||
function writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter) {
|
||||
const type = getTypeOfSymbol(getSymbolOfNode(node));
|
||||
writer.writeStringLiteral(literalTypeToString(<LiteralType>type));
|
||||
}
|
||||
@@ -20059,7 +20128,7 @@ namespace ts {
|
||||
checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
|
||||
}
|
||||
|
||||
function checkGrammarForOmittedArgument(node: CallExpression, args: NodeArray<Expression>): boolean {
|
||||
function checkGrammarForOmittedArgument(node: CallExpression | NewExpression, args: NodeArray<Expression>): boolean {
|
||||
if (args) {
|
||||
const sourceFile = getSourceFileOfNode(node);
|
||||
for (const arg of args) {
|
||||
@@ -20070,7 +20139,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarArguments(node: CallExpression, args: NodeArray<Expression>): boolean {
|
||||
function checkGrammarArguments(node: CallExpression | NewExpression, args: NodeArray<Expression>): boolean {
|
||||
return checkGrammarForOmittedArgument(node, args);
|
||||
}
|
||||
|
||||
@@ -20211,8 +20280,7 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
const name = prop.name;
|
||||
if (prop.kind === SyntaxKind.OmittedExpression ||
|
||||
name && name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
if (name && name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
// If the name is not a ComputedPropertyName, the grammar checking will skip it
|
||||
checkGrammarComputedPropertyName(<ComputedPropertyName>name);
|
||||
}
|
||||
@@ -20259,7 +20327,7 @@ namespace ts {
|
||||
currentKind = SetAccessor;
|
||||
}
|
||||
else {
|
||||
Debug.fail("Unexpected syntax kind:" + prop.kind);
|
||||
Debug.fail("Unexpected syntax kind:" + (<Node>prop).kind);
|
||||
}
|
||||
|
||||
const effectiveName = getPropertyNameForPropertyNameNode(name);
|
||||
@@ -20408,18 +20476,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getAccessorThisParameter(accessor: AccessorDeclaration): ParameterDeclaration {
|
||||
if (accessor.parameters.length === (accessor.kind === SyntaxKind.GetAccessor ? 1 : 2) &&
|
||||
accessor.parameters[0].name.kind === SyntaxKind.Identifier &&
|
||||
(<Identifier>accessor.parameters[0].name).originalKeywordKind === SyntaxKind.ThisKeyword) {
|
||||
return accessor.parameters[0];
|
||||
}
|
||||
}
|
||||
|
||||
function getFunctionLikeThisParameter(func: FunctionLikeDeclaration) {
|
||||
if (func.parameters.length &&
|
||||
func.parameters[0].name.kind === SyntaxKind.Identifier &&
|
||||
(<Identifier>func.parameters[0].name).originalKeywordKind === SyntaxKind.ThisKeyword) {
|
||||
return func.parameters[0];
|
||||
if (accessor.parameters.length === (accessor.kind === SyntaxKind.GetAccessor ? 1 : 2)) {
|
||||
return getThisParameter(accessor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-35
@@ -212,7 +212,7 @@ namespace ts {
|
||||
* true for all elements, otherwise returns a new array instance containing the filtered subset.
|
||||
*/
|
||||
export function filter<T, U extends T>(array: T[], f: (x: T) => x is U): U[];
|
||||
export function filter<T>(array: T[], f: (x: T) => boolean): T[]
|
||||
export function filter<T>(array: T[], f: (x: T) => boolean): T[];
|
||||
export function filter<T>(array: T[], f: (x: T) => boolean): T[] {
|
||||
if (array) {
|
||||
const len = array.length;
|
||||
@@ -1813,9 +1813,9 @@ namespace ts {
|
||||
|
||||
export interface ObjectAllocator {
|
||||
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||
getTokenConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token;
|
||||
getIdentifierConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token;
|
||||
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;
|
||||
getTokenConstructor(): new <TKind extends SyntaxKind>(kind: TKind, pos?: number, end?: number) => Token<TKind>;
|
||||
getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos?: number, end?: number) => Identifier;
|
||||
getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos?: number, end?: number) => SourceFile;
|
||||
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
|
||||
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
|
||||
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
|
||||
@@ -1867,10 +1867,10 @@ namespace ts {
|
||||
declare var process: any;
|
||||
declare var require: any;
|
||||
|
||||
let currentAssertionLevel: AssertionLevel;
|
||||
export let currentAssertionLevel = AssertionLevel.None;
|
||||
|
||||
export function shouldAssert(level: AssertionLevel): boolean {
|
||||
return getCurrentAssertionLevel() >= level;
|
||||
return currentAssertionLevel >= level;
|
||||
}
|
||||
|
||||
export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void {
|
||||
@@ -1887,35 +1887,6 @@ namespace ts {
|
||||
export function fail(message?: string): void {
|
||||
Debug.assert(/*expression*/ false, message);
|
||||
}
|
||||
|
||||
function getCurrentAssertionLevel() {
|
||||
if (currentAssertionLevel !== undefined) {
|
||||
return currentAssertionLevel;
|
||||
}
|
||||
|
||||
if (sys === undefined) {
|
||||
return AssertionLevel.None;
|
||||
}
|
||||
|
||||
const developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV"));
|
||||
currentAssertionLevel = developmentMode
|
||||
? AssertionLevel.Normal
|
||||
: AssertionLevel.None;
|
||||
|
||||
return currentAssertionLevel;
|
||||
}
|
||||
}
|
||||
|
||||
export function getEnvironmentVariable(name: string, host?: CompilerHost) {
|
||||
if (host && host.getEnvironmentVariable) {
|
||||
return host.getEnvironmentVariable(name);
|
||||
}
|
||||
|
||||
if (sys && sys.getEnvironmentVariable) {
|
||||
return sys.getEnvironmentVariable(name);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/** Remove an item from an array, moving everything to its right one space left. */
|
||||
|
||||
@@ -1121,7 +1121,6 @@ namespace ts {
|
||||
writeLine();
|
||||
}
|
||||
|
||||
|
||||
function emitSpreadTypeElement(type: SpreadTypeElement) {
|
||||
write("...");
|
||||
emitType(type.type);
|
||||
@@ -1129,7 +1128,7 @@ namespace ts {
|
||||
writeLine();
|
||||
}
|
||||
|
||||
function emitVariableDeclaration(node: VariableDeclaration) {
|
||||
function emitVariableDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration) {
|
||||
// If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted
|
||||
// so there is no check needed to see if declaration is visible
|
||||
if (node.kind !== SyntaxKind.VariableDeclaration || resolver.isDeclarationVisible(node)) {
|
||||
@@ -1144,7 +1143,7 @@ namespace ts {
|
||||
// If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor
|
||||
// we don't want to emit property declaration with "?"
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature ||
|
||||
(node.kind === SyntaxKind.Parameter && !isParameterPropertyDeclaration(node))) && hasQuestionToken(node)) {
|
||||
(node.kind === SyntaxKind.Parameter && !isParameterPropertyDeclaration(<ParameterDeclaration>node))) && hasQuestionToken(node)) {
|
||||
write("?");
|
||||
}
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) {
|
||||
@@ -1634,8 +1633,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitBindingElement(bindingElement: BindingElement) {
|
||||
|
||||
function emitBindingElement(bindingElement: BindingElement | OmittedExpression) {
|
||||
if (bindingElement.kind === SyntaxKind.OmittedExpression) {
|
||||
// If bindingElement is an omittedExpression (i.e. containing elision),
|
||||
// we will emit blank space (although this may differ from users' original code,
|
||||
|
||||
@@ -2969,6 +2969,10 @@
|
||||
"category": "Error",
|
||||
"code": 7033
|
||||
},
|
||||
"Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined.": {
|
||||
"category": "Error",
|
||||
"code": 7034
|
||||
},
|
||||
"You cannot rename this element.": {
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
|
||||
@@ -655,7 +655,7 @@ const _super = (function (geti, seti) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return emitModuleDeclaration(<ModuleDeclaration>node);
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return emitModuleBlock(<Block>node);
|
||||
return emitModuleBlock(<ModuleBlock>node);
|
||||
case SyntaxKind.CaseBlock:
|
||||
return emitCaseBlock(<CaseBlock>node);
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
@@ -1394,7 +1394,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
}
|
||||
|
||||
function emitBlockStatements(node: Block) {
|
||||
function emitBlockStatements(node: BlockLike) {
|
||||
if (getEmitFlags(node) & EmitFlags.SingleLine) {
|
||||
emitList(node, node.statements, ListFormat.SingleLineBlockStatements);
|
||||
}
|
||||
@@ -1795,7 +1795,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
function emitModuleBlock(node: ModuleBlock) {
|
||||
if (isSingleLineEmptyBlock(node)) {
|
||||
if (isEmptyBlock(node)) {
|
||||
write("{ }");
|
||||
}
|
||||
else {
|
||||
@@ -2615,7 +2615,11 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function isSingleLineEmptyBlock(block: Block) {
|
||||
return !block.multiLine
|
||||
&& block.statements.length === 0
|
||||
&& isEmptyBlock(block);
|
||||
}
|
||||
|
||||
function isEmptyBlock(block: BlockLike) {
|
||||
return block.statements.length === 0
|
||||
&& rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
|
||||
}
|
||||
|
||||
|
||||
+28
-27
@@ -105,6 +105,7 @@ namespace ts {
|
||||
export function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange): StringLiteral;
|
||||
export function createLiteral(value: string, location?: TextRange): StringLiteral;
|
||||
export function createLiteral(value: number, location?: TextRange): NumericLiteral;
|
||||
export function createLiteral(value: boolean, location?: TextRange): BooleanLiteral;
|
||||
export function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression;
|
||||
export function createLiteral(value: string | number | boolean | StringLiteral | Identifier, location?: TextRange): PrimaryExpression {
|
||||
if (typeof value === "number") {
|
||||
@@ -120,7 +121,7 @@ namespace ts {
|
||||
node.text = value;
|
||||
return node;
|
||||
}
|
||||
else {
|
||||
else if (value) {
|
||||
const node = <StringLiteral>createNode(SyntaxKind.StringLiteral, location, /*flags*/ undefined);
|
||||
node.textSourceNode = value;
|
||||
node.text = value.text;
|
||||
@@ -187,8 +188,8 @@ namespace ts {
|
||||
|
||||
// Punctuation
|
||||
|
||||
export function createToken(token: SyntaxKind) {
|
||||
return createNode(token);
|
||||
export function createToken<TKind extends SyntaxKind>(token: TKind) {
|
||||
return <Token<TKind>>createNode(token);
|
||||
}
|
||||
|
||||
// Reserved words
|
||||
@@ -238,7 +239,7 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
export function createParameterDeclaration(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: Node, name: string | Identifier | BindingPattern, questionToken: Node, type: TypeNode, initializer: Expression, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createParameterDeclaration(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <ParameterDeclaration>createNode(SyntaxKind.Parameter, location, flags);
|
||||
node.decorators = decorators ? createNodeArray(decorators) : undefined;
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
@@ -260,7 +261,7 @@ namespace ts {
|
||||
|
||||
// Type members
|
||||
|
||||
export function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: Node, type: TypeNode, initializer: Expression, location?: TextRange) {
|
||||
export function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange) {
|
||||
const node = <PropertyDeclaration>createNode(SyntaxKind.PropertyDeclaration, location);
|
||||
node.decorators = decorators ? createNodeArray(decorators) : undefined;
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
@@ -278,7 +279,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: Node, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <MethodDeclaration>createNode(SyntaxKind.MethodDeclaration, location, flags);
|
||||
node.decorators = decorators ? createNodeArray(decorators) : undefined;
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
@@ -381,7 +382,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: Node, name: string | BindingName, initializer?: Expression, location?: TextRange) {
|
||||
export function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression, location?: TextRange) {
|
||||
const node = <BindingElement>createNode(SyntaxKind.BindingElement, location);
|
||||
node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName;
|
||||
node.dotDotDotToken = dotDotDotToken;
|
||||
@@ -497,14 +498,14 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createTaggedTemplate(tag: Expression, template: Template, location?: TextRange) {
|
||||
export function createTaggedTemplate(tag: Expression, template: TemplateLiteral, location?: TextRange) {
|
||||
const node = <TaggedTemplateExpression>createNode(SyntaxKind.TaggedTemplateExpression, location);
|
||||
node.tag = parenthesizeForAccess(tag);
|
||||
node.template = template;
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: Template) {
|
||||
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral) {
|
||||
if (node.tag !== tag || node.template !== template) {
|
||||
return updateNode(createTaggedTemplate(tag, template, node), node);
|
||||
}
|
||||
@@ -524,7 +525,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createFunctionExpression(asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createFunctionExpression(asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <FunctionExpression>createNode(SyntaxKind.FunctionExpression, location, flags);
|
||||
node.modifiers = undefined;
|
||||
node.asteriskToken = asteriskToken;
|
||||
@@ -543,13 +544,13 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: Node, body: ConciseBody, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction, location, flags);
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined;
|
||||
node.parameters = createNodeArray(parameters);
|
||||
node.type = type;
|
||||
node.equalsGreaterThanToken = equalsGreaterThanToken || createNode(SyntaxKind.EqualsGreaterThanToken);
|
||||
node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(SyntaxKind.EqualsGreaterThanToken);
|
||||
node.body = parenthesizeConciseBody(body);
|
||||
return node;
|
||||
}
|
||||
@@ -613,7 +614,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createPrefix(operator: SyntaxKind, operand: Expression, location?: TextRange) {
|
||||
export function createPrefix(operator: PrefixUnaryOperator, operand: Expression, location?: TextRange) {
|
||||
const node = <PrefixUnaryExpression>createNode(SyntaxKind.PrefixUnaryExpression, location);
|
||||
node.operator = operator;
|
||||
node.operand = parenthesizePrefixOperand(operand);
|
||||
@@ -627,7 +628,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createPostfix(operand: Expression, operator: SyntaxKind, location?: TextRange) {
|
||||
export function createPostfix(operand: Expression, operator: PostfixUnaryOperator, location?: TextRange) {
|
||||
const node = <PostfixUnaryExpression>createNode(SyntaxKind.PostfixUnaryExpression, location);
|
||||
node.operand = parenthesizePostfixOperand(operand);
|
||||
node.operator = operator;
|
||||
@@ -641,8 +642,8 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createBinary(left: Expression, operator: SyntaxKind | Node, right: Expression, location?: TextRange) {
|
||||
const operatorToken = typeof operator === "number" ? createSynthesizedNode(operator) : operator;
|
||||
export function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression, location?: TextRange) {
|
||||
const operatorToken = typeof operator === "number" ? createToken(operator) : operator;
|
||||
const operatorKind = operatorToken.kind;
|
||||
const node = <BinaryExpression>createNode(SyntaxKind.BinaryExpression, location);
|
||||
node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined);
|
||||
@@ -658,7 +659,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createConditional(condition: Expression, questionToken: Node, whenTrue: Expression, colonToken: Node, whenFalse: Expression, location?: TextRange) {
|
||||
export function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression, location?: TextRange) {
|
||||
const node = <ConditionalExpression>createNode(SyntaxKind.ConditionalExpression, location);
|
||||
node.condition = condition;
|
||||
node.questionToken = questionToken;
|
||||
@@ -675,21 +676,21 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createTemplateExpression(head: TemplateLiteralFragment, templateSpans: TemplateSpan[], location?: TextRange) {
|
||||
export function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[], location?: TextRange) {
|
||||
const node = <TemplateExpression>createNode(SyntaxKind.TemplateExpression, location);
|
||||
node.head = head;
|
||||
node.templateSpans = createNodeArray(templateSpans);
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateTemplateExpression(node: TemplateExpression, head: TemplateLiteralFragment, templateSpans: TemplateSpan[]) {
|
||||
export function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]) {
|
||||
if (node.head !== head || node.templateSpans !== templateSpans) {
|
||||
return updateNode(createTemplateExpression(head, templateSpans, node), node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createYield(asteriskToken: Node, expression: Expression, location?: TextRange) {
|
||||
export function createYield(asteriskToken: AsteriskToken, expression: Expression, location?: TextRange) {
|
||||
const node = <YieldExpression>createNode(SyntaxKind.YieldExpression, location);
|
||||
node.asteriskToken = asteriskToken;
|
||||
node.expression = expression;
|
||||
@@ -756,14 +757,14 @@ namespace ts {
|
||||
|
||||
// Misc
|
||||
|
||||
export function createTemplateSpan(expression: Expression, literal: TemplateLiteralFragment, location?: TextRange) {
|
||||
export function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail, location?: TextRange) {
|
||||
const node = <TemplateSpan>createNode(SyntaxKind.TemplateSpan, location);
|
||||
node.expression = expression;
|
||||
node.literal = literal;
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateLiteralFragment) {
|
||||
export function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail) {
|
||||
if (node.expression !== expression || node.literal !== literal) {
|
||||
return updateNode(createTemplateSpan(expression, literal, node), node);
|
||||
}
|
||||
@@ -932,14 +933,14 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateForOf(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement) {
|
||||
export function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement) {
|
||||
if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) {
|
||||
return updateNode(createForOf(initializer, expression, statement, node), node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createContinue(label?: Identifier, location?: TextRange): BreakStatement {
|
||||
export function createContinue(label?: Identifier, location?: TextRange): ContinueStatement {
|
||||
const node = <ContinueStatement>createNode(SyntaxKind.ContinueStatement, location);
|
||||
if (label) {
|
||||
node.label = label;
|
||||
@@ -1065,7 +1066,7 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <FunctionDeclaration>createNode(SyntaxKind.FunctionDeclaration, location, flags);
|
||||
node.decorators = decorators ? createNodeArray(decorators) : undefined;
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
@@ -1560,7 +1561,7 @@ namespace ts {
|
||||
return createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
createSynthesizedNode(SyntaxKind.DotDotDotToken),
|
||||
createToken(SyntaxKind.DotDotDotToken),
|
||||
name,
|
||||
/*questionToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
@@ -1735,7 +1736,7 @@ namespace ts {
|
||||
|
||||
export function createAwaiterHelper(externalHelpersModuleName: Identifier | undefined, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block) {
|
||||
const generatorFunc = createFunctionExpression(
|
||||
createNode(SyntaxKind.AsteriskToken),
|
||||
createToken(SyntaxKind.AsteriskToken),
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/*parameters*/ [],
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace ts {
|
||||
currentDirectory = host.getCurrentDirectory();
|
||||
}
|
||||
|
||||
return currentDirectory && getDefaultTypeRoots(currentDirectory, host);
|
||||
return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -675,23 +675,33 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function loadModuleFromNodeModules(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState, checkOneLevel: boolean): string {
|
||||
return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, /*typesOnly*/ false);
|
||||
}
|
||||
|
||||
function loadModuleFromNodeModulesAtTypes(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState): string {
|
||||
return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, /*checkOneLevel*/ false, /*typesOnly*/ true);
|
||||
}
|
||||
|
||||
function loadModuleFromNodeModulesWorker(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState, checkOneLevel: boolean, typesOnly: boolean): string {
|
||||
directory = normalizeSlashes(directory);
|
||||
while (true) {
|
||||
const baseName = getBaseFileName(directory);
|
||||
if (baseName !== "node_modules") {
|
||||
// Try to load source from the package
|
||||
const packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state);
|
||||
if (packageResult && hasTypeScriptFileExtension(packageResult)) {
|
||||
// Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package
|
||||
return packageResult;
|
||||
}
|
||||
else {
|
||||
// Else prefer a types package over non-TypeScript results (e.g. JavaScript files)
|
||||
const typesResult = loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state);
|
||||
if (typesResult || packageResult) {
|
||||
return typesResult || packageResult;
|
||||
let packageResult: string | undefined;
|
||||
if (!typesOnly) {
|
||||
// Try to load source from the package
|
||||
packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state);
|
||||
if (packageResult && hasTypeScriptFileExtension(packageResult)) {
|
||||
// Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package
|
||||
return packageResult;
|
||||
}
|
||||
}
|
||||
|
||||
// Else prefer a types package over non-TypeScript results (e.g. JavaScript files)
|
||||
const typesResult = loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state);
|
||||
if (typesResult || packageResult) {
|
||||
return typesResult || packageResult;
|
||||
}
|
||||
}
|
||||
|
||||
const parentPath = getDirectoryPath(directory);
|
||||
@@ -709,7 +719,7 @@ namespace ts {
|
||||
const state = { compilerOptions, host, traceEnabled, skipTsx: !compilerOptions.jsx };
|
||||
const failedLookupLocations: string[] = [];
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions);
|
||||
let containingDirectory = getDirectoryPath(containingFile);
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
|
||||
const resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state);
|
||||
if (resolvedFileName) {
|
||||
@@ -718,18 +728,9 @@ namespace ts {
|
||||
|
||||
let referencedSourceFile: string;
|
||||
if (moduleHasNonRelativeName(moduleName)) {
|
||||
while (true) {
|
||||
const searchName = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state);
|
||||
if (referencedSourceFile) {
|
||||
break;
|
||||
}
|
||||
const parentPath = getDirectoryPath(containingDirectory);
|
||||
if (parentPath === containingDirectory) {
|
||||
break;
|
||||
}
|
||||
containingDirectory = parentPath;
|
||||
}
|
||||
referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) ||
|
||||
// If we didn't find the file normally, look it up in @types.
|
||||
loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state);
|
||||
}
|
||||
else {
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
@@ -741,4 +742,20 @@ namespace ts {
|
||||
? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations }
|
||||
: { resolvedModule: undefined, failedLookupLocations };
|
||||
}
|
||||
|
||||
/** Climb up parent directories looking for a module. */
|
||||
function loadModuleFromAncestorDirectories(moduleName: string, containingDirectory: string, supportedExtensions: string[], failedLookupLocations: string[], state: ModuleResolutionState): string | undefined {
|
||||
while (true) {
|
||||
const searchName = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
const referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state);
|
||||
if (referencedSourceFile) {
|
||||
return referencedSourceFile;
|
||||
}
|
||||
const parentPath = getDirectoryPath(containingDirectory);
|
||||
if (parentPath === containingDirectory) {
|
||||
return undefined;
|
||||
}
|
||||
containingDirectory = parentPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
-38
@@ -641,7 +641,7 @@ namespace ts {
|
||||
|
||||
sourceFile.statements = parseList(ParsingContext.SourceElements, parseStatement);
|
||||
Debug.assert(token() === SyntaxKind.EndOfFileToken);
|
||||
sourceFile.endOfFileToken = parseTokenNode();
|
||||
sourceFile.endOfFileToken = <EndOfFileToken>parseTokenNode();
|
||||
|
||||
setExternalModuleIndicator(sourceFile);
|
||||
|
||||
@@ -1008,6 +1008,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseOptionalToken<TKind extends SyntaxKind>(t: TKind): Token<TKind>;
|
||||
function parseOptionalToken(t: SyntaxKind): Node {
|
||||
if (token() === t) {
|
||||
return parseTokenNode();
|
||||
@@ -1015,6 +1016,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parseExpectedToken<TKind extends SyntaxKind>(t: TKind, reportAtCurrentPosition: boolean, diagnosticMessage: DiagnosticMessage, arg0?: any): Token<TKind>;
|
||||
function parseExpectedToken(t: SyntaxKind, reportAtCurrentPosition: boolean, diagnosticMessage: DiagnosticMessage, arg0?: any): Node {
|
||||
return parseOptionalToken(t) ||
|
||||
createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0);
|
||||
@@ -1051,7 +1053,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// note: this function creates only node
|
||||
function createNode(kind: SyntaxKind, pos?: number): Node | Token | Identifier {
|
||||
function createNode<TKind extends SyntaxKind>(kind: TKind, pos?: number): Node | Token<TKind> | Identifier {
|
||||
nodeCount++;
|
||||
if (!(pos >= 0)) {
|
||||
pos = scanner.getStartPos();
|
||||
@@ -1398,8 +1400,8 @@ namespace ts {
|
||||
// Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery
|
||||
return token() === SyntaxKind.CloseParenToken || token() === SyntaxKind.CloseBracketToken /*|| token === SyntaxKind.OpenBraceToken*/;
|
||||
case ParsingContext.TypeArguments:
|
||||
// Tokens other than '>' are here for better error recovery
|
||||
return token() === SyntaxKind.GreaterThanToken || token() === SyntaxKind.OpenParenToken;
|
||||
// All other tokens should cause the type-argument to terminate except comma token
|
||||
return token() !== SyntaxKind.CommaToken;
|
||||
case ParsingContext.HeritageClauses:
|
||||
return token() === SyntaxKind.OpenBraceToken || token() === SyntaxKind.CloseBraceToken;
|
||||
case ParsingContext.JsxAttributes:
|
||||
@@ -1924,7 +1926,7 @@ namespace ts {
|
||||
function parseTemplateExpression(): TemplateExpression {
|
||||
const template = <TemplateExpression>createNode(SyntaxKind.TemplateExpression);
|
||||
|
||||
template.head = parseTemplateLiteralFragment();
|
||||
template.head = parseTemplateHead();
|
||||
Debug.assert(template.head.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind");
|
||||
|
||||
const templateSpans = createNodeArray<TemplateSpan>();
|
||||
@@ -1944,14 +1946,13 @@ namespace ts {
|
||||
const span = <TemplateSpan>createNode(SyntaxKind.TemplateSpan);
|
||||
span.expression = allowInAnd(parseExpression);
|
||||
|
||||
let literal: TemplateLiteralFragment;
|
||||
|
||||
let literal: TemplateMiddle | TemplateTail;
|
||||
if (token() === SyntaxKind.CloseBraceToken) {
|
||||
reScanTemplateToken();
|
||||
literal = parseTemplateLiteralFragment();
|
||||
literal = parseTemplateMiddleOrTemplateTail();
|
||||
}
|
||||
else {
|
||||
literal = <TemplateLiteralFragment>parseExpectedToken(SyntaxKind.TemplateTail, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.CloseBraceToken));
|
||||
literal = <TemplateTail>parseExpectedToken(SyntaxKind.TemplateTail, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.CloseBraceToken));
|
||||
}
|
||||
|
||||
span.literal = literal;
|
||||
@@ -1962,8 +1963,16 @@ namespace ts {
|
||||
return <LiteralExpression>parseLiteralLikeNode(token(), internName);
|
||||
}
|
||||
|
||||
function parseTemplateLiteralFragment(): TemplateLiteralFragment {
|
||||
return <TemplateLiteralFragment>parseLiteralLikeNode(token(), /*internName*/ false);
|
||||
function parseTemplateHead(): TemplateHead {
|
||||
const fragment = parseLiteralLikeNode(token(), /*internName*/ false);
|
||||
Debug.assert(fragment.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind");
|
||||
return <TemplateHead>fragment;
|
||||
}
|
||||
|
||||
function parseTemplateMiddleOrTemplateTail(): TemplateMiddle | TemplateTail {
|
||||
const fragment = parseLiteralLikeNode(token(), /*internName*/ false);
|
||||
Debug.assert(fragment.kind === SyntaxKind.TemplateMiddle || fragment.kind === SyntaxKind.TemplateTail, "Template fragment has wrong token kind");
|
||||
return <TemplateMiddle | TemplateTail>fragment;
|
||||
}
|
||||
|
||||
function parseLiteralLikeNode(kind: SyntaxKind, internName: boolean): LiteralLikeNode {
|
||||
@@ -2738,7 +2747,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
let expr = parseAssignmentExpressionOrHigher();
|
||||
let operatorToken: Node;
|
||||
let operatorToken: BinaryOperatorToken;
|
||||
while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) {
|
||||
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
|
||||
}
|
||||
@@ -2831,7 +2840,7 @@ namespace ts {
|
||||
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
||||
// for cases like > > = becoming >>=
|
||||
if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) {
|
||||
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher());
|
||||
return makeBinaryExpression(expr, <BinaryOperatorToken>parseTokenNode(), parseAssignmentExpressionOrHigher());
|
||||
}
|
||||
|
||||
// It wasn't an assignment or a lambda. This is a conditional expression:
|
||||
@@ -3266,7 +3275,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
|
||||
leftOperand = makeBinaryExpression(leftOperand, <BinaryOperatorToken>parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3326,7 +3335,7 @@ namespace ts {
|
||||
return -1;
|
||||
}
|
||||
|
||||
function makeBinaryExpression(left: Expression, operatorToken: Node, right: Expression): BinaryExpression {
|
||||
function makeBinaryExpression(left: Expression, operatorToken: BinaryOperatorToken, right: Expression): BinaryExpression {
|
||||
const node = <BinaryExpression>createNode(SyntaxKind.BinaryExpression, left.pos);
|
||||
node.left = left;
|
||||
node.operatorToken = operatorToken;
|
||||
@@ -3343,7 +3352,7 @@ namespace ts {
|
||||
|
||||
function parsePrefixUnaryExpression() {
|
||||
const node = <PrefixUnaryExpression>createNode(SyntaxKind.PrefixUnaryExpression);
|
||||
node.operator = token();
|
||||
node.operator = <PrefixUnaryOperator>token();
|
||||
nextToken();
|
||||
node.operand = parseSimpleUnaryExpression();
|
||||
|
||||
@@ -3530,7 +3539,7 @@ namespace ts {
|
||||
function parseIncrementExpression(): IncrementExpression {
|
||||
if (token() === SyntaxKind.PlusPlusToken || token() === SyntaxKind.MinusMinusToken) {
|
||||
const node = <PrefixUnaryExpression>createNode(SyntaxKind.PrefixUnaryExpression);
|
||||
node.operator = token();
|
||||
node.operator = <PrefixUnaryOperator>token();
|
||||
nextToken();
|
||||
node.operand = parseLeftHandSideExpressionOrHigher();
|
||||
return finishNode(node);
|
||||
@@ -3546,7 +3555,7 @@ namespace ts {
|
||||
if ((token() === SyntaxKind.PlusPlusToken || token() === SyntaxKind.MinusMinusToken) && !scanner.hasPrecedingLineBreak()) {
|
||||
const node = <PostfixUnaryExpression>createNode(SyntaxKind.PostfixUnaryExpression, expression.pos);
|
||||
node.operand = expression;
|
||||
node.operator = token();
|
||||
node.operator = <PostfixUnaryOperator>token();
|
||||
nextToken();
|
||||
return finishNode(node);
|
||||
}
|
||||
@@ -3719,7 +3728,7 @@ namespace ts {
|
||||
badNode.end = invalidElement.end;
|
||||
badNode.left = result;
|
||||
badNode.right = invalidElement;
|
||||
badNode.operatorToken = createMissingNode(SyntaxKind.CommaToken, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined);
|
||||
badNode.operatorToken = <BinaryOperatorToken>createMissingNode(SyntaxKind.CommaToken, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined);
|
||||
badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
|
||||
return <JsxElement><Node>badNode;
|
||||
}
|
||||
@@ -3855,7 +3864,7 @@ namespace ts {
|
||||
if (token() === SyntaxKind.EqualsToken) {
|
||||
switch (scanJsxAttributeValue()) {
|
||||
case SyntaxKind.StringLiteral:
|
||||
node.initializer = parseLiteralNode();
|
||||
node.initializer = <StringLiteral>parseLiteralNode();
|
||||
break;
|
||||
default:
|
||||
node.initializer = parseJsxExpression(/*inExpressionContext*/ true);
|
||||
@@ -3940,7 +3949,7 @@ namespace ts {
|
||||
const tagExpression = <TaggedTemplateExpression>createNode(SyntaxKind.TaggedTemplateExpression, expression.pos);
|
||||
tagExpression.tag = expression;
|
||||
tagExpression.template = token() === SyntaxKind.NoSubstitutionTemplateLiteral
|
||||
? parseLiteralNode()
|
||||
? <NoSubstitutionTemplateLiteral>parseLiteralNode()
|
||||
: parseTemplateExpression();
|
||||
expression = finishNode(tagExpression);
|
||||
continue;
|
||||
@@ -4984,7 +4993,7 @@ namespace ts {
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
|
||||
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, asteriskToken: Node, name: PropertyName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
|
||||
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, asteriskToken: AsteriskToken, name: PropertyName, questionToken: QuestionToken, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
|
||||
const method = <MethodDeclaration>createNode(SyntaxKind.MethodDeclaration, fullStart);
|
||||
method.decorators = decorators;
|
||||
method.modifiers = modifiers;
|
||||
@@ -4998,7 +5007,7 @@ namespace ts {
|
||||
return addJSDocComment(finishNode(method));
|
||||
}
|
||||
|
||||
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, name: PropertyName, questionToken: Node): ClassElement {
|
||||
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, name: PropertyName, questionToken: QuestionToken): ClassElement {
|
||||
const property = <PropertyDeclaration>createNode(SyntaxKind.PropertyDeclaration, fullStart);
|
||||
property.decorators = decorators;
|
||||
property.modifiers = modifiers;
|
||||
@@ -5420,7 +5429,7 @@ namespace ts {
|
||||
node.flags |= flags;
|
||||
node.name = parseIdentifier();
|
||||
node.body = parseOptional(SyntaxKind.DotToken)
|
||||
? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.NestedNamespace | namespaceFlag)
|
||||
? <NamespaceDeclaration>parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.NestedNamespace | namespaceFlag)
|
||||
: parseModuleBlock();
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
@@ -5599,8 +5608,10 @@ namespace ts {
|
||||
return finishNode(namespaceImport);
|
||||
}
|
||||
|
||||
function parseNamedImportsOrExports(kind: SyntaxKind.NamedImports): NamedImports;
|
||||
function parseNamedImportsOrExports(kind: SyntaxKind.NamedExports): NamedExports;
|
||||
function parseNamedImportsOrExports(kind: SyntaxKind): NamedImportsOrExports {
|
||||
const node = <NamedImports>createNode(kind);
|
||||
const node = <NamedImports | NamedExports>createNode(kind);
|
||||
|
||||
// NamedImports:
|
||||
// { }
|
||||
@@ -5610,7 +5621,7 @@ namespace ts {
|
||||
// ImportsList:
|
||||
// ImportSpecifier
|
||||
// ImportsList, ImportSpecifier
|
||||
node.elements = parseBracketedList(ParsingContext.ImportOrExportSpecifiers,
|
||||
node.elements = <NodeArray<ImportSpecifier> | NodeArray<ExportSpecifier>>parseBracketedList(ParsingContext.ImportOrExportSpecifiers,
|
||||
kind === SyntaxKind.NamedImports ? parseImportSpecifier : parseExportSpecifier,
|
||||
SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken);
|
||||
return finishNode(node);
|
||||
@@ -5994,14 +6005,15 @@ namespace ts {
|
||||
const parameter = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
|
||||
parameter.type = parseJSDocType();
|
||||
if (parseOptional(SyntaxKind.EqualsToken)) {
|
||||
parameter.questionToken = createNode(SyntaxKind.EqualsToken);
|
||||
// TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken?
|
||||
parameter.questionToken = <QuestionToken>createNode(SyntaxKind.EqualsToken);
|
||||
}
|
||||
return finishNode(parameter);
|
||||
}
|
||||
|
||||
function parseJSDocTypeReference(): JSDocTypeReference {
|
||||
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
|
||||
result.name = parseSimplePropertyName();
|
||||
result.name = <Identifier>parseSimplePropertyName();
|
||||
|
||||
if (token() === SyntaxKind.LessThanToken) {
|
||||
result.typeArguments = parseTypeArguments();
|
||||
@@ -6329,7 +6341,7 @@ namespace ts {
|
||||
|
||||
function parseTag(indent: number) {
|
||||
Debug.assert(token() === SyntaxKind.AtToken);
|
||||
const atToken = createNode(SyntaxKind.AtToken, scanner.getTokenPos());
|
||||
const atToken = <AtToken>createNode(SyntaxKind.AtToken, scanner.getTokenPos());
|
||||
atToken.end = scanner.getTextPos();
|
||||
nextJSDocToken();
|
||||
|
||||
@@ -6435,7 +6447,7 @@ namespace ts {
|
||||
return comments;
|
||||
}
|
||||
|
||||
function parseUnknownTag(atToken: Node, tagName: Identifier) {
|
||||
function parseUnknownTag(atToken: AtToken, tagName: Identifier) {
|
||||
const result = <JSDocTag>createNode(SyntaxKind.JSDocTag, atToken.pos);
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
@@ -6465,7 +6477,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function parseParamTag(atToken: Node, tagName: Identifier) {
|
||||
function parseParamTag(atToken: AtToken, tagName: Identifier) {
|
||||
let typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
|
||||
@@ -6516,7 +6528,7 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseReturnTag(atToken: Node, tagName: Identifier): JSDocReturnTag {
|
||||
function parseReturnTag(atToken: AtToken, tagName: Identifier): JSDocReturnTag {
|
||||
if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) {
|
||||
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
|
||||
}
|
||||
@@ -6528,7 +6540,7 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseTypeTag(atToken: Node, tagName: Identifier): JSDocTypeTag {
|
||||
function parseTypeTag(atToken: AtToken, tagName: Identifier): JSDocTypeTag {
|
||||
if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) {
|
||||
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
|
||||
}
|
||||
@@ -6540,7 +6552,7 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parsePropertyTag(atToken: Node, tagName: Identifier): JSDocPropertyTag {
|
||||
function parsePropertyTag(atToken: AtToken, tagName: Identifier): JSDocPropertyTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
const name = parseJSDocIdentifierName();
|
||||
@@ -6558,7 +6570,7 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseTypedefTag(atToken: Node, tagName: Identifier): JSDocTypedefTag {
|
||||
function parseTypedefTag(atToken: AtToken, tagName: Identifier): JSDocTypedefTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
|
||||
@@ -6580,7 +6592,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
if (!typedefTag.jsDocTypeLiteral) {
|
||||
typedefTag.jsDocTypeLiteral = typeExpression.type;
|
||||
typedefTag.jsDocTypeLiteral = <JSDocTypeLiteral>typeExpression.type;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -6632,7 +6644,7 @@ namespace ts {
|
||||
|
||||
function tryParseChildTag(parentTag: JSDocTypeLiteral): boolean {
|
||||
Debug.assert(token() === SyntaxKind.AtToken);
|
||||
const atToken = createNode(SyntaxKind.AtToken, scanner.getStartPos());
|
||||
const atToken = <AtToken>createNode(SyntaxKind.AtToken, scanner.getStartPos());
|
||||
atToken.end = scanner.getTextPos();
|
||||
nextJSDocToken();
|
||||
|
||||
@@ -6662,7 +6674,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseTemplateTag(atToken: Node, tagName: Identifier): JSDocTemplateTag {
|
||||
function parseTemplateTag(atToken: AtToken, tagName: Identifier): JSDocTemplateTag {
|
||||
if (forEach(tags, t => t.kind === SyntaxKind.JSDocTemplateTag)) {
|
||||
parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace ts {
|
||||
readFile: fileName => sys.readFile(fileName),
|
||||
trace: (s: string) => sys.write(s + newLine),
|
||||
directoryExists: directoryName => sys.directoryExists(directoryName),
|
||||
getEnvironmentVariable: name => getEnvironmentVariable(name, /*host*/ undefined),
|
||||
getEnvironmentVariable: name => sys.getEnvironmentVariable ? sys.getEnvironmentVariable(name) : "",
|
||||
getDirectories: (path: string) => sys.getDirectories(path),
|
||||
realpath
|
||||
};
|
||||
@@ -473,6 +473,7 @@ namespace ts {
|
||||
(oldOptions.configFilePath !== options.configFilePath) ||
|
||||
(oldOptions.baseUrl !== options.baseUrl) ||
|
||||
(oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) ||
|
||||
!arrayIsEqualTo(oldOptions.lib, options.lib) ||
|
||||
!arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) ||
|
||||
!arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
|
||||
!equalOwnProperties(oldOptions.paths, options.paths)) {
|
||||
|
||||
+18
-3
@@ -83,7 +83,7 @@ namespace ts {
|
||||
getEnvironmentVariable?(name: string): string;
|
||||
};
|
||||
|
||||
export var sys: System = (function() {
|
||||
export let sys: System = (function() {
|
||||
|
||||
function getWScriptSystem(): System {
|
||||
|
||||
@@ -311,9 +311,18 @@ namespace ts {
|
||||
return parseInt(process.version.charAt(1)) >= 4;
|
||||
}
|
||||
|
||||
function isFileSystemCaseSensitive(): boolean {
|
||||
// win32\win64 are case insensitive platforms
|
||||
if (platform === "win32" || platform === "win64") {
|
||||
return false;
|
||||
}
|
||||
// convert current file name to upper case / lower case and check if file exists
|
||||
// (guards against cases when name is already all uppercase or lowercase)
|
||||
return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase());
|
||||
}
|
||||
|
||||
const platform: string = _os.platform();
|
||||
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
|
||||
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
|
||||
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
|
||||
|
||||
function readFile(fileName: string, encoding?: string): string {
|
||||
if (!fileExists(fileName)) {
|
||||
@@ -628,4 +637,10 @@ namespace ts {
|
||||
}
|
||||
return sys;
|
||||
})();
|
||||
|
||||
if (sys && sys.getEnvironmentVariable) {
|
||||
Debug.currentAssertionLevel = /^development$/i.test(sys.getEnvironmentVariable("NODE_ENV"))
|
||||
? AssertionLevel.Normal
|
||||
: AssertionLevel.None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace ts {
|
||||
|
||||
function flattenDestructuring(
|
||||
context: TransformationContext,
|
||||
root: BindingElement | BinaryExpression,
|
||||
root: VariableDeclaration | ParameterDeclaration | BindingElement | BinaryExpression,
|
||||
value: Expression,
|
||||
location: TextRange,
|
||||
emitAssignment: (name: Identifier, value: Expression, location: TextRange, original: Node) => void,
|
||||
@@ -320,7 +320,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitBindingElement(target: BindingElement, value: Expression) {
|
||||
function emitBindingElement(target: VariableDeclaration | ParameterDeclaration | BindingElement, value: Expression) {
|
||||
// Any temporary assignments needed to emit target = value should point to target
|
||||
const initializer = visitor ? visitNode(target.initializer, visitor, isExpression) : target.initializer;
|
||||
if (initializer) {
|
||||
|
||||
@@ -982,7 +982,7 @@ namespace ts {
|
||||
if (statementOffset < ctorStatements.length) {
|
||||
firstStatement = ctorStatements[statementOffset];
|
||||
|
||||
if (firstStatement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((firstStatement as ExpressionStatement).expression)) {
|
||||
if (firstStatement.kind === SyntaxKind.ExpressionStatement && isSuperCall((firstStatement as ExpressionStatement).expression)) {
|
||||
const superCall = (firstStatement as ExpressionStatement).expression as CallExpression;
|
||||
superCallExpression = setOriginalNode(
|
||||
saveStateAndInvoke(superCall, visitImmediateSuperCallInBody),
|
||||
@@ -2308,8 +2308,7 @@ namespace ts {
|
||||
extraVariableDeclarations = [];
|
||||
}
|
||||
// hoist collected variable declarations
|
||||
for (const name in currentState.hoistedLocalVariables) {
|
||||
const identifier = currentState.hoistedLocalVariables[name];
|
||||
for (const identifier of currentState.hoistedLocalVariables) {
|
||||
extraVariableDeclarations.push(createVariableDeclaration(identifier));
|
||||
}
|
||||
}
|
||||
@@ -3199,7 +3198,7 @@ namespace ts {
|
||||
* @param node The declaration.
|
||||
* @param allowComments Allow comments for the name.
|
||||
*/
|
||||
function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: EmitFlags) {
|
||||
function getDeclarationName(node: ClassDeclaration | ClassExpression | FunctionDeclaration, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: EmitFlags) {
|
||||
if (node.name && !isGeneratedIdentifier(node.name)) {
|
||||
const name = getMutableClone(node.name);
|
||||
emitFlags |= getEmitFlags(node.name);
|
||||
|
||||
@@ -528,7 +528,7 @@ namespace ts {
|
||||
*
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitAccessorDeclaration(node: GetAccessorDeclaration) {
|
||||
function visitAccessorDeclaration(node: AccessorDeclaration) {
|
||||
const savedInGeneratorFunctionBody = inGeneratorFunctionBody;
|
||||
const savedInStatementContainingYield = inStatementContainingYield;
|
||||
inGeneratorFunctionBody = false;
|
||||
@@ -552,6 +552,7 @@ namespace ts {
|
||||
const savedBlocks = blocks;
|
||||
const savedBlockOffsets = blockOffsets;
|
||||
const savedBlockActions = blockActions;
|
||||
const savedBlockStack = blockStack;
|
||||
const savedLabelOffsets = labelOffsets;
|
||||
const savedLabelExpressions = labelExpressions;
|
||||
const savedNextLabelId = nextLabelId;
|
||||
@@ -566,6 +567,7 @@ namespace ts {
|
||||
blocks = undefined;
|
||||
blockOffsets = undefined;
|
||||
blockActions = undefined;
|
||||
blockStack = undefined;
|
||||
labelOffsets = undefined;
|
||||
labelExpressions = undefined;
|
||||
nextLabelId = 1;
|
||||
@@ -591,6 +593,7 @@ namespace ts {
|
||||
blocks = savedBlocks;
|
||||
blockOffsets = savedBlockOffsets;
|
||||
blockActions = savedBlockActions;
|
||||
blockStack = savedBlockStack;
|
||||
labelOffsets = savedLabelOffsets;
|
||||
labelExpressions = savedLabelExpressions;
|
||||
nextLabelId = savedNextLabelId;
|
||||
@@ -657,12 +660,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isCompoundAssignment(kind: SyntaxKind) {
|
||||
function isCompoundAssignment(kind: BinaryOperator): kind is CompoundAssignmentOperator {
|
||||
return kind >= SyntaxKind.FirstCompoundAssignment
|
||||
&& kind <= SyntaxKind.LastCompoundAssignment;
|
||||
}
|
||||
|
||||
function getOperatorForCompoundAssignment(kind: SyntaxKind) {
|
||||
function getOperatorForCompoundAssignment(kind: CompoundAssignmentOperator): BitwiseOperatorOrHigher {
|
||||
switch (kind) {
|
||||
case SyntaxKind.PlusEqualsToken: return SyntaxKind.PlusToken;
|
||||
case SyntaxKind.MinusEqualsToken: return SyntaxKind.MinusToken;
|
||||
|
||||
@@ -599,7 +599,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
statements.push(
|
||||
createExportStatement(node.name, setEmitFlags(getSynthesizedClone(node.name), EmitFlags.LocalName), /*location*/ node)
|
||||
createExportStatement(<Identifier>node.name, setEmitFlags(getSynthesizedClone(node.name), EmitFlags.LocalName), /*location*/ node)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -796,7 +796,7 @@ namespace ts {
|
||||
addVarForExportedEnumOrNamespaceDeclaration(statements, original);
|
||||
}
|
||||
|
||||
addExportMemberAssignments(statements, original.name);
|
||||
addExportMemberAssignments(statements, <Identifier>original.name);
|
||||
|
||||
return statements;
|
||||
}
|
||||
@@ -819,7 +819,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getDeclarationName(node: DeclarationStatement) {
|
||||
return node.name ? getSynthesizedClone(node.name) : getGeneratedNameForNode(node);
|
||||
return node.name ? getSynthesizedClone(<Identifier>node.name) : getGeneratedNameForNode(node);
|
||||
}
|
||||
|
||||
function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void {
|
||||
@@ -916,7 +916,7 @@ namespace ts {
|
||||
if (node.kind === SyntaxKind.PostfixUnaryExpression) {
|
||||
transformedUnaryExpression = createBinary(
|
||||
operand,
|
||||
createNode(operator === SyntaxKind.PlusPlusToken ? SyntaxKind.PlusEqualsToken : SyntaxKind.MinusEqualsToken),
|
||||
createToken(operator === SyntaxKind.PlusPlusToken ? SyntaxKind.PlusEqualsToken : SyntaxKind.MinusEqualsToken),
|
||||
createLiteral(1),
|
||||
/*location*/ node
|
||||
);
|
||||
|
||||
@@ -1201,7 +1201,7 @@ namespace ts {
|
||||
* @param node The declaration statement.
|
||||
*/
|
||||
function getDeclarationName(node: DeclarationStatement) {
|
||||
return node.name ? getSynthesizedClone(node.name) : getGeneratedNameForNode(node);
|
||||
return node.name ? getSynthesizedClone(<Identifier>node.name) : getGeneratedNameForNode(node);
|
||||
}
|
||||
|
||||
function addExportStarFunction(statements: Statement[], localNames: Identifier) {
|
||||
|
||||
@@ -989,7 +989,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const statement = statements[index];
|
||||
if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((<ExpressionStatement>statement).expression)) {
|
||||
if (statement.kind === SyntaxKind.ExpressionStatement && isSuperCall((<ExpressionStatement>statement).expression)) {
|
||||
result.push(visitNode(statement, visitor, isStatement));
|
||||
return index + 1;
|
||||
}
|
||||
@@ -1801,10 +1801,41 @@ namespace ts {
|
||||
case SyntaxKind.TypeReference:
|
||||
return serializeTypeReferenceNode(<TypeReferenceNode>node);
|
||||
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.UnionType:
|
||||
{
|
||||
const unionOrIntersection = <UnionOrIntersectionTypeNode>node;
|
||||
let serializedUnion: Identifier;
|
||||
for (const typeNode of unionOrIntersection.types) {
|
||||
const serializedIndividual = serializeTypeNode(typeNode) as Identifier;
|
||||
// Non identifier
|
||||
if (serializedIndividual.kind !== SyntaxKind.Identifier) {
|
||||
serializedUnion = undefined;
|
||||
break;
|
||||
}
|
||||
|
||||
// One of the individual is global object, return immediately
|
||||
if (serializedIndividual.text === "Object") {
|
||||
return serializedIndividual;
|
||||
}
|
||||
|
||||
// Different types
|
||||
if (serializedUnion && serializedUnion.text !== serializedIndividual.text) {
|
||||
serializedUnion = undefined;
|
||||
break;
|
||||
}
|
||||
|
||||
serializedUnion = serializedIndividual;
|
||||
}
|
||||
|
||||
// If we were able to find common type
|
||||
if (serializedUnion) {
|
||||
return serializedUnion;
|
||||
}
|
||||
}
|
||||
// Fallthrough
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.ThisType:
|
||||
break;
|
||||
@@ -2374,7 +2405,7 @@ namespace ts {
|
||||
* @param node The parameter declaration node.
|
||||
*/
|
||||
function visitParameter(node: ParameterDeclaration) {
|
||||
if (node.name && isIdentifier(node.name) && node.name.originalKeywordKind === SyntaxKind.ThisKeyword) {
|
||||
if (parameterIsThisKeyword(node)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -3069,7 +3100,7 @@ namespace ts {
|
||||
return createStatement(expression, /*location*/ undefined);
|
||||
}
|
||||
|
||||
function addExportMemberAssignment(statements: Statement[], node: DeclarationStatement) {
|
||||
function addExportMemberAssignment(statements: Statement[], node: ClassDeclaration | FunctionDeclaration) {
|
||||
const expression = createAssignment(
|
||||
getExportName(node),
|
||||
getLocalName(node, /*noSourceMaps*/ true)
|
||||
@@ -3147,7 +3178,7 @@ namespace ts {
|
||||
* @param noSourceMaps A value indicating whether source maps may not be emitted for the name.
|
||||
* @param allowComments A value indicating whether comments may be emitted for the name.
|
||||
*/
|
||||
function getLocalName(node: DeclarationStatement | ClassExpression, noSourceMaps?: boolean, allowComments?: boolean) {
|
||||
function getLocalName(node: FunctionDeclaration | ClassDeclaration | ClassExpression | ModuleDeclaration | EnumDeclaration, noSourceMaps?: boolean, allowComments?: boolean) {
|
||||
return getDeclarationName(node, allowComments, !noSourceMaps, EmitFlags.LocalName);
|
||||
}
|
||||
|
||||
@@ -3161,7 +3192,7 @@ namespace ts {
|
||||
* @param noSourceMaps A value indicating whether source maps may not be emitted for the name.
|
||||
* @param allowComments A value indicating whether comments may be emitted for the name.
|
||||
*/
|
||||
function getExportName(node: DeclarationStatement | ClassExpression, noSourceMaps?: boolean, allowComments?: boolean) {
|
||||
function getExportName(node: FunctionDeclaration | ClassDeclaration | ClassExpression | ModuleDeclaration | EnumDeclaration, noSourceMaps?: boolean, allowComments?: boolean) {
|
||||
if (isNamespaceExport(node)) {
|
||||
return getNamespaceMemberName(getDeclarationName(node), allowComments, !noSourceMaps);
|
||||
}
|
||||
@@ -3177,9 +3208,9 @@ namespace ts {
|
||||
* @param allowSourceMaps A value indicating whether source maps may be emitted for the name.
|
||||
* @param emitFlags Additional NodeEmitFlags to specify for the name.
|
||||
*/
|
||||
function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: EmitFlags) {
|
||||
function getDeclarationName(node: FunctionDeclaration | ClassDeclaration | ClassExpression | ModuleDeclaration | EnumDeclaration, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: EmitFlags) {
|
||||
if (node.name) {
|
||||
const name = getMutableClone(node.name);
|
||||
const name = getMutableClone(<Identifier>node.name);
|
||||
emitFlags |= getEmitFlags(node.name);
|
||||
if (!allowSourceMaps) {
|
||||
emitFlags |= EmitFlags.NoSourceMap;
|
||||
|
||||
+488
-257
File diff suppressed because it is too large
Load Diff
+35
-15
@@ -609,7 +609,7 @@ namespace ts {
|
||||
return !!(getCombinedNodeFlags(node) & NodeFlags.Let);
|
||||
}
|
||||
|
||||
export function isSuperCallExpression(n: Node): boolean {
|
||||
export function isSuperCall(n: Node): n is SuperCall {
|
||||
return n.kind === SyntaxKind.CallExpression && (<CallExpression>n).expression.kind === SyntaxKind.SuperKeyword;
|
||||
}
|
||||
|
||||
@@ -1047,7 +1047,7 @@ namespace ts {
|
||||
/**
|
||||
* Determines whether a node is a property or element access expression for super.
|
||||
*/
|
||||
export function isSuperProperty(node: Node): node is (PropertyAccessExpression | ElementAccessExpression) {
|
||||
export function isSuperProperty(node: Node): node is SuperProperty {
|
||||
const kind = node.kind;
|
||||
return (kind === SyntaxKind.PropertyAccessExpression || kind === SyntaxKind.ElementAccessExpression)
|
||||
&& (<PropertyAccessExpression | ElementAccessExpression>node).expression.kind === SyntaxKind.SuperKeyword;
|
||||
@@ -1375,7 +1375,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration) {
|
||||
export function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport {
|
||||
if (node.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
return <ImportEqualsDeclaration>node;
|
||||
}
|
||||
@@ -2459,7 +2459,7 @@ namespace ts {
|
||||
return file.moduleName || getExternalModuleNameFromPath(host, file.fileName);
|
||||
}
|
||||
|
||||
export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): string {
|
||||
export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string {
|
||||
const file = resolver.getExternalModuleFileFromDeclaration(declaration);
|
||||
if (!file || isDeclarationFile(file)) {
|
||||
return undefined;
|
||||
@@ -2707,15 +2707,35 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
export function getSetAccessorTypeAnnotationNode(accessor: AccessorDeclaration): TypeNode {
|
||||
/** Get the type annotaion for the value parameter. */
|
||||
export function getSetAccessorTypeAnnotationNode(accessor: SetAccessorDeclaration): TypeNode {
|
||||
if (accessor && accessor.parameters.length > 0) {
|
||||
const hasThis = accessor.parameters.length === 2 &&
|
||||
accessor.parameters[0].name.kind === SyntaxKind.Identifier &&
|
||||
(accessor.parameters[0].name as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword;
|
||||
const hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
|
||||
return accessor.parameters[hasThis ? 1 : 0].type;
|
||||
}
|
||||
}
|
||||
|
||||
export function getThisParameter(signature: SignatureDeclaration): ParameterDeclaration | undefined {
|
||||
if (signature.parameters.length) {
|
||||
const thisParameter = signature.parameters[0];
|
||||
if (parameterIsThisKeyword(thisParameter)) {
|
||||
return thisParameter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function parameterIsThisKeyword(parameter: ParameterDeclaration): boolean {
|
||||
return isThisIdentifier(parameter.name);
|
||||
}
|
||||
|
||||
export function isThisIdentifier(node: Node | undefined): boolean {
|
||||
return node && node.kind === SyntaxKind.Identifier && identifierIsThisKeyword(node as Identifier);
|
||||
}
|
||||
|
||||
export function identifierIsThisKeyword(id: Identifier): boolean {
|
||||
return id.originalKeywordKind === SyntaxKind.ThisKeyword;
|
||||
}
|
||||
|
||||
export interface AllAccessorDeclarations {
|
||||
firstAccessor: AccessorDeclaration;
|
||||
secondAccessor: AccessorDeclaration;
|
||||
@@ -3605,14 +3625,14 @@ namespace ts {
|
||||
return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken;
|
||||
}
|
||||
|
||||
function isTemplateLiteralFragmentKind(kind: SyntaxKind) {
|
||||
return kind === SyntaxKind.TemplateHead
|
||||
|| kind === SyntaxKind.TemplateMiddle
|
||||
|| kind === SyntaxKind.TemplateTail;
|
||||
export function isTemplateHead(node: Node): node is TemplateHead {
|
||||
return node.kind === SyntaxKind.TemplateHead;
|
||||
}
|
||||
|
||||
export function isTemplateLiteralFragment(node: Node): node is TemplateLiteralFragment {
|
||||
return isTemplateLiteralFragmentKind(node.kind);
|
||||
export function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.TemplateMiddle
|
||||
|| kind === SyntaxKind.TemplateTail;
|
||||
}
|
||||
|
||||
// Identifiers
|
||||
@@ -3778,7 +3798,7 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.CallExpression;
|
||||
}
|
||||
|
||||
export function isTemplate(node: Node): node is Template {
|
||||
export function isTemplateLiteral(node: Node): node is TemplateLiteral {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.TemplateExpression
|
||||
|| kind === SyntaxKind.NoSubstitutionTemplateLiteral;
|
||||
|
||||
@@ -799,7 +799,7 @@ namespace ts {
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
return updateTaggedTemplate(<TaggedTemplateExpression>node,
|
||||
visitNode((<TaggedTemplateExpression>node).tag, visitor, isExpression),
|
||||
visitNode((<TaggedTemplateExpression>node).template, visitor, isTemplate));
|
||||
visitNode((<TaggedTemplateExpression>node).template, visitor, isTemplateLiteral));
|
||||
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return updateParen(<ParenthesizedExpression>node,
|
||||
@@ -862,7 +862,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.TemplateExpression:
|
||||
return updateTemplateExpression(<TemplateExpression>node,
|
||||
visitNode((<TemplateExpression>node).head, visitor, isTemplateLiteralFragment),
|
||||
visitNode((<TemplateExpression>node).head, visitor, isTemplateHead),
|
||||
visitNodes((<TemplateExpression>node).templateSpans, visitor, isTemplateSpan));
|
||||
|
||||
case SyntaxKind.YieldExpression:
|
||||
@@ -890,7 +890,7 @@ namespace ts {
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return updateTemplateSpan(<TemplateSpan>node,
|
||||
visitNode((<TemplateSpan>node).expression, visitor, isExpression),
|
||||
visitNode((<TemplateSpan>node).literal, visitor, isTemplateLiteralFragment));
|
||||
visitNode((<TemplateSpan>node).literal, visitor, isTemplateMiddleOrTemplateTail));
|
||||
|
||||
// Element
|
||||
case SyntaxKind.Block:
|
||||
|
||||
@@ -754,6 +754,13 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListIsGlobal(expected: boolean) {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
if (completions && completions.isGlobalCompletion !== expected) {
|
||||
this.raiseError(`verifyCompletionListIsGlobal failed - expected result to be ${completions.isGlobalCompletion}`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
if (completions) {
|
||||
@@ -3046,6 +3053,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifyCompletionListIsEmpty(this.negative);
|
||||
}
|
||||
|
||||
public completionListIsGlobal(expected: boolean) {
|
||||
this.state.verifyCompletionListIsGlobal(expected);
|
||||
}
|
||||
|
||||
public completionListAllowsNewIdentifier() {
|
||||
this.state.verifyCompletionListAllowsNewIdentifier(this.negative);
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ namespace Harness {
|
||||
tryEnableSourceMapsForHost?(): void;
|
||||
getEnvironmentVariable?(name: string): string;
|
||||
}
|
||||
export var IO: IO;
|
||||
export let IO: IO;
|
||||
|
||||
// harness always uses one kind of new line
|
||||
const harnessNewLine = "\r\n";
|
||||
@@ -925,7 +925,7 @@ namespace Harness {
|
||||
export const defaultLibFileName = "lib.d.ts";
|
||||
export const es2015DefaultLibFileName = "lib.es2015.d.ts";
|
||||
|
||||
const libFileNameSourceFileMap= ts.createMap<ts.SourceFile>({
|
||||
const libFileNameSourceFileMap = ts.createMap<ts.SourceFile>({
|
||||
[defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest)
|
||||
});
|
||||
|
||||
|
||||
@@ -1898,6 +1898,64 @@ namespace ts.projectSystem {
|
||||
projectService.closeExternalProject(projectName);
|
||||
projectService.checkNumberOfProjects({});
|
||||
});
|
||||
|
||||
it("correctly handles changes in lib section of config file", () => {
|
||||
const libES5 = {
|
||||
path: "/compiler/lib.es5.d.ts",
|
||||
content: "declare const eval: any"
|
||||
};
|
||||
const libES2015Promise = {
|
||||
path: "/compiler/lib.es2015.promise.d.ts",
|
||||
content: "declare class Promise<T> {}"
|
||||
};
|
||||
const app = {
|
||||
path: "/src/app.ts",
|
||||
content: "var x: Promise<string>;"
|
||||
};
|
||||
const config1 = {
|
||||
path: "/src/tsconfig.json",
|
||||
content: JSON.stringify(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": true,
|
||||
"sourceMap": false,
|
||||
"lib": [
|
||||
"es5"
|
||||
]
|
||||
}
|
||||
})
|
||||
};
|
||||
const config2 = {
|
||||
path: config1.path,
|
||||
content: JSON.stringify(
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": true,
|
||||
"sourceMap": false,
|
||||
"lib": [
|
||||
"es5",
|
||||
"es2015.promise"
|
||||
]
|
||||
}
|
||||
})
|
||||
};
|
||||
const host = createServerHost([libES5, libES2015Promise, app, config1], { executingFilePath: "/compiler/tsc.js" });
|
||||
const projectService = createProjectService(host);
|
||||
projectService.openClientFile(app.path);
|
||||
|
||||
projectService.checkNumberOfProjects({ configuredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.configuredProjects[0], [libES5.path, app.path]);
|
||||
|
||||
host.reloadFS([libES5, libES2015Promise, app, config2]);
|
||||
host.triggerFileWatcherCallback(config1.path);
|
||||
|
||||
projectService.checkNumberOfProjects({ configuredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.configuredProjects[0], [libES5.path, libES2015Promise.path, app.path]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("prefer typings to js", () => {
|
||||
|
||||
Vendored
+24
@@ -1200,6 +1200,30 @@ interface Array<T> {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
|
||||
@@ -214,6 +214,7 @@ namespace ts.server {
|
||||
const response = this.processResponse<protocol.CompletionsResponse>(request);
|
||||
|
||||
return {
|
||||
isGlobalCompletion: false,
|
||||
isMemberCompletion: false,
|
||||
isNewIdentifierLocation: false,
|
||||
entries: response.body.map(entry => {
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ts.server {
|
||||
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
|
||||
|
||||
export type ProjectServiceEvent =
|
||||
{ eventName: "context", data: { project: Project, fileName: NormalizedPath } } | { eventName: "configFileDiag", data: { triggerFile?: string, configFileName: string, diagnostics: Diagnostic[] } }
|
||||
{ eventName: "context", data: { project: Project, fileName: NormalizedPath } } | { eventName: "configFileDiag", data: { triggerFile?: string, configFileName: string, diagnostics: Diagnostic[] } };
|
||||
|
||||
export interface ProjectServiceEventHandler {
|
||||
(event: ProjectServiceEvent): void;
|
||||
|
||||
Vendored
+6
@@ -606,6 +606,12 @@ declare namespace ts.server.protocol {
|
||||
/** Defines space handling after opening and before closing non empty brackets. Default value is false. */
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean;
|
||||
|
||||
/** Defines space handling before and after template string braces. Default value is false. */
|
||||
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
|
||||
|
||||
/** Defines space handling before and after JSX expression braces. Default value is false. */
|
||||
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
|
||||
|
||||
/** Defines whether an open brace is put onto a new line for functions or not. Default value is false. */
|
||||
placeOpenBraceOnNewLineForFunctions?: boolean;
|
||||
|
||||
|
||||
@@ -523,6 +523,8 @@ namespace ts.server {
|
||||
process.on("uncaughtException", function (err: Error) {
|
||||
ioSession.logError(err, "unknown");
|
||||
});
|
||||
// See https://github.com/Microsoft/TypeScript/issues/11348
|
||||
(process as any).noAsar = true;
|
||||
// Start listening
|
||||
ioSession.listen();
|
||||
}
|
||||
@@ -1109,7 +1109,7 @@ namespace ts.server {
|
||||
|
||||
private getNavigationBarItems(args: protocol.FileRequestArgs, simplifiedResult: boolean): protocol.NavigationBarItem[] | NavigationBarItem[] {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const items = project.getLanguageService().getNavigationBarItems(file);
|
||||
const items = project.getLanguageService(/*ensureSynchronized*/ false).getNavigationBarItems(file);
|
||||
if (!items) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"utilities.ts",
|
||||
"scriptVersionCache.ts",
|
||||
"scriptInfo.ts",
|
||||
"lshost.ts",
|
||||
"lsHost.ts",
|
||||
"typingsCache.ts",
|
||||
"project.ts",
|
||||
"editorServices.ts",
|
||||
|
||||
@@ -954,8 +954,7 @@ namespace ts {
|
||||
return;
|
||||
case SyntaxKind.Parameter:
|
||||
if ((<ParameterDeclaration>token.parent).name === token) {
|
||||
const isThis = token.kind === SyntaxKind.Identifier && (<Identifier>token).originalKeywordKind === SyntaxKind.ThisKeyword;
|
||||
return isThis ? ClassificationType.keyword : ClassificationType.parameterName;
|
||||
return isThisIdentifier(token) ? ClassificationType.keyword : ClassificationType.parameterName;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+19
-11
@@ -14,17 +14,17 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData;
|
||||
const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData;
|
||||
|
||||
if (isJsDocTagName) {
|
||||
// If the current position is a jsDoc tag name, only tag names should be provided for completion
|
||||
return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getAllJsDocCompletionEntries() };
|
||||
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getAllJsDocCompletionEntries() };
|
||||
}
|
||||
|
||||
const entries: CompletionEntry[] = [];
|
||||
|
||||
if (isSourceFileJavaScript(sourceFile)) {
|
||||
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ false);
|
||||
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true);
|
||||
addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames));
|
||||
}
|
||||
else {
|
||||
@@ -56,7 +56,7 @@ namespace ts.Completions {
|
||||
addRange(entries, keywordCompletions);
|
||||
}
|
||||
|
||||
return { isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries };
|
||||
return { isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries };
|
||||
|
||||
function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map<string>): CompletionEntry[] {
|
||||
const entries: CompletionEntry[] = [];
|
||||
@@ -138,7 +138,9 @@ namespace ts.Completions {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (node.parent.kind === SyntaxKind.PropertyAssignment && node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
if (node.parent.kind === SyntaxKind.PropertyAssignment &&
|
||||
node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression &&
|
||||
(<PropertyAssignment>node.parent).name === node) {
|
||||
// Get quoted name of properties of the object literal expression
|
||||
// i.e. interface ConfigFiles {
|
||||
// 'jspm:dev': string
|
||||
@@ -190,7 +192,7 @@ namespace ts.Completions {
|
||||
if (type) {
|
||||
getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/false);
|
||||
if (entries.length) {
|
||||
return { isMemberCompletion: true, isNewIdentifierLocation: true, entries };
|
||||
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,7 +211,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
if (entries.length) {
|
||||
return { isMemberCompletion: false, isNewIdentifierLocation: true, entries };
|
||||
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries };
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -221,7 +223,7 @@ namespace ts.Completions {
|
||||
if (type) {
|
||||
getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/false);
|
||||
if (entries.length) {
|
||||
return { isMemberCompletion: true, isNewIdentifierLocation: true, entries };
|
||||
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries };
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
@@ -233,7 +235,7 @@ namespace ts.Completions {
|
||||
const entries: CompletionEntry[] = [];
|
||||
addStringLiteralCompletionsFromType(type, entries);
|
||||
if (entries.length) {
|
||||
return { isMemberCompletion: false, isNewIdentifierLocation: false, entries };
|
||||
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries };
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
@@ -281,6 +283,7 @@ namespace ts.Completions {
|
||||
entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span);
|
||||
}
|
||||
return {
|
||||
isGlobalCompletion: false,
|
||||
isMemberCompletion: false,
|
||||
isNewIdentifierLocation: true,
|
||||
entries
|
||||
@@ -558,6 +561,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
return {
|
||||
isGlobalCompletion: false,
|
||||
isMemberCompletion: false,
|
||||
isNewIdentifierLocation: true,
|
||||
entries
|
||||
@@ -812,7 +816,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
if (isJsDocTagName) {
|
||||
return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName };
|
||||
return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName };
|
||||
}
|
||||
|
||||
if (!insideJsDocTagExpression) {
|
||||
@@ -884,6 +888,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
const semanticStart = timestamp();
|
||||
let isGlobalCompletion = false;
|
||||
let isMemberCompletion: boolean;
|
||||
let isNewIdentifierLocation: boolean;
|
||||
let symbols: Symbol[] = [];
|
||||
@@ -919,14 +924,16 @@ namespace ts.Completions {
|
||||
if (!tryGetGlobalSymbols()) {
|
||||
return undefined;
|
||||
}
|
||||
isGlobalCompletion = true;
|
||||
}
|
||||
|
||||
log("getCompletionData: Semantic work: " + (timestamp() - semanticStart));
|
||||
|
||||
return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName };
|
||||
return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName };
|
||||
|
||||
function getTypeScriptMemberSymbols(): void {
|
||||
// Right of dot member completion list
|
||||
isGlobalCompletion = false;
|
||||
isMemberCompletion = true;
|
||||
isNewIdentifierLocation = false;
|
||||
|
||||
@@ -996,6 +1003,7 @@ namespace ts.Completions {
|
||||
if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) {
|
||||
// Cursor is inside a JSX self-closing element or opening element
|
||||
attrsType = typeChecker.getJsxElementAttributesType(<JsxOpeningLikeElement>jsxContainer);
|
||||
isGlobalCompletion = false;
|
||||
|
||||
if (attrsType) {
|
||||
symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), (<JsxOpeningLikeElement>jsxContainer).attributes);
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace ts.formatting {
|
||||
return rangeContainsRange((<InterfaceDeclaration>parent).members, node);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
const body = (<ModuleDeclaration>parent).body;
|
||||
return body && body.kind === SyntaxKind.Block && rangeContainsRange((<Block>body).statements, node);
|
||||
return body && body.kind === SyntaxKind.ModuleBlock && rangeContainsRange((<ModuleBlock>body).statements, node);
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
|
||||
@@ -332,7 +332,7 @@ namespace ts.formatting {
|
||||
(<CallExpression>node.parent).expression !== node) {
|
||||
|
||||
const fullCallOrNewExpression = (<CallExpression | NewExpression>node.parent).expression;
|
||||
const startingExpression = getStartingExpression(<PropertyAccessExpression | CallExpression | ElementAccessExpression>fullCallOrNewExpression);
|
||||
const startingExpression = getStartingExpression(fullCallOrNewExpression);
|
||||
|
||||
if (fullCallOrNewExpression === startingExpression) {
|
||||
return Value.Unknown;
|
||||
@@ -350,15 +350,14 @@ namespace ts.formatting {
|
||||
|
||||
return Value.Unknown;
|
||||
|
||||
function getStartingExpression(node: PropertyAccessExpression | CallExpression | ElementAccessExpression) {
|
||||
function getStartingExpression(node: Expression) {
|
||||
while (true) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
|
||||
node = <PropertyAccessExpression | CallExpression | ElementAccessExpression | PropertyAccessExpression>node.expression;
|
||||
node = (<PropertyAccessExpression | CallExpression | NewExpression | ElementAccessExpression | PropertyAccessExpression>node).expression;
|
||||
break;
|
||||
default:
|
||||
return node;
|
||||
|
||||
+32
-10
@@ -29,9 +29,9 @@ namespace ts {
|
||||
/** The version of the language service API */
|
||||
export const servicesVersion = "0.5";
|
||||
|
||||
function createNode(kind: SyntaxKind, pos: number, end: number, parent?: Node): NodeObject | TokenObject | IdentifierObject {
|
||||
function createNode<TKind extends SyntaxKind>(kind: TKind, pos: number, end: number, parent?: Node): NodeObject | TokenObject<TKind> | IdentifierObject {
|
||||
const node = kind >= SyntaxKind.FirstNode ? new NodeObject(kind, pos, end) :
|
||||
kind === SyntaxKind.Identifier ? new IdentifierObject(kind, pos, end) :
|
||||
kind === SyntaxKind.Identifier ? new IdentifierObject(SyntaxKind.Identifier, pos, end) :
|
||||
new TokenObject(kind, pos, end);
|
||||
node.parent = parent;
|
||||
return node;
|
||||
@@ -210,14 +210,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
class TokenOrIdentifierObject implements Token {
|
||||
class TokenOrIdentifierObject implements Node {
|
||||
public kind: SyntaxKind;
|
||||
public pos: number;
|
||||
public end: number;
|
||||
public flags: NodeFlags;
|
||||
public parent: Node;
|
||||
public jsDocComments: JSDoc[];
|
||||
public __tokenTag: any;
|
||||
|
||||
constructor(pos: number, end: number) {
|
||||
// Set properties in same order as NodeObject
|
||||
@@ -319,16 +318,25 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
class TokenObject extends TokenOrIdentifierObject {
|
||||
public kind: SyntaxKind;
|
||||
constructor(kind: SyntaxKind, pos: number, end: number) {
|
||||
class TokenObject<TKind extends SyntaxKind> extends TokenOrIdentifierObject implements Token<TKind> {
|
||||
public kind: TKind;
|
||||
|
||||
constructor(kind: TKind, pos: number, end: number) {
|
||||
super(pos, end);
|
||||
this.kind = kind;
|
||||
}
|
||||
}
|
||||
|
||||
class IdentifierObject extends TokenOrIdentifierObject {
|
||||
constructor(kind: SyntaxKind, pos: number, end: number) {
|
||||
class IdentifierObject extends TokenOrIdentifierObject implements Identifier {
|
||||
public kind: SyntaxKind.Identifier;
|
||||
public text: string;
|
||||
_primaryExpressionBrand: any;
|
||||
_memberExpressionBrand: any;
|
||||
_leftHandSideExpressionBrand: any;
|
||||
_incrementExpressionBrand: any;
|
||||
_unaryExpressionBrand: any;
|
||||
_expressionBrand: any;
|
||||
constructor(kind: SyntaxKind.Identifier, pos: number, end: number) {
|
||||
super(pos, end);
|
||||
}
|
||||
}
|
||||
@@ -424,6 +432,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
class SourceFileObject extends NodeObject implements SourceFile {
|
||||
public kind: SyntaxKind.SourceFile;
|
||||
public _declarationBrand: any;
|
||||
public fileName: string;
|
||||
public path: Path;
|
||||
@@ -432,7 +441,7 @@ namespace ts {
|
||||
public lineMap: number[];
|
||||
|
||||
public statements: NodeArray<Statement>;
|
||||
public endOfFileToken: Node;
|
||||
public endOfFileToken: Token<SyntaxKind.EndOfFileToken>;
|
||||
|
||||
public amdDependencies: { name: string; path: string }[];
|
||||
public moduleName: string;
|
||||
@@ -1512,12 +1521,25 @@ namespace ts {
|
||||
return NavigationBar.getNavigationBarItems(sourceFile);
|
||||
}
|
||||
|
||||
function isTsOrTsxFile(fileName: string): boolean {
|
||||
const kind = getScriptKind(fileName, host);
|
||||
return kind === ScriptKind.TS || kind === ScriptKind.TSX;
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
if (!isTsOrTsxFile(fileName)) {
|
||||
// do not run semantic classification on non-ts-or-tsx files
|
||||
return [];
|
||||
}
|
||||
synchronizeHostData();
|
||||
return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span);
|
||||
}
|
||||
|
||||
function getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications {
|
||||
if (!isTsOrTsxFile(fileName)) {
|
||||
// do not run semantic classification on non-ts-or-tsx files
|
||||
return { spans: [], endOfLineState: EndOfLineState.None };
|
||||
}
|
||||
synchronizeHostData();
|
||||
return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span);
|
||||
}
|
||||
|
||||
@@ -114,12 +114,12 @@ namespace ts.SymbolDisplay {
|
||||
}
|
||||
|
||||
// try get the call/construct signature from the type if it matches
|
||||
let callExpression: CallExpression;
|
||||
let callExpression: CallExpression | NewExpression;
|
||||
if (location.kind === SyntaxKind.CallExpression || location.kind === SyntaxKind.NewExpression) {
|
||||
callExpression = <CallExpression>location;
|
||||
callExpression = <CallExpression | NewExpression>location;
|
||||
}
|
||||
else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) {
|
||||
callExpression = <CallExpression>location.parent;
|
||||
callExpression = <CallExpression | NewExpression>location.parent;
|
||||
}
|
||||
|
||||
if (callExpression) {
|
||||
|
||||
@@ -503,6 +503,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface CompletionInfo {
|
||||
isGlobalCompletion: boolean;
|
||||
isMemberCompletion: boolean;
|
||||
isNewIdentifierLocation: boolean; // true when the current location also allows for a new identifier
|
||||
entries: CompletionEntry[];
|
||||
|
||||
@@ -376,7 +376,7 @@ namespace ts {
|
||||
return true;
|
||||
case SyntaxKind.Identifier:
|
||||
// 'this' as a parameter
|
||||
return (node as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword && node.parent.kind === SyntaxKind.Parameter;
|
||||
return identifierIsThisKeyword(node as Identifier) && node.parent.kind === SyntaxKind.Parameter;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(10,11): error TS2304: Cann
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty2.ts (2 errors) ====
|
||||
module M {
|
||||
var Symbol;
|
||||
var Symbol: any;
|
||||
|
||||
export class C {
|
||||
[Symbol.iterator]() { }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [ES5SymbolProperty2.ts]
|
||||
module M {
|
||||
var Symbol;
|
||||
var Symbol: any;
|
||||
|
||||
export class C {
|
||||
[Symbol.iterator]() { }
|
||||
|
||||
@@ -2,7 +2,7 @@ tests/cases/conformance/Symbols/ES5SymbolProperty3.ts(4,6): error TS2471: A comp
|
||||
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty3.ts (1 errors) ====
|
||||
var Symbol;
|
||||
var Symbol: any;
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//// [ES5SymbolProperty3.ts]
|
||||
var Symbol;
|
||||
var Symbol: any;
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
|
||||
@@ -1,10 +1,31 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,1): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,1): error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,1): error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,5): error TS2304: Cannot find name 'A'.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,7): error TS2304: Cannot find name 'B'.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,9): error TS1127: Invalid character.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,11): error TS2304: Cannot find name 'C'.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,14): error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,14): error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts (9 errors) ====
|
||||
Foo<A,B,\ C>(4, 5, 6);
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
~~~~~
|
||||
!!! error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
~~~~~~~
|
||||
!!! error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'B'.
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
!!! error TS1127: Invalid character.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'C'.
|
||||
~
|
||||
!!! error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
~~~~
|
||||
!!! error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
@@ -2,4 +2,5 @@
|
||||
Foo<A,B,\ C>(4, 5, 6);
|
||||
|
||||
//// [TypeArgumentList1.js]
|
||||
Foo(4, 5, 6);
|
||||
Foo < A, B, ;
|
||||
C > (4, 5, 6);
|
||||
|
||||
@@ -35,16 +35,16 @@ paired.reduce((b3, b4) => b3.concat({}), []);
|
||||
>b3 : Symbol(b3, Decl(anyInferenceAnonymousFunctions.ts, 13, 15))
|
||||
|
||||
paired.map((c1) => c1.count);
|
||||
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12))
|
||||
>c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12))
|
||||
|
||||
paired.map(function (c2) { return c2.count; });
|
||||
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21))
|
||||
>c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21))
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ paired.reduce((b3, b4) => b3.concat({}), []);
|
||||
|
||||
paired.map((c1) => c1.count);
|
||||
>paired.map((c1) => c1.count) : any[]
|
||||
>paired.map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
|
||||
>paired.map : { <U>(this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; <U>(this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; }
|
||||
>paired : any[]
|
||||
>map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; <U>(this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; }
|
||||
>(c1) => c1.count : (c1: any) => any
|
||||
>c1 : any
|
||||
>c1.count : any
|
||||
@@ -68,9 +68,9 @@ paired.map((c1) => c1.count);
|
||||
|
||||
paired.map(function (c2) { return c2.count; });
|
||||
>paired.map(function (c2) { return c2.count; }) : any[]
|
||||
>paired.map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
|
||||
>paired.map : { <U>(this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; <U>(this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; }
|
||||
>paired : any[]
|
||||
>map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; <U>(this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; }
|
||||
>function (c2) { return c2.count; } : (c2: any) => any
|
||||
>c2 : any
|
||||
>c2.count : any
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//// [anyPlusAny1.ts]
|
||||
var x;
|
||||
var x: any;
|
||||
x.name = "hello";
|
||||
var z = x + x;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/compiler/anyPlusAny1.ts ===
|
||||
var x;
|
||||
var x: any;
|
||||
>x : Symbol(x, Decl(anyPlusAny1.ts, 0, 3))
|
||||
|
||||
x.name = "hello";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/compiler/anyPlusAny1.ts ===
|
||||
var x;
|
||||
var x: any;
|
||||
>x : any
|
||||
|
||||
x.name = "hello";
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
=== tests/cases/compiler/arrayConcatMap.ts ===
|
||||
var x = [].concat([{ a: 1 }], [{ a: 2 }])
|
||||
>x : Symbol(x, Decl(arrayConcatMap.ts, 0, 3))
|
||||
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 20))
|
||||
>a : Symbol(a, Decl(arrayConcatMap.ts, 0, 32))
|
||||
|
||||
.map(b => b.a);
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15))
|
||||
>b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15))
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
var x = [].concat([{ a: 1 }], [{ a: 2 }])
|
||||
>x : any[]
|
||||
>[].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a) : any[]
|
||||
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
|
||||
>[].concat([{ a: 1 }], [{ a: 2 }]) .map : { <U>(this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; <U>(this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; }
|
||||
>[].concat([{ a: 1 }], [{ a: 2 }]) : any[]
|
||||
>[].concat : { (...items: any[][]): any[]; (...items: any[]): any[]; }
|
||||
>[] : undefined[]
|
||||
@@ -17,7 +17,7 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }])
|
||||
>2 : 2
|
||||
|
||||
.map(b => b.a);
|
||||
>map : <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; <U>(this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; }
|
||||
>b => b.a : (b: any) => any
|
||||
>b : any
|
||||
>b.a : any
|
||||
|
||||
@@ -10,10 +10,10 @@ var Foo;
|
||||
>Foo : any
|
||||
|
||||
type
|
||||
>type : any
|
||||
>type : undefined
|
||||
|
||||
Foo = string;
|
||||
>Foo = string : any
|
||||
>Foo = string : undefined
|
||||
>Foo : any
|
||||
>string : any
|
||||
>string : undefined
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@ var e = undefined;
|
||||
>undefined : undefined
|
||||
|
||||
x = e;
|
||||
>x = e : any
|
||||
>x = e : undefined
|
||||
>x : any
|
||||
>e : any
|
||||
>e : undefined
|
||||
|
||||
var e2: typeof undefined;
|
||||
>e2 : any
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//// [assignmentLHSIsReference.ts]
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// identifiers: variable and parameter
|
||||
var x1: number;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsReference.ts ===
|
||||
var value;
|
||||
var value: any;
|
||||
>value : Symbol(value, Decl(assignmentLHSIsReference.ts, 0, 3))
|
||||
|
||||
// identifiers: variable and parameter
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsReference.ts ===
|
||||
var value;
|
||||
var value: any;
|
||||
>value : any
|
||||
|
||||
// identifiers: variable and parameter
|
||||
|
||||
@@ -41,7 +41,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
|
||||
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
|
||||
// expected error for all the LHS of assignments
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [assignmentLHSIsValue.ts]
|
||||
// expected error for all the LHS of assignments
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
// Repro from #10041
|
||||
|
||||
(''.match(/ /) || []).map(s => s.toLowerCase());
|
||||
>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 3, 26))
|
||||
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 3, 26))
|
||||
@@ -28,9 +28,9 @@ function f1() {
|
||||
|
||||
let z = y.map(s => s.toLowerCase());
|
||||
>z : Symbol(z, Decl(bestChoiceType.ts, 10, 7))
|
||||
>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(bestChoiceType.ts, 9, 7))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 10, 18))
|
||||
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 10, 18))
|
||||
@@ -52,9 +52,9 @@ function f2() {
|
||||
|
||||
let z = y.map(s => s.toLowerCase());
|
||||
>z : Symbol(z, Decl(bestChoiceType.ts, 16, 7))
|
||||
>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(bestChoiceType.ts, 15, 7))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 16, 18))
|
||||
>s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(bestChoiceType.ts, 16, 18))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
(''.match(/ /) || []).map(s => s.toLowerCase());
|
||||
>(''.match(/ /) || []).map(s => s.toLowerCase()) : string[]
|
||||
>(''.match(/ /) || []).map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>(''.match(/ /) || []).map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
||||
>(''.match(/ /) || []) : RegExpMatchArray
|
||||
>''.match(/ /) || [] : RegExpMatchArray
|
||||
>''.match(/ /) : RegExpMatchArray | null
|
||||
@@ -13,7 +13,7 @@
|
||||
>match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; }
|
||||
>/ / : RegExp
|
||||
>[] : never[]
|
||||
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
||||
>s => s.toLowerCase() : (s: string) => string
|
||||
>s : string
|
||||
>s.toLowerCase() : string
|
||||
@@ -43,9 +43,9 @@ function f1() {
|
||||
let z = y.map(s => s.toLowerCase());
|
||||
>z : string[]
|
||||
>y.map(s => s.toLowerCase()) : string[]
|
||||
>y.map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>y.map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
||||
>y : RegExpMatchArray
|
||||
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
||||
>s => s.toLowerCase() : (s: string) => string
|
||||
>s : string
|
||||
>s.toLowerCase() : string
|
||||
@@ -75,9 +75,9 @@ function f2() {
|
||||
let z = y.map(s => s.toLowerCase());
|
||||
>z : string[]
|
||||
>y.map(s => s.toLowerCase()) : string[]
|
||||
>y.map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>y.map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
||||
>y : RegExpMatchArray
|
||||
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
||||
>s => s.toLowerCase() : (s: string) => string
|
||||
>s : string
|
||||
>s.toLowerCase() : string
|
||||
|
||||
@@ -39,7 +39,7 @@ for (let x = 0; x < 1; ++x) {
|
||||
}
|
||||
|
||||
switch (x) {
|
||||
>x : any
|
||||
>x : undefined
|
||||
|
||||
case 1:
|
||||
>1 : 1
|
||||
|
||||
@@ -40,7 +40,7 @@ for (let x = 0; x < 1; ++x) {
|
||||
}
|
||||
|
||||
switch (x) {
|
||||
>x : any
|
||||
>x : undefined
|
||||
|
||||
case 1:
|
||||
>1 : 1
|
||||
|
||||
@@ -4,9 +4,9 @@ var s: string[];
|
||||
>s : Symbol(s, Decl(commentInMethodCall.ts, 1, 3))
|
||||
|
||||
s.map(// do something
|
||||
>s.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>s.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(commentInMethodCall.ts, 1, 3))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
function () { });
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ var s: string[];
|
||||
|
||||
s.map(// do something
|
||||
>s.map(// do something function () { }) : void[]
|
||||
>s.map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>s.map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
||||
>s : string[]
|
||||
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; <U>(this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; }
|
||||
|
||||
function () { });
|
||||
>function () { } : () => void
|
||||
|
||||
@@ -17,7 +17,7 @@ foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b);
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
>a + b : any
|
||||
>a : any
|
||||
>a : undefined
|
||||
>b : any
|
||||
|
||||
foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b);
|
||||
@@ -26,7 +26,7 @@ foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b);
|
||||
>function () { } : () => void
|
||||
>() => { } : () => void
|
||||
>a + /*e3*/ b : any
|
||||
>a : any
|
||||
>a : undefined
|
||||
>b : any
|
||||
|
||||
foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b));
|
||||
@@ -36,7 +36,7 @@ foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b));
|
||||
>() => { } : () => void
|
||||
>(a + b) : any
|
||||
>a + b : any
|
||||
>a : any
|
||||
>a : undefined
|
||||
>b : any
|
||||
|
||||
foo(
|
||||
|
||||
@@ -9,12 +9,12 @@ var x1: number;
|
||||
x1 *= value;
|
||||
>x1 *= value : number
|
||||
>x1 : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
x1 += value;
|
||||
>x1 += value : any
|
||||
>x1 += value : number
|
||||
>x1 : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
function fn1(x2: number) {
|
||||
>fn1 : (x2: number) => void
|
||||
@@ -41,41 +41,41 @@ x3.a *= value;
|
||||
>x3.a : number
|
||||
>x3 : { a: number; }
|
||||
>a : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
x3.a += value;
|
||||
>x3.a += value : any
|
||||
>x3.a += value : number
|
||||
>x3.a : number
|
||||
>x3 : { a: number; }
|
||||
>a : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
x3['a'] *= value;
|
||||
>x3['a'] *= value : number
|
||||
>x3['a'] : number
|
||||
>x3 : { a: number; }
|
||||
>'a' : "a"
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
x3['a'] += value;
|
||||
>x3['a'] += value : any
|
||||
>x3['a'] += value : number
|
||||
>x3['a'] : number
|
||||
>x3 : { a: number; }
|
||||
>'a' : "a"
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
// parentheses, the contained expression is reference
|
||||
(x1) *= value;
|
||||
>(x1) *= value : number
|
||||
>(x1) : number
|
||||
>x1 : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
(x1) += value;
|
||||
>(x1) += value : any
|
||||
>(x1) += value : number
|
||||
>(x1) : number
|
||||
>x1 : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
function fn2(x4: number) {
|
||||
>fn2 : (x4: number) => void
|
||||
@@ -100,15 +100,15 @@ function fn2(x4: number) {
|
||||
>x3.a : number
|
||||
>x3 : { a: number; }
|
||||
>a : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
(x3.a) += value;
|
||||
>(x3.a) += value : any
|
||||
>(x3.a) += value : number
|
||||
>(x3.a) : number
|
||||
>x3.a : number
|
||||
>x3 : { a: number; }
|
||||
>a : number
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
(x3['a']) *= value;
|
||||
>(x3['a']) *= value : number
|
||||
@@ -116,13 +116,13 @@ function fn2(x4: number) {
|
||||
>x3['a'] : number
|
||||
>x3 : { a: number; }
|
||||
>'a' : "a"
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
(x3['a']) += value;
|
||||
>(x3['a']) += value : any
|
||||
>(x3['a']) += value : number
|
||||
>(x3['a']) : number
|
||||
>x3['a'] : number
|
||||
>x3 : { a: number; }
|
||||
>'a' : "a"
|
||||
>value : any
|
||||
>value : undefined
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsVa
|
||||
==== tests/cases/conformance/expressions/assignmentOperator/compoundAssignmentLHSIsValue.ts (74 errors) ====
|
||||
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//// [compoundAssignmentLHSIsValue.ts]
|
||||
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//// [compoundExponentiationAssignmentLHSIsReference.ts]
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// identifiers: variable and parameter
|
||||
var x1: number;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsReference.ts ===
|
||||
var value;
|
||||
var value: any;
|
||||
>value : Symbol(value, Decl(compoundExponentiationAssignmentLHSIsReference.ts, 0, 3))
|
||||
|
||||
// identifiers: variable and parameter
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
=== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsReference.ts ===
|
||||
var value;
|
||||
var value: any;
|
||||
>value : any
|
||||
|
||||
// identifiers: variable and parameter
|
||||
|
||||
@@ -40,7 +40,7 @@ tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignm
|
||||
|
||||
==== tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSIsValue.ts (38 errors) ====
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [compoundExponentiationAssignmentLHSIsValue.ts]
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
var value: any;
|
||||
|
||||
// this
|
||||
class C {
|
||||
|
||||
@@ -35,20 +35,20 @@ var a;
|
||||
>a : any
|
||||
|
||||
foo(a);
|
||||
>foo(a) : any
|
||||
>foo(a) : undefined
|
||||
>foo : <T extends String>(x: T) => T
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
foo2(a);
|
||||
>foo2(a) : any
|
||||
>foo2(a) : undefined
|
||||
>foo2 : <T extends { x: number; }>(x: T) => T
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
//foo3(a);
|
||||
foo4(a);
|
||||
>foo4(a) : any
|
||||
>foo4(a) : undefined
|
||||
>foo4 : <T extends <T>(x: T) => void>(x: T) => T
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
var b: number;
|
||||
>b : number
|
||||
@@ -84,10 +84,10 @@ class C<T extends String> {
|
||||
}
|
||||
|
||||
var c1 = new C(a);
|
||||
>c1 : C<any>
|
||||
>new C(a) : C<any>
|
||||
>c1 : C<undefined>
|
||||
>new C(a) : C<undefined>
|
||||
>C : typeof C
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
var c2 = new C<any>(b);
|
||||
>c2 : C<any>
|
||||
@@ -106,10 +106,10 @@ class C2<T extends { x: number }> {
|
||||
}
|
||||
|
||||
var c3 = new C2(a);
|
||||
>c3 : C2<any>
|
||||
>new C2(a) : C2<any>
|
||||
>c3 : C2<undefined>
|
||||
>new C2(a) : C2<undefined>
|
||||
>C2 : typeof C2
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
var c4 = new C2<any>(b);
|
||||
>c4 : C2<any>
|
||||
@@ -138,10 +138,10 @@ class C4<T extends <T>(x:T) => T> {
|
||||
}
|
||||
|
||||
var c7 = new C4(a);
|
||||
>c7 : C4<any>
|
||||
>new C4(a) : C4<any>
|
||||
>c7 : C4<undefined>
|
||||
>new C4(a) : C4<undefined>
|
||||
>C4 : typeof C4
|
||||
>a : any
|
||||
>a : undefined
|
||||
|
||||
var c8 = new C4<any>(b);
|
||||
>c8 : C4<any>
|
||||
|
||||
@@ -12,9 +12,9 @@ function map<T, U>(items: T[], f: (x: T) => U): U[]{
|
||||
>U : Symbol(U, Decl(contextualSignatureInstantiation3.ts, 0, 15))
|
||||
|
||||
return items.map(f);
|
||||
>items.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>items.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>items : Symbol(items, Decl(contextualSignatureInstantiation3.ts, 0, 19))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>f : Symbol(f, Decl(contextualSignatureInstantiation3.ts, 0, 30))
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ var v1: number[];
|
||||
|
||||
var v1 = xs.map(identity); // Error if not number[]
|
||||
>v1 : Symbol(v1, Decl(contextualSignatureInstantiation3.ts, 15, 3), Decl(contextualSignatureInstantiation3.ts, 16, 3), Decl(contextualSignatureInstantiation3.ts, 17, 3))
|
||||
>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>identity : Symbol(identity, Decl(contextualSignatureInstantiation3.ts, 2, 1))
|
||||
|
||||
var v1 = map(xs, identity); // Error if not number[]
|
||||
@@ -63,9 +63,9 @@ var v2: number[][];
|
||||
|
||||
var v2 = xs.map(singleton); // Error if not number[][]
|
||||
>v2 : Symbol(v2, Decl(contextualSignatureInstantiation3.ts, 19, 3), Decl(contextualSignatureInstantiation3.ts, 20, 3), Decl(contextualSignatureInstantiation3.ts, 21, 3))
|
||||
>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>singleton : Symbol(singleton, Decl(contextualSignatureInstantiation3.ts, 6, 1))
|
||||
|
||||
var v2 = map(xs, singleton); // Error if not number[][]
|
||||
|
||||
@@ -13,9 +13,9 @@ function map<T, U>(items: T[], f: (x: T) => U): U[]{
|
||||
|
||||
return items.map(f);
|
||||
>items.map(f) : U[]
|
||||
>items.map : <U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]
|
||||
>items.map : { <U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; <U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; }
|
||||
>items : T[]
|
||||
>map : <U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; <U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; }
|
||||
>f : (x: T) => U
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ var v1: number[];
|
||||
var v1 = xs.map(identity); // Error if not number[]
|
||||
>v1 : number[]
|
||||
>xs.map(identity) : number[]
|
||||
>xs.map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>xs.map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>xs : number[]
|
||||
>map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>identity : <T>(x: T) => T
|
||||
|
||||
var v1 = map(xs, identity); // Error if not number[]
|
||||
@@ -72,9 +72,9 @@ var v2: number[][];
|
||||
var v2 = xs.map(singleton); // Error if not number[][]
|
||||
>v2 : number[][]
|
||||
>xs.map(singleton) : number[][]
|
||||
>xs.map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>xs.map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>xs : number[]
|
||||
>map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>singleton : <T>(x: T) => T[]
|
||||
|
||||
var v2 = map(xs, singleton); // Error if not number[][]
|
||||
|
||||
@@ -73,9 +73,9 @@
|
||||
>first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2))
|
||||
>rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8))
|
||||
>first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2))
|
||||
>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43))
|
||||
>n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43))
|
||||
|
||||
|
||||
@@ -160,9 +160,9 @@
|
||||
>first : number
|
||||
>[] : undefined[]
|
||||
>rest.map(n => n > 0) : boolean[]
|
||||
>rest.map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>rest.map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>rest : number[]
|
||||
>map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; <U>(this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; }
|
||||
>n => n > 0 : (n: number) => boolean
|
||||
>n : number
|
||||
>n > 0 : boolean
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
tests/cases/compiler/controlFlowCaching.ts(38,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(38,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(40,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(40,29): error TS2339: Property 'x' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(42,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(42,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(44,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(44,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(46,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(46,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(48,17): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(48,29): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(53,5): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(53,14): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(55,14): error TS2678: Type '"start"' is not comparable to type 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(58,14): error TS2678: Type '"end"' is not comparable to type 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(61,14): error TS2678: Type '"middle"' is not comparable to type 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(62,13): error TS2532: Object is possibly 'undefined'.
|
||||
tests/cases/compiler/controlFlowCaching.ts(62,25): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/controlFlowCaching.ts (19 errors) ====
|
||||
|
||||
// Repro for #8401
|
||||
|
||||
function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) {
|
||||
var isRtl = this._isRtl(); // chart mirroring
|
||||
// prepare variable
|
||||
var o = this.opt, ta = this.chart.theme.axis, position = o.position,
|
||||
leftBottom = position !== "rightOrTop", rotation = o.rotation % 360,
|
||||
start, stop, titlePos, titleRotation = 0, titleOffset, axisVector, tickVector, anchorOffset, labelOffset, labelAlign,
|
||||
labelGap = this.chart.theme.axis.tick.labelGap,
|
||||
taFont = o.font || (ta.majorTick && ta.majorTick.font) || (ta.tick && ta.tick.font),
|
||||
taTitleFont = o.titleFont || (ta.title && ta.title.font),
|
||||
taFontColor = o.fontColor || (ta.majorTick && ta.majorTick.fontColor) || (ta.tick && ta.tick.fontColor) || "black",
|
||||
taTitleFontColor = o.titleFontColor || (ta.title && ta.title.fontColor) || "black",
|
||||
taTitleGap = (o.titleGap == 0) ? 0 : o.titleGap || (ta.title && ta.title.gap) || 15,
|
||||
taTitleOrientation = o.titleOrientation || (ta.title && ta.title.orientation) || "axis",
|
||||
taMajorTick = this.chart.theme.getTick("major", o),
|
||||
taMinorTick = this.chart.theme.getTick("minor", o),
|
||||
taMicroTick = this.chart.theme.getTick("micro", o),
|
||||
|
||||
taStroke = "stroke" in o ? o.stroke : ta.stroke,
|
||||
size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0,
|
||||
cosr = Math.abs(Math.cos(rotation * Math.PI / 180)),
|
||||
sinr = Math.abs(Math.sin(rotation * Math.PI / 180)),
|
||||
tsize = taTitleFont ? g.normalizedLength(g.splitFontString(taTitleFont).size) : 0;
|
||||
if (rotation < 0) {
|
||||
rotation += 360;
|
||||
}
|
||||
var cachedLabelW = this._getMaxLabelSize();
|
||||
cachedLabelW = cachedLabelW && cachedLabelW.majLabelW;
|
||||
titleOffset = size * cosr + (cachedLabelW || 0) * sinr + labelGap + Math.max(taMajorTick.length > 0 ? taMajorTick.length : 0,
|
||||
taMinorTick.length > 0 ? taMinorTick.length : 0) +
|
||||
tsize + taTitleGap;
|
||||
axisVector = { x: isRtl ? -1 : 1, y: 0 }; // chart mirroring
|
||||
switch (rotation) {
|
||||
default:
|
||||
if (rotation < (90 - centerAnchorLimit)) {
|
||||
labelOffset.y = leftBottom ? size : 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
} else if (rotation < (90 + centerAnchorLimit)) {
|
||||
labelOffset.x = -size * 0.4;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'never'.
|
||||
} else if (rotation < 180) {
|
||||
labelOffset.y = leftBottom ? 0 : -size;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
} else if (rotation < (270 - centerAnchorLimit)) {
|
||||
labelOffset.y = leftBottom ? 0 : -size;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
} else if (rotation < (270 + centerAnchorLimit)) {
|
||||
labelOffset.y = leftBottom ? size * 0.4 : 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
} else {
|
||||
labelOffset.y = leftBottom ? size : 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
}
|
||||
}
|
||||
|
||||
titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0;
|
||||
titlePos.y = offsets.t - titleOffset + (titleRotation ? 0 : tsize);
|
||||
~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
switch (labelAlign) {
|
||||
case "start":
|
||||
~~~~~~~
|
||||
!!! error TS2678: Type '"start"' is not comparable to type 'undefined'.
|
||||
labelAlign = "end";
|
||||
break;
|
||||
case "end":
|
||||
~~~~~
|
||||
!!! error TS2678: Type '"end"' is not comparable to type 'undefined'.
|
||||
labelAlign = "start";
|
||||
break;
|
||||
case "middle":
|
||||
~~~~~~~~
|
||||
!!! error TS2678: Type '"middle"' is not comparable to type 'undefined'.
|
||||
labelOffset.y -= size;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2532: Object is possibly 'undefined'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
break;
|
||||
}
|
||||
|
||||
let _ = rotation;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
|
||||
[{ x: 1 }].map(
|
||||
>[{ x: 1 }].map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>[{ x: 1 }].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 3, 2))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
({ x }) => x
|
||||
>x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 4, 4))
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
[{ x: 1 }].map(
|
||||
>[{ x: 1 }].map( ({ x }) => x) : number[]
|
||||
>[{ x: 1 }].map : <U>(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any) => U[]
|
||||
>[{ x: 1 }].map : { <U>(this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U]; <U>(this: [{ x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; }
|
||||
>[{ x: 1 }] : { x: number; }[]
|
||||
>{ x: 1 } : { x: number; }
|
||||
>x : number
|
||||
>1 : 1
|
||||
>map : <U>(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any) => U[]
|
||||
>map : { <U>(this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U, U]; <U>(this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U]; <U>(this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U]; <U>(this: [{ x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U]; <U>(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; }
|
||||
|
||||
({ x }) => x
|
||||
>({ x }) => x : ({x}: { x: number; }) => number
|
||||
|
||||
@@ -118,7 +118,7 @@ maybeNumber++;
|
||||
|
||||
if (maybeNumber !== undefined) {
|
||||
>maybeNumber !== undefined : boolean
|
||||
>maybeNumber : number | undefined
|
||||
>maybeNumber : number
|
||||
>undefined : undefined
|
||||
|
||||
maybeNumber++;
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
//// [controlFlowLetVar.ts]
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
let x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
let x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
let x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
function f() {
|
||||
const z = x; // any
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
const f = () => {
|
||||
const z = x; // any
|
||||
};
|
||||
}
|
||||
|
||||
//// [controlFlowLetVar.js]
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | null
|
||||
}
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // any
|
||||
}
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | null
|
||||
}
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // any
|
||||
}
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
function f() {
|
||||
var z = x; // any
|
||||
}
|
||||
}
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
var f = function () {
|
||||
var z = x; // any
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
=== tests/cases/compiler/controlFlowLetVar.ts ===
|
||||
|
||||
declare let cond: boolean;
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
>f1 : Symbol(f1, Decl(controlFlowLetVar.ts, 1, 26))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 12, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 5, 7))
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
>f2 : Symbol(f2, Decl(controlFlowLetVar.ts, 13, 1))
|
||||
|
||||
let x = undefined;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 24, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 17, 7))
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
>f3 : Symbol(f3, Decl(controlFlowLetVar.ts, 25, 1))
|
||||
|
||||
let x = null;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 36, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 29, 7))
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
>f4 : Symbol(f4, Decl(controlFlowLetVar.ts, 37, 1))
|
||||
|
||||
let x: any;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
|
||||
}
|
||||
const y = x; // any
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 48, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 41, 7))
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
>f5 : Symbol(f5, Decl(controlFlowLetVar.ts, 49, 1))
|
||||
|
||||
var x;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 60, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 53, 7))
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
>f6 : Symbol(f6, Decl(controlFlowLetVar.ts, 61, 1))
|
||||
|
||||
var x = undefined;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 72, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 65, 7))
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
>f7 : Symbol(f7, Decl(controlFlowLetVar.ts, 73, 1))
|
||||
|
||||
var x = null;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 84, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 77, 7))
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
>f8 : Symbol(f8, Decl(controlFlowLetVar.ts, 85, 1))
|
||||
|
||||
var x: any;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
|
||||
}
|
||||
const y = x; // any
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 96, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 89, 7))
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
>f9 : Symbol(f9, Decl(controlFlowLetVar.ts, 97, 1))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 108, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
|
||||
function f() {
|
||||
>f : Symbol(f, Decl(controlFlowLetVar.ts, 108, 16))
|
||||
|
||||
const z = x; // any
|
||||
>z : Symbol(z, Decl(controlFlowLetVar.ts, 110, 13))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 101, 7))
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
>f10 : Symbol(f10, Decl(controlFlowLetVar.ts, 112, 1))
|
||||
|
||||
let x;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = 1;
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
}
|
||||
if (cond) {
|
||||
>cond : Symbol(cond, Decl(controlFlowLetVar.ts, 1, 11))
|
||||
|
||||
x = "hello";
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : Symbol(y, Decl(controlFlowLetVar.ts, 123, 9))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
|
||||
const f = () => {
|
||||
>f : Symbol(f, Decl(controlFlowLetVar.ts, 124, 9))
|
||||
|
||||
const z = x; // any
|
||||
>z : Symbol(z, Decl(controlFlowLetVar.ts, 125, 13))
|
||||
>x : Symbol(x, Decl(controlFlowLetVar.ts, 116, 7))
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
=== tests/cases/compiler/controlFlowLetVar.ts ===
|
||||
|
||||
declare let cond: boolean;
|
||||
>cond : boolean
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
>f1 : () => void
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
>f2 : () => void
|
||||
|
||||
let x = undefined;
|
||||
>x : any
|
||||
>undefined : undefined
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
>f3 : () => void
|
||||
|
||||
let x = null;
|
||||
>x : any
|
||||
>null : null
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
>y : string | number | null
|
||||
>x : string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
>f4 : () => void
|
||||
|
||||
let x: any;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // any
|
||||
>y : any
|
||||
>x : any
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
>f5 : () => void
|
||||
|
||||
var x;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
>f6 : () => void
|
||||
|
||||
var x = undefined;
|
||||
>x : any
|
||||
>undefined : undefined
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
>f7 : () => void
|
||||
|
||||
var x = null;
|
||||
>x : any
|
||||
>null : null
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
>y : string | number | null
|
||||
>x : string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
>f8 : () => void
|
||||
|
||||
var x: any;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // any
|
||||
>y : any
|
||||
>x : any
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
>f9 : () => void
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
|
||||
function f() {
|
||||
>f : () => void
|
||||
|
||||
const z = x; // any
|
||||
>z : any
|
||||
>x : any
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
>f10 : () => void
|
||||
|
||||
let x;
|
||||
>x : any
|
||||
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = 1;
|
||||
>x = 1 : 1
|
||||
>x : any
|
||||
>1 : 1
|
||||
}
|
||||
if (cond) {
|
||||
>cond : boolean
|
||||
|
||||
x = "hello";
|
||||
>x = "hello" : "hello"
|
||||
>x : any
|
||||
>"hello" : "hello"
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
>y : string | number | undefined
|
||||
>x : string | number | undefined
|
||||
|
||||
const f = () => {
|
||||
>f : () => void
|
||||
>() => { const z = x; // any } : () => void
|
||||
|
||||
const z = x; // any
|
||||
>z : any
|
||||
>x : any
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
tests/cases/compiler/controlFlowNoImplicitAny.ts(102,9): error TS7034: Variable 'x' implicitly has type 'any' in some locations where its type cannot be determined.
|
||||
tests/cases/compiler/controlFlowNoImplicitAny.ts(111,19): error TS7005: Variable 'x' implicitly has an 'any' type.
|
||||
tests/cases/compiler/controlFlowNoImplicitAny.ts(117,9): error TS7034: Variable 'x' implicitly has type 'any' in some locations where its type cannot be determined.
|
||||
tests/cases/compiler/controlFlowNoImplicitAny.ts(126,19): error TS7005: Variable 'x' implicitly has an 'any' type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/controlFlowNoImplicitAny.ts (4 errors) ====
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
let x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
let x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
let x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
let x;
|
||||
~
|
||||
!!! error TS7034: Variable 'x' implicitly has type 'any' in some locations where its type cannot be determined.
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
function f() {
|
||||
const z = x; // any
|
||||
~
|
||||
!!! error TS7005: Variable 'x' implicitly has an 'any' type.
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
let x;
|
||||
~
|
||||
!!! error TS7034: Variable 'x' implicitly has type 'any' in some locations where its type cannot be determined.
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
const f = () => {
|
||||
const z = x; // any
|
||||
~
|
||||
!!! error TS7005: Variable 'x' implicitly has an 'any' type.
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
//// [controlFlowNoImplicitAny.ts]
|
||||
|
||||
declare let cond: boolean;
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
let x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
let x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
let x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
function f() {
|
||||
const z = x; // any
|
||||
}
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
let x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // string | number | undefined
|
||||
const f = () => {
|
||||
const z = x; // any
|
||||
};
|
||||
}
|
||||
|
||||
//// [controlFlowNoImplicitAny.js]
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
function f1() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
function f2() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
function f3() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | null
|
||||
}
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // any
|
||||
}
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
}
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | null
|
||||
}
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // any
|
||||
}
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
function f() {
|
||||
var z = x; // any
|
||||
}
|
||||
}
|
||||
// No CFA for captured outer variables
|
||||
function f10() {
|
||||
var x;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
var y = x; // string | number | undefined
|
||||
var f = function () {
|
||||
var z = x; // any
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [declarationEmitTypeAliasWithTypeParameters1.ts]
|
||||
|
||||
export type Bar<X, Y> = () => [X, Y];
|
||||
export type Foo<Y> = Bar<any, Y>;
|
||||
export const y = (x: Foo<string>) => 1
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters1.js]
|
||||
"use strict";
|
||||
exports.y = function (x) { return 1; };
|
||||
|
||||
|
||||
//// [declarationEmitTypeAliasWithTypeParameters1.d.ts]
|
||||
export declare type Bar<X, Y> = () => [X, Y];
|
||||
export declare type Foo<Y> = Bar<any, Y>;
|
||||
export declare const y: (x: () => [any, string]) => number;
|
||||
@@ -0,0 +1,20 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters1.ts ===
|
||||
|
||||
export type Bar<X, Y> = () => [X, Y];
|
||||
>Bar : Symbol(Bar, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 0, 0))
|
||||
>X : Symbol(X, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 1, 16))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 1, 18))
|
||||
>X : Symbol(X, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 1, 16))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 1, 18))
|
||||
|
||||
export type Foo<Y> = Bar<any, Y>;
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 1, 37))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 2, 16))
|
||||
>Bar : Symbol(Bar, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 0, 0))
|
||||
>Y : Symbol(Y, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 2, 16))
|
||||
|
||||
export const y = (x: Foo<string>) => 1
|
||||
>y : Symbol(y, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 3, 12))
|
||||
>x : Symbol(x, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 3, 18))
|
||||
>Foo : Symbol(Foo, Decl(declarationEmitTypeAliasWithTypeParameters1.ts, 1, 37))
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters1.ts ===
|
||||
|
||||
export type Bar<X, Y> = () => [X, Y];
|
||||
>Bar : Bar<X, Y>
|
||||
>X : X
|
||||
>Y : Y
|
||||
>X : X
|
||||
>Y : Y
|
||||
|
||||
export type Foo<Y> = Bar<any, Y>;
|
||||
>Foo : () => [any, Y]
|
||||
>Y : Y
|
||||
>Bar : Bar<X, Y>
|
||||
>Y : Y
|
||||
|
||||
export const y = (x: Foo<string>) => 1
|
||||
>y : (x: () => [any, string]) => number
|
||||
>(x: Foo<string>) => 1 : (x: () => [any, string]) => number
|
||||
>x : () => [any, string]
|
||||
>Foo : () => [any, Y]
|
||||
>1 : 1
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// -- operator on any type
|
||||
|
||||
var ANY: any;
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
var ANY2: any[] = ["", ""];
|
||||
var obj = {x:1,y:null};
|
||||
class A {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
var ANY: any;
|
||||
>ANY : Symbol(ANY, Decl(decrementOperatorWithAnyOtherType.ts, 2, 3))
|
||||
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
>ANY1 : Symbol(ANY1, Decl(decrementOperatorWithAnyOtherType.ts, 3, 3))
|
||||
|
||||
var ANY2: any[] = ["", ""];
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
var ANY: any;
|
||||
>ANY : any
|
||||
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
>ANY1 : any
|
||||
|
||||
var ANY2: any[] = ["", ""];
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
|
||||
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (50 errors) ====
|
||||
// -- operator on any type
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
var ANY2: any[] = ["", ""];
|
||||
|
||||
var obj: () => {}
|
||||
@@ -63,7 +63,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
|
||||
}
|
||||
class A {
|
||||
public a: any;
|
||||
static foo() {
|
||||
static foo(): any {
|
||||
var a;
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [decrementOperatorWithAnyOtherTypeInvalidOperations.ts]
|
||||
// -- operator on any type
|
||||
var ANY1;
|
||||
var ANY1: any;
|
||||
var ANY2: any[] = ["", ""];
|
||||
|
||||
var obj: () => {}
|
||||
@@ -11,7 +11,7 @@ function foo(): any {
|
||||
}
|
||||
class A {
|
||||
public a: any;
|
||||
static foo() {
|
||||
static foo(): any {
|
||||
var a;
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -77,22 +77,22 @@ use(x);
|
||||
use(z0);
|
||||
>use(z0) : any
|
||||
>use : (a: any) => any
|
||||
>z0 : any
|
||||
>z0 : undefined
|
||||
|
||||
use(z1);
|
||||
>use(z1) : any
|
||||
>use : (a: any) => any
|
||||
>z1 : any
|
||||
>z1 : undefined
|
||||
|
||||
use(z2);
|
||||
>use(z2) : any
|
||||
>use : (a: any) => any
|
||||
>z2 : any
|
||||
>z2 : undefined
|
||||
|
||||
use(z3);
|
||||
>use(z3) : any
|
||||
>use : (a: any) => any
|
||||
>z3 : any
|
||||
>z3 : undefined
|
||||
|
||||
var z6;
|
||||
>z6 : any
|
||||
@@ -149,7 +149,7 @@ use(y);
|
||||
use(z6);
|
||||
>use(z6) : any
|
||||
>use : (a: any) => any
|
||||
>z6 : any
|
||||
>z6 : undefined
|
||||
|
||||
var z = false;
|
||||
>z : boolean
|
||||
|
||||
@@ -83,22 +83,22 @@ use(x);
|
||||
use(z0);
|
||||
>use(z0) : any
|
||||
>use : (a: any) => any
|
||||
>z0 : any
|
||||
>z0 : undefined
|
||||
|
||||
use(z1);
|
||||
>use(z1) : any
|
||||
>use : (a: any) => any
|
||||
>z1 : any
|
||||
>z1 : undefined
|
||||
|
||||
use(z2);
|
||||
>use(z2) : any
|
||||
>use : (a: any) => any
|
||||
>z2 : any
|
||||
>z2 : undefined
|
||||
|
||||
use(z3);
|
||||
>use(z3) : any
|
||||
>use : (a: any) => any
|
||||
>z3 : any
|
||||
>z3 : undefined
|
||||
|
||||
var z6;
|
||||
>z6 : any
|
||||
@@ -155,7 +155,7 @@ use(y);
|
||||
use(z6);
|
||||
>use(z6) : any
|
||||
>use : (a: any) => any
|
||||
>z6 : any
|
||||
>z6 : undefined
|
||||
|
||||
var z = false;
|
||||
>z : boolean
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user