diff --git a/Gulpfile.ts b/Gulpfile.ts index 296e374a53..022606e133 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -1024,7 +1024,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: const fileMatcher = cmdLineOptions["files"]; const files = fileMatcher ? `src/**/${fileMatcher}` - : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/harness/unittests/services/**/*.ts'"; + : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; console.log("Linting: " + cmd); child_process.execSync(cmd, { stdio: [0, 1, 2] }); diff --git a/Jakefile.js b/Jakefile.js index 9c2b3d38d1..c9390f560a 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -29,7 +29,8 @@ var thirdParty = "ThirdPartyNoticeText.txt"; var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter; if (process.env.path !== undefined) { process.env.path = nodeModulesPathPrefix + process.env.path; -} else if (process.env.PATH !== undefined) { +} +else if (process.env.PATH !== undefined) { process.env.PATH = nodeModulesPathPrefix + process.env.PATH; } @@ -312,13 +313,15 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts if (useDebugMode) { if (opts.inlineSourceMap) { options += " --inlineSourceMap --inlineSources"; - } else { + } + else { options += " -sourcemap"; if (!opts.noMapRoot) { options += " -mapRoot file:///" + path.resolve(path.dirname(outFile)); } } - } else { + } + else { options += " --newLine LF"; } @@ -748,7 +751,8 @@ function exec(cmd, completeHandler, errorHandler) { ex.addListener("error", function (e, status) { if (errorHandler) { errorHandler(e, status); - } else { + } + else { fail("Process exited with code " + status); } }); @@ -942,7 +946,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () { // Browser tests var nodeServerOutFile = "tests/webTestServer.js"; var nodeServerInFile = "tests/webTestServer.ts"; -compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true }); +compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true, lib: "es6" }); desc("Runs browserify on run.js to produce a file suitable for running tests in the browser"); task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() { @@ -1006,21 +1010,32 @@ task("baseline-accept", function () { function acceptBaseline(sourceFolder, targetFolder) { console.log('Accept baselines from ' + sourceFolder + ' to ' + targetFolder); - var files = fs.readdirSync(sourceFolder); var deleteEnding = '.delete'; - for (var i in files) { - var filename = files[i]; - var fullLocalPath = path.join(sourceFolder, filename); - if (fs.statSync(fullLocalPath).isFile()) { - if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) { - filename = filename.substr(0, filename.length - deleteEnding.length); - fs.unlinkSync(path.join(targetFolder, filename)); - } else { - var target = path.join(targetFolder, filename); - if (fs.existsSync(target)) { - fs.unlinkSync(target); + + acceptBaselineFolder(sourceFolder, targetFolder); + + function acceptBaselineFolder(sourceFolder, targetFolder) { + var files = fs.readdirSync(sourceFolder); + + for (var i in files) { + var filename = files[i]; + var fullLocalPath = path.join(sourceFolder, filename); + var stat = fs.statSync(fullLocalPath); + if (stat.isFile()) { + if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) { + filename = filename.substr(0, filename.length - deleteEnding.length); + fs.unlinkSync(path.join(targetFolder, filename)); } - fs.renameSync(path.join(sourceFolder, filename), target); + else { + var target = path.join(targetFolder, filename); + if (fs.existsSync(target)) { + fs.unlinkSync(target); + } + fs.renameSync(path.join(sourceFolder, filename), target); + } + } + else if (stat.isDirectory()) { + acceptBaselineFolder(fullLocalPath, path.join(targetFolder, filename)); } } } @@ -1182,7 +1197,7 @@ task("lint", ["build-rules"], () => { const fileMatcher = process.env.f || process.env.file || process.env.files; const files = fileMatcher ? `src/**/${fileMatcher}` - : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/harness/unittests/services/**/*.ts'"; + : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; console.log("Linting: " + cmd); jake.exec([cmd], { interactive: true }, () => { diff --git a/lib/tsc.js b/lib/tsc.js index be8abfb4a0..f7231fcafd 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -53977,7 +53977,7 @@ var ts; var padding = makePadding(marginLength); output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine); output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine); - output.push(padding + "tsc @args.txt" + ts.sys.newLine); + output.push(padding + "tsc --project tsconfig.json" + ts.sys.newLine); output.push(ts.sys.newLine); output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); var optsList = ts.filter(ts.optionDeclarations.slice(), function (v) { return !v.experimental; }); diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 650797c6db..45e8efdf51 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -259,7 +259,7 @@ namespace ts { case SyntaxKind.ExportAssignment: return (node).isExportEquals ? "export=" : "default"; case SyntaxKind.BinaryExpression: - switch (getSpecialPropertyAssignmentKind(node)) { + switch (getSpecialPropertyAssignmentKind(node as BinaryExpression)) { case SpecialPropertyAssignmentKind.ModuleExports: // module.exports = ... return "export="; @@ -2017,30 +2017,28 @@ namespace ts { } break; case SyntaxKind.BinaryExpression: - if (isInJavaScriptFile(node)) { - const specialKind = getSpecialPropertyAssignmentKind(node); - switch (specialKind) { - case SpecialPropertyAssignmentKind.ExportsProperty: - bindExportsPropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.ModuleExports: - bindModuleExportsAssignment(node); - break; - case SpecialPropertyAssignmentKind.PrototypeProperty: - bindPrototypePropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.ThisProperty: - bindThisPropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.Property: - bindStaticPropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.None: - // Nothing to do - break; - default: - Debug.fail("Unknown special property assignment kind"); - } + const specialKind = getSpecialPropertyAssignmentKind(node as BinaryExpression); + switch (specialKind) { + case SpecialPropertyAssignmentKind.ExportsProperty: + bindExportsPropertyAssignment(node); + break; + case SpecialPropertyAssignmentKind.ModuleExports: + bindModuleExportsAssignment(node); + break; + case SpecialPropertyAssignmentKind.PrototypeProperty: + bindPrototypePropertyAssignment(node); + break; + case SpecialPropertyAssignmentKind.ThisProperty: + bindThisPropertyAssignment(node); + break; + case SpecialPropertyAssignmentKind.Property: + bindStaticPropertyAssignment(node); + break; + case SpecialPropertyAssignmentKind.None: + // Nothing to do + break; + default: + Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); case SyntaxKind.CatchClause: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b581ca315b..73ec48c78b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -61,6 +61,7 @@ namespace ts { const noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; const emitResolver = createResolver(); + const nodeBuilder = createNodeBuilder(); const undefinedSymbol = createSymbol(SymbolFlags.Property, "undefined"); undefinedSymbol.declarations = []; @@ -106,6 +107,9 @@ namespace ts { getParameterType: getTypeAtPosition, getReturnTypeOfSignature, getNonNullableType, + typeToTypeNode: nodeBuilder.typeToTypeNode, + indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -284,6 +288,8 @@ namespace ts { let deferredGlobalAsyncIterableIteratorType: GenericType; let deferredGlobalTemplateStringsArrayType: ObjectType; let deferredJsxElementClassType: Type; + let deferredJsxElementType: Type; + let deferredJsxStatelessElementType: Type; let deferredNodes: Node[]; let deferredUnusedIdentifierNodes: Node[]; @@ -404,7 +410,6 @@ namespace ts { }); const typeofType = createTypeofType(); - let jsxElementType: Type; let _jsxNamespace: string; let _jsxFactoryEntity: EntityName; @@ -1068,9 +1073,10 @@ namespace ts { // block-scoped variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped - if (meaning & SymbolFlags.BlockScopedVariable) { + if (meaning & SymbolFlags.BlockScopedVariable || + ((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) { const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable) { + if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class || exportOrLocalSymbol.flags & SymbolFlags.Enum) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } @@ -1183,14 +1189,22 @@ namespace ts { } function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { - Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0); + Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class || result.flags & SymbolFlags.Enum)); // Block-scoped variables cannot be used before their definition - const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined); + const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) || (d.kind === SyntaxKind.EnumDeclaration) ? d : undefined); - Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); + Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { - error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name)); + if (result.flags & SymbolFlags.BlockScopedVariable) { + error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name)); + } + else if (result.flags & SymbolFlags.Class) { + error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationNameToString(declaration.name)); + } + else if (result.flags & SymbolFlags.Enum) { + error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationNameToString(declaration.name)); + } } } @@ -2188,6 +2202,584 @@ namespace ts { return result; } + function createNodeBuilder() { + let context: NodeBuilderContext; + + return { + typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { + context = createNodeBuilderContext(enclosingDeclaration, flags); + const resultingNode = typeToTypeNodeHelper(type); + const result = context.encounteredError ? undefined : resultingNode; + return result; + }, + indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { + context = createNodeBuilderContext(enclosingDeclaration, flags); + const resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind); + const result = context.encounteredError ? undefined : resultingNode; + return result; + }, + signatureToSignatureDeclaration: (signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { + context = createNodeBuilderContext(enclosingDeclaration, flags); + const resultingNode = signatureToSignatureDeclarationHelper(signature, kind); + const result = context.encounteredError ? undefined : resultingNode; + return result; + } + }; + + interface NodeBuilderContext { + readonly enclosingDeclaration: Node | undefined; + readonly flags: NodeBuilderFlags | undefined; + encounteredError: boolean; + inObjectTypeLiteral: boolean; + checkAlias: boolean; + symbolStack: Symbol[] | undefined; + } + + function createNodeBuilderContext(enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeBuilderContext { + return { + enclosingDeclaration, + flags, + encounteredError: false, + inObjectTypeLiteral: false, + checkAlias: true, + symbolStack: undefined + }; + } + + function typeToTypeNodeHelper(type: Type): TypeNode { + if (!type) { + context.encounteredError = true; + // TODO(aozgaa): should we return implict any (undefined) or explicit any (keywordtypenode)? + return undefined; + } + + if (type.flags & TypeFlags.Any) { + return createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + if (type.flags & TypeFlags.String) { + return createKeywordTypeNode(SyntaxKind.StringKeyword); + } + if (type.flags & TypeFlags.Number) { + return createKeywordTypeNode(SyntaxKind.NumberKeyword); + } + if (type.flags & TypeFlags.Boolean) { + return createKeywordTypeNode(SyntaxKind.BooleanKeyword); + } + if (type.flags & TypeFlags.Enum) { + const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & (TypeFlags.StringLiteral)) { + return createLiteralTypeNode((createLiteral((type).text))); + } + if (type.flags & (TypeFlags.NumberLiteral)) { + return createLiteralTypeNode((createNumericLiteral((type).text))); + } + if (type.flags & TypeFlags.BooleanLiteral) { + return (type).intrinsicName === "true" ? createTrue() : createFalse(); + } + if (type.flags & TypeFlags.EnumLiteral) { + const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & TypeFlags.Void) { + return createKeywordTypeNode(SyntaxKind.VoidKeyword); + } + if (type.flags & TypeFlags.Undefined) { + return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); + } + if (type.flags & TypeFlags.Null) { + return createKeywordTypeNode(SyntaxKind.NullKeyword); + } + if (type.flags & TypeFlags.Never) { + return createKeywordTypeNode(SyntaxKind.NeverKeyword); + } + if (type.flags & TypeFlags.ESSymbol) { + return createKeywordTypeNode(SyntaxKind.SymbolKeyword); + } + if (type.flags & TypeFlags.NonPrimitive) { + return createKeywordTypeNode(SyntaxKind.ObjectKeyword); + } + if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { + if (context.inObjectTypeLiteral) { + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowThisInObjectLiteral)) { + context.encounteredError = true; + } + } + return createThis(); + } + + const objectFlags = getObjectFlags(type); + + if (objectFlags & ObjectFlags.Reference) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + return typeReferenceToTypeNode(type); + } + if (objectFlags & ObjectFlags.ClassOrInterface) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + // TODO(aozgaa): handle type arguments. + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & TypeFlags.TypeParameter) { + const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + + if (context.checkAlias && type.aliasSymbol) { + const name = symbolToName(type.aliasSymbol, /*expectsIdentifier*/ false); + const typeArgumentNodes = type.aliasTypeArguments && mapToTypeNodeArray(type.aliasTypeArguments); + return createTypeReferenceNode(name, typeArgumentNodes); + } + context.checkAlias = false; + + if (type.flags & TypeFlags.Union) { + const formattedUnionTypes = formatUnionTypes((type).types); + const unionTypeNodes = formattedUnionTypes && mapToTypeNodeArray(formattedUnionTypes); + if (unionTypeNodes && unionTypeNodes.length > 0) { + return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, unionTypeNodes); + } + else { + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowEmptyUnionOrIntersection)) { + context.encounteredError = true; + } + return undefined; + } + } + + if (type.flags & TypeFlags.Intersection) { + return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); + } + + if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // The type is an object literal type. + return createAnonymousTypeNode(type); + } + + if (type.flags & TypeFlags.Index) { + const indexedType = (type).type; + const indexTypeNode = typeToTypeNodeHelper(indexedType); + return createTypeOperatorNode(indexTypeNode); + } + if (type.flags & TypeFlags.IndexedAccess) { + const objectTypeNode = typeToTypeNodeHelper((type).objectType); + const indexTypeNode = typeToTypeNodeHelper((type).indexType); + return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); + } + + Debug.fail("Should be unreachable."); + + function mapToTypeNodeArray(types: Type[]): TypeNode[] { + const result = []; + for (const type of types) { + const typeNode = typeToTypeNodeHelper(type); + if (typeNode) { + result.push(typeNode); + } + } + return result; + } + + function createMappedTypeNodeFromType(type: MappedType) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const typeParameter = getTypeParameterFromMappedType(type); + const typeParameterNode = typeParameterToDeclaration(typeParameter); + + const templateType = getTemplateTypeFromMappedType(type); + const templateTypeNode = typeToTypeNodeHelper(templateType); + const readonlyToken = type.declaration && type.declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; + const questionToken = type.declaration && type.declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; + + return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } + + function createAnonymousTypeNode(type: ObjectType): TypeNode { + const symbol = type.symbol; + if (symbol) { + // Always use 'typeof T' for type of class, enum, and module objects + if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || + shouldWriteTypeOfFunctionSymbol()) { + return createTypeQueryNodeFromSymbol(symbol); + } + else if (contains(context.symbolStack, symbol)) { + // If type is an anonymous type literal in a type alias declaration, use type alias name + const typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + // The specified symbol flags need to be reinterpreted as type flags + const entityName = symbolToName(typeAlias, /*expectsIdentifier*/ false); + return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); + } + else { + return createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + } + else { + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.symbolStack) { + context.symbolStack = []; + } + context.symbolStack.push(symbol); + const result = createTypeNodeFromObjectType(type); + context.symbolStack.pop(); + return result; + } + } + else { + // Anonymous types without a symbol are never circular. + return createTypeNodeFromObjectType(type); + } + + function shouldWriteTypeOfFunctionSymbol() { + const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method + forEach(symbol.declarations, declaration => getModifierFlags(declaration) & ModifierFlags.Static)); + const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && + (symbol.parent || // is exported function symbol + forEach(symbol.declarations, declaration => + declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return contains(context.symbolStack, symbol); // it is type of the symbol uses itself recursively + } + } + } + + function createTypeNodeFromObjectType(type: ObjectType): TypeNode { + if (type.objectFlags & ObjectFlags.Mapped) { + if (getConstraintTypeFromMappedType(type).flags & (TypeFlags.TypeParameter | TypeFlags.Index)) { + return createMappedTypeNodeFromType(type); + } + } + + const resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + return createTypeLiteralNode(/*members*/ undefined); + } + + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + const signature = resolved.callSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, SyntaxKind.FunctionType); + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + const signature = resolved.constructSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructorType); + } + } + + const saveInObjectTypeLiteral = context.inObjectTypeLiteral; + context.inObjectTypeLiteral = true; + const members = createTypeNodesFromResolvedType(resolved); + context.inObjectTypeLiteral = saveInObjectTypeLiteral; + return createTypeLiteralNode(members); + } + + function createTypeQueryNodeFromSymbol(symbol: Symbol) { + const entityName = symbolToName(symbol, /*expectsIdentifier*/ false); + return createTypeQueryNode(entityName); + } + + function typeReferenceToTypeNode(type: TypeReference) { + const typeArguments: Type[] = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + const elementType = typeToTypeNodeHelper(typeArguments[0]); + return createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & ObjectFlags.Tuple) { + if (typeArguments.length > 0) { + const tupleConstituentNodes = mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))); + if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + return createTupleTypeNode(tupleConstituentNodes); + } + } + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowEmptyTuple)) { + context.encounteredError = true; + } + return undefined; + } + else { + const outerTypeParameters = type.target.outerTypeParameters; + let i = 0; + let qualifiedName: QualifiedName | undefined = undefined; + if (outerTypeParameters) { + const length = outerTypeParameters.length; + while (i < length) { + // Find group of type arguments for type parameters with the same declaring container. + const start = i; + const parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + // When type parameters are their own type arguments for the whole group (i.e. we have + // the default outer type arguments), we don't show the group. + if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { + const qualifiedNamePart = symbolToName(parent, /*expectsIdentifier*/ true); + if (!qualifiedName) { + qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); + } + else { + Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); + } + } + } + } + let entityName: EntityName = undefined; + const nameIdentifier = symbolToName(type.symbol, /*expectsIdentifier*/ true); + if (qualifiedName) { + Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + const typeParameterCount = (type.target.typeParameters || emptyArray).length; + const typeArgumentNodes = some(typeArguments) ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; + return createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + + function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { + const typeElements: TypeElement[] = []; + for (const signature of resolvedType.callSignatures) { + typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.CallSignature)); + } + for (const signature of resolvedType.constructSignatures) { + typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructSignature)); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, IndexKind.String)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, IndexKind.Number)); + } + + const properties = resolvedType.properties; + if (!properties) { + return typeElements; + } + + for (const propertySymbol of properties) { + const propertyType = getTypeOfSymbol(propertySymbol); + const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement; + if (!oldDeclaration) { + return; + } + const propertyName = oldDeclaration.name; + const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined; + if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { + const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); + for (const signature of signatures) { + const methodDeclaration = signatureToSignatureDeclarationHelper(signature, SyntaxKind.MethodSignature); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); + } + } + else { + + // TODO(aozgaa): should we create a node with explicit or implict any? + const propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType) : createKeywordTypeNode(SyntaxKind.AnyKeyword); + typeElements.push(createPropertySignature( + propertyName, + optionalToken, + propertyTypeNode, + /*initializer*/undefined)); + } + } + return typeElements.length ? typeElements : undefined; + } + } + + function indexInfoToIndexSignatureDeclarationHelper(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration { + const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); + const name = getNameFromIndexInfo(indexInfo); + + const indexingParameter = createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + name, + /*questionToken*/ undefined, + indexerTypeNode, + /*initializer*/ undefined); + const typeNode = typeToTypeNodeHelper(indexInfo.type); + return createIndexSignatureDeclaration( + /*decorators*/ undefined, + indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined, + [indexingParameter], + typeNode); + } + + function signatureToSignatureDeclarationHelper(signature: Signature, kind: SyntaxKind): SignatureDeclaration { + + const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter)); + const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter)); + let returnTypeNode: TypeNode | TypePredicate; + if (signature.typePredicate) { + const typePredicate = signature.typePredicate; + const parameterName = typePredicate.kind === TypePredicateKind.Identifier ? createIdentifier((typePredicate).parameterName) : createThisTypeNode(); + const typeNode = typeToTypeNodeHelper(typePredicate.type); + returnTypeNode = createTypePredicateNode(parameterName, typeNode); + } + else { + const returnType = getReturnTypeOfSignature(signature); + returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + } + const returnTypeNodeExceptAny = returnTypeNode && returnTypeNode.kind !== SyntaxKind.AnyKeyword ? returnTypeNode : undefined; + + return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNodeExceptAny); + } + + function typeParameterToDeclaration(type: TypeParameter): TypeParameterDeclaration { + const constraint = getConstraintFromTypeParameter(type); + const constraintNode = constraint && typeToTypeNodeHelper(constraint); + const defaultParameter = getDefaultFromTypeParameter(type); + const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter); + const name = symbolToName(type.symbol, /*expectsIdentifier*/ true); + return createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); + } + + function symbolToParameterDeclaration(parameterSymbol: Symbol): ParameterDeclaration { + const parameterDeclaration = getDeclarationOfKind(parameterSymbol, SyntaxKind.Parameter); + const parameterType = getTypeOfSymbol(parameterSymbol); + const parameterTypeNode = typeToTypeNodeHelper(parameterType); + // TODO(aozgaa): In the future, check initializer accessibility. + const parameterNode = createParameter( + parameterDeclaration.decorators, + parameterDeclaration.modifiers, + parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken), + // Clone name to remove trivia. + getSynthesizedClone(parameterDeclaration.name), + parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken), + parameterTypeNode, + parameterDeclaration.initializer); + return parameterNode; + } + + function symbolToName(symbol: Symbol, expectsIdentifier: true): Identifier; + function symbolToName(symbol: Symbol, expectsIdentifier: false): EntityName; + function symbolToName(symbol: Symbol, expectsIdentifier: boolean): EntityName { + + // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. + let chain: Symbol[]; + const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; + if (!isTypeParameter && context.enclosingDeclaration) { + chain = getSymbolChain(symbol, SymbolFlags.None, /*endOfChain*/ true); + Debug.assert(chain && chain.length > 0); + } + else { + chain = [symbol]; + } + + if (expectsIdentifier && chain.length !== 1 + && !context.encounteredError + && !(context.flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier)) { + context.encounteredError = true; + } + return createEntityNameFromSymbolChain(chain, chain.length - 1); + + function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName { + Debug.assert(chain && 0 <= index && index < chain.length); + // const parentIndex = index - 1; + const symbol = chain[index]; + let typeParameterString = ""; + if (index > 0) { + + const parentSymbol = chain[index - 1]; + let typeParameters: TypeParameter[]; + if (getCheckFlags(symbol) & CheckFlags.Instantiated) { + typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); + } + else { + const targetSymbol = getTargetSymbol(parentSymbol); + if (targetSymbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeAlias)) { + typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + } + } + if (typeParameters && typeParameters.length > 0) { + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowTypeParameterInQualifiedName)) { + context.encounteredError = true; + } + const writer = getSingleLineStringWriter(); + const displayBuilder = getSymbolDisplayBuilder(); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, context.enclosingDeclaration, 0); + typeParameterString = writer.string(); + releaseStringWriter(writer); + + } + } + const symbolName = getNameOfSymbol(symbol); + const symbolNameWithTypeParameters = typeParameterString.length > 0 ? `${symbolName}<${typeParameterString}>` : symbolName; + const identifier = createIdentifier(symbolNameWithTypeParameters); + + return index > 0 ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; + } + + /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ + function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { + let accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/false); + let parentSymbol: Symbol; + + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + + // Go up and add our parent. + const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + if (parentChain) { + parentSymbol = parent; + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + } + } + } + + if (accessibleSymbolChain) { + return accessibleSymbolChain; + } + if ( + // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. + endOfChain || + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + // If a parent symbol is an anonymous type, don't write it. + !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { + + return [symbol]; + } + } + + function getNameOfSymbol(symbol: Symbol): string { + const declaration = firstOrUndefined(symbol.declarations); + if (declaration) { + if (declaration.name) { + return declarationNameToString(declaration.name); + } + if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { + return declarationNameToString((declaration.parent).name); + } + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowAnonymousIdentifier)) { + context.encounteredError = true; + } + switch (declaration.kind) { + case SyntaxKind.ClassExpression: + return "(Anonymous class)"; + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return "(Anonymous function)"; + } + } + return symbol.name; + } + } + } + function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Declaration, flags?: TypeFormatFlags): string { const writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); @@ -2456,6 +3048,7 @@ namespace ts { } } + function writeTypeList(types: Type[], delimiter: SyntaxKind) { for (let i = 0; i < types.length; i++) { if (i > 0) { @@ -3983,14 +4576,15 @@ namespace ts { return getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } - function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] { + function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[], location: Node): Signature[] { const typeArgCount = length(typeArgumentNodes); + const isJavaScript = isInJavaScriptFile(location); return filter(getSignaturesOfType(type, SignatureKind.Construct), - sig => typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= length(sig.typeParameters)); + sig => (isJavaScript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= length(sig.typeParameters)); } - function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] { - let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[], location: Node): Signature[] { + let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); if (typeArgumentNodes) { const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); signatures = map(signatures, sig => getSignatureInstantiation(sig, typeArguments)); @@ -4073,7 +4667,7 @@ namespace ts { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere // we check that all instantiated signatures return the same type. - const constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments); + const constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { error(baseTypeNode.expression, Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); return; @@ -4583,14 +5177,15 @@ namespace ts { return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } const baseTypeNode = getBaseTypeNodeOfClass(classType); + const isJavaScript = isInJavaScriptFile(baseTypeNode); const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); const typeArgCount = length(typeArguments); const result: Signature[] = []; for (const baseSig of baseSignatures) { const minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); const typeParamCount = length(baseSig.typeParameters); - if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { - const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); + if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { + const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -5423,11 +6018,12 @@ namespace ts { * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number) { + function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, location?: Node) { const numTypeParameters = length(typeParameters); if (numTypeParameters) { const numTypeArguments = length(typeArguments); - if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + const isJavaScript = isInJavaScriptFile(location); + if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; } @@ -5436,12 +6032,12 @@ namespace ts { // If a type parameter does not have a default type, or if the default type // is a forward reference, the empty object type is used. for (let i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = emptyObjectType; + typeArguments[i] = isJavaScript ? anyType : emptyObjectType; } for (let i = numTypeArguments; i < numTypeParameters; i++) { const mapper = createTypeMapper(typeParameters, typeArguments); const defaultType = getDefaultFromTypeParameter(typeParameters[i]); - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : isJavaScript ? anyType : emptyObjectType; } } } @@ -5815,7 +6411,7 @@ namespace ts { if (typeParameters) { const numTypeArguments = length(node.typeArguments); const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + if (!isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? Diagnostics.Generic_type_0_requires_1_type_argument_s @@ -5828,7 +6424,7 @@ namespace ts { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, node)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -7932,16 +8528,9 @@ namespace ts { } } else if (target.flags & TypeFlags.IndexedAccess) { - // if we have indexed access types with identical index types, see if relationship holds for - // the two object types. - if (source.flags & TypeFlags.IndexedAccess && (source).indexType === (target).indexType) { - if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { - return result; - } - } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - const constraint = getBaseConstraintOfType(target); + const constraint = getConstraintOfType(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -7988,6 +8577,13 @@ namespace ts { return result; } } + else if (target.flags & TypeFlags.IndexedAccess && (source).indexType === (target).indexType) { + // if we have indexed access types with identical index types, see if relationship holds for + // the two object types. + if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { + return result; + } + } } else { if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { @@ -8267,8 +8863,8 @@ namespace ts { maybeStack[depth].set(id, RelationComparisonResult.Succeeded); depth++; const saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; + if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; + if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; let result: Ternary; if (expandingFlags === 3) { result = Ternary.Maybe; @@ -8688,21 +9284,23 @@ namespace ts { return false; } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type: Type, stack: Type[], depth: number): boolean { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (getObjectFlags(type) & (ObjectFlags.Reference | ObjectFlags.Instantiated) && depth >= 5) { + // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons + // for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely + // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 + // levels, but unequal at some level beyond that. + function isDeeplyNestedType(type: Type, stack: Type[], depth: number): boolean { + // We track all object types that have an associated symbol (representing the origin of the type) + if (depth >= 5 && type.flags & TypeFlags.Object) { const symbol = type.symbol; - let count = 0; - for (let i = 0; i < depth; i++) { - const t = stack[i]; - if (getObjectFlags(t) & (ObjectFlags.Reference | ObjectFlags.Instantiated) && t.symbol === symbol) { - count++; - if (count >= 5) return true; + if (symbol) { + let count = 0; + for (let i = 0; i < depth; i++) { + const t = stack[i]; + if (t.flags & TypeFlags.Object && t.symbol === symbol) { + count++; + if (count >= 5) return true; + } } } } @@ -9445,7 +10043,7 @@ namespace ts { if (isInProcess(source, target)) { return; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + if (isDeeplyNestedType(source, sourceStack, depth) && isDeeplyNestedType(target, targetStack, depth)) { return; } const key = source.id + "," + target.id; @@ -11334,8 +11932,8 @@ namespace ts { // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } if (container.kind === SyntaxKind.FunctionExpression && - isInJavaScriptFile(container.parent) && - getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) { + container.parent.kind === SyntaxKind.BinaryExpression && + getSpecialPropertyAssignmentKind(container.parent as BinaryExpression) === SpecialPropertyAssignmentKind.PrototypeProperty) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') const className = (((container.parent as BinaryExpression) // x.prototype.y = f .left as PropertyAccessExpression) // x.prototype.y @@ -12453,12 +13051,12 @@ namespace ts { type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } - function checkJsxSelfClosingElement(node: JsxSelfClosingElement) { + function checkJsxSelfClosingElement(node: JsxSelfClosingElement): Type { checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } - function checkJsxElement(node: JsxElement) { + function checkJsxElement(node: JsxElement): Type { // Check attributes checkJsxOpeningLikeElement(node.openingElement); @@ -12485,7 +13083,7 @@ namespace ts { } } - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } /** @@ -12726,13 +13324,14 @@ namespace ts { function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement: JsxOpeningLikeElement, elementType: Type, elemInstanceType: Type, elementClassType?: Type): Type { Debug.assert(!(elementType.flags & TypeFlags.Union)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + const jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. const callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); if (callSignature !== unknownSignature) { const callReturnType = callSignature && getReturnTypeOfSignature(callSignature); let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); if (intrinsicAttributes !== unknownType) { @@ -12760,7 +13359,8 @@ namespace ts { Debug.assert(!(elementType.flags & TypeFlags.Union)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - if (jsxElementType) { + const jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. const candidatesOutArray: Signature[] = []; getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); @@ -12769,7 +13369,7 @@ namespace ts { for (const candidate of candidatesOutArray) { const callReturnType = getReturnTypeOfSignature(candidate); const paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { let shouldBeCandidate = true; for (const attribute of openingLikeElement.attributes.properties) { if (isJsxAttribute(attribute) && @@ -13013,6 +13613,23 @@ namespace ts { return deferredJsxElementClassType; } + function getJsxGlobalElementType(): Type { + if (!deferredJsxElementType) { + deferredJsxElementType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.Element); + } + return deferredJsxElementType; + } + + function getJsxGlobalStatelessElementType(): Type { + if (!deferredJsxStatelessElementType) { + const jsxElementType = getJsxGlobalElementType(); + if (jsxElementType) { + deferredJsxStatelessElementType = getUnionType([jsxElementType, nullType]); + } + } + return deferredJsxStatelessElementType; + } + /** * Returns all the properties of the Jsx.IntrinsicElements interface */ @@ -13027,7 +13644,7 @@ namespace ts { error(errorNode, Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } - if (jsxElementType === undefined) { + if (getJsxGlobalElementType() === undefined) { if (noImplicitAny) { error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } @@ -13322,10 +13939,17 @@ namespace ts { } return unknownType; } - if (prop.valueDeclaration && - isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + if (prop.valueDeclaration) { + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } + if (prop.valueDeclaration.kind === SyntaxKind.ClassDeclaration && + node.parent && node.parent.kind !== SyntaxKind.TypeReference && + !isInAmbientContext(prop.valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, Diagnostics.Class_0_used_before_its_declaration, right.text); + } } markPropertyAsReferenced(prop); @@ -14445,7 +15069,7 @@ namespace ts { // with the type arguments specified in the extends clause. const baseTypeNode = getClassExtendsHeritageClauseElement(getContainingClass(node)); if (baseTypeNode) { - const baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + const baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); } } @@ -15110,8 +15734,8 @@ namespace ts { else { let types: Type[]; if (functionFlags & FunctionFlags.Generator) { // Generator or AsyncGenerator function - types = checkAndAggregateYieldOperandTypes(func, checkMode); - if (types.length === 0) { + types = concatenate(checkAndAggregateYieldOperandTypes(func, checkMode), checkAndAggregateReturnExpressionTypes(func, checkMode)); + if (!types || types.length === 0) { const iterableIteratorAny = functionFlags & FunctionFlags.Async ? createAsyncIterableIteratorType(anyType) // AsyncGenerator function : createIterableIteratorType(anyType); // Generator function @@ -18752,7 +19376,7 @@ namespace ts { // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeVariable)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeVariable | TypeFlags.NonPrimitive)) { error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } @@ -19521,7 +20145,7 @@ namespace ts { } function checkClassLikeDeclaration(node: ClassLikeDeclaration) { - checkGrammarClassDeclarationHeritageClauses(node); + checkGrammarClassLikeDeclaration(node); checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0); @@ -19559,7 +20183,7 @@ namespace ts { checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { forEach(baseTypeNode.typeArguments, checkSourceElement); - for (const constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) { + for (const constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode)) { if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { break; } @@ -19572,20 +20196,12 @@ namespace ts { error(node.name || node, Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (baseType.symbol && baseType.symbol.valueDeclaration && - !isInAmbientContext(baseType.symbol.valueDeclaration) && - baseType.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) { - if (!isBlockScopedNameDeclaredBeforeUse(baseType.symbol.valueDeclaration, node)) { - error(baseTypeNode, Diagnostics.A_class_must_be_declared_after_its_base_class); - } - } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class) && !(baseConstructorType.flags & TypeFlags.TypeVariable)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked // that the base type is a class or interface type (and not, for example, an anonymous object type). - const constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + const constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); if (forEach(constructors, sig => getReturnTypeOfSignature(sig) !== baseType)) { error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type); } @@ -21028,7 +21644,7 @@ namespace ts { } function getSpecialPropertyAssignmentSymbolFromEntityName(entityName: EntityName | PropertyAccessExpression) { - const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent); + const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent as BinaryExpression); switch (specialPropertyAssignmentKind) { case SpecialPropertyAssignmentKind.ExportsProperty: case SpecialPropertyAssignmentKind.PrototypeProperty: @@ -22072,7 +22688,6 @@ namespace ts { globalNumberType = getGlobalType("Number", /*arity*/ 0, /*reportErrors*/ true); globalBooleanType = getGlobalType("Boolean", /*arity*/ 0, /*reportErrors*/ true); globalRegExpType = getGlobalType("RegExp", /*arity*/ 0, /*reportErrors*/ true); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); @@ -22491,6 +23106,11 @@ namespace ts { checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } + function checkGrammarClassLikeDeclaration(node: ClassLikeDeclaration): boolean { + const file = getSourceFileOfNode(node); + return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); + } + function checkGrammarArrowFunction(node: FunctionLikeDeclaration, file: SourceFile): boolean { if (node.kind === SyntaxKind.ArrowFunction) { const arrowFunction = node; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 4b3dc23d56..24abac1e29 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -9,40 +9,13 @@ namespace ts { export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean" }; /* @internal */ export const optionDeclarations: CommandLineOption[] = [ - { - name: "charset", - type: "string", - }, - compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, + // CommandLine only options { name: "help", shortName: "h", type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, description: Diagnostics.Print_this_message, }, { @@ -50,53 +23,71 @@ namespace ts { shortName: "?", type: "boolean" }, + { + name: "all", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Show_all_compiler_options, + }, + { + name: "version", + shortName: "v", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Print_the_compiler_s_version, + }, { name: "init", type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: createMapFromTemplate({ - "preserve": JsxEmit.Preserve, - "react-native": JsxEmit.ReactNative, - "react": JsxEmit.React - }), - paramType: Diagnostics.KIND, - description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", + name: "project", + shortName: "p", type: "string", isFilePath: true, - description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: Diagnostics.LOCATION, + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + paramType: Diagnostics.FILE_OR_DIRECTORY, + description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, + { + name: "watch", + shortName: "w", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Command_line_Options, + description: Diagnostics.Watch_input_files, + }, + + // Basic + { + name: "target", + shortName: "t", + type: createMapFromTemplate({ + "es3": ScriptTarget.ES3, + "es5": ScriptTarget.ES5, + "es6": ScriptTarget.ES2015, + "es2015": ScriptTarget.ES2015, + "es2016": ScriptTarget.ES2016, + "es2017": ScriptTarget.ES2017, + "esnext": ScriptTarget.ESNext, + }), + paramType: Diagnostics.VERSION, + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { name: "module", @@ -110,305 +101,10 @@ namespace ts { "es6": ModuleKind.ES2015, "es2015": ModuleKind.ES2015, }), - description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: Diagnostics.KIND, - }, - { - name: "newLine", - type: createMapFromTemplate({ - "crlf": NewLineKind.CarriageReturnLineFeed, - "lf": NewLineKind.LineFeed - }), - description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files - // for correct behaviour, please use outFile - paramType: Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: Diagnostics.Redirect_output_structure_to_the_directory, - paramType: Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, - paramType: Diagnostics.FILE_OR_DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: Diagnostics.Do_not_emit_comments_to_output, - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: Diagnostics.LOCATION, - description: Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", - type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: createMapFromTemplate({ - "es3": ScriptTarget.ES3, - "es5": ScriptTarget.ES5, - "es6": ScriptTarget.ES2015, - "es2015": ScriptTarget.ES2015, - "es2016": ScriptTarget.ES2016, - "es2017": ScriptTarget.ES2017, - "esnext": ScriptTarget.ESNext, - }), - description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, - paramType: Diagnostics.VERSION, - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: createMapFromTemplate({ - "node": ModuleResolutionKind.NodeJs, - "classic": ModuleResolutionKind.Classic, - }), - description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - name: "downlevelIteration", - type: "boolean", - description: Diagnostics.Use_full_down_level_iteration_for_iterables_and_arrays_for_for_of_spread_and_destructuring_in_ES5_Slash3 - }, - { - name: "baseUrl", - type: "string", - isFilePath: true, - description: Diagnostics.Base_directory_to_resolve_non_absolute_module_names - }, - { - // this option can only be specified in tsconfig.json - // use type = object to copy the value as-is - name: "paths", - type: "object", - isTSConfigOnly: true - }, - { - // this option can only be specified in tsconfig.json - // use type = object to copy the value as-is - name: "rootDirs", - type: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: Diagnostics.Allow_javascript_files_to_be_compiled - }, - { - name: "allowSyntheticDefaultImports", - type: "boolean", - description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking - }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { name: "lib", @@ -446,31 +142,481 @@ namespace ts { "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableSizeLimit", - type: "boolean" + name: "allowJs", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Allow_javascript_files_to_be_compiled }, { - name: "strictNullChecks", + name: "checkJs", type: "boolean", - description: Diagnostics.Enable_strict_null_checks + category: Diagnostics.Basic_Options, + description: Diagnostics.Report_errors_in_js_files + }, + { + name: "jsx", + type: createMapFromTemplate({ + "preserve": JsxEmit.Preserve, + "react-native": JsxEmit.ReactNative, + "react": JsxEmit.React + }), + paramType: Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "sourceMap", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Generates_corresponding_map_file, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + paramType: Diagnostics.FILE, + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Concatenate_and_emit_output_to_single_file, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + paramType: Diagnostics.DIRECTORY, + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Redirect_output_structure_to_the_directory, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: Diagnostics.LOCATION, + category: Diagnostics.Basic_Options, + description: Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "removeComments", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "noEmit", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Basic_Options, + description: Diagnostics.Do_not_emit_outputs, }, { name: "importHelpers", type: "boolean", + category: Diagnostics.Basic_Options, description: Diagnostics.Import_emit_helpers_from_tslib }, + { + name: "downlevelIteration", + type: "boolean", + category: Diagnostics.Basic_Options, + description: Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 + }, + { + name: "isolatedModules", + type: "boolean", + category: Diagnostics.Basic_Options, + description: Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + }, + + // Strict Type Checks + { + name: "strict", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Strict_Type_Checking_Options, + description: Diagnostics.Enable_all_strict_type_checking_options + }, + { + name: "noImplicitAny", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Strict_Type_Checking_Options, + description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "strictNullChecks", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Strict_Type_Checking_Options, + description: Diagnostics.Enable_strict_null_checks + }, + { + name: "noImplicitThis", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Strict_Type_Checking_Options, + description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, { name: "alwaysStrict", type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Strict_Type_Checking_Options, description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, + + // Additional Checks { - name: "strict", + name: "noUnusedLocals", type: "boolean", - description: Diagnostics.Enable_all_strict_type_checks + showInSimplifiedHelpView: true, + category: Diagnostics.Additional_Checks, + description: Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Additional_Checks, + description: Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noImplicitReturns", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Additional_Checks, + description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Additional_Checks, + description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + + // Module Resolution + { + name: "moduleResolution", + type: createMapFromTemplate({ + "node": ModuleResolutionKind.NodeJs, + "classic": ModuleResolutionKind.Classic, + }), + paramType: Diagnostics.STRATEGY, + category: Diagnostics.Module_Resolution_Options, + description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + category: Diagnostics.Module_Resolution_Options, + description: Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "paths", + type: "object", + isTSConfigOnly: true, + category: Diagnostics.Module_Resolution_Options, + description: Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + }, + category: Diagnostics.Module_Resolution_Options, + description: Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + }, + category: Diagnostics.Module_Resolution_Options, + description: Diagnostics.List_of_folders_to_include_type_definitions_from + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + showInSimplifiedHelpView: true, + category: Diagnostics.Module_Resolution_Options, + description: Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + category: Diagnostics.Module_Resolution_Options, + description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + + // Source Maps + { + name: "sourceRoot", + type: "string", + isFilePath: true, + paramType: Diagnostics.LOCATION, + category: Diagnostics.Source_Map_Options, + description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + paramType: Diagnostics.LOCATION, + category: Diagnostics.Source_Map_Options, + description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + }, + { + name: "inlineSourceMap", + type: "boolean", + category: Diagnostics.Source_Map_Options, + description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + }, + { + name: "inlineSources", + type: "boolean", + category: Diagnostics.Source_Map_Options, + description: Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + }, + + // Experimental + { + name: "experimentalDecorators", + type: "boolean", + category: Diagnostics.Experimental_Options, + description: Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + category: Diagnostics.Experimental_Options, + description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + + // Advanced + { + name: "jsxFactory", + type: "string", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + { + name: "diagnostics", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Show_diagnostic_information + }, + { + name: "extendedDiagnostics", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Show_verbose_diagnostic_information + }, + { + name: "traceResolution", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "listFiles", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Print_names_of_files_part_of_the_compilation + }, + { + name: "listEmittedFiles", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Print_names_of_generated_files_part_of_the_compilation + }, + + { + name: "out", + type: "string", + isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files + // for correct behaviour, please use outFile + category: Diagnostics.Advanced_Options, + paramType: Diagnostics.FILE, + description: Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + }, + { + name: "reactNamespace", + type: "string", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files + }, + { + name: "charset", + type: "string", + category: Diagnostics.Advanced_Options, + description: Diagnostics.The_character_set_of_the_input_files + }, + { + name: "emitBOM", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + }, + { + name: "locale", + type: "string", + category: Diagnostics.Advanced_Options, + description: Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + }, + { + name: "newLine", + type: createMapFromTemplate({ + "crlf": NewLineKind.CarriageReturnLineFeed, + "lf": NewLineKind.LineFeed + }), + paramType: Diagnostics.NEWLINE, + category: Diagnostics.Advanced_Options, + description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + }, + { + name: "noErrorTruncation", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_truncate_error_messages + }, + { + name: "noLib", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + }, + { + name: "noResolve", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + }, + { + name: "stripInternal", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + }, + { + name: "disableSizeLimit", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Disable_size_limitations_on_JavaScript_projects + }, + { + name: "noImplicitUseStrict", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "noEmitHelpers", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + }, + { + name: "noEmitOnError", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "preserveConstEnums", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: Diagnostics.DIRECTORY, + category: Diagnostics.Advanced_Options, + description: Diagnostics.Output_directory_for_generated_declaration_files + }, + { + name: "skipLibCheck", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "allowUnusedLabels", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "allowUnreachableCode", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Suppress_excess_property_checks_for_object_literals, + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + category: Diagnostics.Advanced_Options, + description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, { // A list of plugins to load in the language service @@ -480,7 +626,8 @@ namespace ts { element: { name: "plugin", type: "object" - } + }, + description: Diagnostics.List_of_language_service_plugins } ]; @@ -525,8 +672,7 @@ namespace ts { export const defaultInitCompilerOptions: CompilerOptions = { module: ModuleKind.CommonJS, target: ScriptTarget.ES5, - strict: true, - sourceMap: false, + strict: true }; let optionNameMapCache: OptionNameMap; @@ -749,9 +895,9 @@ namespace ts { * @param fileNames array of filenames to be generated into tsconfig.json */ /* @internal */ - export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: MapLike } { + export function generateTSConfig(options: CompilerOptions, fileNames: string[]): string { const compilerOptions = extend(options, defaultInitCompilerOptions); - const configurations: any = { + const configurations: { compilerOptions: MapLike; files?: string[] } = { compilerOptions: serializeCompilerOptions(compilerOptions) }; if (fileNames && fileNames.length) { @@ -759,7 +905,8 @@ namespace ts { configurations.files = fileNames; } - return configurations; + + return writeConfigurations(); function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map | undefined { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { @@ -791,43 +938,123 @@ namespace ts { if (hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - const value = options[name]; - const optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - // There is no map associated with this compiler option then use the value as-is - // This is the case if the value is expect to be string, number, boolean or list of string - result[name] = value; - } - else { - if (optionDefinition.type === "list") { - const convertedValue: string[] = []; - for (const element of value as (string | number)[]) { - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name] = convertedValue; - } - else { - // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name] = getNameOfCompilerOptionValue(value, customTypeMap); - } + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === Diagnostics.Command_line_Options) { + continue; + } + const value = options[name]; + const optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + const convertedValue: string[] = []; + for (const element of value as (string | number)[]) { + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } + result[name] = convertedValue; } - break; + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } } } } return result; } + + function getDefaultValueForOption(option: CommandLineOption) { + switch (option.type) { + case "number": + return 1; + case "boolean": + return true; + case "string": + return option.isFilePath ? "./" : ""; + case "list": + return []; + case "object": + return {}; + default: + return arrayFrom((option).type.keys())[0]; + } + } + + function makePadding(paddingLength: number): string { + return Array(paddingLength + 1).join(" "); + } + + function writeConfigurations() { + // Filter applicable options to place in the file + const categorizedOptions = reduceLeft( + filter(optionDeclarations, o => o.category !== Diagnostics.Command_line_Options && o.category !== Diagnostics.Advanced_Options), + (memo, value) => { + if (value.category) { + const name = getLocaleSpecificMessage(value.category); + (memo[name] || (memo[name] = [])).push(value); + } + return memo; + }, >{}); + + // Serialize all options and thier descriptions + let marginLength = 0; + let seenKnownKeys = 0; + const nameColumn: string[] = []; + const descriptionColumn: string[] = []; + const knownKesyCount = getOwnKeys(configurations.compilerOptions).length; + for (const category in categorizedOptions) { + if (nameColumn.length !== 0) { + nameColumn.push(""); + descriptionColumn.push(""); + } + nameColumn.push(`/* ${category} */`); + descriptionColumn.push(""); + for (const option of categorizedOptions[category]) { + let optionName; + if (hasProperty(configurations.compilerOptions, option.name)) { + optionName = `"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${(seenKnownKeys += 1) === knownKesyCount ? "" : ","}`; + } + else { + optionName = `// "${option.name}": ${JSON.stringify(getDefaultValueForOption(option))},`; + } + nameColumn.push(optionName); + descriptionColumn.push(`/* ${option.description && getLocaleSpecificMessage(option.description) || option.name} */`); + marginLength = Math.max(optionName.length, marginLength); + } + } + + // Write the output + const tab = makePadding(2); + const result: string[] = []; + result.push(`{`); + result.push(`${tab}"compilerOptions": {`); + // Print out each row, aligning all the descriptions on the same column. + for (let i = 0; i < nameColumn.length; i++) { + const optionName = nameColumn[i]; + const description = descriptionColumn[i]; + result.push(tab + tab + optionName + makePadding(marginLength - optionName.length + 2) + description); + } + if (configurations.files && configurations.files.length) { + result.push(`${tab}},`); + result.push(`${tab}"files": [`); + for (let i = 0; i < configurations.files.length; i++) { + result.push(`${tab}${tab}${JSON.stringify(configurations.files[i])}${i === configurations.files.length - 1 ? "" : ","}`); + } + result.push(`${tab}]`); + } + else { + result.push(`${tab}}`); + } + result.push(`}`); + + return result.join(sys.newLine); + } } /** @@ -1430,4 +1657,4 @@ namespace ts { function caseInsensitiveKeyMapper(key: string) { return key.toLowerCase(); } -} +} \ No newline at end of file diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c380a39611..a56f1004d2 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2360,4 +2360,8 @@ namespace ts { return Extension.Jsx; } } + + export function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) { + return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; + } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 919158645a..983e128ec7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1,4 +1,4 @@ -{ +{ "Unterminated string literal.": { "category": "Error", "code": 1002 @@ -1435,6 +1435,14 @@ "category": "Error", "code": 2448 }, + "Class '{0}' used before its declaration.": { + "category": "Error", + "code": 2449 + }, + "Enum '{0}' used before its declaration.": { + "category": "Error", + "code": 2450 + }, "Cannot redeclare block-scoped variable '{0}'.": { "category": "Error", "code": 2451 @@ -2019,10 +2027,6 @@ "category": "Error", "code": 2689 }, - "A class must be declared after its base class.": { - "category": "Error", - "code": 2690 - }, "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead.": { "category": "Error", "code": 2691 @@ -2781,7 +2785,7 @@ "category": "Message", "code": 6083 }, - "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit.": { + "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit": { "category": "Message", "code": 6084 }, @@ -3037,14 +3041,139 @@ "category": "Message", "code": 6148 }, - "Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3.": { + "Show diagnostic information.": { "category": "Message", "code": 6149 }, - "Enable all strict type checks.": { + "Show verbose diagnostic information.": { "category": "Message", "code": 6150 }, + "Emit a single file with source maps instead of having a separate file.": { + "category": "Message", + "code": 6151 + }, + "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set.": { + "category": "Message", + "code": 6152 + }, + "Transpile each file as a separate module (similar to 'ts.transpileModule').": { + "category": "Message", + "code": 6153 + }, + "Print names of generated files part of the compilation.": { + "category": "Message", + "code": 6154 + }, + "Print names of files part of the compilation.": { + "category": "Message", + "code": 6155 + }, + "The locale used when displaying messages to the user (e.g. 'en-us')": { + "category": "Message", + "code": 6156 + }, + "Do not generate custom helper functions like '__extends' in compiled output.": { + "category": "Message", + "code": 6157 + }, + "Do not include the default library file (lib.d.ts).": { + "category": "Message", + "code": 6158 + }, + "Do not add triple-slash references or imported modules to the list of compiled files.": { + "category": "Message", + "code": 6159 + }, + "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files.": { + "category": "Message", + "code": 6160 + }, + "List of folders to include type definitions from.": { + "category": "Message", + "code": 6161 + }, + "Disable size limitations on JavaScript projects.": { + "category": "Message", + "code": 6162 + }, + "The character set of the input files.": { + "category": "Message", + "code": 6163 + }, + "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.": { + "category": "Message", + "code": 6164 + }, + "Do not truncate error messages.": { + "category": "Message", + "code": 6165 + }, + "Output directory for generated declaration files.": { + "category": "Message", + "code": 6166 + }, + "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'.": { + "category": "Message", + "code": 6167 + }, + "List of root folders whose combined content represents the structure of the project at runtime.": { + "category": "Message", + "code": 6168 + }, + "Show all compiler options.": { + "category": "Message", + "code": 6169 + }, + "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file": { + "category": "Message", + "code": 6170 + }, + "Command-line Options": { + "category": "Message", + "code": 6171 + }, + "Basic Options": { + "category": "Message", + "code": 6172 + }, + "Strict Type-Checking Options": { + "category": "Message", + "code": 6173 + }, + "Module Resolution Options": { + "category": "Message", + "code": 6174 + }, + "Source Map Options": { + "category": "Message", + "code": 6175 + }, + "Additional Checks": { + "category": "Message", + "code": 6176 + }, + "Experimental Options": { + "category": "Message", + "code": 6177 + }, + "Advanced Options": { + "category": "Message", + "code": 6178 + }, + "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'.": { + "category": "Message", + "code": 6179 + }, + "Enable all strict type-checking options.": { + "category": "Message", + "code": 6180 + }, + "List of language service plugins.": { + "category": "Message", + "code": 6181 + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 @@ -3351,6 +3480,24 @@ "category": "Message", "code": 90017 }, + "Disable checking for this file.": { + "category": "Message", + "code": 90018 + }, + "Ignore this error message.": { + "category": "Message", + "code": 90019 + }, + "Initialize property '{0}' in the constructor.": { + "category": "Message", + "code": 90020 + }, + "Initialize static property '{0}'.": { + "category": "Message", + "code": 90021 + }, + + "Octal literal types must use ES2015 syntax. Use the syntax '{0}'.": { "category": "Error", "code": 8017 @@ -3358,5 +3505,9 @@ "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'.": { "category": "Error", "code": 8018 + }, + "Report errors in .js files.": { + "category": "Message", + "code": 8019 } } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 669c66c433..66b3eb713e 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -45,7 +45,7 @@ namespace ts { * Creates a shallow, memberwise clone of a node with no source map location. */ /* @internal */ - export function getSynthesizedClone(node: T): T { + export function getSynthesizedClone(node: T | undefined): T { // We don't use "clone" from core.ts here, as we need to preserve the prototype chain of // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). @@ -166,23 +166,23 @@ namespace ts { // Reserved words export function createSuper() { - return createSynthesizedNode(SyntaxKind.SuperKeyword); + return createSynthesizedNode(SyntaxKind.SuperKeyword); } export function createThis() { - return createSynthesizedNode(SyntaxKind.ThisKeyword); + return >createSynthesizedNode(SyntaxKind.ThisKeyword); } export function createNull() { - return createSynthesizedNode(SyntaxKind.NullKeyword); + return >createSynthesizedNode(SyntaxKind.NullKeyword); } export function createTrue() { - return createSynthesizedNode(SyntaxKind.TrueKeyword); + return >createSynthesizedNode(SyntaxKind.TrueKeyword); } export function createFalse() { - return createSynthesizedNode(SyntaxKind.FalseKeyword); + return >createSynthesizedNode(SyntaxKind.FalseKeyword); } // Names @@ -213,6 +213,284 @@ namespace ts { : node; } + // Type Elements + + export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + const signatureDeclaration = createSynthesizedNode(kind) as SignatureDeclaration; + signatureDeclaration.typeParameters = asNodeArray(typeParameters); + signatureDeclaration.parameters = asNodeArray(parameters); + signatureDeclaration.type = type; + return signatureDeclaration; + } + + function updateSignatureDeclaration(node: SignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) + : node; + } + + export function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.FunctionType, typeParameters, parameters, type) as FunctionTypeNode; + } + + export function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.ConstructorType, typeParameters, parameters, type) as ConstructorTypeNode; + } + + export function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.CallSignature, typeParameters, parameters, type) as CallSignatureDeclaration; + } + + export function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.ConstructSignature, typeParameters, parameters, type) as ConstructSignatureDeclaration; + } + + export function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined) { + const methodSignature = createSignatureDeclaration(SyntaxKind.MethodSignature, typeParameters, parameters, type) as MethodSignature; + methodSignature.name = asName(name); + methodSignature.questionToken = questionToken; + return methodSignature; + } + + export function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.name !== name + || node.questionToken !== questionToken + ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) + : node; + } + + // Types + + export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]) { + return createSynthesizedNode(kind); + } + + export function createThisTypeNode() { + return createSynthesizedNode(SyntaxKind.ThisType); + } + + export function createLiteralTypeNode(literal: Expression) { + const literalTypeNode = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; + literalTypeNode.literal = literal; + return literalTypeNode; + } + + export function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression) { + return node.literal !== literal + ? updateNode(createLiteralTypeNode(literal), node) + : node; + } + + export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined) { + const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; + typeReference.typeName = asName(typeName); + typeReference.typeArguments = asNodeArray(typeArguments); + return typeReference; + } + + export function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined) { + return node.typeName !== typeName + || node.typeArguments !== typeArguments + ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + : node; + } + + export function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode) { + const typePredicateNode = createSynthesizedNode(SyntaxKind.TypePredicate) as TypePredicateNode; + typePredicateNode.parameterName = asName(parameterName); + typePredicateNode.type = type; + return typePredicateNode; + } + + export function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode) { + return node.parameterName !== parameterName + || node.type !== type + ? updateNode(createTypePredicateNode(parameterName, type), node) + : node; + } + + export function createTypeQueryNode(exprName: EntityName) { + const typeQueryNode = createSynthesizedNode(SyntaxKind.TypeQuery) as TypeQueryNode; + typeQueryNode.exprName = exprName; + return typeQueryNode; + } + + export function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName) { + return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName), node) : node; + } + + export function createArrayTypeNode(elementType: TypeNode) { + const arrayTypeNode = createSynthesizedNode(SyntaxKind.ArrayType) as ArrayTypeNode; + arrayTypeNode.elementType = elementType; + return arrayTypeNode; + } + + export function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode { + return node.elementType !== elementType + ? updateNode(createArrayTypeNode(elementType), node) + : node; + } + + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode; + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode; + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode; + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]) { + const unionTypeNode = createSynthesizedNode(kind) as UnionTypeNode | IntersectionTypeNode; + unionTypeNode.types = createNodeArray(types); + return unionTypeNode; + } + + export function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, types: NodeArray) { + return node.types !== types + ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node) + : node; + } + + export function createTypeLiteralNode(members: TypeElement[]) { + const typeLiteralNode = createSynthesizedNode(SyntaxKind.TypeLiteral) as TypeLiteralNode; + typeLiteralNode.members = createNodeArray(members); + return typeLiteralNode; + } + + export function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray) { + return node.members !== members + ? updateNode(createTypeLiteralNode(members), node) + : node; + } + + export function createTupleTypeNode(elementTypes: TypeNode[]) { + const tupleTypeNode = createSynthesizedNode(SyntaxKind.TupleType) as TupleTypeNode; + tupleTypeNode.elementTypes = createNodeArray(elementTypes); + return tupleTypeNode; + } + + export function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]) { + return node.elementTypes !== elementTypes + ? updateNode(createTupleTypeNode(elementTypes), node) + : node; + } + + export function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { + const mappedTypeNode = createSynthesizedNode(SyntaxKind.MappedType) as MappedTypeNode; + mappedTypeNode.readonlyToken = readonlyToken; + mappedTypeNode.typeParameter = typeParameter; + mappedTypeNode.questionToken = questionToken; + mappedTypeNode.type = type; + return mappedTypeNode; + } + + export function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { + return node.readonlyToken !== readonlyToken + || node.typeParameter !== typeParameter + || node.questionToken !== questionToken + || node.type !== type + ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) + : node; + } + + export function createTypeOperatorNode(type: TypeNode) { + const typeOperatorNode = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode; + typeOperatorNode.operator = SyntaxKind.KeyOfKeyword; + typeOperatorNode.type = type; + return typeOperatorNode; + } + + export function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode) { + return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + } + + export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) { + const indexedAccessTypeNode = createSynthesizedNode(SyntaxKind.IndexedAccessType) as IndexedAccessTypeNode; + indexedAccessTypeNode.objectType = objectType; + indexedAccessTypeNode.indexType = indexType; + return indexedAccessTypeNode; + } + + export function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode) { + return node.objectType !== objectType + || node.indexType !== indexType + ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node) + : node; + } + + // Type Declarations + + export function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) { + const typeParameter = createSynthesizedNode(SyntaxKind.TypeParameter) as TypeParameterDeclaration; + typeParameter.name = asName(name); + typeParameter.constraint = constraint; + typeParameter.default = defaultType; + + return typeParameter; + } + + export function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) { + return node.name !== name + || node.constraint !== constraint + || node.default !== defaultType + ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node) + : node; + } + + // Signature elements + + export function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature { + const propertySignature = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature; + propertySignature.name = asName(name); + propertySignature.questionToken = questionToken; + propertySignature.type = type; + propertySignature.initializer = initializer; + return propertySignature; + } + + export function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) { + return node.name !== name + || node.questionToken !== questionToken + || node.type !== type + || node.initializer !== initializer + ? updateNode(createPropertySignature(name, questionToken, type, initializer), node) + : node; + } + + export function createIndexSignatureDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration { + const indexSignature = createSynthesizedNode(SyntaxKind.IndexSignature) as IndexSignatureDeclaration; + indexSignature.decorators = asNodeArray(decorators); + indexSignature.modifiers = asNodeArray(modifiers); + indexSignature.parameters = createNodeArray(parameters); + indexSignature.type = type; + return indexSignature; + } + + export function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode) { + return node.parameters !== parameters + || node.type !== type + || node.decorators !== decorators + || node.modifiers !== modifiers + ? updateNode(createIndexSignatureDeclaration(decorators, modifiers, parameters, type), node) + : node; + } + // Signature elements export function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { @@ -227,11 +505,12 @@ namespace ts { return node; } - export function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined) { + export function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) { return node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name + || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) @@ -273,12 +552,13 @@ namespace ts { : node; } - export function createMethod(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + export function createMethodDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.MethodDeclaration); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); + node.questionToken = questionToken; node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -286,7 +566,7 @@ namespace ts { return node; } - export function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + export function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { return node.decorators !== decorators || node.modifiers !== modifiers || node.asteriskToken !== asteriskToken @@ -295,7 +575,7 @@ namespace ts { || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } @@ -1099,10 +1379,6 @@ namespace ts { : node; } - export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode { - return createSynthesizedNode(kind); - } - export function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.FunctionDeclaration); node.decorators = asNodeArray(decorators); @@ -1486,7 +1762,7 @@ namespace ts { // Clauses - export function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]) { + export function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]) { const node = createSynthesizedNode(SyntaxKind.HeritageClause); node.token = token; node.types = createNodeArray(types); @@ -1793,7 +2069,9 @@ namespace ts { function asName(name: string | Identifier): Identifier; function asName(name: string | BindingName): BindingName; function asName(name: string | PropertyName): PropertyName; - function asName(name: string | Identifier | BindingName | PropertyName) { + function asName(name: string | EntityName): EntityName; + function asName(name: string | Identifier | ThisTypeNode): Identifier | ThisTypeNode; + function asName(name: string | Identifier | BindingName | PropertyName | QualifiedName | ThisTypeNode) { return typeof name === "string" ? createIdentifier(name) : name; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f2175f385e..a6def4bcc3 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5437,9 +5437,10 @@ namespace ts { } function parseHeritageClause(): HeritageClause | undefined { - if (token() === SyntaxKind.ExtendsKeyword || token() === SyntaxKind.ImplementsKeyword) { + const tok = token(); + if (tok === SyntaxKind.ExtendsKeyword || tok === SyntaxKind.ImplementsKeyword) { const node = createNode(SyntaxKind.HeritageClause); - node.token = token(); + node.token = tok; nextToken(); node.types = parseDelimitedList(ParsingContext.HeritageClauseElement, parseExpressionWithTypeArguments); return finishNode(node); @@ -5821,6 +5822,7 @@ namespace ts { const typeReferenceDirectives: FileReference[] = []; const amdDependencies: { path: string; name: string }[] = []; let amdModuleName: string; + let checkJsDirective: CheckJsDirective = undefined; // Keep scanning all the leading trivia in the file until we get to something that // isn't trivia. Any single line comment will be analyzed to see if it is a @@ -5882,6 +5884,16 @@ namespace ts { amdDependencies.push(amdDependency); } } + + const checkJsDirectiveRegEx = /^\/\/\/?\s*(@ts-check|@ts-nocheck)\s*$/gim; + const checkJsDirectiveMatchResult = checkJsDirectiveRegEx.exec(comment); + if (checkJsDirectiveMatchResult) { + checkJsDirective = { + enabled: compareStrings(checkJsDirectiveMatchResult[1], "@ts-check", /*ignoreCase*/ true) === Comparison.EqualTo, + end: range.end, + pos: range.pos + }; + } } } @@ -5889,6 +5901,7 @@ namespace ts { sourceFile.typeReferenceDirectives = typeReferenceDirectives; sourceFile.amdDependencies = amdDependencies; sourceFile.moduleName = amdModuleName; + sourceFile.checkJsDirective = checkJsDirective; } function setExternalModuleIndicator(sourceFile: SourceFile) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index cffb6df1e3..31fc665649 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -4,6 +4,7 @@ namespace ts { const emptyArray: any[] = []; + const ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string { while (true) { @@ -911,17 +912,42 @@ namespace ts { Debug.assert(!!sourceFile.bindDiagnostics); const bindDiagnostics = sourceFile.bindDiagnostics; - // For JavaScript files, we don't want to report semantic errors. - // Instead, we'll report errors for using TypeScript-only constructs from within a - // JavaScript file when we get syntactic diagnostics for the file. - const checkDiagnostics = isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); + // For JavaScript files, we don't want to report semantic errors unless explicitly requested. + const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || isCheckJsEnabledForFile(sourceFile, options); + const checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + const diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + return isSourceFileJavaScript(sourceFile) + ? filter(diagnostics, shouldReportDiagnostic) + : diagnostics; }); } + /** + * Skip errors if previous line start with '// @ts-ignore' comment, not counting non-empty non-comment lines + */ + function shouldReportDiagnostic(diagnostic: Diagnostic) { + const { file, start } = diagnostic; + const lineStarts = getLineStarts(file); + let { line } = computeLineAndCharacterOfPosition(lineStarts, start); + while (line > 0) { + const previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); + const result = ignoreDiagnosticCommentRegEx.exec(previousLineText); + if (!result) { + // non-empty line + return true; + } + if (result[3]) { + // @ts-ignore + return false; + } + line--; + } + return true; + } + function getJavaScriptSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { return runWithCancellationToken(() => { const diagnostics: Diagnostic[] = []; @@ -1722,6 +1748,10 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); } + if (options.checkJs && !options.allowJs) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); + } + if (options.emitDecoratorMetadata && !options.experimentalDecorators) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 31aae5055a..088c57866d 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -125,6 +125,7 @@ namespace ts { visitNodes(node.modifiers, visitor, isModifier), node.asteriskToken, node.name, + /*questionToken*/ undefined, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 971dddd20e..83e84e6eab 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -475,6 +475,7 @@ namespace ts { /*modifiers*/ undefined, node.dotDotDotToken, getGeneratedNameForNode(node), + /*questionToken*/ undefined, /*type*/ undefined, visitNode(node.initializer, visitor, isExpression) ); @@ -540,6 +541,7 @@ namespace ts { ? undefined : node.asteriskToken, visitNode(node.name, visitor, isPropertyName), + visitNode(/*questionToken*/ undefined, visitor, isToken), /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 885f8fad89..6dc643b954 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2049,6 +2049,7 @@ namespace ts { visitNodes(node.modifiers, modifierVisitor, isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), + /*questionToken*/ undefined, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 32b6a90e26..4fd3ecb02b 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -225,9 +225,9 @@ namespace ts { return sys.exit(ExitStatus.Success); } - if (commandLine.options.help) { + if (commandLine.options.help || commandLine.options.all) { printVersion(); - printHelp(); + printHelp(commandLine.options.all); return sys.exit(ExitStatus.Success); } @@ -264,7 +264,7 @@ namespace ts { if (commandLine.fileNames.length === 0 && !configFileName) { printVersion(); - printHelp(); + printHelp(commandLine.options.all); return sys.exit(ExitStatus.Success); } @@ -618,7 +618,7 @@ namespace ts { sys.write(getDiagnosticText(Diagnostics.Version_0, ts.version) + sys.newLine); } - function printHelp() { + function printHelp(showAllOptions: boolean) { const output: string[] = []; // We want to align our "syntax" and "examples" commands to a certain margin. @@ -643,8 +643,9 @@ namespace ts { output.push(getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine); // Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch") - const optsList = filter(optionDeclarations.slice(), v => !v.experimental); - optsList.sort((a, b) => compareValues(a.name.toLowerCase(), b.name.toLowerCase())); + const optsList = showAllOptions ? + optionDeclarations.slice().sort((a, b) => compareValues(a.name.toLowerCase(), b.name.toLowerCase())) : + filter(optionDeclarations.slice(), v => v.showInSimplifiedHelpView); // We want our descriptions to align at the same column in our output, // so we keep track of the longest option usage string. @@ -738,7 +739,7 @@ namespace ts { reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* host */ undefined); } else { - sys.writeFile(file, JSON.stringify(generateTSConfig(options, fileNames), undefined, 4)); + sys.writeFile(file, generateTSConfig(options, fileNames)); reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* host */ undefined); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 26d6730ce5..d945af89a2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -815,18 +815,21 @@ namespace ts { export interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { kind: SyntaxKind.Constructor; + parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; } - // For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. + /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements.*/ export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; + parent?: ClassDeclaration | ClassExpression; } // See the comment on MethodDeclaration for the intuition behind GetAccessorDeclaration being a // ClassElement and an ObjectLiteralElement. export interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.GetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } @@ -835,6 +838,7 @@ namespace ts { // ClassElement and an ObjectLiteralElement. export interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.SetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } @@ -843,6 +847,7 @@ namespace ts { export interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; + parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } export interface TypeNode extends Node { @@ -856,22 +861,24 @@ namespace ts { | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword - | SyntaxKind.VoidKeyword; + | SyntaxKind.ThisKeyword + | SyntaxKind.VoidKeyword + | SyntaxKind.UndefinedKeyword + | SyntaxKind.NullKeyword + | SyntaxKind.NeverKeyword; } export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - export interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; - } + export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - export interface FunctionTypeNode extends FunctionOrConstructorTypeNode { + export interface FunctionTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.FunctionType; } - export interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { + export interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.ConstructorType; } @@ -908,17 +915,16 @@ namespace ts { elementTypes: NodeArray; } - export interface UnionOrIntersectionTypeNode extends TypeNode { - kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; + export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + + export interface UnionTypeNode extends TypeNode { + kind: SyntaxKind.UnionType; types: NodeArray; } - export interface UnionTypeNode extends UnionOrIntersectionTypeNode { - kind: SyntaxKind.UnionType; - } - - export interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + export interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; + types: NodeArray; } export interface ParenthesizedTypeNode extends TypeNode { @@ -940,6 +946,7 @@ namespace ts { export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; + parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; @@ -1027,15 +1034,15 @@ namespace ts { _primaryExpressionBrand: any; } - export interface NullLiteral extends PrimaryExpression { + export interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - export interface BooleanLiteral extends PrimaryExpression { + export interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - export interface ThisExpression extends PrimaryExpression { + export interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } @@ -1453,7 +1460,7 @@ namespace ts { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; - arguments: NodeArray; + arguments?: NodeArray; } export interface TaggedTemplateExpression extends MemberExpression { @@ -1507,6 +1514,7 @@ namespace ts { export type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; export interface JsxAttributes extends ObjectLiteralExpressionBase { + parent?: JsxOpeningLikeElement; } /// The opening element of a ... JsxElement @@ -1526,7 +1534,7 @@ namespace ts { export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; - parent?: JsxOpeningLikeElement; + parent?: JsxAttributes; name: Identifier; /// JSX attribute initializers are optional; is sugar for initializer?: StringLiteral | JsxExpression; @@ -1534,7 +1542,7 @@ namespace ts { export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; - parent?: JsxOpeningLikeElement; + parent?: JsxAttributes; expression: Expression; } @@ -1779,8 +1787,8 @@ namespace ts { export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; parent?: InterfaceDeclaration | ClassDeclaration | ClassExpression; - token: SyntaxKind; - types?: NodeArray; + token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; + types: NodeArray; } export interface TypeAliasDeclaration extends DeclarationStatement { @@ -1944,6 +1952,10 @@ namespace ts { fileName: string; } + export interface CheckJsDirective extends TextRange { + enabled: boolean; + } + export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; export interface CommentRange extends TextRange { @@ -2286,6 +2298,7 @@ namespace ts { /* @internal */ moduleAugmentations: LiteralExpression[]; /* @internal */ patternAmbientModules?: PatternAmbientModule[]; /* @internal */ ambientModuleNames: string[]; + /* @internal */ checkJsDirective: CheckJsDirective | undefined; } export interface Bundle extends Node { @@ -2468,6 +2481,14 @@ namespace ts { /* @internal */ getParameterType(signature: Signature, parameterIndex: number): Type; getNonNullableType(type: Type): Type; + /** Note that the resulting nodes cannot be checked. */ + + typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; + /** Note that the resulting nodes cannot be checked. */ + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration; + /** Note that the resulting nodes cannot be checked. */ + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration; + getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; @@ -2519,6 +2540,16 @@ namespace ts { /* @internal */ getTypeCount(): number; } + export enum NodeBuilderFlags { + None = 0, + allowThisInObjectLiteral = 1 << 0, + allowQualifedNameInPlaceOfIdentifier = 1 << 1, + allowTypeParameterInQualifiedName = 1 << 2, + allowAnonymousIdentifier = 1 << 3, + allowEmptyUnionOrIntersection = 1 << 4, + allowEmptyTuple = 1 << 5 + } + export interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; @@ -3010,7 +3041,6 @@ namespace ts { ObjectLiteral = 1 << 7, // Originates in an object literal EvolvingArray = 1 << 8, // Evolving array type ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties - NonPrimitive = 1 << 10, // NonPrimitive object type ClassOrInterface = Class | Interface } @@ -3321,6 +3351,7 @@ namespace ts { export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; export interface CompilerOptions { + /*@internal*/ all?: boolean; allowJs?: boolean; /*@internal*/ allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; @@ -3329,6 +3360,7 @@ namespace ts { alwaysStrict?: boolean; // Always combine with strict property baseUrl?: string; charset?: string; + checkJs?: boolean; /* @internal */ configFilePath?: string; declaration?: boolean; declarationDir?: string; @@ -3513,8 +3545,10 @@ namespace ts { shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' description?: DiagnosticMessage; // The message describing what the command line switch does paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter - experimental?: boolean; isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file + isCommandLineOnly?: boolean; + showInSimplifiedHelpView?: boolean; + category?: DiagnosticMessage; } /* @internal */ @@ -4067,7 +4101,7 @@ namespace ts { export type Transformer = (node: T) => T; /** - * A function that accepts and possible transforms a node. + * A function that accepts and possibly transforms a node. */ export type Visitor = (node: Node) => VisitResult; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 030b66813a..f091685598 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -525,6 +525,10 @@ namespace ts { return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } + export function getNameFromIndexInfo(info: IndexInfo) { + return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; + } + export function getTextOfPropertyName(name: PropertyName): string { switch (name.kind) { case SyntaxKind.Identifier: @@ -740,8 +744,8 @@ namespace ts { // // let a: A.B.C; // - // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or - // A.B.C is a type node. + // Calling isPartOfTypeNode would consider the qualified name A.B a type node. + // Only C and A.B.C are type nodes. if (SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= SyntaxKind.LastTypeNode) { return true; } @@ -1446,13 +1450,10 @@ namespace ts { /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder - export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind { + export function getSpecialPropertyAssignmentKind(expression: ts.BinaryExpression): SpecialPropertyAssignmentKind { if (!isInJavaScriptFile(expression)) { return SpecialPropertyAssignmentKind.None; } - if (expression.kind !== SyntaxKind.BinaryExpression) { - return SpecialPropertyAssignmentKind.None; - } const expr = expression; if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || expr.left.kind !== SyntaxKind.PropertyAccessExpression) { return SpecialPropertyAssignmentKind.None; @@ -2675,7 +2676,7 @@ namespace ts { if (sourceFiles.length) { const jsFilePath = options.outFile || options.out; const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined; + const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath, sourceMapFilePath, declarationFilePath }, createBundle(sourceFiles), emitOnlyDtsFiles); } } @@ -3713,10 +3714,14 @@ namespace ts { return (kind >= SyntaxKind.FirstTypeNode && kind <= SyntaxKind.LastTypeNode) || kind === SyntaxKind.AnyKeyword || kind === SyntaxKind.NumberKeyword + || kind === SyntaxKind.ObjectKeyword || kind === SyntaxKind.BooleanKeyword || kind === SyntaxKind.StringKeyword || kind === SyntaxKind.SymbolKeyword + || kind === SyntaxKind.ThisKeyword || kind === SyntaxKind.VoidKeyword + || kind === SyntaxKind.UndefinedKeyword + || kind === SyntaxKind.NullKeyword || kind === SyntaxKind.NeverKeyword || kind === SyntaxKind.ExpressionWithTypeArguments; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 133c62e192..297d2cc0dd 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -204,21 +204,17 @@ namespace ts { * @param visitor The callback used to visit each child. * @param context A lexical environment context for the visitor. */ - export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): T | undefined; + export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; - export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes): Node { + export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes, tokenVisitor?: Visitor): Node { if (node === undefined) { return undefined; } const kind = node.kind; - // No need to visit nodes with no children. - if ((kind > SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken)) { - return node; - } - // We do not yet support types. - if ((kind >= SyntaxKind.TypePredicate && kind <= SyntaxKind.LiteralType)) { + // No need to visit nodes with no children. + if ((kind > SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken) || kind === SyntaxKind.ThisType) { return node; } @@ -227,6 +223,8 @@ namespace ts { case SyntaxKind.EmptyStatement: case SyntaxKind.OmittedExpression: case SyntaxKind.DebuggerStatement: + case SyntaxKind.EndOfDeclarationMarker: + case SyntaxKind.MissingDeclaration: // No need to visit nodes with no children. return node; @@ -240,13 +238,53 @@ namespace ts { return updateComputedPropertyName(node, visitNode((node).expression, visitor, isExpression)); - // Signature elements + // Signatures and Signature Elements + case SyntaxKind.FunctionType: + return updateFunctionTypeNode(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.ConstructorType: + return updateConstructorTypeNode(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.CallSignature: + return updateCallSignatureDeclaration(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.ConstructSignature: + return updateConstructSignatureDeclaration(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.MethodSignature: + return updateMethodSignature(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode), + visitNode((node).name, visitor, isPropertyName), + visitNode((node).questionToken, tokenVisitor, isToken)); + + case SyntaxKind.IndexSignature: + return updateIndexSignatureDeclaration(node, + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.Parameter: return updateParameter(node, nodesVisitor((node).decorators, visitor, isDecorator), nodesVisitor((node).modifiers, visitor, isModifier), - (node).dotDotDotToken, + visitNode((node).dotDotDotToken, tokenVisitor, isToken), visitNode((node).name, visitor, isBindingName), + visitNode((node).questionToken, tokenVisitor, isToken), visitNode((node).type, visitor, isTypeNode), visitNode((node).initializer, visitor, isExpression)); @@ -254,7 +292,74 @@ namespace ts { return updateDecorator(node, visitNode((node).expression, visitor, isExpression)); - // Type member + // Types + + case SyntaxKind.TypeReference: + return updateTypeReferenceNode(node, + visitNode((node).typeName, visitor, isEntityName), + nodesVisitor((node).typeArguments, visitor, isTypeNode)); + + case SyntaxKind.TypePredicate: + return updateTypePredicateNode(node, + visitNode((node).parameterName, visitor), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.TypeQuery: + return updateTypeQueryNode((node), visitNode((node).exprName, visitor, isEntityName)); + + case SyntaxKind.TypeLiteral: + return updateTypeLiteralNode((node), nodesVisitor((node).members, visitor)); + + case SyntaxKind.ArrayType: + return updateArrayTypeNode(node, visitNode((node).elementType, visitor, isTypeNode)); + + case SyntaxKind.TupleType: + return updateTypleTypeNode((node), nodesVisitor((node).elementTypes, visitor, isTypeNode)); + + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: + return updateUnionOrIntersectionTypeNode(node, + nodesVisitor((node).types, visitor, isTypeNode)); + + case SyntaxKind.ParenthesizedType: + Debug.fail("not implemented."); + + case SyntaxKind.TypeOperator: + return updateTypeOperatorNode(node, visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.IndexedAccessType: + return updateIndexedAccessTypeNode((node), + visitNode((node).objectType, visitor, isTypeNode), + visitNode((node).indexType, visitor, isTypeNode)); + + case SyntaxKind.MappedType: + return updateMappedTypeNode((node), + visitNode((node).readonlyToken, tokenVisitor, isToken), + visitNode((node).typeParameter, visitor, isTypeParameter), + visitNode((node).questionToken, tokenVisitor, isToken), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.LiteralType: + return updateLiteralTypeNode(node, + visitNode((node).literal, visitor, isExpression)); + + // Type Declarations + + case SyntaxKind.TypeParameter: + return updateTypeParameterDeclaration(node, + visitNode((node).name, visitor, isIdentifier), + visitNode((node).constraint, visitor, isTypeNode), + visitNode((node).default, visitor, isTypeNode)); + + // Type members + + case SyntaxKind.PropertySignature: + return updatePropertySignature((node), + visitNode((node).name, visitor, isPropertyName), + visitNode((node).questionToken, tokenVisitor, isToken), + visitNode((node).type, visitor, isTypeNode), + visitNode((node).initializer, visitor, isExpression)); + case SyntaxKind.PropertyDeclaration: return updateProperty(node, nodesVisitor((node).decorators, visitor, isDecorator), @@ -267,8 +372,9 @@ namespace ts { return updateMethod(node, nodesVisitor((node).decorators, visitor, isDecorator), nodesVisitor((node).modifiers, visitor, isModifier), - (node).asteriskToken, + visitNode((node).asteriskToken, tokenVisitor, isToken), visitNode((node).name, visitor, isPropertyName), + visitNode((node).questionToken, tokenVisitor, isToken), nodesVisitor((node).typeParameters, visitor, isTypeParameter), visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), @@ -309,7 +415,7 @@ namespace ts { case SyntaxKind.BindingElement: return updateBindingElement(node, - (node).dotDotDotToken, + visitNode((node).dotDotDotToken, tokenVisitor, isToken), visitNode((node).propertyName, visitor, isPropertyName), visitNode((node).name, visitor, isBindingName), visitNode((node).initializer, visitor, isExpression)); @@ -362,7 +468,7 @@ namespace ts { case SyntaxKind.FunctionExpression: return updateFunctionExpression(node, nodesVisitor((node).modifiers, visitor, isModifier), - (node).asteriskToken, + visitNode((node).asteriskToken, tokenVisitor, isToken), visitNode((node).name, visitor, isIdentifier), nodesVisitor((node).typeParameters, visitor, isTypeParameter), visitParameterList((node).parameters, visitor, context, nodesVisitor), @@ -419,7 +525,7 @@ namespace ts { case SyntaxKind.YieldExpression: return updateYield(node, - (node).asteriskToken, + visitNode((node).asteriskToken, tokenVisitor, isToken), visitNode((node).expression, visitor, isExpression)); case SyntaxKind.SpreadElement: @@ -555,7 +661,7 @@ namespace ts { return updateFunctionDeclaration(node, nodesVisitor((node).decorators, visitor, isDecorator), nodesVisitor((node).modifiers, visitor, isModifier), - (node).asteriskToken, + visitNode((node).asteriskToken, tokenVisitor, isToken), visitNode((node).name, visitor, isIdentifier), nodesVisitor((node).typeParameters, visitor, isTypeParameter), visitParameterList((node).parameters, visitor, context, nodesVisitor), diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 98ebacd49b..aa07407b0f 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2584,6 +2584,11 @@ namespace FourSlash { } } + public printAvailableCodeFixes() { + const codeFixes = this.getCodeFixActions(this.activeFile.fileName); + Harness.IO.log(stringify(codeFixes)); + } + // Get the text of the entire line the caret is currently at private getCurrentLineContent() { const text = this.getFileContent(this.activeFile.fileName); @@ -3772,6 +3777,10 @@ namespace FourSlashInterface { this.state.printCompletionListMembers(); } + public printAvailableCodeFixes() { + this.state.printAvailableCodeFixes(); + } + public printBreakpointLocation(pos: number) { this.state.printBreakpointLocation(pos); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 8ab6ec2fb6..2c4eef1739 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -191,7 +191,7 @@ namespace Utils { for (const childName in node) { if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator" || // for now ignore jsdoc comments - childName === "jsDocComment") { + childName === "jsDocComment" || childName === "checkJsDirective") { continue; } const child = (node)[childName]; diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 1bbdfa7128..4fded517e1 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -1,4 +1,4 @@ -{ +{ "extends": "../tsconfig-base", "compilerOptions": { "removeComments": false, @@ -81,6 +81,7 @@ "../services/codefixes/helpers.ts", "../services/codefixes/importFixes.ts", "../services/codefixes/unusedIdentifierFixes.ts", + "../services/codefixes/disableJsDiagnostics.ts", "harness.ts", "sourceMapRecorder.ts", diff --git a/src/harness/unittests/initializeTSConfig.ts b/src/harness/unittests/initializeTSConfig.ts index ab9aaea000..d0bc72d430 100644 --- a/src/harness/unittests/initializeTSConfig.ts +++ b/src/harness/unittests/initializeTSConfig.ts @@ -12,7 +12,8 @@ namespace ts { it(`Correct output for ${outputFileName}`, () => { Harness.Baseline.runBaseline(outputFileName, () => { if (initResult) { - return JSON.stringify(initResult, undefined, 4); + // normalize line endings + return initResult.replace(new RegExp(sys.newLine, "g"), "\n"); } else { // This can happen if compiler recieve invalid compiler-options diff --git a/src/harness/unittests/services/formatting/documentFormattingTests.json b/src/harness/unittests/services/formatting/documentFormattingTests.json deleted file mode 100644 index f7d48dba8c..0000000000 --- a/src/harness/unittests/services/formatting/documentFormattingTests.json +++ /dev/null @@ -1,80 +0,0 @@ -{ input: "function foo () {}", rules: [ ], span: { start: 0, length: 20 }, expected: "function foo() { }" }, -{ input: "var a = (0);\r\na = (1 % 2);\r\nvar b = new Array(1, 2);\r\nfunction c(d) {\r\n try { }\r\n catch (e) { }\r\n for (f = 0; f < 10; ++f) { }\r\n for (g in h) { }\r\n if (true) {\r\n } else if (false) { }\r\n switch (i) {\r\n case (0):\r\n break;\r\n }\r\n do { } while (true);\r\n with (j) {\r\n }\r\n delete (h);\r\n void (i);\r\n}", rules: [ "SpaceAfterOpenParen", "SpaceBeforeCloseParen", "NoSpaceBetweenParens" ], span: { start: 0, length: 349 }, expected: "var a = ( 0 );\r\na = ( 1 % 2 );\r\nvar b = new Array( 1, 2 );\r\nfunction c( d ) {\r\n try { }\r\n catch ( e ) { }\r\n for ( f = 0; f < 10; ++f ) { }\r\n for ( g in h ) { }\r\n if ( true ) {\r\n } else if ( false ) { }\r\n switch ( i ) {\r\n case ( 0 ):\r\n break;\r\n }\r\n do { } while ( true );\r\n with ( j ) {\r\n }\r\n delete ( h );\r\n void ( i );\r\n}" }, -{ input: "var a = ( 0 );\r\na = ( 1 % 2 );\r\nvar b = new Array( 1, 2 );\r\nfunction c( d ) {\r\n try { }\r\n catch ( e ) { }\r\n for ( f = 0; f < 10; ++f ) { }\r\n for ( g in h ) { }\r\n if ( true ) {\r\n } else if ( false ) { }\r\n switch ( i ) {\r\n case ( 0 ):\r\n break;\r\n }\r\n do { } while ( true );\r\n with ( j ) {\r\n }\r\n delete ( h );\r\n void ( i );\r\n}", rules: [ "NoSpaceAfterOpenParen", "NoSpaceBeforeCloseParen", "NoSpaceBetweenParens" ], span: { start: 0, length: 379 }, expected: "var a = (0);\r\na = (1 % 2);\r\nvar b = new Array(1, 2);\r\nfunction c(d) {\r\n try { }\r\n catch (e) { }\r\n for (f = 0; f < 10; ++f) { }\r\n for (g in h) { }\r\n if (true) {\r\n } else if (false) { }\r\n switch (i) {\r\n case (0):\r\n break;\r\n }\r\n do { } while (true);\r\n with (j) {\r\n }\r\n delete (h);\r\n void (i);\r\n}" }, -{ input: "this . alert( \"Hello, World!\" );", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 32 }, expected: "this.alert( \"Hello, World!\" );" }, -{ input: "a\r\n;b;", rules: [ ], span: { start: 0, length: 6 }, expected: "a\r\n; b;" }, -{ input: "a\r\n; b;", rules: [ ], span: { start: 0, length: 8 }, expected: "a\r\n; b;" }, -{ input: "var a , b;\r\nf(a , b);", rules: [ ], span: { start: 0, length: 40 }, expected: "var a, b;\r\nf(a, b);" }, -{ input: "function a() {\r\n while(false)\r\n switch(b) { }\r\n\r\n for(c in d)\r\n if(c)\r\n break;\r\n\r\n do { } while(true);\r\n with(f)\r\n g = null;\r\n}", rules: [ "SpaceAfterKeywordInControl" ], span: { start: 0, length: 171 }, expected: "function a() {\r\n while (false)\r\n switch (b) { }\r\n\r\n for (c in d)\r\n if (c)\r\n break;\r\n\r\n do { } while (true);\r\n with (f)\r\n g = null;\r\n}" }, -{ input: "function a() {\r\n while (false)\r\n switch (b) { }\r\n\r\n for (c in d)\r\n if (c)\r\n break;\r\n\r\n do { } while (true);\r\n with (f)\r\n g = null;\r\n}", rules: [ "NoSpaceAfterKeywordInControl" ], span: { start: 0, length: 177 }, expected: "function a() {\r\n while(false)\r\n switch(b) { }\r\n\r\n for(c in d)\r\n if(c)\r\n break;\r\n\r\n do { } while(true);\r\n with(f)\r\n g = null;\r\n}" }, -{ input: "{\r\n(a);\r\n}", rules: [ ], span: { start: 0, length: 10 }, expected: "{\r\n (a);\r\n}" }, -{ input: "var a=[1,2];\r\nvar b=8>>2 ;\r\nvar c=1+2;", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 14, length: 12 }, expected: "var a=[1,2];\r\nvar b = 8 >> 2;\r\nvar c=1+2;" }, -{ input: "if (true) {\r\n(a);\r\n}", rules: [ ], span: { start: 0, length: 20 }, expected: "if (true) {\r\n (a);\r\n}" }, -{ input: " // var a=[1,2];\r\n /*var a=[3,4];*/\r\n /*\r\n var a=[5,6];\r\n */", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 62 }, expected: "// var a=[1,2];\r\n/*var a=[3,4];*/\r\n/*\r\n var a=[5,6];\r\n */" }, -{ input: "f ();", rules: [ ], span: { start: 0, length: 14 }, expected: "f();" }, -{ input: "var a = { b: 1 , c: 2 };\r\nvar d = [1 , 2];", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 44 }, expected: "var a = { b: 1, c: 2 };\r\nvar d = [1, 2];" }, -{ input: "if (a)\r\n if (b)\r\n if (c)\r\n c();\r\n else\r\n b();\r\n else\r\n b();\r\nelse\r\n a();", rules: [ ], span: { start: 0, length: 124 }, expected: "if (a)\r\n if (b)\r\n if (c)\r\n c();\r\n else\r\n b();\r\n else\r\n b();\r\nelse\r\n a();" }, -{ input: "function a() { };", rules: [ ], span: { start: 0, length: 20 }, expected: "function a() { };" }, -{ input: "var a =[1.2,\"JavaScript\",true,{ x: 1,y: 3 }];\r\nvar b =[[1,2],[3,4]];\r\nvar c =[1,,,,5];\r\nvar d =[\r\n [1,2],\r\n [3,4]\r\n];", rules: [ "SpaceAfterComma" ], span: { start: 0, length: 123 }, expected: "var a =[1.2, \"JavaScript\", true, { x: 1, y: 3 }];\r\nvar b =[[1, 2], [3, 4]];\r\nvar c =[1, , , , 5];\r\nvar d =[\r\n [1, 2],\r\n [3, 4]\r\n];" }, -{ input: "var a =[1.2, \"JavaScript\", true, { x: 1, y: 3 }];\r\nvar b =[[1, 2], [3, 4]];\r\nvar c =[1, , , , 5];\r\nvar d =[\r\n [1, 2],\r\n [3, 4]\r\n];", rules: [ "NoSpaceAfterComma" ], span: { start: 0, length: 136 }, expected: "var a =[1.2,\"JavaScript\",true,{ x: 1,y: 3 }];\r\nvar b =[[1,2],[3,4]];\r\nvar c =[1,,,,5];\r\nvar d =[\r\n [1,2],\r\n [3,4]\r\n];" }, -{ input: "function a(b,c) { }\r\na(0,1);\r\nvar a =[,];\r\nvar a =[0,1];\r\nvar a,b,c = 0,d = 0;\r\nfor (var a = 0,b = 10; a < 10,b >= 0; ++a,--b) { }\r\nvar a = new ActiveXObject(\"\",\"\");\r\nswitch (a) {\r\n case 1,2,3:\r\n break;\r\n}", rules: [ "SpaceAfterComma" ], span: { start: 0, length: 215 }, expected: "function a(b, c) { }\r\na(0, 1);\r\nvar a =[, ];\r\nvar a =[0, 1];\r\nvar a, b, c = 0, d = 0;\r\nfor (var a = 0, b = 10; a < 10, b >= 0; ++a, --b) { }\r\nvar a = new ActiveXObject(\"\", \"\");\r\nswitch (a) {\r\n case 1, 2, 3:\r\n break;\r\n}" }, -{ input: "function a(b, c) { }\r\na(0, 1);\r\nvar a =[, ];\r\nvar a =[0, 1];\r\nvar a, b, c = 0, d = 0;\r\nfor (var a = 0, b = 10; a < 10, b >= 0; ++a, --b) { }\r\nvar a = new ActiveXObject(\"\", \"\");\r\nswitch (a) {\r\n case 1, 2, 3:\r\n break;\r\n}", rules: [ "NoSpaceAfterComma" ], span: { start: 0, length: 228 }, expected: "function a(b,c) { }\r\na(0,1);\r\nvar a =[,];\r\nvar a =[0,1];\r\nvar a,b,c = 0,d = 0;\r\nfor (var a = 0,b = 10; a < 10,b >= 0; ++a,--b) { }\r\nvar a = new ActiveXObject(\"\",\"\");\r\nswitch (a) {\r\n case 1,2,3:\r\n break;\r\n}" }, -{ input: "function Sum(a, b, c) {\r\nvar d = 1;\r\n}", rules: [ ], span: { start: 0, length: 38 }, expected: "function Sum(a, b, c) {\r\n var d = 1;\r\n}" }, -{ input: "(function() { })();\r\nvar a = function() { };\r\nvar a = { b: function() { } };", rules: [ "SpaceAfterAnonymousFunctionKeyword" ], span: { start: 0, length: 76 }, expected: "(function () { })();\r\nvar a = function () { };\r\nvar a = { b: function () { } };" }, -{ input: "(function () { })();\r\nvar a = function () { };\r\nvar a = { b: function () { } };", rules: [ "NoSpaceAfterAnonymousFunctionKeyword" ], span: { start: 0, length: 79 }, expected: "(function() { })();\r\nvar a = function() { };\r\nvar a = { b: function() { } };" }, -{ input: "function a() {\r\n}b;", rules: [ ], span: { start: 0, length: 19 }, expected: "function a() {\r\n} b;" }, -{ input: "function a() {\r\n} b;", rules: [ ], span: { start: 0, length: 21 }, expected: "function a() {\r\n} b;" }, -{ input: "function a(){return 0;}\r\nfunction b(){toString();return 0;}", rules: [ ], span: { start: 0, length: 59 }, expected: "function a() { return 0; }\r\nfunction b() { toString(); return 0; }" }, -{ input: "for (var i = 0;i < 10;++i) { }", rules: [ "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 30 }, expected: "for (var i = 0; i < 10; ++i) { }" }, -{ input: "for (var i = 0; i < 10; ++i) { }", rules: [ "NoSpaceAfterSemicolonInFor" ], span: { start: 0, length: 32 }, expected: "for (var i = 0;i < 10;++i) { }" }, -{ input: "function f() {\r\nif (1)\r\n{\r\nvar a=0;\r\n}\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl", "NewLineBeforeOpenCurlyInFunction" ], span: { start: 0, length: 41 }, expected: "function f()\n{\r\n if (1) {\r\n var a=0;\r\n }\r\n}" }, -{ input: "function a(b) {\r\n a({\r\n});\r\n}", rules: [ ], span: { start: 0, length: 32 }, expected: "function a(b) {\r\n a({\r\n });\r\n}" }, -{ input: "// var a=[1,2];\r\n/*\r\nvar a=[1,2];\r\n*/", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 3, length: 12 }, expected: "// var a=[1,2];\r\n/*\r\nvar a=[1,2];\r\n*/" }, -{ input: "// var a=[1,2];\r\n/*\r\nvar a=[1,2];\r\n*/", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 21, length: 12 }, expected: "// var a=[1,2];\r\n/*\r\nvar a=[1,2];\r\n*/" }, -{ input: "eval(\"var a=b[1,2+3];\");", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 6, length: 15 }, expected: "eval(\"var a=b[1,2+3];\");" }, -{ input: "0 + +1;\r\n0 + +a;\r\n0 + +(1);\r\n0 + +(+1);\r\n0 + +[1];\r\n0 + +[+1];\r\n0 + +this.a;\r\n0 + +new Number(+1);\r\n\r\n0 - -1;\r\n0 - -a;\r\n0 - -(1);\r\n0 - -(-1);\r\n0 - -[1];\r\n0 - -[-1];\r\n0 - -this.a;\r\n0 - -new Number(-1);\r\n\r\n0 + ~1;\r\n0 - ~a;\r\n0 + ~(1);\r\n0 - ~(~1);\r\n0 + ~[1];\r\n0 - ~[~1];\r\n0 + ~this.a;\r\n0 - ~new Number(~1);\r\n\r\n0 - !1;\r\n0 + !a;\r\n0 - !(1);\r\n0 + !(!1);\r\n0 - ![1];\r\n0 + ![!1];\r\n0 - !this.a;\r\n0 + !new Number(!1);", rules: [ "NoSpaceBeforeBinaryOperator", "NoSpaceAfterBinaryOperator" ], span: { start: 0, length: 404 }, expected: "0+ +1;\r\n0+ +a;\r\n0+ +(1);\r\n0+ +(+1);\r\n0+ +[1];\r\n0+ +[+1];\r\n0+ +this.a;\r\n0+ +new Number(+1);\r\n\r\n0- -1;\r\n0- -a;\r\n0- -(1);\r\n0- -(-1);\r\n0- -[1];\r\n0- -[-1];\r\n0- -this.a;\r\n0- -new Number(-1);\r\n\r\n0+~1;\r\n0-~a;\r\n0+~(1);\r\n0-~(~1);\r\n0+~[1];\r\n0-~[~1];\r\n0+~this.a;\r\n0-~new Number(~1);\r\n\r\n0-!1;\r\n0+!a;\r\n0-!(1);\r\n0+!(!1);\r\n0-![1];\r\n0+![!1];\r\n0-!this.a;\r\n0+!new Number(!1);" }, -{ input: "0+ +1;\r\n0+ +a;\r\n0+ +(1);\r\n0+ +(+1);\r\n0+ +[1];\r\n0+ +[+1];\r\n0+ +this.a;\r\n0+ +new Number(+1);\r\n\r\n0- -1;\r\n0- -a;\r\n0- -(1);\r\n0- -(-1);\r\n0- -[1];\r\n0- -[-1];\r\n0- -this.a;\r\n0- -new Number(-1);\r\n\r\n0+~1;\r\n0-~a;\r\n0+~(1);\r\n0-~(~1);\r\n0+~[1];\r\n0-~[~1];\r\n0+~this.a;\r\n0-~new Number(~1);\r\n\r\n0-!1;\r\n0+!a;\r\n0-!(1);\r\n0+!(!1);\r\n0-![1];\r\n0+![!1];\r\n0-!this.a;\r\n0+!new Number(!1);", rules: [ "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 356 }, expected: "0 + +1;\r\n0 + +a;\r\n0 + +(1);\r\n0 + +(+1);\r\n0 + +[1];\r\n0 + +[+1];\r\n0 + +this.a;\r\n0 + +new Number(+1);\r\n\r\n0 - -1;\r\n0 - -a;\r\n0 - -(1);\r\n0 - -(-1);\r\n0 - -[1];\r\n0 - -[-1];\r\n0 - -this.a;\r\n0 - -new Number(-1);\r\n\r\n0 + ~1;\r\n0 - ~a;\r\n0 + ~(1);\r\n0 - ~(~1);\r\n0 + ~[1];\r\n0 - ~[~1];\r\n0 + ~this.a;\r\n0 - ~new Number(~1);\r\n\r\n0 - !1;\r\n0 + !a;\r\n0 - !(1);\r\n0 + !(!1);\r\n0 - ![1];\r\n0 + ![!1];\r\n0 - !this.a;\r\n0 + !new Number(!1);" }, -{ input: "for (var a = 0; a < 2; ++a) {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl", "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 32 }, expected: "for (var a = 0; a < 2; ++a)\n{\r\n}" }, -{ input: "for (var a = 0; a < 2; ++a)\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl", "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 32 }, expected: "for (var a = 0; a < 2; ++a) {\r\n}" }, -{ input: "function foo(a, b, c) { a = b + c;\n}", rules: [ "NewLineBeforeOpenCurlyInFunction", "NewLineAfterOpenCurlyInBlockContext", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 36 }, expected: "function foo(a, b, c)\n{\n a = b + c;\n}" }, -{ input: "function a() {\r\n // comment\r\n}", rules: [ ], span: { start: 0, length: 33 }, expected: "function a() {\r\n // comment\r\n}" }, -{ input: "if (false) {\r\n} else if (true) {\r\n} else {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 45 }, expected: "if (false)\n{\r\n} else if (true)\n{\r\n} else\n{\r\n}" }, -{ input: "if (false)\n{\r\n} else if (true)\n{\r\n} else\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 45 }, expected: "if (false) {\r\n} else if (true) {\r\n} else {\r\n}" }, -{ input: "var a = (0);\r\nvar b = (1);\r\nvar c = (1 + 2);\r\nvar d = ((1 + 2)-(3 + 4));\r\n\r\nvar e = ( 0 );\r\nvar f = ( 1 );\r\nvar g = ( 1 + 2 );\r\nvar h = ( ( 1 + 2 ) - ( 3 + 4 ) );", rules: [ "SpaceAfterOpenParen", "SpaceBeforeCloseParen", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 162 }, expected: "var a = ( 0 );\r\nvar b = ( 1 );\r\nvar c = ( 1 + 2 );\r\nvar d = ( ( 1 + 2 ) - ( 3 + 4 ) );\r\n\r\nvar e = ( 0 );\r\nvar f = ( 1 );\r\nvar g = ( 1 + 2 );\r\nvar h = ( ( 1 + 2 ) - ( 3 + 4 ) );" }, -{ input: "eval(\"var a=b[1,2+3];\");", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 24 }, expected: "eval(\"var a=b[1,2+3];\");" }, -{ input: "for (a in b)\r\n\r\n{ i++; }\r\n\r\nfor (a in b)\r\n\r\n{\r\ni++; }", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 53 }, expected: "for (a in b)\r\n\r\n{ i++; }\r\n\r\nfor (a in b) {\r\n i++;\n}" }, -{ input: "for (a in b) {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 17 }, expected: "for (a in b)\n{\r\n}" }, -{ input: "for (a in b)\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 17 }, expected: "for (a in b) {\r\n}" }, -{ input: " var a = { } ; \r\nvar b = { c : d, e : { } };\r\n ", rules: [ "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 59 }, expected: "var a = {};\r\nvar b = { c: d, e: {} };\r\n" }, -{ input: "while (true) { }", rules: [ ], span: { start: 0, length: 19 }, expected: "while (true) { }" }, -{ input: "for (a in b){ i++; }\r\n\r\nfor (a in b){ i++; }", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 44 }, expected: "for (a in b) { i++; }\r\n\r\nfor (a in b) { i++; }" }, -{ input: "function a() {\r\n}", rules: [ "NewLineBeforeOpenCurlyInFunction" ], span: { start: 0, length: 17 }, expected: "function a()\n{\r\n}" }, -{ input: "function a()\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInFunction" ], span: { start: 0, length: 17 }, expected: "function a() {\r\n}" }, -{ input: "a;\r\nb;c;\r\nd;", rules: [ ], span: { start: 0, length: 12 }, expected: "a;\r\nb; c;\r\nd;" }, -{ input: "a;\r\nb; c;\r\nd;", rules: [ ], span: { start: 0, length: 14 }, expected: "a;\r\nb; c;\r\nd;" }, -{ input: " var a = 0;\r\n function b() {\r\n var c = 0;\r\n }", rules: [ "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 61 }, expected: "var a = 0;\r\nfunction b() {\r\n var c = 0;\r\n}" }, -{ input: "a;b;", rules: [ ], span: { start: 0, length: 4 }, expected: "a; b;" }, -{ input: "a; b;", rules: [ ], span: { start: 0, length: 6 }, expected: "a; b;" }, -{ input: "var a = (0);\r\nvar b = (1);\r\nvar c = (1 + 2);\r\nvar d = ((1 + 2)-(3 + 4));\r\n\r\nvar e = ( 0 );\r\nvar f = ( 1 );\r\nvar g = ( 1 + 2 );\r\nvar h = ( ( 1 + 2 ) - ( 3 + 4 ) );", rules: [ "NoSpaceAfterOpenParen", "NoSpaceBeforeCloseParen", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 162 }, expected: "var a = (0);\r\nvar b = (1);\r\nvar c = (1 + 2);\r\nvar d = ((1 + 2) - (3 + 4));\r\n\r\nvar e = (0);\r\nvar f = (1);\r\nvar g = (1 + 2);\r\nvar h = ((1 + 2) - (3 + 4));" }, -{ input: "function a() {\r\n(b);\r\n}", rules: [ ], span: { start: 0, length: 23 }, expected: "function a() {\r\n (b);\r\n}" }, -{ input: "function test(a) {\n var i;\n for (i = 0;i < 1; i++){ //select\n a++;//select\n }\n}", rules: [ "NewLineBeforeOpenCurlyInControl", "NewLineAfterOpenCurlyInBlockContext", "NewLineBeforeOpenCurlyInFunction", "SpaceAfterSemicolonInFor" ], span: { start: 30, length: 50 }, expected: "function test(a) {\n var i;\n for (i = 0; i < 1; i++)\n { //select\n a++;//select\n }\n}" }, -{ input: "function a(){ return 1; }", rules: [ "SpaceBeforeOpenCurlyInFunction" ], span: { start: 0, length: 25 }, expected: "function a() { return 1; }" }, -{ input: "do {\r\n} while (true);", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 21 }, expected: "do\n{\r\n} while (true);" }, -{ input: "do\n{\r\n} while (true);", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 21 }, expected: "do {\r\n} while (true);" }, -{ input: "for (;;) { a = b + c; b = 2;\n}", rules: [ "NewLineBeforeOpenCurlyInControl", "NewLineAfterOpenCurlyInBlockContext", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator", "NoSpaceAfterSemicolonInFor" ], span: { start: 0, length: 30 }, expected: "for (;;)\n{\n a = b + c; b = 2;\n}" }, -{ input: "var a =0;\r\n\r\n+ 1;\r\n+ a;\r\n+ (1);\r\n+ (+ 1);\r\n+ [1];\r\n+ [+ 1];\r\n+ this.a;\r\n+ new Number(+ 1);\r\n\r\n- 1;\r\n- a;\r\n- (1);\r\n- (- 1);\r\n- [1];\r\n- [- 1];\r\n- this.a;\r\n- new Number(- 1);\r\n\r\n~ 1;\r\n~ a;\r\n~ (1);\r\n~ (~ 1);\r\n~ [1];\r\n~ [~ 1];\r\n~ this.a;\r\n~ new Number(~ 1);\r\n\r\n! 1;\r\n! a;\r\n! (1);\r\n! (! 1);\r\n! [1];\r\n! [! 1];\r\n! this.a;\r\n! new Number(! 1);\r\n\r\n++ a;\r\n++ (a);\r\n++ this.a;\r\n++ new f().a;\r\n\r\n-- a;\r\n-- (a);\r\n-- this.a;\r\n-- new f().a;\r\n\r\na ++;\r\n(a) ++;\r\nthis.a ++;\r\nnew f().a ++;\r\n\r\na --;\r\n(a) --;\r\nthis.a --;\r\nnew f().a --;", rules: [ ], span: { start: 0, length: 513 }, expected: "var a =0;\r\n\r\n+1;\r\n+a;\r\n+(1);\r\n+(+1);\r\n+[1];\r\n+[+1];\r\n+this.a;\r\n+new Number(+1);\r\n\r\n-1;\r\n-a;\r\n-(1);\r\n-(-1);\r\n-[1];\r\n-[-1];\r\n-this.a;\r\n-new Number(-1);\r\n\r\n~1;\r\n~a;\r\n~(1);\r\n~(~1);\r\n~[1];\r\n~[~1];\r\n~this.a;\r\n~new Number(~1);\r\n\r\n!1;\r\n!a;\r\n!(1);\r\n!(!1);\r\n![1];\r\n![!1];\r\n!this.a;\r\n!new Number(!1);\r\n\r\n++a;\r\n++(a);\r\n++this.a;\r\n++new f().a;\r\n\r\n--a;\r\n--(a);\r\n--this.a;\r\n--new f().a;\r\n\r\na++;\r\n(a)++;\r\nthis.a++;\r\nnew f().a++;\r\n\r\na--;\r\n(a)--;\r\nthis.a--;\r\nnew f().a--;" }, -{ input: "switch (a) {\r\n case 0:\r\n break;\r\n default:\r\n break;\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 74 }, expected: "switch (a)\n{\r\n case 0:\r\n break;\r\n default:\r\n break;\r\n}" }, -{ input: "switch (a)\n{\r\n case 0:\r\n break;\r\n default:\r\n break;\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 74 }, expected: "switch (a) {\r\n case 0:\r\n break;\r\n default:\r\n break;\r\n}" }, -{ input: "function a()\r\n\r\n\r\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInFunction" ], span: { start: 0, length: 22 }, expected: "function a() {\r\n}" }, -{ input: "try {\r\n} catch (e) {\r\n} finally {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 36 }, expected: "try\n{\r\n} catch (e)\n{\r\n} finally\n{\r\n}" }, -{ input: "try\n{\r\n} catch (e)\n{\r\n} finally\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 36 }, expected: "try {\r\n} catch (e) {\r\n} finally {\r\n}" }, -{ input: "with (a) {\r\n b = 0;\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 25 }, expected: "with (a)\n{\r\n b = 0;\r\n}" }, -{ input: "with (a)\n{\r\n b = 0;\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 25 }, expected: "with (a) {\r\n b = 0;\r\n}" }, -{ input: "var a=0+1-2*3/4%5;\r\na+=6;\r\na-=7;\r\na*=7;\r\na/=8;\r\na%=9;\r\na=+1- -2+ +3;\r\na=1.0+2.+.0;\r\n++a+a++;\r\n--a-a--;\r\n\r\nvar b=~1&2|3^4<<1>>1>>>2;\r\nb&=5;\r\nb^=6;\r\nb|=7;\r\nb<<=8;\r\nb>>=9;\r\nb>>>=10;\r\n\r\nvar c=a>b;\r\nc=b=b;\r\nc=!c;\r\n\r\n++a+ ++a+a++ +a++ + ++a;\r\n--a- --a-a-- -a-- - --a;\r\n\r\nfunction d::e() { }", rules: [ "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 366 }, expected: "var a = 0 + 1 - 2 * 3 / 4 % 5;\r\na += 6;\r\na -= 7;\r\na *= 7;\r\na /= 8;\r\na %= 9;\r\na = +1 - -2 + +3;\r\na = 1.0 + 2. + .0;\r\n++a + a++;\r\n--a - a--;\r\n\r\nvar b = ~1 & 2 | 3 ^ 4 << 1 >> 1 >>> 2;\r\nb &= 5;\r\nb ^= 6;\r\nb |= 7;\r\nb <<= 8;\r\nb >>= 9;\r\nb >>>= 10;\r\n\r\nvar c = a > b;\r\nc = b < a ? a : b;\r\nc = true && false || true;\r\nc = a == b;\r\nc = a === b;\r\nc = a != b;\r\nc = a !== b;\r\nc = a <= b;\r\nc = a >= b;\r\nc = !c;\r\n\r\n++a + ++a + a++ + a++ + ++a;\r\n--a - --a - a-- - a-- - --a;\r\n\r\nfunction d::e() { }" }, -{ input: "var a = 0 + 1 - 2 * 3 / 4 % 5;\r\na += 6;\r\na -= 7;\r\na *= 7;\r\na /= 8;\r\na %= 9;\r\na = +1 - -2 + +3;\r\na = 1.0 + 2. + .0;\r\n++a + a++;\r\n--a - a--;\r\n\r\nvar b = ~1 & 2 | 3 ^ 4 << 1 >> 1 >>> 2;\r\nb &= 5;\r\nb ^= 6;\r\nb |= 7;\r\nb <<= 8;\r\nb >>= 9;\r\nb >>>= 10;\r\n\r\nvar c = a > b;\r\nc = b < a ? a : b;\r\nc = true && false || true;\r\nc = a == b;\r\nc = a === b;\r\nc = a != b;\r\nc = a !== b;\r\nc = a <= b;\r\nc = a >= b;\r\nc = !c;\r\n\r\n++a + ++a + a++ + a++ + ++a;\r\n--a - --a - a-- - a-- - --a;\r\n\r\nfunction d::e() { }", rules: [ "NoSpaceBeforeBinaryOperator", "NoSpaceAfterBinaryOperator" ], span: { start: 0, length: 480 }, expected: "var a=0+1-2*3/4%5;\r\na+=6;\r\na-=7;\r\na*=7;\r\na/=8;\r\na%=9;\r\na=+1- -2+ +3;\r\na=1.0+2.+.0;\r\n++a+a++;\r\n--a-a--;\r\n\r\nvar b=~1&2|3^4<<1>>1>>>2;\r\nb&=5;\r\nb^=6;\r\nb|=7;\r\nb<<=8;\r\nb>>=9;\r\nb>>>=10;\r\n\r\nvar c=a>b;\r\nc=b=b;\r\nc=!c;\r\n\r\n++a+ ++a+a++ +a++ + ++a;\r\n--a- --a-a-- -a-- - --a;\r\n\r\nfunction d::e() { }" }, -{ input: "function foo()\n\n{ a = 1\n}", rules: [ "NewLineBeforeOpenCurlyInFunction" ], span: { start: 0, length: 25 }, expected: "function foo()\n{\n a = 1\n}" }, -{ input: "while (true) {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 17 }, expected: "while (true)\n{\r\n}" }, -{ input: "while (true)\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 17 }, expected: "while (true) {\r\n}" }, -{ input: "var z = 1;\r\n for (i = 0; i < 10; i++)\r\n for (j = 0; j < 10; j++)\r\nfor (k = 0; k < 10; ++k)\r\n{\r\nz++;\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl", "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 117 }, expected: "var z = 1;\r\nfor (i = 0; i < 10; i++)\r\n for (j = 0; j < 10; j++)\r\n for (k = 0; k < 10; ++k) {\r\n z++;\r\n }" }, -{ input: "a++;b++;\nfor (; ; ) {\nx++;m++;\n}", rules: [ "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 32 }, expected: "a++; b++;\nfor (; ; ) {\n x++; m++;\n}" }, -{ input: "var a;\r\n $(document).ready(function() {\r\n alert('hello');\r\n});\r\n", rules: [ ], span: { start: 0, length: 117 }, expected: "var a;\r\n$(document).ready(function () {\r\n alert('hello');\r\n});\r\n" } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/formatDiffTemplate.html b/src/harness/unittests/services/formatting/formatDiffTemplate.html deleted file mode 100644 index d5bc6537cc..0000000000 --- a/src/harness/unittests/services/formatting/formatDiffTemplate.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts b/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts deleted file mode 100644 index 9ad1102d2f..0000000000 --- a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts +++ /dev/null @@ -1,88 +0,0 @@ -/// - -describe('getFormattingEditsForRange', function() { - // - // Verify that formatting the typescript file "sourceFileName" results in the - // baseline file "baselineFileName". - // - function getFormattingEditsForRange(sourceFileName: string) { - var baselineFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + "BaseLine.ts"; - sourceFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + ".ts"; - - var typescriptLS = new Harness.TypeScriptLS(); - typescriptLS.addDefaultLibrary(); - typescriptLS.addFile(sourceFileName); - - var ls = typescriptLS.getLanguageService(); - var script = ls.languageService.getScriptAST(sourceFileName); - assert.notNull(script); - - var edits = ls.languageService.getFormattingEditsForRange(sourceFileName, 0, script.limChar, new Services.FormatCodeOptions()); - typescriptLS.checkEdits(sourceFileName, baselineFileName, edits); - } - - describe('test cases for formatting engine', function() { - it("formats typescript constructs properly", function() { - getFormattingEditsForRange('typescriptConstructs'); - }); - it("formats document ready function properly", function() { - getFormattingEditsForRange('documentReadyFunction'); - }); - it("formats on closing bracket properly", function() { - getFormattingEditsForRange('onClosingBracket'); - }); - it("formats various javascript constructs", function() { - getFormattingEditsForRange('various'); - }); - it("formats main javascript program", function() { - getFormattingEditsForRange('main'); - }); - it("formats on semicolon properly", function() { - getFormattingEditsForRange('onSemiColon'); - }); - it("formats enum with trailling tab characters properly", function() { - getFormattingEditsForRange('tabAfterCloseCurly'); - }); - it("formats object literal", function() { - getFormattingEditsForRange('objectLiteral'); - }); - it("formats with statements", function() { - getFormattingEditsForRange('withStatement'); - }); - it("formats ':' and '?' in parameters", function() { - getFormattingEditsForRange('colonAndQMark'); - }); - it("formats 'import' declaration", function() { - getFormattingEditsForRange('importDeclaration'); - }); - it("formats exported class with implicit module", function() { - //TODO: this is to force generation of implicit module in AST - var svGenTarget = TypeScript.moduleGenTarget; - try { - TypeScript.moduleGenTarget = TypeScript.ModuleGenTarget.Asynchronous; - getFormattingEditsForRange('implicitModule'); - } - finally { - TypeScript.moduleGenTarget = svGenTarget; - } - }); - it("formats constructor statements correctelly", function() { - getFormattingEditsForRange('spaceAfterConstructor'); - }); - it("formats classes and interfaces correctelly", function() { - getFormattingEditsForRange('classes'); - }); - it("formats modules correctly", function() { - getFormattingEditsForRange('modules'); - }); - it("formats fat arrow expressions correctelly", function() { - getFormattingEditsForRange('fatArrowFunctions'); - }); - it("formats empty object/interface literals correctelly", function() { - getFormattingEditsForRange('emptyInterfaceLiteral'); - }); - it("formats variable declaration lists", function() { - getFormattingEditsForRange('formatVariableDeclarationList'); - }); - }); -}); diff --git a/src/harness/unittests/services/formatting/getSmartIndentAtLineNumber.ts b/src/harness/unittests/services/formatting/getSmartIndentAtLineNumber.ts deleted file mode 100644 index 52e7982bd4..0000000000 --- a/src/harness/unittests/services/formatting/getSmartIndentAtLineNumber.ts +++ /dev/null @@ -1,410 +0,0 @@ -/// - -describe('getSmartIndentAtLineNumber', function() { - var typescriptLS = new Harness.TypeScriptLS(); - - typescriptLS.addDefaultLibrary(); - - var fileName = 'tests/cases/unittests/services/testCode/getSmartIndentAtLineNumber.ts'; - var fileName2 = 'tests/cases/unittests/services/testCode/getSmartIndentAtLineNumber2.ts'; - var fileName3 = 'tests/cases/unittests/services/testCode/getSmartIndentAtLineNumber3.ts'; - - typescriptLS.addFile(fileName); - typescriptLS.addFile(fileName2); - typescriptLS.addFile(fileName3); - - var ls = typescriptLS.getLanguageService(); - - // - // line is 1-based - // - function getSmartIndent(fileName: string, line: number): number { - assert.is(line >= 1); - var options = new Services.EditorOptions(); - var position = typescriptLS.lineColToPosition(fileName, line, 1); - return ls.languageService.getSmartIndentAtLineNumber(fileName, position, options); - } - - describe("test cases for smart indent", function() { - - it("smart indent inside module", function() { - var result = getSmartIndent(fileName, 2); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside class", function() { - var result = getSmartIndent(fileName, 4); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after property in class", function() { - var result = getSmartIndent(fileName, 6); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent inside method in class ", function() { - var result = getSmartIndent(fileName, 9); - - assert.notNull(result); - assert.equal(12, result); - }); - - it("smart indent after after method in class", function() { - var result = getSmartIndent(fileName, 12); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after class", function() { - var result = getSmartIndent(fileName, 17); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent in interface", function() { - var result = getSmartIndent(fileName, 19); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after property in interface", function() { - var result = getSmartIndent(fileName, 21); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after method in interface", function() { - var result = getSmartIndent(fileName, 23); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after interface", function() { - var result = getSmartIndent(fileName, 25); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent in nested module", function() { - var result = getSmartIndent(fileName, 27); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after function in nested module", function() { - var result = getSmartIndent(fileName, 30); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after variable in nested module", function() { - var result = getSmartIndent(fileName, 32); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after nested module", function() { - var result = getSmartIndent(fileName, 34); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent in enum", function() { - var result = getSmartIndent(fileName, 36); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after variable in enum", function() { - var result = getSmartIndent(fileName, 38); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after 2nd variable in enum", function() { - var result = getSmartIndent(fileName, 40); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after enum", function() { - var result = getSmartIndent(fileName, 42); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent after module", function() { - var result = getSmartIndent(fileName, 44); - - assert.notNull(result); - assert.equal(0, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent after an aligned function argument", function() { - var result = getSmartIndent(fileName, 47); - - assert.notNull(result); - assert.equal(13, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent inside a 'for' statement", function() { - var result = getSmartIndent(fileName, 53); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'for' statement", function() { - var result = getSmartIndent(fileName, 55); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside a 'for in' statement", function() { - var result = getSmartIndent(fileName, 57); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'for in' statement", function() { - var result = getSmartIndent(fileName, 59); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside a 'with' statement", function() { - var result = getSmartIndent(fileName, 61); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'with' statement", function() { - var result = getSmartIndent(fileName, 63); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside a 'switch' statement", function() { - var result = getSmartIndent(fileName, 65); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'switch' statement", function() { - var result = getSmartIndent(fileName, 67); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside a 'break' statement", function() { - var result = getSmartIndent(fileName, 69); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'break' statement", function() { - var result = getSmartIndent(fileName, 71); - - assert.notNull(result); - assert.equal(12, result); - }); - - it("smart indent after a 'break' statement", function() { - var result = getSmartIndent(fileName, 73); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after last 'switch' statement", function() { - var result = getSmartIndent(fileName, 75); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent before 'try' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 79); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent insde 'try' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 81); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent before 'catch' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 83); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside 'catch' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 85); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after 'catch' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 87); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent before 'try' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 92); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent insde 'try' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 94); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent before 'finally' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 96); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside 'finally' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 98); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after 'finally' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 100); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent before 'try' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 104); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent insde 'try' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 106); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent before 'catch' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 108); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside 'catch' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 110); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent before 'finally' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 112); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside 'finally' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 114); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after 'finally' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 116); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent inside a block inside case", function() { - var result = getSmartIndent(fileName, 127); - - assert.notNull(result); - assert.equal(20, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent works for a non terminated argument list at the end of a file", function() { - var result = getSmartIndent(fileName2, 8); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent works for a non terminated if statement at the end of a file", function() { - var result = getSmartIndent(fileName3, 7); - - assert.notNull(result); - assert.equal(4, result); - }); - }); -}); diff --git a/src/harness/unittests/services/formatting/importedJavaScriptFormatting.ts b/src/harness/unittests/services/formatting/importedJavaScriptFormatting.ts deleted file mode 100644 index 2fcb997767..0000000000 --- a/src/harness/unittests/services/formatting/importedJavaScriptFormatting.ts +++ /dev/null @@ -1,212 +0,0 @@ -/// -/// - -interface DocumentTestJson { - input: string; - rules: string[]; - span: { start: number; length: number; }; - expected: string; -} - -interface FormatOperationTestJson { - input: string; - operations: { - operation: string; - point: { position: number; }; - span: { start: number; length: number; }; - }[]; - expected: string; -} - -function markupCodeForHtml(code: string) { - var formatted = code.replace(/'); - var escaped = encodeURIComponent(code).replace(/'/g, '%27'); - - return formatted + '
Copy'; -} - -describe('importedJavaScriptFormatting - formatting rules', function() { - var documentTests: DocumentTestJson[] = eval('[' + IO.readFile(Harness.userSpecifiedroot + 'tests/cases/unittests/services/documentFormattingTests.json').contents() + ']'); - - var outputFile = 'diff-1.html'; - IO.writeFile(outputFile, IO.readFile(Harness.userSpecifiedroot + 'tests/cases/unittests/services/formatDiffTemplate.html').contents(), false); - - var checkTest = function(test: DocumentTestJson) { - var filename = 'temp.ts'; - var typescriptLS = new Harness.TypeScriptLS(); - typescriptLS.addScript(filename, test.input); - - var ls = typescriptLS.getLanguageService().languageService; - - var unsupportedRules = []; - var ruleMap = { - 'SpaceAfterSemicolonInFor': 'InsertSpaceAfterSemicolonInForStatements', - 'SpaceAfterComma': 'InsertSpaceAfterCommaDelimiter', - 'NewLineBeforeOpenCurlyInControl': 'PlaceOpenBraceOnNewLineForControlBlocks', - 'NewLineBeforeOpenCurlyInFunction': 'PlaceOpenBraceOnNewLineForFunctions' - }; - - var options = new Services.FormatCodeOptions(); - if (test.rules.indexOf('SpaceBeforeBinaryOperator') >= 0 && test.rules.indexOf('SpaceAfterBinaryOperator') >= 0) { - test.rules.splice(test.rules.indexOf('SpaceBeforeBinaryOperator'), 1); - test.rules.splice(test.rules.indexOf('SpaceAfterBinaryOperator'), 1); - options.InsertSpaceBeforeAndAfterBinaryOperators = true; - } - - test.rules.forEach(ruleName => { - if (options[ruleName] !== undefined) { - // The options struct has a matching property, just set it directly - options[ruleName] = true; - } else { - if (ruleMap[ruleName] !== undefined) { - // We have a remapping of this name, use that instead - options[ruleMap[ruleName]] = true; - } else { - if (ruleName.indexOf('No') === 0) { - // This is a 'NoFoo', set 'Foo' to false - options[ruleMap[ruleName.substr(2)]] = false; - } else { - // ?? - IO.printLine('Unsupported rule name ' + ruleName); - return; - } - } - } - }); - - var edits = ls.getFormattingEditsForRange(filename, test.span.start, test.span.start + test.span.length, options); - - var output = typescriptLS.applyEdits(test.input, edits); - - // Normalize line endings - output = output.replace(/\r\n/g, '\n'); - test.expected = test.expected.replace(/\r\n/g, '\n'); - - if (output != test.expected) { - var outputHtml = ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += '
InputOutputExpected
' + markupCodeForHtml(test.input) + '' + markupCodeForHtml(output) + '' + markupCodeForHtml(test.expected) + '
Format from character ' + test.span.start + ' to ' + (test.span.start + test.span.length) + ' with rules: ' + test.rules.join(', ') + '
'; // test-table - - IO.writeFile(outputFile, IO.readFile(outputFile).contents() + outputHtml, false); - - // TODO: Uncomment when things are working - // throw new Error("Formatting failed - refer to diff-1.html"); - } - } - - var i = 0; - - for (var i = 0; i < documentTests.length; i++) { - var test = documentTests[i]; - - var msg = 'formats the code (index ' + i + ') from ' + test.span.start + ' to ' + (test.span.start + test.span.length) + ' with rules = [' + test.rules.join(', ') + '] correctly'; - it(msg, function(t) { - return function() { - checkTest(t); - } - }(test)); - } -}); - -describe('importedJavaScriptFormatting - formatting operations', function() { - var outputFile = 'diff-2.html'; - IO.writeFile(outputFile, IO.readFile(Harness.userSpecifiedroot + 'tests/cases/unittests/services/formatDiffTemplate.html').contents(), false); - - var checkTest = function(test: FormatOperationTestJson) { - var filename = 'temp.ts'; - var typescriptLS = new Harness.TypeScriptLS(); - typescriptLS.addScript(filename, test.input); - - var ls = typescriptLS.getLanguageService(); - - var operationsText = ''; - - var markedUpInput = test.input; - var output = test.input; - - for (var i = 0; i < test.operations.length; i++) { - var options = new Services.FormatCodeOptions(); - var op = test.operations[i]; - var edits: Services.TextEdit[]; - - if (op.operation === 'CloseBrace') { - edits = ls.languageService.getFormattingEditsAfterKeystroke(filename, op.point.position, '}', options); - operationsText += 'Format for } at position ' + op.point.position.toString(); - markedUpInput = markedUpInput.substring(0, op.point.position) + '✪' + markedUpInput.substring(op.point.position); - } else if (op.operation === 'Enter') { - edits = ls.languageService.getFormattingEditsAfterKeystroke(filename, op.point.position, '\n', options); - operationsText += 'Format for [enter] at position ' + op.point.position.toString(); - markedUpInput = markedUpInput.substring(0, op.point.position) + '✪' + markedUpInput.substring(op.point.position); - } else if (op.operation === 'Semicolon') { - edits = ls.languageService.getFormattingEditsAfterKeystroke(filename, op.point.position, ';', options); - operationsText += 'Format for ; at position ' + op.point.position.toString(); - markedUpInput = markedUpInput.substring(0, op.point.position) + '✪' + markedUpInput.substring(op.point.position); - } else if (op.operation === 'Document') { - edits = ls.languageService.getFormattingEditsForRange(filename, 0, output.length, options); - operationsText += 'Format Document'; - } else if (op.operation === 'Selection') { - edits = ls.languageService.getFormattingEditsForRange(filename, op.span.start, op.span.start + op.span.length, options); - operationsText += 'Format selection from ' + op.span.start + ', length = ' + op.span.length; - } else if (op.operation === 'Paste') { - edits = ls.languageService.getFormattingEditsForRange(filename, op.span.start, op.span.start + op.span.length, options); - operationsText += 'Format pasted content from ' + op.span.start + ', length = ' + op.span.length; - } else { - throw new Error('Unknown operation: ' + op.operation); - } - - output = typescriptLS.applyEdits(test.input, edits); - typescriptLS.updateScript(filename, output); - } - - // Normalize line endings - output = output.replace(/\r\n/g, '\n'); - test.expected = test.expected.replace(/\r\n/g, '\n'); - - var outputHtml = ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += '
InputOutputExpected
' + markupCodeForHtml(markedUpInput) + '' + markupCodeForHtml(output) + '' + markupCodeForHtml(test.expected) + '
' + operationsText + '
'; // test-table - - if (test.expected == output) { - // Pass - } else { - IO.writeFile(outputFile, IO.readFile(outputFile).contents() + outputHtml, false); - // TODO: Uncomment when things are working - // throw new Error('Format test failed - refer to ' + outputFile); - } - } - - var operationsTests: FormatOperationTestJson[] = eval('[' + IO.readFile(Harness.userSpecifiedroot + 'tests/cases/unittests/services/ruleFormattingTests.json').contents() + ']'); - for (var i = 0; i < operationsTests.length; i++) { - var test = operationsTests[i]; - - var msg = 'formats the text correctly, line = ' + i; - it(msg, function(t) { - return function() { - checkTest(t); - } - }(test)); - } -}); - diff --git a/src/harness/unittests/services/formatting/ruleFormattingTests.json b/src/harness/unittests/services/formatting/ruleFormattingTests.json deleted file mode 100644 index 8f330156f6..0000000000 --- a/src/harness/unittests/services/formatting/ruleFormattingTests.json +++ /dev/null @@ -1,284 +0,0 @@ -{ input: "function a() {\r\nvar b = 0;//}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 31 } } ], expected: "function a() {\r\nvar b = 0;//}\r\n}" }, -{ input: "function foo() {\n do {\n } while (y < 10)\n\n}", operations: [ { operation: "Enter", point: { position: 50 } } ], expected: "function foo() {\n do {\n } while (y < 10)\n\n}" }, -{ input: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n}\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 87 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n }\r\n\r\n}" }, -{ input: "function a() {\r\n return (\r\n {\r\n x: 0\r\n }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 76 } } ], expected: "function a() {\r\n return (\r\n {\r\n x: 0\r\n }\r\n}" }, -{ input: " if ( a[\";\"])\r\nb++;", operations: [ { operation: "Semicolon", point: { position: 10 } } ], expected: " if ( a[\";\"])\r\nb++;" }, -{ input: "(function () {\r\n a({\r\n b: 0\r\n });\r\n\r\n})();", operations: [ { operation: "Enter", point: { position: 48 } } ], expected: "(function () {\r\n a({\r\n b: 0\r\n });\r\n\r\n})();" }, -{ input: "var obj={a:{b:2,c:{d:{e:{\r\n}}}}}", operations: [ { operation: "Enter", point: { position: 27 } } ], expected: "var obj = {\n a: {\n b: 2, c: {\n d: {\n e: {\r\n }\n }\n }\n }\n}" }, -{ input: "if(1)if(1)if(1)if(1)x+=2;", operations: [ { operation: "Semicolon", point: { position: 25 } } ], expected: "if (1) if (1) if (1) if (1) x += 2;" }, -{ input: "\r\nvar webclass = [\r\n { 'student':\r\n { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }\r\n }\r\n]", operations: [ { operation: "Document" } ], expected: "\r\nvar webclass = [\r\n {\n 'student':\r\n { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }\r\n }\r\n]" }, -{ input: "function f(x){ return x }\nwhile (f(true))\n y++;\n", operations: [ { operation: "Enter", point: { position: 51 } } ], expected: "function f(x){ return x }\nwhile (f(true))\n y++;\n" }, -{ input: "throw e;", operations: [ { operation: "Document" } ], expected: "throw e;" }, -{ input: "x = {\n a: 1,\n b: 1\n +\n // test\n 2\n}", operations: [ { operation: "Document" } ], expected: "x = {\n a: 1,\n b: 1\n +\n // test\n 2\n}" }, -{ input: "return 1;", operations: [ { operation: "Document" } ], expected: "return 1;" }, -{ input: "var x = [\n 1,\n 2,\n 3\n]", operations: [ { operation: "Document" } ], expected: "var x = [\n 1,\n 2,\n 3\n]" }, -{ input: "switch \r\n( a ){\r\n case 1:x+=2; break\r\n case 2:{\r\n }\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 9 } } ], expected: "switch\r\n(a) {\r\n case 1:x+=2; break\r\n case 2:{\r\n }\r\n}\r\n" }, -{ input: "if (a)\r\ntest;\r\nelse\r\nif (b)\r\ntest;\r\n", operations: [ { operation: "Enter", point: { position: 36 } } ], expected: "if (a)\r\ntest;\r\nelse\r\nif (b)\r\n test;\r\n" }, -{ input: "do{\r\ndo{\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)", operations: [ { operation: "CloseBrace", point: { position: 16 } } ], expected: "do{\r\ndo{\r\n do {\r\n } while (a !== b)\r\n}while(a!==b)\r\n}while(a!==b)" }, -{ input: "label1:\r\nvar a;\r\nvar b;", operations: [ { operation: "Document" } ], expected: "label1:\r\n var a;\r\nvar b;" }, -{ input: "\r\nfunction a() {\r\nfunction test() // test\r\n{\r\nif (test) // test\r\n{\r\n}\r\n}\r\n}", operations: [ { operation: "Document" } ], expected: "\r\nfunction a() {\r\n function test() // test\r\n {\r\n if (test) // test\r\n {\r\n }\r\n }\r\n}" }, -{ input: "var obj = {\r\na:{\r\nb:2,c:{\r\nd: {\r\ne: function f() {\r\nreturn obj.a.c.d.e() +f();\r\n}\r\n}\r\n}\r\n}\r\n};", operations: [ { operation: "Semicolon", point: { position: 94 } } ], expected: "var obj = {\r\n a: {\r\n b: 2, c: {\r\n d: {\r\n e: function f() {\r\n return obj.a.c.d.e() + f();\r\n }\r\n }\r\n }\r\n }\r\n};" }, -{ input: "function f() {\r\n do{\r\nx++ }\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "function f() {\r\n do{\r\n x++\n }\r\n\r\n}" }, -{ input: "function foo (a, b, c)", operations: [ { operation: "Document" } ], expected: "function foo(a, b, c)" }, -{ input: "{ var b;\n}", operations: [ { operation: "Document" } ], expected: "{\n var b;\n}" }, -{ input: "var z = {\na: 1};", operations: [ { operation: "Document" } ], expected: "var z = {\n a: 1\n};" }, -{ input: "for (var i = 0; i < 10; i++)\n { var a\n}", operations: [ { operation: "Document" } ], expected: "for (var i = 0; i < 10; i++) {\n var a\n}" }, -{ input: "if (1)\n {\nvar a }", operations: [ { operation: "Document" } ], expected: "if (1) {\n var a\n}" }, -{ input: "while (1)\n { var a\n}", operations: [ { operation: "Document" } ], expected: "while (1) {\n var a\n}" }, -{ input: "do\n { var a\n} while (1)", operations: [ { operation: "Document" } ], expected: "do {\n var a\n} while (1)" }, -{ input: "for (var a in b)\n { var a\n}", operations: [ { operation: "Document" } ], expected: "for (var a in b) {\n var a\n}" }, -{ input: "with (x)\n { var a\n}", operations: [ { operation: "Document" } ], expected: "with (x) {\n var a\n}" }, -{ input: "try\n { var a\n} \ncatch (e)\n { var a\n} \nfinally\n {\n}", operations: [ { operation: "Document" } ], expected: "try {\n var a\n}\ncatch (e) {\n var a\n}\nfinally {\n}" }, -{ input: "switch (x)\n { case 1: { var a }\n}", operations: [ { operation: "Document" } ], expected: "switch (x) {\n case 1: { var a }\n}" }, -{ input: "function f()\n { var x\n}", operations: [ { operation: "Document" } ], expected: "function f() {\n var x\n}" }, -{ input: "if(1)if(1)if(1)if(1){x+=2\r\n}", operations: [ { operation: "CloseBrace", point: { position: 28 } } ], expected: "if (1) if (1) if (1) if (1) {\n x += 2\r\n}" }, -{ input: "switch (a){\r\n case 1: x += 2;\r\n case 2 : \r\n for (var i=0;i<10;i++)\r\ni --;\r\n}\r\n", operations: [ { operation: "Semicolon", point: { position: 84 } } ], expected: "switch (a){\r\n case 1: x += 2;\r\n case 2 : \r\n for (var i = 0; i < 10; i++)\r\n i--;\r\n}\r\n" }, -{ input: "do{for(var i=0;i<10;i++)i-=2}while(1!==1);", operations: [ { operation: "Semicolon", point: { position: 42 } } ], expected: "do { for (var i = 0; i < 10; i++) i -= 2 } while (1 !== 1);" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;j++)\r\n{j-=i}}", operations: [ { operation: "Enter", point: { position: 45 } } ], expected: "for (var i = 0; i < 10; i++) {\n for (var j = 0; j < 10; j++)\r\n { j -= i }\n}" }, -{ input: "function f() {\r\nstring='string\\r\n line2' + 'other part'}", operations: [ { operation: "CloseBrace", point: { position: 63 } } ], expected: "function f() {\r\n string = 'string\\r\n line2' + 'other part'\n}" }, -{ input: "x =\r\n function ()\r\n{\r\n var a\r\n}", operations: [ { operation: "Document" } ], expected: "x =\r\n function () {\r\n var a\r\n }" }, -{ input: "if (a instanceof b) { }", operations: [ { operation: "Document" } ], expected: "if (a instanceof b) { }" }, -{ input: "do a++; while (0)", operations: [ { operation: "Document" } ], expected: "do a++; while (0)" }, -{ input: "foo\r\n(1, 2, 3)", operations: [ { operation: "Document" } ], expected: "foo\r\n(1, 2, 3)" }, -{ input: "if(1) //comment\r\n{\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "if (1) //comment\r\n{\r\n}\r\n" }, -{ input: "var x =\n [\n1\n]", operations: [ { operation: "Document" } ], expected: "var x =\n [\n1\n ]" }, -{ input: "\r\n{\r\n function f() {\r\n var s = 1\r\n }\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 59 } } ], expected: "\r\n{\r\n function f() {\r\n var s = 1\r\n }\r\n\r\n}" }, -{ input: "\r\ndefine(null,\r\n function test() {\r\nvar a;\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\ndefine(null,\r\n function test() {\r\n var a;\r\n }\r\n" }, -{ input: "x = [\r\n 1,\r\n\r\n]", operations: [ { operation: "Enter", point: { position: 15 } } ], expected: "x = [\r\n 1,\r\n\r\n]" }, -{ input: "var x =\n {\na: 1\n}", operations: [ { operation: "Document" } ], expected: "var x =\n {\n a: 1\n }" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "CloseBrace", point: { position: 50 } } ], expected: "for (var i = 0; i < 10; i++) { for (var j = 0; j < 10; j++) { j -= i } }" }, -{ input: "function f()\n{\n for (a in b)\n a++;\n}", operations: [ { operation: "Semicolon", point: { position: 40 } } ], expected: "function f()\n{\n for (a in b)\n a++;\n}" }, -{ input: "if(x!=1^y===2) \r\nx+=2\r\n", operations: [ { operation: "Enter", point: { position: 25 } } ], expected: "if(x!=1^y===2) \r\n x += 2\r\n" }, -{ input: "if (1)\r\n if (1)\r\n x++\r\n else\r\n if (1)\r\n x--\r\nelse\r\n x+=2\r\n", operations: [ { operation: "Enter", point: { position: 81 } } ], expected: "if (1)\r\n if (1)\r\n x++\r\n else\r\n if (1)\r\n x--\r\n else\r\n x += 2\r\n" }, -{ input: "switch (a){\r\ncase 1 : x+=2 ; break;\r\n case 2:{\r\n }\r\n}\r\n", operations: [ { operation: "Semicolon", point: { position: 44 } } ], expected: "switch (a){\r\n case 1: x += 2; break;\r\n case 2:{\r\n }\r\n}\r\n" }, -{ input: "{ { {\r\n{\r\ntest\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Selection", span: { start: 7, length: 19 } } ], expected: "{ { {\r\n {\r\n test\r\n }\r\n}\r\n}\r\n}" }, -{ input: "do {\r\n do {\r\n do {\r\n }while(a!==b)\r\n\r\n} while (a !== b)\r\n} while (a !== b)", operations: [ { operation: "Enter", point: { position: 55 } } ], expected: "do {\r\n do {\r\n do {\r\n }while(a!==b)\r\n\r\n } while (a !== b)\r\n} while (a !== b)" }, -{ input: "\r\nswitch (t) {\r\n case 1:\r\n{\r\ntest\r\n}\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\nswitch (t) {\r\n case 1:\r\n {\r\n test\r\n }\r\n}\r\n" }, -{ input: "if (true) {\r\n \r\n}", operations: [ { operation: "Document" } ], expected: "if (true) {\r\n\r\n}" }, -{ input: "for(var j=0;j<10;j++)\r\nj-=i;", operations: [ { operation: "Semicolon", point: { position: 28 } } ], expected: "for (var j = 0; j < 10; j++)\r\n j -= i;" }, -{ input: "function a() {\r\n function b() {\r\n //\r\n\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 48 } } ], expected: "function a() {\r\n function b() {\r\n //\r\n\r\n }\r\n}" }, -{ input: "if(1)if(1)if(1)if(1)x+=2\r\n", operations: [ { operation: "Enter", point: { position: 26 } } ], expected: "if (1) if (1) if (1) if (1) x += 2\r\n" }, -{ input: "do{do{do{}while(a!==b)}while(a!==b)}while(a!==b)\r\n", operations: [ { operation: "Enter", point: { position: 50 } } ], expected: "do { do { do { } while (a !== b) } while (a !== b) } while (a !== b)\r\n" }, -{ input: "foo(\r\n)", operations: [ { operation: "Document" } ], expected: "foo(\r\n)" }, -{ input: "function f() {\r\n'use strict';\r\n}", operations: [ { operation: "Semicolon", point: { position: 29 } } ], expected: "function f() {\r\n 'use strict';\r\n}" }, -{ input: "var x = function() {\n//comment\nreturn 1;\n}", operations: [ { operation: "Document" } ], expected: "var x = function () {\n //comment\n return 1;\n}" }, -{ input: " function foo4() {\r\n function foo5() {\r\n function foo6() {\r\n test1\r\n }\r\n test2\r\n }\r\n }", operations: [ { operation: "Selection", span: { start: 62, length: 120 } } ], expected: " function foo4() {\r\n function foo5() {\r\n function foo6() {\r\n test1\r\n }\r\n test2\r\n }\r\n }" }, -{ input: "do{\r\ndo{\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)", operations: [ { operation: "CloseBrace", point: { position: 46 } } ], expected: "do {\r\n do {\r\n do {\r\n } while (a !== b)\r\n } while (a !== b)\r\n} while (a !== b)" }, -{ input: "if (true)\n// test\n test;", operations: [ { operation: "Document" } ], expected: "if (true)\n // test\n test;" }, -{ input: "function test() {\r\n return (\r\n function test() {\r\n test;\r\n }\r\n );\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n return (\r\n function test() {\r\n test;\r\n }\r\n );\r\n}" }, -{ input: "for(var i=0;i<10;i++){\r\nfor(var j=0;j<10;j++){\r\nj-=i\r\n}}", operations: [ { operation: "CloseBrace", point: { position: 56 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n }\n}" }, -{ input: " var a = 0 ;", operations: [ { operation: "Semicolon", point: { position: 14 } } ], expected: "var a = 0;" }, -{ input: "var obj={a:{b:2,c:{d:\r\n{e:{}}}}}", operations: [ { operation: "Enter", point: { position: 23 } } ], expected: "var obj = {\n a: {\n b: 2, c: {\n d:\r\n { e: {} }\n }\n }\n}" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n}finally {\r\nx+=2\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 74 } } ], expected: "function foo() {\r\n try {\r\n x += 2\r\n }\r\n catch (e) {\r\n x += 2\r\n } finally {\r\n x += 2\r\n }\r\n}" }, -{ input: "var obj = {\r\na: {\r\nb: 2, c: {\r\nd: {\r\ne: function f() {\r\nreturn obj.a.c.d.e() + f();\r\n}\r\n}\r\n}\r\n}}", operations: [ { operation: "CloseBrace", point: { position: 96 } } ], expected: "var obj = {\r\n a: {\r\n b: 2, c: {\r\n d: {\r\n e: function f() {\r\n return obj.a.c.d.e() + f();\r\n }\r\n }\r\n }\r\n }\n}" }, -{ input: "if (x!=1^y===2){ x+=2}", operations: [ { operation: "CloseBrace", point: { position: 24 } } ], expected: "if (x != 1 ^ y === 2) { x += 2 }" }, -{ input: "function test() {\r\n var a;\r\n label:\r\n for (; ;)\r\n\r\n", operations: [ { operation: "Enter", point: { position: 58 } } ], expected: "function test() {\r\n var a;\r\n label:\r\n for (; ;)\r\n\r\n" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;j++){\r\nj-=i}}", operations: [ { operation: "Enter", point: { position: 46 } } ], expected: "for (var i = 0; i < 10; i++) {\n for (var j = 0; j < 10; j++) {\r\n j -= i\n }\n}" }, -{ input: "do {\r\n for (var i = 0; i < 10; i++)\r\n i -= 2\r\n }\r\nwhile (1 !== 1)", operations: [ { operation: "Enter", point: { position: 67 } } ], expected: "do {\r\n for (var i = 0; i < 10; i++)\r\n i -= 2\r\n}\r\nwhile (1 !== 1)" }, -{ input: "{\r\n try {\r\n } catch (e) {\r\n }\r\n}", operations: [ { operation: "Document" } ], expected: "{\r\n try {\r\n } catch (e) {\r\n }\r\n}" }, -{ input: "{ { {\r\n{\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Selection", span: { start: 7, length: 13 } } ], expected: "{ { {\r\n {\r\n }\r\n}\r\n}\r\n}" }, -{ input: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\nj -= i}}\r\n", operations: [ { operation: "Enter", point: { position: 78 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\n }\n}\r\n" }, -{ input: "var a = {\r\n}", operations: [ { operation: "Document" } ], expected: "var a = {\r\n}" }, -{ input: "\r\n switch ( a ) {\r\n case 1: x+=2;\r\n case 2:{\r\n }\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 2 } } ], expected: "\r\nswitch (a) {\r\n case 1: x+=2;\r\n case 2:{\r\n }\r\n}\r\n" }, -{ input: "function a() {\r\nvar b = 0;//;\r\n}", operations: [ { operation: "Semicolon", point: { position: 31 } } ], expected: "function a() {\r\nvar b = 0;//;\r\n}" }, -{ input: "for (a in b) { }", operations: [ { operation: "Document" } ], expected: "for (a in b) { }" }, -{ input: "\r\n{\r\nfunction test(/* test */ a,\r\n /* test */ b\r\n /* test */) {\r\n// test\r\n}\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\n{\r\n function test(/* test */ a,\r\n /* test */ b\r\n /* test */) {\r\n // test\r\n }\r\n}\r\n" }, -{ input: " //\r\n", operations: [ { operation: "Enter", point: { position: 8 } } ], expected: "//\r\n" }, -{ input: " if ( a[\"}\"])\r\nb++;", operations: [ { operation: "CloseBrace", point: { position: 10 } } ], expected: " if ( a[\"}\"])\r\nb++;" }, -{ input: "$ ( document ) . ready ( function ( ) { \n alert ( \"i am ready\" ) ;\n } );", operations: [ { operation: "Semicolon", point: { position: 138 } } ], expected: "$(document).ready(function () {\n alert(\"i am ready\");\n});" }, -{ input: "function f() {\r\nvar s=\"string\";\r\n}", operations: [ { operation: "Semicolon", point: { position: 31 } } ], expected: "function f() {\r\n var s = \"string\";\r\n}" }, -{ input: "do{for(var i=0;i<10;i++)i-=2\r\n}while(1!==1)", operations: [ { operation: "Enter", point: { position: 30 } } ], expected: "do {\n for (var i = 0; i < 10; i++) i -= 2\r\n} while (1 !== 1)" }, -{ input: "do{\r\ndo{\r\n\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)", operations: [ { operation: "Enter", point: { position: 12 } } ], expected: "do{\r\ndo{\r\n\r\n do {\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "CloseBrace", point: { position: 49 } } ], expected: "for (var i = 0; i < 10; i++) { for (var j = 0; j < 10; j++) { j -= i }}" }, -{ input: "var obj = {\r\na: {\r\nb: 2, c: {\r\nd: {\r\ne: function f() {\r\nreturn obj.a.c.d.e() + f();\r\n}\r\n}\r\n } \r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 99 } } ], expected: "var obj = {\r\na: {\r\n b: 2, c: {\r\n d: {\r\n e: function f() {\r\n return obj.a.c.d.e() + f();\r\n }\r\n }\r\n }\r\n}\r\n}" }, -{ input: "var a = 0 ;var b=0;var c = 0 ;", operations: [ { operation: "Paste", span: { start: 13, length: 7 } } ], expected: "var a = 0; var b = 0; var c = 0;" }, -{ input: "function a()\r\n{\r\n}", operations: [ { operation: "Enter", point: { position: 14 } } ], expected: "function a()\r\n{\r\n}" }, -{ input: " function test() { function foo() { function foo3() { function foo4() { function foo5() { function foo6()\r\n{\r\ntest\r\n}\r\n}\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Selection", span: { start: 110, length: 25 } } ], expected: " function test() { function foo() { function foo3() { function foo4() { function foo5() { function foo6()\r\n {\r\n test\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }" }, -{ input: " \r\nfunction a() { \r\n return; \r\n} \r\n ", operations: [ { operation: "Document" } ], expected: "\r\nfunction a() {\r\n return;\r\n}\r\n" }, -{ input: "foo(\r\n1, 2, 3)", operations: [ { operation: "Document" } ], expected: "foo(\r\n1, 2, 3)" }, -{ input: "function Init() {\r\n var a = [[1, 2],\r\n [3, 4],\r\n\r\n ];\r\n}", operations: [ { operation: "Enter", point: { position: 63 } } ], expected: "function Init() {\r\n var a = [[1, 2],\r\n [3, 4],\r\n\r\n ];\r\n}" }, -{ input: "\r\n //function start\r\n function abc() { }\r\n //function end\r\n", operations: [ { operation: "Document" } ], expected: "\r\n//function start\r\nfunction abc() { }\r\n//function end\r\n" }, -{ input: "for(var i=0;i<10;i++){\r\n for (var j = 0; j < 10; j++) {\r\nj-=i\r\n\r\n}\r\n}", operations: [ { operation: "Enter", point: { position: 66 } } ], expected: "for(var i=0;i<10;i++){\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n\r\n}\r\n}" }, -{ input: "// JScript source code\r\nfunction adder(a, b) {\r\n ///Adds two numbers \r\n return a + b;\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 94 } } ], expected: "// JScript source code\r\nfunction adder(a, b) {\r\n ///Adds two numbers \r\n return a + b;\r\n}\r\n" }, -{ input: "x = {\r\n a: function() {\r\n},\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "x = {\r\n a: function() {\r\n },\r\n\r\n}" }, -{ input: "if(1)\r\n if(1)\r\n x++\r\n else\r\n if(1)\r\n x+=2\r\n else\r\nx+=2\r\n", operations: [ { operation: "Enter", point: { position: 94 } } ], expected: "if(1)\r\n if(1)\r\n x++\r\n else\r\n if(1)\r\n x+=2\r\n else\r\n x += 2\r\n" }, -{ input: "for (a in b) {\nx++;}\n", operations: [ { operation: "Enter", point: { position: 21 } } ], expected: "for (a in b) {\n x++;\n}\n" }, -{ input: "if(1)if(1)if(1)if(1){x+=2}", operations: [ { operation: "CloseBrace", point: { position: 26 } } ], expected: "if (1) if (1) if (1) if (1) { x += 2 }" }, -{ input: "if (x!=1^y===2){ x+=2\r\n}", operations: [ { operation: "CloseBrace", point: { position: 26 } } ], expected: "if (x != 1 ^ y === 2) {\n x += 2\r\n}" }, -{ input: "var d = new Date ()", operations: [ { operation: "Document" } ], expected: "var d = new Date()" }, -{ input: "do {\r\n} while (1 == 10);", operations: [ { operation: "Document" } ], expected: "do {\r\n} while (1 == 10);" }, -{ input: "string='string+=2';", operations: [ { operation: "Semicolon", point: { position: 19 } } ], expected: "string = 'string+=2';" }, -{ input: "function foo() {\r\n try {\r\n }\r\ncatch(e){\r\n } finally {\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 48 } } ], expected: "function foo() {\r\n try {\r\n }\r\n catch (e) {\r\n } finally {\r\n }\r\n}" }, -{ input: "try // comment\r\n{\r\n}\r\ncatch (e) // comment\r\n{\r\n}\r\nfinally // comment\r\n{\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "try // comment\r\n{\r\n}\r\ncatch (e) // comment\r\n{\r\n}\r\nfinally // comment\r\n{\r\n}\r\n" }, -{ input: "function f() {\r\n /**/ var x;\r\n}", operations: [ { operation: "Semicolon", point: { position: 39 } } ], expected: "function f() {\r\n /**/ var x;\r\n}" }, -{ input: "if (a)\r\ntest;\r\nelse if (b)\r\ntest;", operations: [ { operation: "Document" } ], expected: "if (a)\r\n test;\r\nelse if (b)\r\n test;" }, -{ input: "foo(1, 2, 3\r\n)", operations: [ { operation: "Document" } ], expected: "foo(1, 2, 3\r\n)" }, -{ input: "\r\nswitch (a){\r\n case 1: x++;\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\nswitch (a) {\r\n case 1: x++;\r\n}\r\n" }, -{ input: "x = {\r\n a: function () {\r\n\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 39 } } ], expected: "x = {\r\n a: function () {\r\n\r\n }\r\n}" }, -{ input: "switch (a) {\n case 1: b++;\n break;\n\n default: a++;\n break;\n}", operations: [ { operation: "Enter", point: { position: 45 } } ], expected: "switch (a) {\n case 1: b++;\n break;\n\n default: a++;\n break;\n}" }, -{ input: "string='string+=2;'", operations: [ { operation: "Semicolon", point: { position: 18 } } ], expected: "string='string+=2;'" }, -{ input: "function test() {\r\n function foo() {\r\n var a;\r\n// some\r\ncomment\r\n", operations: [ { operation: "Enter", point: { position: 66 } } ], expected: "function test() {\r\n function foo() {\r\n var a;\r\n // some\r\n comment\r\n" }, -{ input: "switch ( a ) {\r\n case 1: x+=2;\r\n case 2:{for(var i=0;i<10;i++){ \r\nx+=2;}\r\n }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 89 } } ], expected: "switch (a) {\r\n case 1: x += 2;\r\n case 2: {\n for (var i = 0; i < 10; i++) {\r\n x += 2;\n }\r\n }\r\n}" }, -{ input: "do{\r\nfor(var i=0;i<10;i++)\r\ni-=2;\r\n}while(1!==1)", operations: [ { operation: "Semicolon", point: { position: 33 } } ], expected: "do{\r\n for (var i = 0; i < 10; i++)\r\n i -= 2;\r\n}while(1!==1)" }, -{ input: "\r\nfunction foo() {\r\n try{ } catch (e) { } finally { }\r\n\r\n\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 63 } } ], expected: "\r\nfunction foo() {\r\n try { } catch (e) { } finally { }\r\n\r\n\r\n}\r\n" }, -{ input: "do{for(var i=0;i<10;i++)\r\ni-=2}while(1!==1)", operations: [ { operation: "Enter", point: { position: 26 } } ], expected: "do {\n for (var i = 0; i < 10; i++)\r\n i -= 2\n} while (1 !== 1)" }, -{ input: "\r\n fun(\r\n {\r\n a: 1\r\n });\r\n", operations: [ { operation: "Document" } ], expected: "\r\nfun(\r\n {\r\n a: 1\r\n });\r\n" }, -{ input: "function f () //comment\r\n{\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "function f() //comment\r\n{\r\n}\r\n" }, -{ input: "function a(b) {\r\n var c = 0;\r\n if (b != null) {\r\n for (d in b) {\r\n }\r\n }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 94 } } ], expected: "function a(b) {\r\n var c = 0;\r\n if (b != null) {\r\n for (d in b) {\r\n }\r\n }\r\n}" }, -{ input: "switch (a) {\r\n case 1:\r\n\r\n break;\r\n}", operations: [ { operation: "Enter", point: { position: 34 } } ], expected: "switch (a) {\r\n case 1:\r\n\r\n break;\r\n}" }, -{ input: " \r\n do{\r\n for(var i=0;i<10;i++)\r\n i -= 2\r\n}\r\nwhile (1 !== 1)", operations: [ { operation: "Enter", point: { position: 5 } } ], expected: "\r\ndo {\r\n for(var i=0;i<10;i++)\r\n i -= 2\r\n}\r\nwhile (1 !== 1)" }, -{ input: "function test() {\r\n label1:\r\nvar a\r\n\r\n var b;\r\n}", operations: [ { operation: "Enter", point: { position: 39 } } ], expected: "function test() {\r\n label1:\r\n var a\r\n\r\n var b;\r\n}" }, -{ input: "var x = {\n//comment\na: 1\n}", operations: [ { operation: "Document" } ], expected: "var x = {\n //comment\n a: 1\n}" }, -{ input: "for(var i=0;i<10;i++){\r\n\r\nfor(var j=0;j<10;j++){\r\nj-=i\r\n}\r\n}", operations: [ { operation: "Enter", point: { position: 26 } } ], expected: "for(var i=0;i<10;i++){\r\n\r\n for (var j = 0; j < 10; j++) {\r\nj-=i\r\n}\r\n}" }, -{ input: "if (true) {\r\n//\r\n} else if (false) {\r\n//\r\n} else\r\n if (true)\r\n//", operations: [ { operation: "Document" } ], expected: "if (true) {\r\n //\r\n} else if (false) {\r\n //\r\n} else\r\n if (true)\r\n //" }, -{ input: "x = [\n 1,\n 1\n +\n // test\n 2\n]", operations: [ { operation: "Document" } ], expected: "x = [\n 1,\n 1\n +\n // test\n 2\n]" }, -{ input: "var x =\n function() {\nreturn 1;\n}", operations: [ { operation: "Document" } ], expected: "var x =\n function () {\n return 1;\n }" }, -{ input: "function f() {\n var x }", operations: [ { operation: "Document" } ], expected: "function f() {\n var x\n}" }, -{ input: "switch (a) {\r\n case 1: b++;\r\n break ;\r\n\r\n default: a++;\r\n break;\r\n}", operations: [ { operation: "Enter", point: { position: 46 } } ], expected: "switch (a) {\r\n case 1: b++;\r\n break;\r\n\r\n default: a++;\r\n break;\r\n}" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n} finally {\r\nx+=2\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 32 } } ], expected: "function foo() {\r\n try {\r\n x += 2\r\n }\r\ncatch( e){\r\nx+=2\r\n} finally {\r\nx+=2\r\n}\r\n}" }, -{ input: "function f(a, b\n , c){\n}", operations: [ { operation: "CloseBrace", point: { position: 39 } } ], expected: "function f(a, b\n , c) {\n}" }, -{ input: "function add(a, b) { return a + b}", operations: [ { operation: "Document" } ], expected: "function add(a, b) { return a + b }" }, -{ input: "var a = 0 ;\r\n", operations: [ { operation: "Enter", point: { position: 15 } } ], expected: "var a = 0;\r\n" }, -{ input: "var a = function (b) {\r\nb = 0;\r\n}", operations: [ { operation: "CloseBrace", point: { position: 33 } } ], expected: "var a = function (b) {\r\n b = 0;\r\n}" }, -{ input: "\r\nif (\r\n test) {\r\n a;\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\nif (\r\n test) {\r\n a;\r\n}\r\n" }, -{ input: " var a = 0 ;\r\n var b = { } ;\r\n var c = false ;", operations: [ { operation: "Selection", span: { start: 18, length: 34 } } ], expected: " var a = 0 ;\r\n var b = {};\r\n var c = false ;" }, -{ input: "function a() {\r\n return (\r\n function () {\r\n return 0;\r\n }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 93 } } ], expected: "function a() {\r\n return (\r\n function () {\r\n return 0;\r\n }\r\n}" }, -{ input: "function test() {\r\n label1:\r\n a();\r\n b()\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 59 } } ], expected: "function test() {\r\n label1:\r\n a();\r\n b()\r\n\r\n}" }, -{ input: "(function () {\r\n a({\r\n b: 0\r\n });\r\n})();", operations: [ { operation: "Document" } ], expected: "(function () {\r\n a({\r\n b: 0\r\n });\r\n})();" }, -{ input: "function a() {\r\n /**/ }", operations: [ { operation: "Document" } ], expected: "function a() {\r\n /**/\n}" }, -{ input: "for (var i = 0; i < 10; i++) {\r\n for (var j=0;j<10;j++) {\r\nj=i;\r\n }\r\n}", operations: [ { operation: "Semicolon", point: { position: 64 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j=0;j<10;j++) {\r\n j = i;\r\n }\r\n}" }, -{ input: "function f() {\r\n var x; /*\r\n */ var y = 2;\r\n}", operations: [ { operation: "Document" } ], expected: "function f() {\r\n var x; /*\r\n */ var y = 2;\r\n}" }, -{ input: "foo (1, 2, 3)", operations: [ { operation: "Document" } ], expected: "foo(1, 2, 3)" }, -{ input: "if (typeof a == null);", operations: [ { operation: "Document" } ], expected: "if (typeof a == null);" }, -{ input: "function f() {\r\n var x = \"\\r\n \"; var y = 2;\r\n}", operations: [ { operation: "Document" } ], expected: "function f() {\r\n var x = \"\\r\n \"; var y = 2;\r\n}" }, -{ input: "void x;", operations: [ { operation: "Document" } ], expected: "void x;" }, -{ input: "function f() {\r\n string='string'\r\n }\r\n", operations: [ { operation: "Enter", point: { position: 44 } } ], expected: "function f() {\r\n string='string'\r\n}\r\n" }, -{ input: "do{\r\nfor(var i=0;i<10;i++)\r\ni-=2\r\n}while(1!==1);", operations: [ { operation: "Semicolon", point: { position: 48 } } ], expected: "do {\r\n for (var i = 0; i < 10; i++)\r\n i -= 2\r\n} while (1 !== 1);" }, -{ input: "function test() {\r\n return (\r\n {\r\n a: 1\r\n }\r\n );\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n return (\r\n {\r\n a: 1\r\n }\r\n );\r\n}" }, -{ input: "for(var i=0;i<10;i++)\r\n{for(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "Enter", point: { position: 23 } } ], expected: "for (var i = 0; i < 10; i++)\r\n{ for (var j = 0; j < 10; j++) { j -= i } }" }, -{ input: "for(var i=0;i<10;i++){\r\nfor(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "Enter", point: { position: 24 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) { j -= i }\n}" }, -{ input: "do{\r\nfor(var i=0;i<10;i++)\r\ni-=2\r\n}while(1!==1)\r\n", operations: [ { operation: "Enter", point: { position: 49 } } ], expected: "do{\r\nfor(var i=0;i<10;i++)\r\ni-=2\r\n} while (1 !== 1)\r\n" }, -{ input: "if(1===1\r\n&& 2===2)x+=2", operations: [ { operation: "Enter", point: { position: 10 } } ], expected: "if (1 === 1\r\n&& 2 === 2) x += 2" }, -{ input: "\r\n{\r\n\r\n/* test\r\n test2\r\n test3 */\r\nvar a,\r\n // test\r\n // test\r\n b;\r\n\r\nx = {\r\na: 1 +\r\n // test\r\n /* test\r\n test2 */\r\n 2\r\n}\r\n\r\na(1,\r\n 2). // test\r\n test(); /* test */\r\n\r\n/* test\r\n test2\r\n test3 */\r\nfunction foo(a, b,\r\n /* test\r\n test2\r\n test3 */\r\n c) {\r\n}\r\n\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\n{\r\n\r\n /* test\r\n test2\r\n test3 */\r\n var a,\r\n // test\r\n // test\r\n b;\r\n\r\n x = {\r\n a: 1 +\r\n // test\r\n /* test\r\n test2 */\r\n 2\r\n }\r\n\r\n a(1,\r\n 2). // test\r\n test(); /* test */\r\n\r\n /* test\r\n test2\r\n test3 */\r\n function foo(a, b,\r\n /* test\r\n test2\r\n test3 */\r\n c) {\r\n }\r\n\r\n}\r\n" }, -{ input: "\r\n for (var i = 0; i < 10\r\n ; i--) {\r\n test\r\n ;\r\n }\r\n", operations: [ { operation: "Document" } ], expected: "\r\nfor (var i = 0; i < 10\r\n ; i--) {\r\n test\r\n ;\r\n}\r\n" }, -{ input: "if (1)\r\n x++;\r\nelse if (1)\r\n x--;", operations: [ { operation: "Document" } ], expected: "if (1)\r\n x++;\r\nelse if (1)\r\n x--;" }, -{ input: "x = {\n get foo () {\n },\n set foo (val) {\n }\n};", operations: [ { operation: "Document" } ], expected: "x = {\n get foo() {\n },\n set foo(val) {\n }\n};" }, -{ input: "function foo\r\n(a, b, c) {\r\n}", operations: [ { operation: "Document" } ], expected: "function foo\r\n(a, b, c) {\r\n}" }, -{ input: "switch ( a ) {\r\n case 1: x+=2;\r\n case 2:{for(var i=0;i<10;i++){ \r\nx+=2;\r\n }}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 80 } } ], expected: "switch ( a ) {\r\n case 1: x+=2;\r\n case 2: {\n for (var i = 0; i < 10; i++) {\r\n x += 2;\r\n }\n }\r\n}" }, -{ input: "function f() {\r\n'use strict'}", operations: [ { operation: "CloseBrace", point: { position: 29 } } ], expected: "function f() {\r\n 'use strict'\n}" }, -{ input: "foo(1\r\n, 2, 3)", operations: [ { operation: "Document" } ], expected: "foo(1\r\n, 2, 3)" }, -{ input: "do{\r\ndo\r\n{\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)", operations: [ { operation: "Enter", point: { position: 9 } } ], expected: "do{\r\n do\r\n {\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)" }, -{ input: "function Sum(a,b,c) {\r\n for(i=0,j=1,k=0,fib=1;i<5;i++,fib=j+k,k=j,j=fib) {\r\n var sparseArray = [1,,,,5]\r\n }\r\n}", operations: [ { operation: "Selection", span: { start: 49, length: 3 } } ], expected: "function Sum(a,b,c) {\r\n for (i = 0, j = 1, k = 0, fib = 1; i < 5; i++, fib = j + k, k = j, j = fib) {\r\n var sparseArray = [1,,,,5]\r\n }\r\n}" }, -{ input: "function a() {\r\n function b() {\r\n\r\n }\r\n}", operations: [ { operation: "Document" } ], expected: "function a() {\r\n function b() {\r\n\r\n }\r\n}" }, -{ input: "", operations: [ { operation: "Document" } ], expected: "" }, -{ input: "function a() {\r\nvar b=\"c\"\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 27 } } ], expected: "function a() {\r\n var b = \"c\"\r\n\r\n}" }, -{ input: " if ( a[\"\r\n\"])\r\nb++;", operations: [ { operation: "Enter", point: { position: 11 } } ], expected: "if ( a[\"\r\n\"])\r\nb++;" }, -{ input: "/* \r\n \r\n*/ ", operations: [ { operation: "Document" } ], expected: "/* \r\n \r\n*/" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n}finally {\r\nx+=2\r\n}\r\n};", operations: [ { operation: "Semicolon", point: { position: 75 } } ], expected: "function foo() {\r\n try {\r\n x += 2\r\n }\r\n catch (e) {\r\n x += 2\r\n } finally {\r\n x += 2\r\n }\r\n};" }, -{ input: "if (1) if (1) a++;", operations: [ { operation: "Document" } ], expected: "if (1) if (1) a++;" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n}finally {\r\nx+=2\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 53 } } ], expected: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\n catch (e) {\r\n x += 2\r\n }finally {\r\nx+=2\r\n}\r\n}" }, -{ input: "function f() {\r\n'use strict'\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 30 } } ], expected: "function f() {\r\n 'use strict'\r\n\r\n}" }, -{ input: " \r\n ", operations: [ { operation: "Document" } ], expected: " \r\n " }, -{ input: "{ var b; }", operations: [ { operation: "Document" } ], expected: "{ var b; }" }, -{ input: "var z = {a: 1};", operations: [ { operation: "Document" } ], expected: "var z = { a: 1 };" }, -{ input: "var z =\n {a: 1};", operations: [ { operation: "Document" } ], expected: "var z =\n { a: 1 };" }, -{ input: "for (var i = 0; i < 10; i++) { var a }", operations: [ { operation: "Document" } ], expected: "for (var i = 0; i < 10; i++) { var a }" }, -{ input: "for (var i = 0; i < 10; i++)\n { var a }", operations: [ { operation: "Document" } ], expected: "for (var i = 0; i < 10; i++)\n{ var a }" }, -{ input: "if (1) { var a }", operations: [ { operation: "Document" } ], expected: "if (1) { var a }" }, -{ input: "if (1)\n { var a }", operations: [ { operation: "Document" } ], expected: "if (1)\n{ var a }" }, -{ input: "while (1) { var a }", operations: [ { operation: "Document" } ], expected: "while (1) { var a }" }, -{ input: "while (1)\n { var a }", operations: [ { operation: "Document" } ], expected: "while (1)\n{ var a }" }, -{ input: "do { var a } while (1)", operations: [ { operation: "Document" } ], expected: "do { var a } while (1)" }, -{ input: "do\n { var a }\n while (1)", operations: [ { operation: "Document" } ], expected: "do\n{ var a }\nwhile (1)" }, -{ input: "for (var a in b) { var a }", operations: [ { operation: "Document" } ], expected: "for (var a in b) { var a }" }, -{ input: "for (var a in b)\n { var a }", operations: [ { operation: "Document" } ], expected: "for (var a in b)\n{ var a }" }, -{ input: "with (x) { var a }", operations: [ { operation: "Document" } ], expected: "with (x) { var a }" }, -{ input: "with (x)\n { var a }", operations: [ { operation: "Document" } ], expected: "with (x)\n{ var a }" }, -{ input: "try { var a } \ncatch (e) { var a } \nfinally { }", operations: [ { operation: "Document" } ], expected: "try { var a }\ncatch (e) { var a }\nfinally { }" }, -{ input: "try\n { var a } \ncatch (e)\n { var a } \nfinally\n { }", operations: [ { operation: "Document" } ], expected: "try\n{ var a }\ncatch (e)\n{ var a }\nfinally\n{ }" }, -{ input: "switch (x) { case 1: { var a } }", operations: [ { operation: "Document" } ], expected: "switch (x) { case 1: { var a } }" }, -{ input: "switch (x)\n { case 1: { var a } }", operations: [ { operation: "Document" } ], expected: "switch (x)\n{ case 1: { var a } }" }, -{ input: "function f() { var x }", operations: [ { operation: "Document" } ], expected: "function f() { var x }" }, -{ input: "function f()\n\n { var x }", operations: [ { operation: "Document" } ], expected: "function f()\n\n{ var x }" }, -{ input: "function test() {\r\nlabel1:\r\nvar a;\r\nvar b;\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n label1:\r\n var a;\r\n var b;\r\n}" }, -{ input: "{\n x =\nfunction () {\n };\n}", operations: [ { operation: "Document" } ], expected: "{\n x =\nfunction () {\n};\n}" }, -{ input: "switch (a){\r\n case 1: x+=2;\r\ncase 2 : { \r\nx+=2}\r\n}", operations: [ { operation: "Enter", point: { position: 49 } } ], expected: "switch (a){\r\n case 1: x+=2;\r\n case 2: {\r\n x += 2\n }\r\n}" }, -{ input: " // ;", operations: [ { operation: "Semicolon", point: { position: 7 } } ], expected: " // ;" }, -{ input: "// JScript source code\r\nfunction adder(a, b) {\r\n ///Adds two numbers \r\n return a + b;\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 115 } } ], expected: "// JScript source code\r\nfunction adder(a, b) {\r\n ///Adds two numbers \r\n return a + b;\r\n}\r\n" }, -{ input: "function foo4() {\r\n test;\r\n for (; ;) {\r\n test\r\n }\r\n}", operations: [ { operation: "Selection", span: { start: 46, length: 33 } } ], expected: "function foo4() {\r\n test;\r\n for (; ;) {\r\n test\r\n }\r\n}" }, -{ input: "if (a in b) { }", operations: [ { operation: "Document" } ], expected: "if (a in b) { }" }, -{ input: "\r\nfunction f() {\r\nlabel0:\r\nfor (var i = 0; i < 10; i++) {\r\nlabel1: {\r\nfor (var i = 0; i < 10; i++)\r\nx = 2;\r\nlabel2:\r\nfor (var i = 0; i < 10; i++) {\r\nbreak label2\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Document" } ], expected: "\r\nfunction f() {\r\n label0:\r\n for (var i = 0; i < 10; i++) {\r\n label1: {\r\n for (var i = 0; i < 10; i++)\r\n x = 2;\r\n label2:\r\n for (var i = 0; i < 10; i++) {\r\n break label2\r\n }\r\n }\r\n }\r\n}" }, -{ input: "function f() {\r\nstring='string'}", operations: [ { operation: "CloseBrace", point: { position: 32 } } ], expected: "function f() {\r\n string = 'string'\n}" }, -{ input: "\r\nfunction a() {\r\nfunction test() /* test */\r\n{\r\nif (test) /* test */\r\n{\r\n}\r\n}\r\n}", operations: [ { operation: "Document" } ], expected: "\r\nfunction a() {\r\n function test() /* test */ {\r\n if (test) /* test */ {\r\n }\r\n }\r\n}" }, -{ input: "that = {\r\n method: function () {\r\n return this.datum;\r\n } , \r\n\r\n datum: 0\r\n};", operations: [ { operation: "Enter", point: { position: 98 } } ], expected: "that = {\r\n method: function () {\r\n return this.datum;\r\n },\r\n\r\n datum: 0\r\n};" }, -{ input: "for (; ;)\n// test\n test;", operations: [ { operation: "Document" } ], expected: "for (; ;)\n // test\n test;" }, -{ input: "(function () {\r\n a({\r\n b: 0\r\n });\r\n\r\n})();", operations: [ { operation: "Enter", point: { position: 50 } } ], expected: "(function () {\r\n a({\r\n b: 0\r\n });\r\n\r\n})();" }, -{ input: "var f = function () {\n mycanvas.onmousedown = function () {\n };\n\n}", operations: [ { operation: "Enter", point: { position: 70 } } ], expected: "var f = function () {\n mycanvas.onmousedown = function () {\n };\n\n}" }, -{ input: "var obj={a:{b:2,c:{d:{e:{}}}}};", operations: [ { operation: "Semicolon", point: { position: 31 } } ], expected: "var obj = { a: { b: 2, c: { d: { e: {} } } } };" }, -{ input: "if (1)\r\n x++;\r\nelse x--;", operations: [ { operation: "Document" } ], expected: "if (1)\r\n x++;\r\nelse x--;" }, -{ input: "do{\r\nfor(var i=0;i<10;i++)i-=2}while(1!==1)", operations: [ { operation: "Enter", point: { position: 5 } } ], expected: "do {\r\n for (var i = 0; i < 10; i++) i -= 2\n} while (1 !== 1)" }, -{ input: "switch (a){\r\n case 1,2,3:\r\n break;\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "switch (a) {\r\n case 1, 2, 3:\r\n break;\r\n}\r\n" }, -{ input: " foo(function (file) {\r\n return 0\r\n })\r\n .then(function (doc) {\r\n return 1\r\n });", operations: [ { operation: "Document" } ], expected: "foo(function (file) {\r\n return 0\r\n})\r\n .then(function (doc) {\r\n return 1\r\n });" }, -{ input: "var a = 1;\nvar f = function () {\n var b = 2;\n}\n", operations: [ { operation: "Enter", point: { position: 50 } } ], expected: "var a = 1;\nvar f = function () {\n var b = 2;\n}\n" }, -{ input: "do{for(var i=0;i<10;i++)i-=2}\r\nwhile(1!==1)", operations: [ { operation: "Enter", point: { position: 31 } } ], expected: "do { for (var i = 0; i < 10; i++) i -= 2 }\r\nwhile (1 !== 1)" }, -{ input: " function a( b,c ) \r\n {\r\n var d=0 ;\r\n }", operations: [ { operation: "Document" } ], expected: "function a(b, c) {\r\n var d = 0;\r\n}" }, -{ input: "function f() {\r\n /*\r\n */ var x\r\n\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 59 } } ], expected: "function f() {\r\n /*\r\n */ var x\r\n\r\n\r\n}" }, -{ input: "if (x!=1^y===2) x+=2\r\n", operations: [ { operation: "Enter", point: { position: 24 } } ], expected: "if (x != 1 ^ y === 2) x += 2\r\n" }, -{ input: "function f() {\n }", operations: [ { operation: "Enter", point: { position: 15 } } ], expected: "function f() {\n}" }, -{ input: "function test() {\r\n try { }\r\n catch (e) { }\r\n finally\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n try { }\r\n catch (e) { }\r\n finally\r\n }" }, -{ input: "a = [\n // test\n foo(\n // test\n 1),\n 2\n];", operations: [ { operation: "Document" } ], expected: "a = [\n // test\n foo(\n // test\n 1),\n 2\n];" }, -{ input: "if (x!=1^y===2) x+=2;", operations: [ { operation: "Semicolon", point: { position: 23 } } ], expected: "if (x != 1 ^ y === 2) x += 2;" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n}finally {\r\nx+=2\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 71 } } ], expected: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n} finally {\r\n x += 2\r\n}\r\n}" }, -{ input: "switch (a) {\n case 1: b++;\n break;\n\n default: a++;\n break;\n}", operations: [ { operation: "Enter", point: { position: 46 } } ], expected: "switch (a) {\n case 1: b++;\n break;\n\n default: a++;\n break;\n}" }, -{ input: "function test() { }\r\n", operations: [ { operation: "Enter", point: { position: 27 } } ], expected: "function test() { }\r\n" }, -{ input: "delete x;", operations: [ { operation: "Document" } ], expected: "delete x;" }, -{ input: "\r\n{\r\n\r\nvar a,\r\n b;\r\n\r\nx = {\r\na: 1 +\r\n 2\r\n}\r\n\r\na(1,\r\n 2).\r\n test();\r\n\r\nfunction foo(a, b,\r\n c) {\r\n}\r\n\r\nfor (i = 0;\r\n i < 1;\r\n i++) {\r\n}\r\n\r\nfor (a\r\n in b) {\r\n}\r\n\r\nwhile (i +\r\n 2) {\r\n}\r\n\r\nswitch (i +\r\n 2) {\r\n\r\n case 1 +\r\n 3:\r\n break;\r\n}\r\n\r\ntry {\r\n}\r\ncatch (\r\n e) {\r\n}\r\n\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\n{\r\n\r\n var a,\r\n b;\r\n\r\n x = {\r\n a: 1 +\r\n 2\r\n }\r\n\r\n a(1,\r\n 2).\r\n test();\r\n\r\n function foo(a, b,\r\n c) {\r\n }\r\n\r\n for (i = 0;\r\n i < 1;\r\n i++) {\r\n }\r\n\r\n for (a\r\n in b) {\r\n }\r\n\r\n while (i +\r\n 2) {\r\n }\r\n\r\n switch (i +\r\n 2) {\r\n\r\n case 1 +\r\n 3:\r\n break;\r\n }\r\n\r\n try {\r\n }\r\n catch (\r\n e) {\r\n }\r\n\r\n}\r\n" }, -{ input: "function f() {\r\n do{\r\nx++ }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 30 } } ], expected: "function f() {\r\n do {\r\n x++\n }\r\n}" }, -{ input: "do\r\n{for(var i=0;i<10;i++)i-=2}while(1!==1)", operations: [ { operation: "Enter", point: { position: 4 } } ], expected: "do\r\n{ for (var i = 0; i < 10; i++) i -= 2 } while (1 !== 1)" }, -{ input: "switch (a){\r\n case 1 :\r\n x+=2\r\n case 2:{\r\n }\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 28 } } ], expected: "switch (a){\r\n case 1:\r\n x += 2\r\n case 2:{\r\n }\r\n}\r\n" }, -{ input: "var x = [\n //comment\n 1,\n 2,\n 3\n]", operations: [ { operation: "Document" } ], expected: "var x = [\n //comment\n 1,\n 2,\n 3\n]" }, -{ input: "switch (a){\r\n case 1: x += 2;\r\n\r\ncase 1 : x+=2;\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 36 } } ], expected: "switch (a){\r\n case 1: x += 2;\r\n\r\n case 1: x += 2;\r\n}\r\n" }, -{ input: " foo(function (file) {\r\n return 0\r\n }).then(function (doc) {\r\n return 1\r\n });", operations: [ { operation: "Document" } ], expected: "foo(function (file) {\r\n return 0\r\n}).then(function (doc) {\r\n return 1\r\n});" }, -{ input: "function f() {\r\nvar s=1 /**/;\r\n}", operations: [ { operation: "Semicolon", point: { position: 30 } } ], expected: "function f() {\r\n var s = 1 /**/;\r\n}" }, -{ input: "switch (a){\r\n case 1: x+=2;\r\n case 2:{\r\n }\r\n \r\n}", operations: [ { operation: "Enter", point: { position: 61 } } ], expected: "switch (a){\r\n case 1: x+=2;\r\n case 2:{\r\n }\r\n\r\n}" }, -{ input: "if(1)\r\nif(1)\r\nx++\r\nelse\r\nif(1)\r\nx+=2\r\nelse\r\nx+=2\r\n\r\n\r\n\r\n;", operations: [ { operation: "Semicolon", point: { position: 57 } } ], expected: "if (1)\r\n if (1)\r\n x++\r\n else\r\n if (1)\r\n x += 2\r\n else\r\n x += 2\r\n\r\n\r\n\r\n;" }, -{ input: "function a() {\r\nvar b = 0;//\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "function a() {\r\n var b = 0;//\r\n\r\n}" }, -{ input: "if (a)\r\ntest;\r\nelse\r\nif (b)\r\ntest;", operations: [ { operation: "Document" } ], expected: "if (a)\r\n test;\r\nelse\r\n if (b)\r\n test;" }, -{ input: "for(var j=0;j<10;j++)j-=i;", operations: [ { operation: "Semicolon", point: { position: 26 } } ], expected: "for (var j = 0; j < 10; j++) j -= i;" }, -{ input: "if(1)\r\nif(1)\r\nx++\r\nelse\r\nif(1)\r\nx+=2\r\nelse\r\nx+=2;", operations: [ { operation: "Semicolon", point: { position: 49 } } ], expected: "if (1)\r\n if (1)\r\n x++\r\n else\r\n if (1)\r\n x += 2\r\n else\r\n x += 2;" }, -{ input: "function test() {\r\n var a\r\n }", operations: [ { operation: "Document" } ], expected: "function test() {\r\n var a\r\n}" }, -{ input: "if (1) {\r\n} else { }", operations: [ { operation: "Document" } ], expected: "if (1) {\r\n} else { }" }, -{ input: "function f() {\r\n /*\r\n\r\n */\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "function f() {\r\n /*\r\n\r\n */\r\n}" }, -{ input: "if (x!=1^y===2) \r\n x+=2", operations: [ { operation: "Enter", point: { position: 18 } } ], expected: "if (x != 1 ^ y === 2)\r\n x += 2" }, -{ input: "for (a in b) {\n for (c in d) {\n for (e in f) {\n for (q in w) {}}}}\n", operations: [ { operation: "Enter", point: { position: 88 } } ], expected: "for (a in b) {\n for (c in d) {\n for (e in f) {\n for (q in w) { }\n }\n }\n}\n" }, -{ input: "a=a+\nb+\n c+\n d +\ne +\nm+f;", operations: [ { operation: "Semicolon", point: { position: 100 } } ], expected: "a = a +\nb +\n c +\n d +\ne +\nm + f;" }, -{ input: "x = {\r\n get a() {\r\n\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "x = {\r\n get a() {\r\n\r\n }\r\n}" }, -{ input: "if(1)\r\n;", operations: [ { operation: "Enter", point: { position: 7 } } ], expected: "if (1)\r\n ;" }, -{ input: "function test() {\r\n return (\r\n [\r\n 1\r\n ]\r\n );\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n return (\r\n [\r\n 1\r\n ]\r\n );\r\n}" }, -{ input: "string='string+=2\\r\n'", operations: [ { operation: "Enter", point: { position: 20 } } ], expected: "string = 'string+=2\\r\n'" }, -{ input: "if(1)\r\nif(1)\r\nx++\r\nelse\r\n{if(1)\r\nx+=2\r\nelse\r\nx+=2}", operations: [ { operation: "CloseBrace", point: { position: 50 } } ], expected: "if(1)\r\n if (1)\r\n x++\r\n else {\n if (1)\r\n x += 2\r\n else\r\n x += 2\n }" }, -{ input: " function test() { function foo() { function foo3() { function foo4() { function foo5() { function foo6()\r\n{\r\n}\r\n}\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Selection", span: { start: 110, length: 19 } } ], expected: " function test() { function foo() { function foo3() { function foo4() { function foo5() { function foo6()\r\n {\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }" }, -{ input: "switch (a){\r\n case 1: x+=2;\r\n case 2 : { x+=2;}\r\n}\r\n", operations: [ { operation: "Semicolon", point: { position: 53 } } ], expected: "switch (a){\r\n case 1: x+=2;\r\n case 2: { x += 2;}\r\n}\r\n" }, -{ input: "// ", operations: [ { operation: "Document" } ], expected: "// " }, -{ input: "for(var i=0;\r\ni<10;i++){for(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "Enter", point: { position: 14 } } ], expected: "for (var i = 0;\r\ni < 10; i++) { for (var j = 0; j < 10; j++) { j -= i } }" }, -{ input: "if (a) if (b) if (c) if (d)\r\ntest;", operations: [ { operation: "Document" } ], expected: "if (a) if (b) if (c) if (d)\r\n test;" }, -{ input: "do{for(var i=0;i<10;i++)i-=2}while(1!==1)", operations: [ { operation: "Semicolon", point: { position: 15 } } ], expected: "do { for (var i = 0;i<10;i++)i-=2}while(1!==1)" }, -{ input: "$ ( '#TextBox1' ) . unbind ( ) ;", operations: [ { operation: "Document" } ], expected: "$('#TextBox1').unbind();" }, -{ input: "do{do{do{}while(a!==b)}while(a!==b)}while(a!==b);", operations: [ { operation: "Semicolon", point: { position: 49 } } ], expected: "do { do { do { } while (a !== b) } while (a !== b) } while (a !== b);" }, -{ input: "do{for(var i=0;i<10;i++)i-=2;}while(1!==1)", operations: [ { operation: "Semicolon", point: { position: 29 } } ], expected: "do { for (var i = 0; i < 10; i++) i -= 2;}while(1!==1)" }, -{ input: "for(var i=0;i<10;i++){\r\nfor(var j=0;j<10;j++){\r\nj-=i\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 55 } } ], expected: "for(var i=0;i<10;i++){\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n }\r\n}" }, -{ input: "function a() {\r\nfunction b() {\r\nfunction c() {\r\n}}}", operations: [ { operation: "CloseBrace", point: { position: 51 } } ], expected: "function a() {\r\n function b() {\r\n function c() {\r\n }\n }\n}" }, -{ input: " do do do do\r\n test;\r\n while (0)\r\n while (0)\r\n while (0)\r\n while (0)", operations: [ { operation: "Document" } ], expected: "do do do do\r\n test;\r\nwhile (0)\r\nwhile (0)\r\nwhile (0)\r\nwhile (0)" }, -{ input: "/**/ ", operations: [ { operation: "Document" } ], expected: "/**/" }, -{ input: "function a()\n{ var a\n}", operations: [ { operation: "Enter", point: { position: 21 } } ], expected: "function a()\n{\n var a\n}" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;\r\nj++){j-=i}}", operations: [ { operation: "Enter", point: { position: 41 } } ], expected: "for (var i = 0; i < 10; i++) {\n for (var j = 0; j < 10;\r\n j++) { j -= i }\n}" }, -{ input: "function a() {\r\n if (true) {\r\n }\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 40 } } ], expected: "function a() {\r\n if (true) {\r\n }\r\n\r\n}" }, -{ input: "string='string+=2'\r\n", operations: [ { operation: "Enter", point: { position: 20 } } ], expected: "string = 'string+=2'\r\n" }, -{ input: "for (a in b) {\r\nx++;}\r\n", operations: [ { operation: "Enter", point: { position: 23 } } ], expected: "for (a in b) {\r\n x++;\n}\r\n" }, -{ input: "var obj={a:{b:2,c:{\r\nd:{e:{}}}}}", operations: [ { operation: "Enter", point: { position: 21 } } ], expected: "var obj = {\n a: {\n b: 2, c: {\r\n d: { e: {} }\n }\n }\n}" }, -{ input: "\r\n// test\r\n\r\n{\r\n// test\r\n}\r\n\r\nfunction foo() {\r\n// test\r\n\r\nswitch (a) {\r\n// test\r\ncase 1:\r\n// test\r\ndefault:\r\n// test\r\n}\r\n\r\nif (false)\r\n// test\r\nifblock;\r\n\r\nif (false) {\r\n//test\r\n}\r\n\r\nif (false) test;\r\nelse\r\n// test\r\ntest;\r\n\r\nif (false) test;\r\nelse {\r\n// test\r\ntest;\r\n}\r\n\r\nfor (; ;)\r\n// test\r\ntest;\r\n\r\nfor (; ;) {\r\n// test\r\nforblock;\r\n}\r\n\r\nfor (a in b)\r\n// test\r\ntest;\r\n\r\nfor (a in b) {\r\n// test\r\ntest\r\n}\r\n\r\nwhile (false)\r\n// test\r\ntest;\r\n\r\nwhile (false) {\r\n// test\r\ntest;\r\n}\r\n\r\nwith (a) {\r\n// test\r\n}\r\n\r\ndo\r\n// test\r\ntestl\r\nwhile (false)\r\n\r\ndo {\r\n// test\r\ntest;\r\n} while (false)\r\n\r\ntry {\r\n// test\r\n} catch (e) {\r\n// test\r\n} finally {\r\n// test\r\n}\r\n\r\n(function () {\r\nvar a = function () {\r\nreturn 1;\r\n},\r\n// This is a comment inline with a multiline statement\r\nb = 2,\r\nc = 3;\r\n})();\r\n\r\n\r\nvar a = {\r\n// test\r\nx: 1,\r\ny: 2 +\r\n// test\r\n3 +\r\n4,\r\n}\r\n\r\n\r\nvar a,\r\n// test\r\nb;\r\n\r\nvar a = [\r\n// test\r\n1,\r\n2,\r\n3\r\n];\r\n\r\na = 1 +\r\n// test\r\n2;\r\n\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\n// test\r\n\r\n{\r\n // test\r\n}\r\n\r\nfunction foo() {\r\n // test\r\n\r\n switch (a) {\r\n // test\r\n case 1:\r\n // test\r\n default:\r\n // test\r\n }\r\n\r\n if (false)\r\n // test\r\n ifblock;\r\n\r\n if (false) {\r\n //test\r\n }\r\n\r\n if (false) test;\r\n else\r\n // test\r\n test;\r\n\r\n if (false) test;\r\n else {\r\n // test\r\n test;\r\n }\r\n\r\n for (; ;)\r\n // test\r\n test;\r\n\r\n for (; ;) {\r\n // test\r\n forblock;\r\n }\r\n\r\n for (a in b)\r\n // test\r\n test;\r\n\r\n for (a in b) {\r\n // test\r\n test\r\n }\r\n\r\n while (false)\r\n // test\r\n test;\r\n\r\n while (false) {\r\n // test\r\n test;\r\n }\r\n\r\n with (a) {\r\n // test\r\n }\r\n\r\n do\r\n // test\r\n testl\r\n while (false)\r\n\r\n do {\r\n // test\r\n test;\r\n } while (false)\r\n\r\n try {\r\n // test\r\n } catch (e) {\r\n // test\r\n } finally {\r\n // test\r\n }\r\n\r\n (function () {\r\n var a = function () {\r\n return 1;\r\n },\r\n // This is a comment inline with a multiline statement\r\n b = 2,\r\n c = 3;\r\n })();\r\n\r\n\r\n var a = {\r\n // test\r\n x: 1,\r\n y: 2 +\r\n // test\r\n 3 +\r\n 4,\r\n }\r\n\r\n\r\n var a,\r\n // test\r\n b;\r\n\r\n var a = [\r\n // test\r\n 1,\r\n 2,\r\n 3\r\n ];\r\n\r\n a = 1 +\r\n // test\r\n 2;\r\n\r\n}\r\n" }, -{ input: " \r\n /* \r\n\r\n a \r\n a\r\n a \r\n a \r\na \r\n \r\n\r\n */ \r\n ", operations: [ { operation: "Document" } ], expected: "\r\n/* \r\n\r\n a \r\n a\r\n a \r\na \r\na \r\n\r\n\r\n*/\r\n" }, -{ input: "string='{string +=2}'", operations: [ { operation: "CloseBrace", point: { position: 20 } } ], expected: "string='{string +=2}'" }, -{ input: "var obj={a:{b:2,c:{d:{e:{}}}}}\r\n", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "var obj = { a: { b: 2, c: { d: { e: {} } } } }\r\n" }, -{ input: "string='string\\r\n line2'+'other part'\r\n", operations: [ { operation: "Enter", point: { position: 47 } } ], expected: "string='string\\r\n line2' + 'other part'\r\n" }, -{ input: " switch( a)\r\n{case 1 :x+=2 ;break\r\n case 2:{\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 13 } } ], expected: "switch (a)\r\n{\n case 1: x += 2; break\r\n case 2:{\r\n }\r\n}" } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/classes.ts b/src/harness/unittests/services/formatting/testCode/formatting/classes.ts deleted file mode 100644 index e779f69810..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/classes.ts +++ /dev/null @@ -1,79 +0,0 @@ - class a { - constructor ( n : number ) ; - constructor ( s : string ) ; - constructor ( ns : any ) { - - } - - public pgF ( ) { } ; - - public pv ; - public get d ( ) { - return 30 ; - } - public set d ( ) { - } - - public static get p2 ( ) { - return { x : 30 , y : 40 } ; - } - - private static d2 ( ) { - } - private static get p3 ( ) { - return "string" ; - } - private pv3 ; - - private foo ( n : number ) : string ; - private foo ( s : string ) : string ; - private foo ( ns : any ) { - return ns.toString ( ) ; - } -} - - class b extends a { -} - - class m1b { - -} - - interface m1ib { - - } - class c extends m1b { -} - - class ib2 implements m1ib { -} - - declare class aAmbient { - constructor ( n : number ) ; - constructor ( s : string ) ; - public pgF ( ) : void ; - public pv ; - public d : number ; - static p2 : { x : number ; y : number ; } ; - static d2 ( ) ; - static p3 ; - private pv3 ; - private foo ( s ) ; -} - - class d { - private foo ( n : number ) : string ; - private foo ( ns : any ) { - return ns.toString ( ) ; - } - private foo ( s : string ) : string ; -} - - class e { - private foo ( ns : any ) { - return ns.toString ( ) ; - } - private foo ( s : string ) : string ; - private foo ( n : number ) : string ; -} - diff --git a/src/harness/unittests/services/formatting/testCode/formatting/classesBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/classesBaseline.ts deleted file mode 100644 index e7e69b4412..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/classesBaseline.ts +++ /dev/null @@ -1,79 +0,0 @@ -class a { - constructor(n: number); - constructor(s: string); - constructor(ns: any) { - - } - - public pgF() { }; - - public pv; - public get d() { - return 30; - } - public set d() { - } - - public static get p2() { - return { x: 30, y: 40 }; - } - - private static d2() { - } - private static get p3() { - return "string"; - } - private pv3; - - private foo(n: number): string; - private foo(s: string): string; - private foo(ns: any) { - return ns.toString(); - } -} - -class b extends a { -} - -class m1b { - -} - -interface m1ib { - -} -class c extends m1b { -} - -class ib2 implements m1ib { -} - -declare class aAmbient { - constructor(n: number); - constructor(s: string); - public pgF(): void; - public pv; - public d: number; - static p2: { x: number; y: number; }; - static d2(); - static p3; - private pv3; - private foo(s); -} - -class d { - private foo(n: number): string; - private foo(ns: any) { - return ns.toString(); - } - private foo(s: string): string; -} - -class e { - private foo(ns: any) { - return ns.toString(); - } - private foo(s: string): string; - private foo(n: number): string; -} - diff --git a/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMark.ts b/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMark.ts deleted file mode 100644 index 5562e14204..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMark.ts +++ /dev/null @@ -1,4 +0,0 @@ -class foo { - constructor (n?: number, m? = 5, o?: string = "") { } - x:number = 1?2:3; -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMarkBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMarkBaseline.ts deleted file mode 100644 index 52bbe56251..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMarkBaseline.ts +++ /dev/null @@ -1,4 +0,0 @@ -class foo { - constructor(n?: number, m? = 5, o?: string = "") { } - x: number = 1 ? 2 : 3; -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunction.ts b/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunction.ts deleted file mode 100644 index 35daa4d895..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunction.ts +++ /dev/null @@ -1,3 +0,0 @@ -$ ( document ) . ready ( function ( ) { - alert ( 'i am ready' ) ; - } ); \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunctionBaseLine.ts b/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunctionBaseLine.ts deleted file mode 100644 index 838ef68220..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunctionBaseLine.ts +++ /dev/null @@ -1,3 +0,0 @@ -$(document).ready(function() { - alert('i am ready'); -}); \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/emptyBlock.ts b/src/harness/unittests/services/formatting/testCode/formatting/emptyBlock.ts deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/emptyBlock.ts +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/emptyBlockBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/emptyBlockBaseline.ts deleted file mode 100644 index 6f31cf5a2e..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/emptyBlockBaseline.ts +++ /dev/null @@ -1 +0,0 @@ -{ } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteral.ts b/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteral.ts deleted file mode 100644 index 1feec453d0..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteral.ts +++ /dev/null @@ -1,10 +0,0 @@ - function foo ( x : { } ) { } - -foo ( { } ) ; - - - - interface bar { - x : { } ; - y : ( ) => { } ; - } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteralBaseLine.ts b/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteralBaseLine.ts deleted file mode 100644 index 04f3c0bc9b..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteralBaseLine.ts +++ /dev/null @@ -1,10 +0,0 @@ -function foo(x: {}) { } - -foo({}); - - - -interface bar { - x: {}; - y: () => {}; -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctions.ts b/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctions.ts deleted file mode 100644 index ebbf54557f..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctions.ts +++ /dev/null @@ -1,112 +0,0 @@ -// valid - ( ) => 1 ; - ( arg ) => 2 ; - arg => 2 ; - ( arg = 1 ) => 3 ; - ( arg ? ) => 4 ; - ( arg : number ) => 5 ; - ( arg : number = 0 ) => 6 ; - ( arg ? : number ) => 7 ; - ( ... arg : number [ ] ) => 8 ; - ( arg1 , arg2 ) => 12 ; - ( arg1 = 1 , arg2 =3 ) => 13 ; - ( arg1 ? , arg2 ? ) => 14 ; - ( arg1 : number , arg2 : number ) => 15 ; - ( arg1 : number = 0 , arg2 : number = 1 ) => 16 ; - ( arg1 ? : number , arg2 ? : number ) => 17 ; - ( arg1 , ... arg2 : number [ ] ) => 18 ; - ( arg1 , arg2 ? : number ) => 19 ; - -// in paren - ( ( ) => 21 ) ; - ( ( arg ) => 22 ) ; - ( ( arg = 1 ) => 23 ) ; - ( ( arg ? ) => 24 ) ; - ( ( arg : number ) => 25 ) ; - ( ( arg : number = 0 ) => 26 ) ; - ( ( arg ? : number ) => 27 ) ; - ( ( ... arg : number [ ] ) => 28 ) ; - -// in multiple paren - ( ( ( ( ( arg ) => { return 32 ; } ) ) ) ) ; - -// in ternary exression - false ? ( ) => 41 : null ; - false ? ( arg ) => 42 : null ; - false ? ( arg = 1 ) => 43 : null ; - false ? ( arg ? ) => 44 : null ; - false ? ( arg : number ) => 45 : null ; - false ? ( arg ? : number ) => 46 : null ; - false ? ( arg ? : number = 0 ) => 47 : null ; - false ? ( ... arg : number [ ] ) => 48 : null ; - -// in ternary exression within paren - false ? ( ( ) => 51 ) : null ; - false ? ( ( arg ) => 52 ) : null ; - false ? ( ( arg = 1 ) => 53 ) : null ; - false ? ( ( arg ? ) => 54 ) : null ; - false ? ( ( arg : number ) => 55 ) : null ; - false ? ( ( arg ? : number ) => 56 ) : null ; - false ? ( ( arg ? : number = 0 ) => 57 ) : null ; - false ? ( ( ... arg : number [ ] ) => 58 ) : null ; - -// ternary exression's else clause - false ? null : ( ) => 61 ; - false ? null : ( arg ) => 62 ; - false ? null : ( arg = 1 ) => 63 ; - false ? null : ( arg ? ) => 64 ; - false ? null : ( arg : number ) => 65 ; - false ? null : ( arg ? : number ) => 66 ; - false ? null : ( arg ? : number = 0 ) => 67 ; - false ? null : ( ... arg : number [ ] ) => 68 ; - - -// nested ternary expressions - ( a ? ) => { return a ; } ? ( b ? ) => { return b ; } : ( c ? ) => { return c ; } ; - -//multiple levels - ( a ? ) => { return a ; } ? ( b ) => ( c ) => 81 : ( c ) => ( d ) => 82 ; - - -// In Expressions - ( ( arg ) => 90 ) instanceof Function ; - ( ( arg = 1 ) => 91 ) instanceof Function ; - ( ( arg ? ) => 92 ) instanceof Function ; - ( ( arg : number ) => 93 ) instanceof Function ; - ( ( arg : number = 1 ) => 94 ) instanceof Function ; - ( ( arg ? : number ) => 95 ) instanceof Function ; - ( ( ... arg : number [ ] ) => 96 ) instanceof Function ; - -'' + ( arg ) => 100 ; - ( ( arg ) => 0 ) + '' + ( arg ) => 101 ; - ( ( arg = 1 ) => 0 ) + '' + ( arg = 2 ) => 102 ; - ( ( arg ? ) => 0 ) + '' + ( arg ? ) => 103 ; - ( ( arg : number ) => 0 ) + '' + ( arg : number ) => 104 ; - ( ( arg : number = 1 ) => 0 ) + '' + ( arg : number = 2 ) => 105 ; - ( ( arg ? : number = 1 ) => 0 ) + '' + ( arg ? : number = 2 ) => 106 ; - ( ( ... arg : number [ ] ) => 0 ) + '' + ( ... arg : number [ ] ) => 107 ; - ( ( arg1 , arg2 ? ) => 0 ) + '' + ( arg1 , arg2 ? ) => 108 ; - ( ( arg1 , ... arg2 : number [ ] ) => 0 ) + '' + ( arg1 , ... arg2 : number [ ] ) => 108 ; - - -// Function Parameters -function foo ( ... arg : any [ ] ) { } - -foo ( - ( a ) => 110 , - ( ( a ) => 111 ) , - ( a ) => { - return 112 ; - } , - ( a ? ) => 113 , - ( a , b ? ) => 114 , - ( a : number ) => 115 , - ( a : number = 0 ) => 116 , - ( a = 0 ) => 117 , - ( a ? : number = 0 ) => 118 , - ( a ? , b ? : number = 0 ) => 118 , - ( ... a : number [ ] ) => 119 , - ( a , b ? = 0 , ... c : number [ ] ) => 120 , - ( a ) => ( b ) => ( c ) => 121 , - false ? ( a ) => 0 : ( b ) => 122 - ) ; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctionsBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctionsBaseline.ts deleted file mode 100644 index 7a1ef86f5a..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctionsBaseline.ts +++ /dev/null @@ -1,112 +0,0 @@ -// valid -() => 1; -(arg) => 2; -arg => 2; -(arg = 1) => 3; -(arg?) => 4; -(arg: number) => 5; -(arg: number = 0) => 6; -(arg?: number) => 7; -(...arg: number[]) => 8; -(arg1, arg2) => 12; -(arg1 = 1, arg2 = 3) => 13; -(arg1?, arg2?) => 14; -(arg1: number, arg2: number) => 15; -(arg1: number = 0, arg2: number = 1) => 16; -(arg1?: number, arg2?: number) => 17; -(arg1, ...arg2: number[]) => 18; -(arg1, arg2?: number) => 19; - -// in paren -(() => 21); -((arg) => 22); -((arg = 1) => 23); -((arg?) => 24); -((arg: number) => 25); -((arg: number = 0) => 26); -((arg?: number) => 27); -((...arg: number[]) => 28); - -// in multiple paren -(((((arg) => { return 32; })))); - -// in ternary exression -false ? () => 41 : null; -false ? (arg) => 42 : null; -false ? (arg = 1) => 43 : null; -false ? (arg?) => 44 : null; -false ? (arg: number) => 45 : null; -false ? (arg?: number) => 46 : null; -false ? (arg?: number = 0) => 47 : null; -false ? (...arg: number[]) => 48 : null; - -// in ternary exression within paren -false ? (() => 51) : null; -false ? ((arg) => 52) : null; -false ? ((arg = 1) => 53) : null; -false ? ((arg?) => 54) : null; -false ? ((arg: number) => 55) : null; -false ? ((arg?: number) => 56) : null; -false ? ((arg?: number = 0) => 57) : null; -false ? ((...arg: number[]) => 58) : null; - -// ternary exression's else clause -false ? null : () => 61; -false ? null : (arg) => 62; -false ? null : (arg = 1) => 63; -false ? null : (arg?) => 64; -false ? null : (arg: number) => 65; -false ? null : (arg?: number) => 66; -false ? null : (arg?: number = 0) => 67; -false ? null : (...arg: number[]) => 68; - - -// nested ternary expressions -(a?) => { return a; } ? (b?) => { return b; } : (c?) => { return c; }; - -//multiple levels -(a?) => { return a; } ? (b) => (c) => 81 : (c) => (d) => 82; - - -// In Expressions -((arg) => 90) instanceof Function; -((arg = 1) => 91) instanceof Function; -((arg?) => 92) instanceof Function; -((arg: number) => 93) instanceof Function; -((arg: number = 1) => 94) instanceof Function; -((arg?: number) => 95) instanceof Function; -((...arg: number[]) => 96) instanceof Function; - -'' + (arg) => 100; -((arg) => 0) + '' + (arg) => 101; -((arg = 1) => 0) + '' + (arg = 2) => 102; -((arg?) => 0) + '' + (arg?) => 103; -((arg: number) => 0) + '' + (arg: number) => 104; -((arg: number = 1) => 0) + '' + (arg: number = 2) => 105; -((arg?: number = 1) => 0) + '' + (arg?: number = 2) => 106; -((...arg: number[]) => 0) + '' + (...arg: number[]) => 107; -((arg1, arg2?) => 0) + '' + (arg1, arg2?) => 108; -((arg1, ...arg2: number[]) => 0) + '' + (arg1, ...arg2: number[]) => 108; - - -// Function Parameters -function foo(...arg: any[]) { } - -foo( - (a) => 110, - ((a) => 111), - (a) => { - return 112; - }, - (a?) => 113, - (a, b?) => 114, - (a: number) => 115, - (a: number = 0) => 116, - (a = 0) => 117, - (a?: number = 0) => 118, - (a?, b?: number = 0) => 118, - (...a: number[]) => 119, - (a, b? = 0, ...c: number[]) => 120, - (a) => (b) => (c) => 121, - false ? (a) => 0 : (b) => 122 - ); \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatement.ts b/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatement.ts deleted file mode 100644 index 314cd416a8..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatement.ts +++ /dev/null @@ -1,2 +0,0 @@ -if(false){debugger;} - if ( false ) { debugger ; } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatementBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatementBaseline.ts deleted file mode 100644 index c03acf91ec..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatementBaseline.ts +++ /dev/null @@ -1,2 +0,0 @@ -if (false) { debugger; } -if (false) { debugger; } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationList.ts b/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationList.ts deleted file mode 100644 index 956309d2c4..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationList.ts +++ /dev/null @@ -1,13 +0,0 @@ -var fun1 = function ( ) { - var x = 'foo' , - z = 'bar' ; - return x ; -}, - -fun2 = ( function ( f ) { - var fun = function ( ) { - console . log ( f ( ) ) ; - }, - x = 'Foo' ; - return fun ; -} ( fun1 ) ) ; diff --git a/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationListBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationListBaseline.ts deleted file mode 100644 index f1d32283fd..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationListBaseline.ts +++ /dev/null @@ -1,13 +0,0 @@ -var fun1 = function() { - var x = 'foo', - z = 'bar'; - return x; -}, - -fun2 = (function(f) { - var fun = function() { - console.log(f()); - }, - x = 'Foo'; - return fun; -} (fun1)); diff --git a/src/harness/unittests/services/formatting/testCode/formatting/implicitModule.ts b/src/harness/unittests/services/formatting/testCode/formatting/implicitModule.ts deleted file mode 100644 index 352a252593..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/implicitModule.ts +++ /dev/null @@ -1,3 +0,0 @@ - export class A { - - } diff --git a/src/harness/unittests/services/formatting/testCode/formatting/implicitModuleBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/implicitModuleBaseline.ts deleted file mode 100644 index df93540466..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/implicitModuleBaseline.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class A { - -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/importDeclaration.ts b/src/harness/unittests/services/formatting/testCode/formatting/importDeclaration.ts deleted file mode 100644 index afd010fe8b..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/importDeclaration.ts +++ /dev/null @@ -1,6 +0,0 @@ -module Foo { -} - -import bar = Foo; - -import bar2=Foo; diff --git a/src/harness/unittests/services/formatting/testCode/formatting/importDeclarationBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/importDeclarationBaseline.ts deleted file mode 100644 index d0a4e190d9..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/importDeclarationBaseline.ts +++ /dev/null @@ -1,6 +0,0 @@ -module Foo { -} - -import bar = Foo; - -import bar2 = Foo; diff --git a/src/harness/unittests/services/formatting/testCode/formatting/main.ts b/src/harness/unittests/services/formatting/testCode/formatting/main.ts deleted file mode 100644 index 7640013af8..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/main.ts +++ /dev/null @@ -1,95 +0,0 @@ - -var a;var c , b;var $d -var $e -var f -a++;b++; - -function f ( ) { - for (i = 0; i < 10; i++) { - k = abc + 123 ^ d; - a = XYZ[m (a[b[c][d]])]; - break; - - switch ( variable){ - case 1: abc += 425; -break; -case 404 : a [x--/2]%=3 ; - break ; - case vari : v[--x ] *=++y*( m + n / k[z]); - for (a in b){ - for (a = 0; a < 10; ++a) { - a++;--a; - if (a == b) { - a++;b--; - } -else -if (a == c){ -++a; -(--c)+=d; -$c = $a + --$b; -} -if (a == b) -if (a != b) { - if (a !== b) - if (a === b) - --a; - else - --a; - else { - a--;++b; -a++ - } - } - } - for (x in y) { -m-=m; -k=1+2+3+4; -} -} - break; - - } - } - var a ={b:function(){}}; - return {a:1,b:2} -} - -var z = 1; - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) -for (k = 0; k < 10; ++k) { -z++; -} - -for (k = 0; k < 10; k += 2) { -z++; -} - - $(document).ready (); - - - function pageLoad() { - $('#TextBox1' ) . unbind ( ) ; -$('#TextBox1' ) . datepicker ( ) ; -} - - function pageLoad ( ) { - var webclass=[ - { 'student' : - { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' } - } , -{ 'student': -{'id':'2','name':'Adam Davidson','legacySkill':'Cobol,MainFrame'} -} , - { 'student': -{ 'id':'3','name':'Charles Boyer' ,'legacySkill':'HTML, XML'} -} - ]; - -$create(Sys.UI.DataView,{data:webclass},null,null,$get('SList')); - -} - -$( document ).ready(function(){ -alert('hello'); - } ) ; diff --git a/src/harness/unittests/services/formatting/testCode/formatting/mainBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/mainBaseline.ts deleted file mode 100644 index 30756f547c..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/mainBaseline.ts +++ /dev/null @@ -1,98 +0,0 @@ - -var a; var c, b; var $d -var $e -var f -a++; b++; - -function f() { - for (i = 0; i < 10; i++) { - k = abc + 123 ^ d; - a = XYZ[m(a[b[c][d]])]; - break; - - switch (variable) { - case 1: abc += 425; - break; - case 404: a[x-- / 2] %= 3; - break; - case vari: v[--x] *= ++y * (m + n / k[z]); - for (a in b) { - for (a = 0; a < 10; ++a) { - a++; --a; - if (a == b) { - a++; b--; - } - else - if (a == c) { - ++a; - (--c) += d; - $c = $a + --$b; - } - if (a == b) - if (a != b) { - if (a !== b) - if (a === b) - --a; - else - --a; - else { - a--; ++b; - a++ - } - } - } - for (x in y) { - m -= m; - k = 1 + 2 + 3 + 4; - } - } - break; - - } - } - var a = { b: function() { } }; - return { a: 1, b: 2 } -} - -var z = 1; -for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; ++k) { - z++; - } - -for (k = 0; k < 10; k += 2) { - z++; -} - -$(document).ready(); - - -function pageLoad() { - $('#TextBox1').unbind(); - $('#TextBox1').datepicker(); -} - -function pageLoad() { - var webclass = [ - { - 'student': - { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' } - }, -{ - 'student': - { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' } -}, - { - 'student': - { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' } - } - ]; - - $create(Sys.UI.DataView, { data: webclass }, null, null, $get('SList')); - -} - -$(document).ready(function() { - alert('hello'); -}); diff --git a/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentation.ts b/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentation.ts deleted file mode 100644 index 3030a36630..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentation.ts +++ /dev/null @@ -1,3 +0,0 @@ - module Foo { - export module A . B . C { } - } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentationBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentationBaseline.ts deleted file mode 100644 index 0013b367dc..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentationBaseline.ts +++ /dev/null @@ -1,3 +0,0 @@ -module Foo { - export module A.B.C { } -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/modules.ts b/src/harness/unittests/services/formatting/testCode/formatting/modules.ts deleted file mode 100644 index 5ce0d19b63..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/modules.ts +++ /dev/null @@ -1,76 +0,0 @@ - module mod1 { - export class b { - } - class d { - } - - - export interface ib { - } -} - - module m2 { - - export module m3 { - export class c extends mod1.b { - } - export class ib2 implements mod1.ib { - } - } -} - - class c extends mod1.b { -} - - class ib2 implements mod1.ib { -} - - declare export module "m4" { - export class d { - } ; - var x : d ; - export function foo ( ) : d ; -} - - import m4 = module ( "m4" ) ; - export var x4 = m4.x ; - export var d4 = m4.d ; - export var f4 = m4.foo ( ) ; - - export module m1 { - declare export module "m2" { - export class d { - } ; - var x: d ; - export function foo ( ) : d ; - } - import m2 = module ( "m2" ) ; - import m3 = module ( "m4" ) ; - - export var x2 = m2.x ; - export var d2 = m2.d ; - export var f2 = m2.foo ( ) ; - - export var x3 = m3.x ; - export var d3 = m3.d ; - export var f3 = m3.foo ( ) ; -} - - export var x2 = m1.m2.x ; - export var d2 = m1.m2.d ; - export var f2 = m1.m2.foo ( ) ; - - export var x3 = m1.m3.x ; - export var d3 = m1.m3.d ; - export var f3 = m1.m3.foo ( ) ; - - export module m5 { - export var x2 = m1.m2.x ; - export var d2 = m1.m2.d ; - export var f2 = m1.m2.foo ( ) ; - - export var x3 = m1.m3.x ; - export var d3 = m1.m3.d ; - export var f3 = m1.m3.foo ( ) ; -} - diff --git a/src/harness/unittests/services/formatting/testCode/formatting/modulesBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/modulesBaseline.ts deleted file mode 100644 index e6f62024fe..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/modulesBaseline.ts +++ /dev/null @@ -1,76 +0,0 @@ -module mod1 { - export class b { - } - class d { - } - - - export interface ib { - } -} - -module m2 { - - export module m3 { - export class c extends mod1.b { - } - export class ib2 implements mod1.ib { - } - } -} - -class c extends mod1.b { -} - -class ib2 implements mod1.ib { -} - -declare export module "m4" { - export class d { - }; - var x: d; - export function foo(): d; -} - -import m4 = module("m4"); -export var x4 = m4.x; -export var d4 = m4.d; -export var f4 = m4.foo(); - -export module m1 { - declare export module "m2" { - export class d { - }; - var x: d; - export function foo(): d; - } - import m2 = module("m2"); - import m3 = module("m4"); - - export var x2 = m2.x; - export var d2 = m2.d; - export var f2 = m2.foo(); - - export var x3 = m3.x; - export var d3 = m3.d; - export var f3 = m3.foo(); -} - -export var x2 = m1.m2.x; -export var d2 = m1.m2.d; -export var f2 = m1.m2.foo(); - -export var x3 = m1.m3.x; -export var d3 = m1.m3.d; -export var f3 = m1.m3.foo(); - -export module m5 { - export var x2 = m1.m2.x; - export var d2 = m1.m2.d; - export var f2 = m1.m2.foo(); - - export var x3 = m1.m3.x; - export var d3 = m1.m3.d; - export var f3 = m1.m3.foo(); -} - diff --git a/src/harness/unittests/services/formatting/testCode/formatting/objectLiteral.ts b/src/harness/unittests/services/formatting/testCode/formatting/objectLiteral.ts deleted file mode 100644 index dbecc4d4fe..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/objectLiteral.ts +++ /dev/null @@ -1,27 +0,0 @@ -var x = {foo: 1, -bar: "tt", -boo: 1 + 5}; - -var x2 = {foo: 1, -bar: "tt",boo:1+5}; - -function Foo() { -var typeICalc = { -clear: { -"()": [1, 2, 3] -} -} -} - -// Rule for object literal members for the "value" of the memebr to follow the indent -// of the member, i.e. the relative position of the value is maintained when the member -// is indented. -var x2 = { - foo: -3, - 'bar': - { a: 1, b : 2} -}; - -var x={ }; -var y = {}; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/objectLiteralBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/objectLiteralBaseline.ts deleted file mode 100644 index 3a7fa63d92..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/objectLiteralBaseline.ts +++ /dev/null @@ -1,31 +0,0 @@ -var x = { - foo: 1, - bar: "tt", - boo: 1 + 5 -}; - -var x2 = { - foo: 1, - bar: "tt", boo: 1 + 5 -}; - -function Foo() { - var typeICalc = { - clear: { - "()": [1, 2, 3] - } - } -} - -// Rule for object literal members for the "value" of the memebr to follow the indent -// of the member, i.e. the relative position of the value is maintained when the member -// is indented. -var x2 = { - foo: - 3, - 'bar': - { a: 1, b: 2 } -}; - -var x = {}; -var y = {}; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracket.ts b/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracket.ts deleted file mode 100644 index 0161f04308..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracket.ts +++ /dev/null @@ -1,32 +0,0 @@ -function f( ) { -var x = 3; - var z = 2 ; - a = z ++ - 2 * x ; - for ( ; ; ) { - a+=(g +g)*a%t; - b -- ; -} - - switch ( a ) - { - case 1 : { - a ++ ; - b--; - if(a===a) - return; - else - { - for(a in b) - if(a!=a) - { - for(a in b) - { -a++; - } - } - } - } - default: - break; - } -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracketBaseLine.ts b/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracketBaseLine.ts deleted file mode 100644 index 051a4ebd13..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracketBaseLine.ts +++ /dev/null @@ -1,28 +0,0 @@ -function f() { - var x = 3; - var z = 2; - a = z++ - 2 * x; - for (; ;) { - a += (g + g) * a % t; - b--; - } - - switch (a) { - case 1: { - a++; - b--; - if (a === a) - return; - else { - for (a in b) - if (a != a) { - for (a in b) { - a++; - } - } - } - } - default: - break; - } -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/onSemiColon.ts b/src/harness/unittests/services/formatting/testCode/formatting/onSemiColon.ts deleted file mode 100644 index 3b5b5456a6..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/onSemiColon.ts +++ /dev/null @@ -1 +0,0 @@ -var a=b+c^d-e*++f; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/onSemiColonBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/onSemiColonBaseline.ts deleted file mode 100644 index 2ba96e4f88..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/onSemiColonBaseline.ts +++ /dev/null @@ -1 +0,0 @@ -var a = b + c ^ d - e * ++f; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructor.ts b/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructor.ts deleted file mode 100644 index 7d98d5a8f4..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructor.ts +++ /dev/null @@ -1 +0,0 @@ -class test { constructor () { } } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructorBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructorBaseline.ts deleted file mode 100644 index bc124d41ba..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructorBaseline.ts +++ /dev/null @@ -1 +0,0 @@ -class test { constructor() { } } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurly.ts b/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurly.ts deleted file mode 100644 index ec093e0e37..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurly.ts +++ /dev/null @@ -1,10 +0,0 @@ -module Tools { - export enum NodeType { - Error, - Comment, - } - export enum foob - { - Blah=1, Bleah=2 - } -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurlyBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurlyBaseline.ts deleted file mode 100644 index d0a3db2d51..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurlyBaseline.ts +++ /dev/null @@ -1,9 +0,0 @@ -module Tools { - export enum NodeType { - Error, - Comment, - } - export enum foob { - Blah = 1, Bleah = 2 - } -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructs.ts b/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructs.ts deleted file mode 100644 index 43ef3710ef..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructs.ts +++ /dev/null @@ -1,65 +0,0 @@ - module MyModule - { - module A.B.C { -module F { -} - } -interface Blah -{ -boo: string; -} - - class Foo - { - -} - -class Foo2 { -public foo():number { -return 5 * 6; -} -public foo2() { -if (1 === 2) - - -{ -var y : number= 76; -return y; -} - - while (2 == 3) { - if ( y == null ) { - -} - } -} - -public foo3() { -if (1 === 2) - -//comment preventing line merging -{ -var y = 76; -return y; -} - -} - } - } - -function foo(a:number, b:number):number -{ -return 0; -} - -function bar(a:number, b:number) :number[] { -return []; -} - -module BugFix3 { -declare var f: { - (): any; - (x: number): string; - foo: number; -}; -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructsBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructsBaseline.ts deleted file mode 100644 index 929334e473..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructsBaseline.ts +++ /dev/null @@ -1,58 +0,0 @@ -module MyModule { - module A.B.C { - module F { - } - } - interface Blah { - boo: string; - } - - class Foo { - - } - - class Foo2 { - public foo(): number { - return 5 * 6; - } - public foo2() { - if (1 === 2) { - var y: number = 76; - return y; - } - - while (2 == 3) { - if (y == null) { - - } - } - } - - public foo3() { - if (1 === 2) - - //comment preventing line merging - { - var y = 76; - return y; - } - - } - } -} - -function foo(a: number, b: number): number { - return 0; -} - -function bar(a: number, b: number): number[] { - return []; -} - -module BugFix3 { - declare var f: { - (): any; - (x: number): string; - foo: number; - }; -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/various.ts b/src/harness/unittests/services/formatting/testCode/formatting/various.ts deleted file mode 100644 index bd814c2348..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/various.ts +++ /dev/null @@ -1,17 +0,0 @@ -function f(a,b,c,d){ -for(var i=0;i<10;i++){ -var a=0; -var b=a+a+a*a%a/2-1; -b+=a; -++b; -f(a,b,c,d); -if(1===1){ -var m=function(e,f){ -return e^f; -} -} -} -} - -for (var i = 0 ; i < this.foo(); i++) { -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/variousBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/variousBaseline.ts deleted file mode 100644 index a4b5ceeb1c..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/variousBaseline.ts +++ /dev/null @@ -1,17 +0,0 @@ -function f(a, b, c, d) { - for (var i = 0; i < 10; i++) { - var a = 0; - var b = a + a + a * a % a / 2 - 1; - b += a; - ++b; - f(a, b, c, d); - if (1 === 1) { - var m = function(e, f) { - return e ^ f; - } - } - } -} - -for (var i = 0 ; i < this.foo(); i++) { -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/withStatement.ts b/src/harness/unittests/services/formatting/testCode/formatting/withStatement.ts deleted file mode 100644 index 66ec4bf546..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/withStatement.ts +++ /dev/null @@ -1,9 +0,0 @@ -with (foo.bar) - - { - - } - -with (bar.blah) -{ -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/withStatementBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/withStatementBaseline.ts deleted file mode 100644 index f81378d7f8..0000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/withStatementBaseline.ts +++ /dev/null @@ -1,6 +0,0 @@ -with (foo.bar) { - -} - -with (bar.blah) { -} diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 5ea0df91ca..b2fc432224 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -176,11 +176,11 @@ namespace ts.projectSystem { } }; - export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler, cancellationToken?: server.ServerCancellationToken) { + export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler, cancellationToken?: server.ServerCancellationToken, throttleWaitMilliseconds?: number) { if (typingsInstaller === undefined) { typingsInstaller = new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host); } - return new TestSession(host, cancellationToken || server.nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler); + return new TestSession(host, cancellationToken || server.nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler, throttleWaitMilliseconds); } export interface CreateProjectServiceParameters { @@ -547,6 +547,49 @@ namespace ts.projectSystem { readonly getEnvironmentVariable = notImplemented; } + /** + * Test server cancellation token used to mock host token cancellation requests. + * The cancelAfterRequest constructor param specifies how many isCancellationRequested() calls + * should be made before canceling the token. The id of the request to cancel should be set with + * setRequestToCancel(); + */ + export class TestServerCancellationToken implements server.ServerCancellationToken { + private currentId = -1; + private requestToCancel = -1; + private isCancellationRequestedCount = 0; + + constructor(private cancelAfterRequest = 0) { + } + + setRequest(requestId: number) { + this.currentId = requestId; + } + + setRequestToCancel(requestId: number) { + this.resetToken(); + this.requestToCancel = requestId; + } + + resetRequest(requestId: number) { + assert.equal(requestId, this.currentId, "unexpected request id in cancellation"); + this.currentId = undefined; + } + + isCancellationRequested() { + this.isCancellationRequestedCount++; + // If the request id is the request to cancel and isCancellationRequestedCount + // has been met then cancel the request. Ex: cancel the request if it is a + // nav bar request & isCancellationRequested() has already been called three times. + return this.requestToCancel === this.currentId && this.isCancellationRequestedCount >= this.cancelAfterRequest; + } + + resetToken() { + this.currentId = -1; + this.isCancellationRequestedCount = 0; + this.requestToCancel = -1; + } + } + export function makeSessionRequest(command: string, args: T) { const newRequest: protocol.Request = { seq: 0, @@ -1007,6 +1050,41 @@ namespace ts.projectSystem { checkProjectRootFiles(projectService.configuredProjects[0], [commonFile1.path, commonFile2.path]); }); + it("should disable features when the files are too large", () => { + const file1 = { + path: "/a/b/f1.js", + content: "let x =1;", + fileSize: 10 * 1024 * 1024 + }; + const file2 = { + path: "/a/b/f2.js", + content: "let y =1;", + fileSize: 6 * 1024 * 1024 + }; + const file3 = { + path: "/a/b/f3.js", + content: "let y =1;", + fileSize: 6 * 1024 * 1024 + }; + + const proj1name = "proj1", proj2name = "proj2", proj3name = "proj3"; + + const host = createServerHost([file1, file2, file3]); + const projectService = createProjectService(host); + + projectService.openExternalProject({ rootFiles: toExternalFiles([file1.path]), options: {}, projectFileName: proj1name }); + const proj1 = projectService.findProject(proj1name); + assert.isTrue(proj1.languageServiceEnabled); + + projectService.openExternalProject({ rootFiles: toExternalFiles([file2.path]), options: {}, projectFileName: proj2name }); + const proj2 = projectService.findProject(proj2name); + assert.isTrue(proj2.languageServiceEnabled); + + projectService.openExternalProject({ rootFiles: toExternalFiles([file3.path]), options: {}, projectFileName: proj3name }); + const proj3 = projectService.findProject(proj3name); + assert.isFalse(proj3.languageServiceEnabled); + }); + it("should use only one inferred project if 'useOneInferredProject' is set", () => { const file1 = { path: "/a/b/main.ts", @@ -3349,6 +3427,7 @@ namespace ts.projectSystem { }, resetRequest: noop }; + const session = createSession(host, /*typingsInstaller*/ undefined, /*projectServiceEventHandler*/ undefined, cancellationToken); expectedRequestId = session.getNextSeq(); @@ -3387,22 +3466,7 @@ namespace ts.projectSystem { }) }; - let requestToCancel = -1; - const cancellationToken: server.ServerCancellationToken = (function(){ - let currentId: number; - return { - setRequest(requestId) { - currentId = requestId; - }, - resetRequest(requestId) { - assert.equal(requestId, currentId, "unexpected request id in cancellation"); - currentId = undefined; - }, - isCancellationRequested() { - return requestToCancel === currentId; - } - }; - })(); + const cancellationToken = new TestServerCancellationToken(); const host = createServerHost([f1, config]); const session = createSession(host, /*typingsInstaller*/ undefined, () => {}, cancellationToken); { @@ -3437,13 +3501,13 @@ namespace ts.projectSystem { host.clearOutput(); // cancel previously issued Geterr - requestToCancel = getErrId; + cancellationToken.setRequestToCancel(getErrId); host.runQueuedTimeoutCallbacks(); assert.equal(host.getOutput().length, 1, "expect 1 message"); verifyRequestCompleted(getErrId, 0); - requestToCancel = -1; + cancellationToken.resetToken(); } { const getErrId = session.getNextSeq(); @@ -3460,12 +3524,12 @@ namespace ts.projectSystem { assert.equal(e1.event, "syntaxDiag"); host.clearOutput(); - requestToCancel = getErrId; + cancellationToken.setRequestToCancel(getErrId); host.runQueuedImmediateCallbacks(); assert.equal(host.getOutput().length, 1, "expect 1 message"); verifyRequestCompleted(getErrId, 0); - requestToCancel = -1; + cancellationToken.resetToken(); } { const getErrId = session.getNextSeq(); @@ -3488,7 +3552,7 @@ namespace ts.projectSystem { assert.equal(e2.event, "semanticDiag"); verifyRequestCompleted(getErrId, 1); - requestToCancel = -1; + cancellationToken.resetToken(); } { const getErr1 = session.getNextSeq(); @@ -3523,6 +3587,68 @@ namespace ts.projectSystem { return JSON.parse(server.extractMessage(host.getOutput()[n])); } }); + it("Lower priority tasks are cancellable", () => { + const f1 = { + path: "/a/app.ts", + content: `{ let x = 1; } var foo = "foo"; var bar = "bar"; var fooBar = "fooBar";` + }; + const config = { + path: "/a/tsconfig.json", + content: JSON.stringify({ + compilerOptions: {} + }) + }; + const cancellationToken = new TestServerCancellationToken(/*cancelAfterRequest*/ 3); + const host = createServerHost([f1, config]); + const session = createSession(host, /*typingsInstaller*/ undefined, () => { }, cancellationToken, /*throttleWaitMilliseconds*/ 0); + { + session.executeCommandSeq({ + command: "open", + arguments: { file: f1.path } + }); + + // send navbar request (normal priority) + session.executeCommandSeq({ + command: "navbar", + arguments: { file: f1.path } + }); + + // ensure the nav bar request can be canceled + verifyExecuteCommandSeqIsCancellable({ + command: "navbar", + arguments: { file: f1.path } + }); + + // send outlining spans request (normal priority) + session.executeCommandSeq({ + command: "outliningSpans", + arguments: { file: f1.path } + }); + + // ensure the outlining spans request can be canceled + verifyExecuteCommandSeqIsCancellable({ + command: "outliningSpans", + arguments: { file: f1.path } + }); + } + + function verifyExecuteCommandSeqIsCancellable(request: Partial) { + // Set the next request to be cancellable + // The cancellation token will cancel the request the third time + // isCancellationRequested() is called. + cancellationToken.setRequestToCancel(session.getNextSeq()); + let operationCanceledExceptionThrown = false; + + try { + session.executeCommandSeq(request); + } + catch (e) { + assert(e instanceof OperationCanceledException); + operationCanceledExceptionThrown = true; + } + assert(operationCanceledExceptionThrown, "Operation Canceled Exception not thrown for request: " + JSON.stringify(request)); + } + }); }); describe("occurence highlight on string", () => { diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 5d4bb9ce6e..348e52246a 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -1396,6 +1396,7 @@ interface AudioNode extends EventTarget { readonly numberOfInputs: number; readonly numberOfOutputs: number; connect(destination: AudioNode, output?: number, input?: number): AudioNode; + connect(destination: AudioParam, output?: number): void; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -2152,7 +2153,9 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; drawFocusIfNeeded(element: Element): void; - drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; fillText(text: string, x: number, y: number, maxWidth?: number): void; @@ -2449,10 +2452,10 @@ declare var DOMException: { } interface DOMImplementation { - createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; + createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document; createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(): boolean; + hasFeature(feature: string | null, version: string | null): boolean; } declare var DOMImplementation: { @@ -3449,6 +3452,7 @@ declare var Document: { } interface DocumentFragment extends Node, NodeSelector, ParentNode { + getElementById(elementId: string): HTMLElement | null; } declare var DocumentFragment: { @@ -11837,7 +11841,7 @@ interface URL { protocol: string; search: string; username: string; - readonly searchparams: URLSearchParams; + readonly searchParams: URLSearchParams; toString(): string; } @@ -12161,12 +12165,12 @@ interface WebGLRenderingContext { stencilMaskSeparate(face: number, mask: number): void; stencilOp(fail: number, zfail: number, zpass: number): void; stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; - texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels?: ArrayBufferView): void; - texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; texParameterf(target: number, pname: number, param: number): void; texParameteri(target: number, pname: number, param: number): void; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels?: ArrayBufferView): void; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; uniform1f(location: WebGLUniformLocation | null, x: number): void; uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; uniform1i(location: WebGLUniformLocation | null, x: number): void; @@ -13260,6 +13264,8 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; scroll(options?: ScrollToOptions): void; scrollTo(options?: ScrollToOptions): void; scrollBy(options?: ScrollToOptions): void; @@ -13473,6 +13479,7 @@ interface Body { blob(): Promise; json(): Promise; text(): Promise; + formData(): Promise; } interface CanvasPathMethods { @@ -13835,6 +13842,21 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + interface URLSearchParams { /** * Appends a specified key/value pair as a new search parameter. @@ -13879,6 +13901,7 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; + [index: number]: T; } interface BlobPropertyBag { @@ -14840,6 +14863,8 @@ declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function scroll(options?: ScrollToOptions): void; declare function scrollTo(options?: ScrollToOptions): void; declare function scrollBy(options?: ScrollToOptions): void; diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 9a04b723ac..c79e007996 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -4,6 +4,23 @@ interface DOMTokenList { [Symbol.iterator](): IterableIterator; } +interface FormData { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[string, string | File]>; + /** + * Returns a list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns a list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + interface NodeList { /** * Returns an array of key, value pairs for every entry in the list diff --git a/src/lib/es2015.generator.d.ts b/src/lib/es2015.generator.d.ts index 2f522ad877..5637ef816d 100644 --- a/src/lib/es2015.generator.d.ts +++ b/src/lib/es2015.generator.d.ts @@ -1,4 +1,29 @@ -interface GeneratorFunction extends Function { } +interface Generator extends Iterator { } + +interface GeneratorFunction { + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + new (...args: any[]): Generator; + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + (...args: any[]): Generator; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: Generator; +} interface GeneratorFunctionConstructor { /** @@ -6,7 +31,22 @@ interface GeneratorFunctionConstructor { * @param args A list of arguments the function accepts. */ new (...args: string[]): GeneratorFunction; + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ (...args: string[]): GeneratorFunction; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ readonly prototype: GeneratorFunction; } declare var GeneratorFunction: GeneratorFunctionConstructor; diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 71e4cb7c89..5334dae9e0 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -137,7 +137,7 @@ interface Function { [Symbol.hasInstance](value: any): boolean; } -interface GeneratorFunction extends Function { +interface GeneratorFunction { readonly [Symbol.toStringTag]: "GeneratorFunction"; } diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index e9563db1bc..326a3a9546 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -1407,6 +1407,8 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo readonly performance: Performance; readonly self: WorkerGlobalScope; msWriteProfilerMark(profilerMarkName: string): void; + createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -1467,6 +1469,21 @@ interface ErrorEventInit { error?: any; } +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + interface BlobPropertyBag { type?: string; endings?: string; @@ -1697,6 +1714,8 @@ declare var onerror: (this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any; declare var performance: Performance; declare var self: WorkerGlobalScope; declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function dispatchEvent(evt: Event): boolean; declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare var indexedDB: IDBFactory; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 397de9ead3..30c7a87dc7 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -254,6 +254,7 @@ namespace ts.server { private compilerOptionsForInferredProjects: CompilerOptions; private compileOnSaveForInferredProjects: boolean; + private readonly projectToSizeMap: Map = createMap(); private readonly directoryWatchers: DirectoryWatchers; private readonly throttledOperations: ThrottledOperations; @@ -270,7 +271,8 @@ namespace ts.server { public readonly cancellationToken: HostCancellationToken, public readonly useSingleInferredProject: boolean, readonly typingsInstaller: ITypingsInstaller = nullTypingsInstaller, - private readonly eventHandler?: ProjectServiceEventHandler) { + private readonly eventHandler?: ProjectServiceEventHandler, + public readonly throttleWaitMilliseconds?: number) { Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); @@ -563,9 +565,11 @@ namespace ts.server { switch (project.projectKind) { case ProjectKind.External: removeItemFromSet(this.externalProjects, project); + this.projectToSizeMap.delete((project as ExternalProject).externalProjectName); break; case ProjectKind.Configured: removeItemFromSet(this.configuredProjects, project); + this.projectToSizeMap.delete((project as ConfiguredProject).canonicalConfigFilePath); break; case ProjectKind.Inferred: removeItemFromSet(this.inferredProjects, project); @@ -852,10 +856,15 @@ namespace ts.server { return { success: true, projectOptions, configFileErrors: errors }; } - private exceededTotalSizeLimitForNonTsFiles(options: CompilerOptions, fileNames: T[], propertyReader: FilePropertyReader) { + private exceededTotalSizeLimitForNonTsFiles(name: string, options: CompilerOptions, fileNames: T[], propertyReader: FilePropertyReader) { if (options && options.disableSizeLimit || !this.host.getFileSize) { return false; } + + let availableSpace = maxProgramSizeForNonTsFiles; + this.projectToSizeMap.set(name, 0); + this.projectToSizeMap.forEach(val => (availableSpace -= (val || 0))); + let totalNonTsFileSize = 0; for (const f of fileNames) { const fileName = propertyReader.getFileName(f); @@ -864,9 +873,16 @@ namespace ts.server { } totalNonTsFileSize += this.host.getFileSize(fileName); if (totalNonTsFileSize > maxProgramSizeForNonTsFiles) { + // Keep the size as zero since it's disabled return true; } } + + if (totalNonTsFileSize > availableSpace) { + return true; + } + + this.projectToSizeMap.set(name, totalNonTsFileSize); return false; } @@ -877,7 +893,7 @@ namespace ts.server { this, this.documentRegistry, compilerOptions, - /*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), + /*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, /*clientFileName*/ undefined, typeAcquisition, /*configFileErrors*/ undefined); @@ -897,7 +913,7 @@ namespace ts.server { } private createAndAddConfiguredProject(configFileName: NormalizedPath, projectOptions: ProjectOptions, configFileErrors: Diagnostic[], clientFileName?: string) { - const sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + const sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); const project = new ConfiguredProject( configFileName, this, @@ -1050,7 +1066,7 @@ namespace ts.server { return configFileErrors; } - if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + if (this.exceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { project.setCompilerOptions(projectOptions.compilerOptions); if (!project.languageServiceEnabled) { // language service is already disabled @@ -1414,7 +1430,7 @@ namespace ts.server { if (externalProject) { if (!tsConfigFiles) { const compilerOptions = convertCompilerOptions(proj.options); - if (this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, proj.rootFiles, externalFilePropertyReader)) { + if (this.exceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader)) { externalProject.disableLanguageService(); } else { diff --git a/src/server/lsHost.ts b/src/server/lsHost.ts index eee80d82e7..ec655c545e 100644 --- a/src/server/lsHost.ts +++ b/src/server/lsHost.ts @@ -16,6 +16,7 @@ namespace ts.server { readonly realpath?: (path: string) => string; constructor(private readonly host: ServerHost, private readonly project: Project, private readonly cancellationToken: HostCancellationToken) { + this.cancellationToken = new ThrottledCancellationToken(cancellationToken, project.projectService.throttleWaitMilliseconds); this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); if (host.trace) { diff --git a/src/server/project.ts b/src/server/project.ts index 385816b102..e57e605d65 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1031,7 +1031,7 @@ namespace ts.server { export class ExternalProject extends Project { private typeAcquisition: TypeAcquisition; - constructor(externalProjectName: string, + constructor(public externalProjectName: string, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions, diff --git a/src/server/server.ts b/src/server/server.ts index 4e443add77..e38f82f35f 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -219,6 +219,7 @@ namespace ts.server { host: ServerHost, eventPort: number, readonly globalTypingsCacheLocation: string, + readonly typingSafeListLocation: string, private newLine: string) { this.throttledOperations = new ThrottledOperations(host); if (eventPort) { @@ -260,6 +261,9 @@ namespace ts.server { if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { args.push(Arguments.LogFile, combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`)); } + if (this.typingSafeListLocation) { + args.push(Arguments.TypingSafeListLocation, this.typingSafeListLocation); + } const execArgv: string[] = []; { for (const arg of process.execArgv) { @@ -378,11 +382,12 @@ namespace ts.server { useSingleInferredProject: boolean, disableAutomaticTypingAcquisition: boolean, globalTypingsCacheLocation: string, + typingSafeListLocation: string, telemetryEnabled: boolean, logger: server.Logger) { const typingsInstaller = disableAutomaticTypingAcquisition ? undefined - : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine); + : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, host.newLine); super( host, @@ -729,6 +734,8 @@ namespace ts.server { validateLocaleAndSetLanguage(localeStr, sys); } + const typingSafeListLocation = findArgument("--typingSafeListLocation"); + const useSingleInferredProject = hasArgument("--useSingleInferredProject"); const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition"); const telemetryEnabled = hasArgument(Arguments.EnableTelemetry); @@ -741,6 +748,7 @@ namespace ts.server { useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), + typingSafeListLocation, telemetryEnabled, logger); process.on("uncaughtException", function (err: Error) { diff --git a/src/server/session.ts b/src/server/session.ts index 8dd0411d07..7161bdc04d 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -25,8 +25,15 @@ namespace ts.server { return ((1e9 * seconds) + nanoseconds) / 1000000.0; } - function shouldSkipSematicCheck(project: Project) { - return (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject(); + function shouldSkipSemanticCheck(project: Project) { + if (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) { + return project.isJsOnlyProject(); + } + else { + // For configured projects, require that skipLibCheck be set also + const options = project.getCompilerOptions(); + return options.skipLibCheck && !options.checkJs && project.isJsOnlyProject(); + } } interface FileStart { @@ -331,7 +338,8 @@ namespace ts.server { private hrtime: (start?: number[]) => number[], protected logger: Logger, protected readonly canUseEvents: boolean, - eventHandler?: ProjectServiceEventHandler) { + eventHandler?: ProjectServiceEventHandler, + private readonly throttleWaitMilliseconds?: number) { this.eventHander = canUseEvents ? eventHandler || (event => this.defaultEventHandler(event)) @@ -346,7 +354,7 @@ namespace ts.server { isCancellationRequested: () => cancellationToken.isCancellationRequested() }; this.errorCheck = new MultistepOperation(multistepOperationHost); - this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); + this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander, this.throttleWaitMilliseconds); this.gcTimer = new GcTimer(host, /*delay*/ 7000, logger); } @@ -447,7 +455,7 @@ namespace ts.server { private semanticCheck(file: NormalizedPath, project: Project) { try { let diags: Diagnostic[] = []; - if (!shouldSkipSematicCheck(project)) { + if (!shouldSkipSemanticCheck(project)) { diags = project.getLanguageService().getSemanticDiagnostics(file); } @@ -555,7 +563,7 @@ namespace ts.server { private getDiagnosticsWorker(args: protocol.FileRequestArgs, isSemantic: boolean, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) { const { project, file } = this.getFileAndProject(args); - if (isSemantic && shouldSkipSematicCheck(project)) { + if (isSemantic && shouldSkipSemanticCheck(project)) { return []; } const scriptInfo = project.getScriptInfoForNormalizedPath(file); diff --git a/src/server/shared.ts b/src/server/shared.ts index 5d65f8c90e..6dcf888192 100644 --- a/src/server/shared.ts +++ b/src/server/shared.ts @@ -11,6 +11,7 @@ namespace ts.server { export const GlobalCacheLocation = "--globalTypingsCacheLocation"; export const LogFile = "--logFile"; export const EnableTelemetry = "--enableTelemetry"; + export const TypingSafeListLocation = "--typingSafeListLocation"; } export function hasArgument(argumentName: string) { diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 0a9d8ee29f..1018b37d90 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -76,11 +76,11 @@ namespace ts.server.typingsInstaller { private delayedInitializationError: InitializationFailedResponse; - constructor(globalTypingsCacheLocation: string, throttleLimit: number, log: Log) { + constructor(globalTypingsCacheLocation: string, typingSafeListLocation: string, throttleLimit: number, log: Log) { super( sys, globalTypingsCacheLocation, - toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), + typingSafeListLocation ? toPath(typingSafeListLocation, "", createGetCanonicalFileName(sys.useCaseSensitiveFileNames)) : toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), throttleLimit, log); if (this.log.isEnabled()) { @@ -164,6 +164,7 @@ namespace ts.server.typingsInstaller { const logFilePath = findArgument(server.Arguments.LogFile); const globalTypingsCacheLocation = findArgument(server.Arguments.GlobalCacheLocation); + const typingSafeListLocation = findArgument(server.Arguments.TypingSafeListLocation); const log = new FileLog(logFilePath); if (log.isEnabled()) { @@ -177,6 +178,6 @@ namespace ts.server.typingsInstaller { } process.exit(0); }); - const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, /*throttleLimit*/5, log); + const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, /*throttleLimit*/5, log); installer.listen(); } \ No newline at end of file diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts new file mode 100644 index 0000000000..7fa5c5bf23 --- /dev/null +++ b/src/services/codefixes/disableJsDiagnostics.ts @@ -0,0 +1,70 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: getApplicableDiagnosticCodes(), + getCodeActions: getDisableJsDiagnosticsCodeActions + }); + + function getApplicableDiagnosticCodes(): number[] { + const allDiagnostcs = >Diagnostics; + return Object.keys(allDiagnostcs) + .filter(d => allDiagnostcs[d] && allDiagnostcs[d].category === DiagnosticCategory.Error) + .map(d => allDiagnostcs[d].code); + } + + function getIgnoreCommentLocationForLocation(sourceFile: SourceFile, position: number, newLineCharacter: string) { + const { line } = getLineAndCharacterOfPosition(sourceFile, position); + const lineStartPosition = getStartPositionOfLine(line, sourceFile); + const startPosition = getFirstNonSpaceCharacterPosition(sourceFile.text, lineStartPosition); + + // First try to see if we can put the '// @ts-ignore' on the previous line. + // We need to make sure that we are not in the middle of a string literal or a comment. + // We also want to check if the previous line holds a comment for a node on the next line + // if so, we do not want to separate the node from its comment if we can. + if (!isInComment(sourceFile, startPosition) && !isInString(sourceFile, startPosition) && !isInTemplateString(sourceFile, startPosition)) { + const token = getTouchingToken(sourceFile, startPosition); + const tokenLeadingCommnets = getLeadingCommentRangesOfNode(token, sourceFile); + if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) { + return { + span: { start: startPosition, length: 0 }, + newText: `// @ts-ignore${newLineCharacter}` + }; + } + } + + // If all fails, add an extra new line immediatlly before the error span. + return { + span: { start: position, length: 0 }, + newText: `${position === startPosition ? "" : newLineCharacter}// @ts-ignore${newLineCharacter}` + }; + } + + function getDisableJsDiagnosticsCodeActions(context: CodeFixContext): CodeAction[] | undefined { + const { sourceFile, program, newLineCharacter, span } = context; + + if (!isInJavaScriptFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) { + return undefined; + } + + return [{ + description: getLocaleSpecificMessage(Diagnostics.Ignore_this_error_message), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [getIgnoreCommentLocationForLocation(sourceFile, span.start, newLineCharacter)] + }] + }, + { + description: getLocaleSpecificMessage(Diagnostics.Disable_checking_for_this_file), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { + start: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.pos : 0, + length: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.end - sourceFile.checkJsDirective.pos : 0 + }, + newText: `// @ts-nocheck${newLineCharacter}` + }] + }] + }]; + } +} \ No newline at end of file diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 6ae2ba3f51..ec772e1e29 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -18,50 +18,121 @@ namespace ts.codefix { return undefined; } - const classDeclaration = getContainingClass(token); - if (!classDeclaration) { + if (!isPropertyAccessExpression(token.parent) || token.parent.expression.kind !== SyntaxKind.ThisKeyword) { return undefined; } - if (!(token.parent && token.parent.kind === SyntaxKind.PropertyAccessExpression)) { + const classMemberDeclaration = getThisContainer(token, /*includeArrowFunctions*/ false); + if (!isClassElement(classMemberDeclaration)) { return undefined; } - if ((token.parent as PropertyAccessExpression).expression.kind !== SyntaxKind.ThisKeyword) { + const classDeclaration = classMemberDeclaration.parent; + if (!classDeclaration || !isClassLike(classDeclaration)) { return undefined; } - let typeString = "any"; + const isStatic = hasModifier(classMemberDeclaration, ModifierFlags.Static); - if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { - const binaryExpression = token.parent.parent as BinaryExpression; + return isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); - const checker = context.program.getTypeChecker(); - const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); - typeString = checker.typeToString(widenedType); + function getActionsForAddMissingMemberInJavaScriptFile(): CodeAction[] | undefined { + const memberName = token.getText(); + + if (isStatic) { + if (classDeclaration.kind === SyntaxKind.ClassExpression) { + return undefined; + } + + const className = classDeclaration.name.getText(); + + return [{ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_static_property_0), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classDeclaration.getEnd(), length: 0 }, + newText: `${context.newLineCharacter}${className}.${memberName} = undefined;${context.newLineCharacter}` + }] + }] + }]; + + } + else { + const classConstructor = getFirstConstructorWithBody(classDeclaration); + if (!classConstructor) { + return undefined; + } + + return [{ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classConstructor.body.getEnd() - 1, length: 0 }, + newText: `this.${memberName} = undefined;${context.newLineCharacter}` + }] + }] + }]; + } } - const startPos = classDeclaration.members.pos; + function getActionsForAddMissingMemberInTypeScriptFile(): CodeAction[] | undefined { + let typeNode: TypeNode; - return [{ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: `${token.getFullText(sourceFile)}: ${typeString};` - }] - }] - }, - { - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: `[name: string]: ${typeString};` - }] - }] - }]; + if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { + const binaryExpression = token.parent.parent as BinaryExpression; + + const checker = context.program.getTypeChecker(); + const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration); + } + + typeNode = typeNode || createKeywordTypeNode(SyntaxKind.AnyKeyword); + + const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile); + + const property = createProperty( + /*decorators*/undefined, + /*modifiers*/ isStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined, + token.getText(sourceFile), + /*questionToken*/ undefined, + typeNode, + /*initializer*/ undefined); + const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter }); + + const actions = [{ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), + changes: propertyChangeTracker.getChanges() + }]; + + if (!isStatic) { + const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword); + const indexingParameter = createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + "x", + /*questionToken*/ undefined, + stringTypeNode, + /*initializer*/ undefined); + const indexSignature = createIndexSignatureDeclaration( + /*decorators*/undefined, + /*modifiers*/ undefined, + [indexingParameter], + typeNode); + + const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter }); + + actions.push({ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), + changes: indexSignatureChangeTracker.getChanges() + }); + } + + return actions; + } } } \ No newline at end of file diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index 16edce0a51..62f89b1a21 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -19,10 +19,9 @@ namespace ts.codefix { const checker = context.program.getTypeChecker(); if (isClassLike(token.parent)) { - const classDecl = token.parent as ClassLikeDeclaration; - const startPos = classDecl.members.pos; + const classDeclaration = token.parent as ClassLikeDeclaration; - const extendsNode = getClassExtendsHeritageClauseElement(classDecl); + const extendsNode = getClassExtendsHeritageClauseElement(classDeclaration); const instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, @@ -30,18 +29,12 @@ namespace ts.codefix { const extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); const abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); - const insertion = getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); - - if (insertion.length) { + const newNodes = createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, checker); + const changes = newNodesToChanges(newNodes, getOpenBraceOfClassLike(classDeclaration, sourceFile), context); + if (changes && changes.length > 0) { return [{ description: getLocaleSpecificMessage(Diagnostics.Implement_inherited_abstract_class), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes }]; } } diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 67b2242c8d..3b1b99febb 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -11,14 +11,14 @@ namespace ts.codefix { const token = getTokenAtPosition(sourceFile, start); const checker = context.program.getTypeChecker(); - const classDecl = getContainingClass(token); - if (!classDecl) { + const classDeclaration = getContainingClass(token); + if (!classDeclaration) { return undefined; } - const startPos: number = classDecl.members.pos; - const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; - const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDecl); + const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile); + const classType = checker.getTypeAtLocation(classDeclaration) as InterfaceType; + const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDeclaration); const hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, IndexKind.Number); const hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, IndexKind.String); @@ -31,43 +31,36 @@ namespace ts.codefix { const implementedTypeSymbols = checker.getPropertiesOfType(implementedType); const nonPrivateMembers = implementedTypeSymbols.filter(symbol => !(getModifierFlags(symbol.valueDeclaration) & ModifierFlags.Private)); - let insertion = getMissingIndexSignatureInsertion(implementedType, IndexKind.Number, classDecl, hasNumericIndexSignature); - insertion += getMissingIndexSignatureInsertion(implementedType, IndexKind.String, classDecl, hasStringIndexSignature); - insertion += getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); - + let newNodes: Node[] = []; + createAndAddMissingIndexSignatureDeclaration(implementedType, IndexKind.Number, hasNumericIndexSignature, newNodes); + createAndAddMissingIndexSignatureDeclaration(implementedType, IndexKind.String, hasStringIndexSignature, newNodes); + newNodes = newNodes.concat(createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker)); const message = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); - if (insertion) { - pushAction(result, insertion, message); + if (newNodes.length > 0) { + pushAction(result, newNodes, message); } } return result; - function getMissingIndexSignatureInsertion(type: InterfaceType, kind: IndexKind, enclosingDeclaration: ClassLikeDeclaration, hasIndexSigOfKind: boolean) { - if (!hasIndexSigOfKind) { - const IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); - if (IndexInfoOfKind) { - const writer = getSingleLineStringWriter(); - checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - const result = writer.string(); - releaseStringWriter(writer); - - return result; - } + function createAndAddMissingIndexSignatureDeclaration(type: InterfaceType, kind: IndexKind, hasIndexSigOfKind: boolean, newNodes: Node[]): void { + if (hasIndexSigOfKind) { + return; } - return ""; + + const indexInfoOfKind = checker.getIndexInfoOfType(type, kind); + + if (!indexInfoOfKind) { + return; + } + const newIndexSignatureDeclaration = checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, kind, classDeclaration); + newNodes.push(newIndexSignatureDeclaration); } - function pushAction(result: CodeAction[], insertion: string, description: string): void { + function pushAction(result: CodeAction[], newNodes: Node[], description: string): void { const newAction: CodeAction = { description: description, - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: newNodesToChanges(newNodes, openBrace, context) }; result.push(newAction); } diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 6d7efb64c6..fc2be3cd0c 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -16,7 +16,7 @@ namespace ts.codefix { return undefined; } - // figure out if the this access is actuall inside the supercall + // figure out if the `this` access is actually inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix if (superCall.expression && superCall.expression.kind == SyntaxKind.CallExpression) { const arguments = (superCall.expression).arguments; diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts index 76be34c67c..ae1643dfa3 100644 --- a/src/services/codefixes/fixes.ts +++ b/src/services/codefixes/fixes.ts @@ -7,4 +7,5 @@ /// /// /// +/// /// diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index d20fc0129c..b836815fc2 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -1,47 +1,88 @@ /* @internal */ namespace ts.codefix { + export function newNodesToChanges(newNodes: Node[], insertAfter: Node, context: CodeFixContext) { + const sourceFile = context.sourceFile; + + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + + for (const newNode of newNodes) { + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); + } + + const changes = changeTracker.getChanges(); + if (!some(changes)) { + return changes; + } + + Debug.assert(changes.length === 1); + const consolidatedChanges: FileTextChanges[] = [{ + fileName: changes[0].fileName, + textChanges: [{ + span: changes[0].textChanges[0].span, + newText: changes[0].textChanges.reduce((prev, cur) => prev + cur.newText, "") + }] + + }]; + return consolidatedChanges; + } + /** * Finds members of the resolved type that are missing in the class pointed to by class decl * and generates source code for the missing members. * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. * @returns Empty string iff there are no member insertions. */ - export function getMissingMembersInsertion(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker, newlineChar: string): string { + export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker): Node[] { const classMembers = classDeclaration.symbol.members; const missingMembers = possiblyMissingSymbols.filter(symbol => !classMembers.has(symbol.getName())); - let insertion = ""; - + let newNodes: Node[] = []; for (const symbol of missingMembers) { - insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + const newNode = createNewNodeForMemberSymbol(symbol, classDeclaration, checker); + if (newNode) { + if (Array.isArray(newNode)) { + newNodes = newNodes.concat(newNode); + } + else { + newNodes.push(newNode); + } + } } - return insertion; + return newNodes; } /** * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ - function getInsertionForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker, newlineChar: string): string { + function createNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker): Node[] | Node | undefined { const declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { - return ""; + return undefined; } const declaration = declarations[0] as Declaration; - const name = declaration.name ? declaration.name.getText() : undefined; - const visibility = getVisibilityPrefixWithSpace(getModifierFlags(declaration)); - - const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + // Clone name to remove leading trivia. + const name = getSynthesizedClone(declaration.name); + const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); + const modifiers = visibilityModifier ? createNodeArray([visibilityModifier]) : undefined; + const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); + const optional = !!(symbol.flags & SymbolFlags.Optional); switch (declaration.kind) { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: - const typeString = checker.typeToString(type, enclosingDeclaration, TypeFormatFlags.None); - return `${visibility}${name}: ${typeString};${newlineChar}`; - + const typeNode = checker.typeToTypeNode(type, enclosingDeclaration); + const property = createProperty( + /*decorators*/undefined, + modifiers, + name, + optional ? createToken(SyntaxKind.QuestionToken) : undefined, + typeNode, + /*initializer*/ undefined); + return property; case SyntaxKind.MethodSignature: case SyntaxKind.MethodDeclaration: // The signature for the implementation appears as an entry in `signatures` iff @@ -52,109 +93,142 @@ namespace ts.codefix { // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. const signatures = checker.getSignaturesOfType(type, SignatureKind.Call); - if (!(signatures && signatures.length > 0)) { - return ""; + if (!some(signatures)) { + return undefined; } + if (declarations.length === 1) { Debug.assert(signatures.length === 1); - const sigString = checker.signatureToString(signatures[0], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); - return getStubbedMethod(visibility, name, sigString, newlineChar); + const signature = signatures[0]; + return signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); } - let result = ""; + const signatureDeclarations: MethodDeclaration[] = []; for (let i = 0; i < signatures.length; i++) { - const sigString = checker.signatureToString(signatures[i], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); - result += `${visibility}${name}${sigString};${newlineChar}`; + const signature = signatures[i]; + const methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } - // If there is a declaration with a body, it is the last declaration, - // and it isn't caught by `getSignaturesOfType`. - let bodySig: Signature | undefined = undefined; if (declarations.length > signatures.length) { - bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); + const signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); + const methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } else { Debug.assert(declarations.length === signatures.length); - bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); + const methodImplementingSignatures = createMethodImplementingSignatures(signatures, name, optional, modifiers); + signatureDeclarations.push(methodImplementingSignatures); } - const sigString = checker.signatureToString(bodySig, enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); - result += getStubbedMethod(visibility, name, sigString, newlineChar); - - return result; + return signatureDeclarations; default: - return ""; + return undefined; + } + + function signatureToMethodDeclaration(signature: Signature, enclosingDeclaration: Node, body?: Block) { + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); + if (signatureDeclaration) { + signatureDeclaration.decorators = undefined; + signatureDeclaration.modifiers = modifiers; + signatureDeclaration.name = name; + signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; + signatureDeclaration.body = body; + } + return signatureDeclaration; } } - function createBodySignatureWithAnyTypes(signatures: Signature[], enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker): Signature { - const newSignatureDeclaration = createNode(SyntaxKind.CallSignature) as SignatureDeclaration; - newSignatureDeclaration.parent = enclosingDeclaration; - newSignatureDeclaration.name = signatures[0].getDeclaration().name; - - let maxNonRestArgs = -1; - let maxArgsIndex = 0; + function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration { + /** This is *a* signature with the maximal number of arguments, + * such that if there is a "maximal" signature without rest arguments, + * this is one of them. + */ + let maxArgsSignature = signatures[0]; let minArgumentCount = signatures[0].minArgumentCount; - let hasRestParameter = false; + let someSigHasRestParameter = false; for (let i = 0; i < signatures.length; i++) { const sig = signatures[i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - hasRestParameter = hasRestParameter || sig.hasRestParameter; - const nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); - if (nonRestLength > maxNonRestArgs) { - maxNonRestArgs = nonRestLength; - maxArgsIndex = i; + if (sig.hasRestParameter) { + someSigHasRestParameter = true; + } + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + maxArgsSignature = sig; } } - const maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(symbol => symbol.getName()); + const maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + const maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(symbol => symbol.getName()); - const optionalToken = createToken(SyntaxKind.QuestionToken); - - newSignatureDeclaration.parameters = createNodeArray(); + const parameters: ParameterDeclaration[] = []; for (let i = 0; i < maxNonRestArgs; i++) { - const newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); - newSignatureDeclaration.parameters.push(newParameter); + const anyType = createKeywordTypeNode(SyntaxKind.AnyKeyword); + const newParameter = createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + maxArgsParameterSymbolNames[i], + /*questionToken*/ i >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined, + anyType, + /*initializer*/ undefined); + parameters.push(newParameter); } - if (hasRestParameter) { - const restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); - restParameter.dotDotDotToken = createToken(SyntaxKind.DotDotDotToken); - newSignatureDeclaration.parameters.push(restParameter); + if (someSigHasRestParameter) { + const anyArrayType = createArrayTypeNode(createKeywordTypeNode(SyntaxKind.AnyKeyword)); + const restParameter = createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createToken(SyntaxKind.DotDotDotToken), + maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined, + anyArrayType, + /*initializer*/ undefined); + parameters.push(restParameter); } - return checker.getSignatureFromDeclaration(newSignatureDeclaration); - - function createParameterDeclarationWithoutType(index: number, minArgCount: number, enclosingSignatureDeclaration: SignatureDeclaration): ParameterDeclaration { - const newParameter = createNode(SyntaxKind.Parameter) as ParameterDeclaration; - - newParameter.symbol = new SymbolConstructor(SymbolFlags.FunctionScopedVariable, maxArgsParameterSymbolNames[index] || "rest"); - newParameter.symbol.valueDeclaration = newParameter; - newParameter.symbol.declarations = [newParameter]; - newParameter.parent = enclosingSignatureDeclaration; - if (index >= minArgCount) { - newParameter.questionToken = optionalToken; - } - - return newParameter; - } + return createStubbedMethod( + modifiers, + name, + optional, + /*typeParameters*/undefined, + parameters, + /*returnType*/ undefined); } - export function getStubbedMethod(visibility: string, name: string, sigString = "()", newlineChar: string): string { - return `${visibility}${name}${sigString}${getMethodBodyStub(newlineChar)}`; + export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, optional: boolean, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { + return createMethodDeclaration( + /*decorators*/ undefined, + modifiers, + /*asteriskToken*/ undefined, + name, + optional ? createToken(SyntaxKind.QuestionToken) : undefined, + typeParameters, + parameters, + returnType, + createStubbedMethodBody()); } - function getMethodBodyStub(newlineChar: string) { - return ` {${newlineChar}throw new Error('Method not implemented.');${newlineChar}}${newlineChar}`; + function createStubbedMethodBody() { + return createBlock( + [createThrow( + createNew( + createIdentifier("Error"), + /*typeArguments*/undefined, + [createLiteral("Method not implemented.")]))], + /*multiline*/true); } - function getVisibilityPrefixWithSpace(flags: ModifierFlags): string { + function createVisibilityModifier(flags: ModifierFlags) { if (flags & ModifierFlags.Public) { - return "public "; + return createToken(SyntaxKind.PublicKeyword); } else if (flags & ModifierFlags.Protected) { - return "protected "; + return createToken(SyntaxKind.ProtectedKeyword); } - return ""; + return undefined; } - - const SymbolConstructor = objectAllocator.getSymbolConstructor(); } \ No newline at end of file diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 25059d1f57..7a2508fcfd 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -2,6 +2,36 @@ /* @internal */ namespace ts.NavigationBar { + /** + * Matches all whitespace characters in a string. Eg: + * + * "app. + * + * onactivated" + * + * matches because of the newline, whereas + * + * "app.onactivated" + * + * does not match. + */ + const whiteSpaceRegex = /\s+/g; + + // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. + let curCancellationToken: CancellationToken; + let curSourceFile: SourceFile; + + /** + * For performance, we keep navigation bar parents on a stack rather than passing them through each recursion. + * `parent` is the current parent and is *not* stored in parentsStack. + * `startNode` sets a new parent and `endNode` returns to the previous parent. + */ + let parentsStack: NavigationBarNode[] = []; + let parent: NavigationBarNode; + + // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. + let emptyChildItemArray: NavigationBarItem[] = []; + /** * Represents a navigation bar item and its children. * The returned NavigationBarItem is more complicated and doesn't include 'parent', so we use these to do work before converting. @@ -14,22 +44,36 @@ namespace ts.NavigationBar { indent: number; // # of parents } - export function getNavigationBarItems(sourceFile: SourceFile): NavigationBarItem[] { + export function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationBarItem[] { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - const result = map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); - curSourceFile = undefined; - return result; + try { + return map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + } + finally { + reset(); + } } - export function getNavigationTree(sourceFile: SourceFile): NavigationTree { + export function getNavigationTree(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationTree { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - const result = convertToTree(rootNavigationBarNode(sourceFile)); - curSourceFile = undefined; - return result; + try { + return convertToTree(rootNavigationBarNode(sourceFile)); + } + finally { + reset(); + } + } + + function reset() { + curSourceFile = undefined; + curCancellationToken = undefined; + parentsStack = []; + parent = undefined; + emptyChildItemArray = []; } - // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. - let curSourceFile: SourceFile; function nodeText(node: Node): string { return node.getText(curSourceFile); } @@ -47,14 +91,6 @@ namespace ts.NavigationBar { } } - /* - For performance, we keep navigation bar parents on a stack rather than passing them through each recursion. - `parent` is the current parent and is *not* stored in parentsStack. - `startNode` sets a new parent and `endNode` returns to the previous parent. - */ - const parentsStack: NavigationBarNode[] = []; - let parent: NavigationBarNode; - function rootNavigationBarNode(sourceFile: SourceFile): NavigationBarNode { Debug.assert(!parentsStack.length); const root: NavigationBarNode = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; @@ -111,6 +147,8 @@ namespace ts.NavigationBar { /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node: Node): void { + curCancellationToken.throwIfCancellationRequested(); + if (!node || isToken(node)) { return; } @@ -487,9 +525,6 @@ namespace ts.NavigationBar { } } - // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. - const emptyChildItemArray: NavigationBarItem[] = []; - function convertToTree(n: NavigationBarNode): NavigationTree { return { text: getItemName(n.node), @@ -610,19 +645,4 @@ namespace ts.NavigationBar { function isFunctionOrClassExpression(node: Node): boolean { return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction || node.kind === SyntaxKind.ClassExpression; } - - /** - * Matches all whitespace characters in a string. Eg: - * - * "app. - * - * onactivated" - * - * matches because of the newline, whereas - * - * "app.onactivated" - * - * does not match. - */ - const whiteSpaceRegex = /\s+/g; } diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 43054a10f5..510f78c3f3 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.OutliningElementsCollector { - export function collectElements(sourceFile: SourceFile): OutliningSpan[] { + export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; const collapseText = "..."; @@ -38,6 +38,7 @@ namespace ts.OutliningElementsCollector { let singleLineCommentCount = 0; for (const currentComment of comments) { + cancellationToken.throwIfCancellationRequested(); // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last @@ -84,6 +85,7 @@ namespace ts.OutliningElementsCollector { let depth = 0; const maxDepth = 20; function walk(n: Node): void { + cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { return; } diff --git a/src/services/services.ts b/src/services/services.ts index d8a4cbeae6..68429cb957 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -482,6 +482,7 @@ namespace ts { public moduleAugmentations: LiteralExpression[]; private namedDeclarations: Map; public ambientModuleNames: string[]; + public checkJsDirective: CheckJsDirective | undefined; constructor(kind: SyntaxKind, pos: number, end: number) { super(kind, pos, end); @@ -981,6 +982,36 @@ namespace ts { } } + /* @internal */ + /** A cancellation that throttles calls to the host */ + export class ThrottledCancellationToken implements CancellationToken { + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + private lastCancellationCheckTime = 0; + + constructor(private hostCancellationToken: HostCancellationToken, private readonly throttleWaitMilliseconds = 20) { + } + + public isCancellationRequested(): boolean { + const time = timestamp(); + const duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration >= this.throttleWaitMilliseconds) { + // Check no more than once every throttle wait milliseconds + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + + return false; + } + + public throwIfCancellationRequested(): void { + if (this.isCancellationRequested()) { + throw new OperationCanceledException(); + } + } + } + export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { @@ -1552,11 +1583,11 @@ namespace ts { } function getNavigationBarItems(fileName: string): NavigationBarItem[] { - return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function getNavigationTree(fileName: string): NavigationTree { - return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function isTsOrTsxFile(fileName: string): boolean { @@ -1595,7 +1626,7 @@ namespace ts { function getOutliningSpans(fileName: string): OutliningSpan[] { // doesn't use compiler - no need to synchronize with host const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return OutliningElementsCollector.collectElements(sourceFile); + return OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } function getBraceMatchingAtPosition(fileName: string, position: number) { diff --git a/src/services/shims.ts b/src/services/shims.ts index 6fe9aed144..de2fd39b8a 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -469,29 +469,6 @@ namespace ts { } } - /** A cancellation that throttles calls to the host */ - class ThrottledCancellationToken implements HostCancellationToken { - // Store when we last tried to cancel. Checking cancellation can be expensive (as we have - // to marshall over to the host layer). So we only bother actually checking once enough - // time has passed. - private lastCancellationCheckTime = 0; - - constructor(private hostCancellationToken: HostCancellationToken) { - } - - public isCancellationRequested(): boolean { - const time = timestamp(); - const duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - // Check no more than once every 10 ms. - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - - return false; - } - } - export class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { public directoryExists: (directoryName: string) => boolean; diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index b457165b67..3fcc467f6a 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -419,7 +419,7 @@ namespace ts.SymbolDisplay { if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & SymbolFlags.Property) { - // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` + // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. if (symbol.parent && forEach(symbol.parent.declarations, declaration => declaration.kind === SyntaxKind.SourceFile)) { diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 424399db72..afc9892749 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -274,9 +274,9 @@ namespace ts.textChanges { } /** - * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, - * i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that - * for them separators are treated as the part of the node. + * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, + * i.e. arguments in arguments lists, parameters in parameter lists etc. + * Note that separators are part of the node in statements and class elements. */ public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile); @@ -484,7 +484,7 @@ namespace ts.textChanges { private static normalize(changes: Change[]) { // order changes by start position const normalized = stableSort(changes, (a, b) => a.range.pos - b.range.pos); - // verify that end position of the change is less than start position of the next change + // verify that change intervals do not overlap, except possibly at end points. for (let i = 0; i < normalized.length - 2; i++) { Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); } @@ -549,7 +549,7 @@ namespace ts.textChanges { }; function assignPositionsToNode(node: Node): Node { - const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray); + const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes const newNode = nodeIsSynthesized(visited) ? visited diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index b1391bd730..6b40c71e20 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -91,6 +91,7 @@ "codefixes/fixes.ts", "codefixes/helpers.ts", "codefixes/importFixes.ts", - "codefixes/unusedIdentifierFixes.ts" + "codefixes/unusedIdentifierFixes.ts", + "codefixes/disableJsDiagnostics.ts" ] } \ No newline at end of file diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 1b32b3bbad..2c48cd79b9 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1380,8 +1380,19 @@ namespace ts { }; } + export function getFirstNonSpaceCharacterPosition(text: string, position: number) { + while (isWhiteSpace(text.charCodeAt(position))) { + position += 1; + } + return position; + } + export function getOpenBrace(constructor: ConstructorDeclaration, sourceFile: SourceFile) { // First token is the open curly, this is where we want to put the 'super' call. return constructor.body.getFirstToken(sourceFile); } + + export function getOpenBraceOfClassLike(declaration: ClassLikeDeclaration, sourceFile: SourceFile) { + return getTokenAtPosition(sourceFile, declaration.members.pos - 1); + } } diff --git a/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt index b762db8a04..7839958ba5 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(1,15): error TS2495: Type 'StringIterator' is not an array type or a string type. -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(11,6): error TS2304: Cannot find name 'Symbol'. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(10,6): error TS2304: Cannot find name 'Symbol'. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(15,15): error TS2495: Type 'StringIterator' is not an array type or a string type. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts (2 errors) ==== - for (var v of new StringIterator) { } - ~~~~~~~~~~~~~~~~~~ -!!! error TS2495: Type 'StringIterator' is not an array type or a string type. // In ES3/5, you cannot for...of over an arbitrary iterable. class StringIterator { @@ -20,4 +17,8 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(11,6 !!! error TS2304: Cannot find name 'Symbol'. return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~~~~~~~~~~~~~~~~~~ +!!! error TS2495: Type 'StringIterator' is not an array type or a string type. \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-ofTypeCheck10.js b/tests/baselines/reference/ES5For-ofTypeCheck10.js index 0fe92e289a..9b197c2d20 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck10.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck10.js @@ -1,5 +1,4 @@ //// [ES5For-ofTypeCheck10.ts] -for (var v of new StringIterator) { } // In ES3/5, you cannot for...of over an arbitrary iterable. class StringIterator { @@ -12,12 +11,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [ES5For-ofTypeCheck10.js] -for (var _i = 0, _a = new StringIterator; _i < _a.length; _i++) { - var v = _a[_i]; -} // In ES3/5, you cannot for...of over an arbitrary iterable. var StringIterator = (function () { function StringIterator() { @@ -33,3 +31,6 @@ var StringIterator = (function () { }; return StringIterator; }()); +for (var _i = 0, _a = new StringIterator; _i < _a.length; _i++) { + var v = _a[_i]; +} diff --git a/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt index 2a464e8826..0da61368ee 100644 --- a/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt +++ b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/internalModules/DeclarationMerging/module.ts(2,19): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(1,8): error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged. +tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(2,31): error TS2449: Class 'A' used before its declaration. ==== tests/cases/conformance/internalModules/DeclarationMerging/module.ts (1 errors) ==== @@ -24,11 +25,13 @@ tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(1,8): error } } -==== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts (1 errors) ==== +==== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts (2 errors) ==== module A { ~ !!! error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged. export var Instance = new A(); + ~ +!!! error TS2449: Class 'A' used before its declaration. } // duplicate identifier diff --git a/tests/baselines/reference/checkJsFiles.errors.txt b/tests/baselines/reference/checkJsFiles.errors.txt new file mode 100644 index 0000000000..41344dc384 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/a.js(3,1): error TS2322: Type '0' is not assignable to type 'string'. + + +==== tests/cases/compiler/a.js (1 errors) ==== + + var x = "string"; + x = 0; + ~ +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/checkJsFiles2.errors.txt b/tests/baselines/reference/checkJsFiles2.errors.txt new file mode 100644 index 0000000000..7fc852fba1 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles2.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type 'string'. + + +==== tests/cases/compiler/a.js (1 errors) ==== + + // @ts-check + var x = "string"; + x = 0; + ~ +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/checkJsFiles3.errors.txt b/tests/baselines/reference/checkJsFiles3.errors.txt new file mode 100644 index 0000000000..7fc852fba1 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles3.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type 'string'. + + +==== tests/cases/compiler/a.js (1 errors) ==== + + // @ts-check + var x = "string"; + x = 0; + ~ +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/checkJsFiles4.errors.txt b/tests/baselines/reference/checkJsFiles4.errors.txt new file mode 100644 index 0000000000..7fc852fba1 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles4.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type 'string'. + + +==== tests/cases/compiler/a.js (1 errors) ==== + + // @ts-check + var x = "string"; + x = 0; + ~ +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/checkJsFiles5.symbols b/tests/baselines/reference/checkJsFiles5.symbols new file mode 100644 index 0000000000..76cc21c46a --- /dev/null +++ b/tests/baselines/reference/checkJsFiles5.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.js === + +// @ts-nocheck +var x = "string"; +>x : Symbol(x, Decl(a.js, 2, 3)) + +x = 0; +>x : Symbol(x, Decl(a.js, 2, 3)) + diff --git a/tests/baselines/reference/checkJsFiles5.types b/tests/baselines/reference/checkJsFiles5.types new file mode 100644 index 0000000000..15704315bb --- /dev/null +++ b/tests/baselines/reference/checkJsFiles5.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/a.js === + +// @ts-nocheck +var x = "string"; +>x : string +>"string" : "string" + +x = 0; +>x = 0 : 0 +>x : string +>0 : 0 + diff --git a/tests/baselines/reference/checkJsFiles6.errors.txt b/tests/baselines/reference/checkJsFiles6.errors.txt new file mode 100644 index 0000000000..89063e5069 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles6.errors.txt @@ -0,0 +1,9 @@ +error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. +error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. + + +!!! error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. +!!! error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +==== tests/cases/compiler/a.js (0 errors) ==== + + var x; \ No newline at end of file diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols new file mode 100644 index 0000000000..eb2afaf436 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols @@ -0,0 +1,38 @@ +=== tests/cases/compiler/a.js === + +var x = 0; +>x : Symbol(x, Decl(a.js, 1, 3)) + + +/// @ts-ignore +x(); +>x : Symbol(x, Decl(a.js, 1, 3)) + +/// @ts-ignore +x(); +>x : Symbol(x, Decl(a.js, 1, 3)) + +/// @ts-ignore +x( +>x : Symbol(x, Decl(a.js, 1, 3)) + + 2, + 3); + + + +// @ts-ignore +// come comment +// some other comment + +// @anohter + +x(); +>x : Symbol(x, Decl(a.js, 1, 3)) + + + +// @ts-ignore: no call signature +x(); +>x : Symbol(x, Decl(a.js, 1, 3)) + diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.types b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types new file mode 100644 index 0000000000..aa24f1f054 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/a.js === + +var x = 0; +>x : number +>0 : 0 + + +/// @ts-ignore +x(); +>x() : any +>x : number + +/// @ts-ignore +x(); +>x() : any +>x : number + +/// @ts-ignore +x( +>x( 2, 3) : any +>x : number + + 2, +>2 : 2 + + 3); +>3 : 3 + + + +// @ts-ignore +// come comment +// some other comment + +// @anohter + +x(); +>x() : any +>x : number + + + +// @ts-ignore: no call signature +x(); +>x() : any +>x : number + diff --git a/tests/baselines/reference/circularImportAlias.errors.txt b/tests/baselines/reference/circularImportAlias.errors.txt index 82c9205ae5..13ff1d8c7c 100644 --- a/tests/baselines/reference/circularImportAlias.errors.txt +++ b/tests/baselines/reference/circularImportAlias.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts(5,28): error TS2690: A class must be declared after its base class. +tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts(5,30): error TS2449: Class 'C' used before its declaration. ==== tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts (1 errors) ==== @@ -7,8 +7,8 @@ tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.t module B { export import a = A; export class D extends a.C { - ~~~ -!!! error TS2690: A class must be declared after its base class. + ~ +!!! error TS2449: Class 'C' used before its declaration. id: number; } } diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt index bf4cd851fb..15b63a6d3e 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -3,13 +3,14 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst Cannot assign an abstract constructor type to a non-abstract constructor type. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(23,15): error TS2449: Class 'C' used before its declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be abstract or non-abstract. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (8 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (9 errors) ==== class A { // ... } @@ -42,6 +43,8 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst !!! error TS2511: Cannot create an instance of the abstract class 'B'. var x : any = C; + ~ +!!! error TS2449: Class 'C' used before its declaration. new x; // okay -- undefined behavior at runtime class C extends B { } // error -- not declared abstract diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.js b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.js new file mode 100644 index 0000000000..195cd78f35 --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.js @@ -0,0 +1,15 @@ +//// [classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts] +function f() { + new C2(); // OK +} +class C2 { } + +//// [classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.js] +function f() { + new C2(); // OK +} +var C2 = (function () { + function C2() { + } + return C2; +}()); diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.symbols b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.symbols new file mode 100644 index 0000000000..19e4620b5c --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts === +function f() { +>f : Symbol(f, Decl(classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts, 0, 0)) + + new C2(); // OK +>C2 : Symbol(C2, Decl(classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts, 2, 1)) +} +class C2 { } +>C2 : Symbol(C2, Decl(classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts, 2, 1)) + diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.types b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.types new file mode 100644 index 0000000000..6255006523 --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts === +function f() { +>f : () => void + + new C2(); // OK +>new C2() : C2 +>C2 : typeof C2 +} +class C2 { } +>C2 : C2 + diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.js b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.js new file mode 100644 index 0000000000..b3a3d25a81 --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.js @@ -0,0 +1,9 @@ +//// [classDeclarationCheckUsedBeforeDefinitionInItself.ts] +class C3 { + static intance = new C3(); // ok +} + +//// [classDeclarationCheckUsedBeforeDefinitionInItself.js] +class C3 { +} +C3.intance = new C3(); // ok diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.symbols b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.symbols new file mode 100644 index 0000000000..f0e6f2a5a7 --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts === +class C3 { +>C3 : Symbol(C3, Decl(classDeclarationCheckUsedBeforeDefinitionInItself.ts, 0, 0)) + + static intance = new C3(); // ok +>intance : Symbol(C3.intance, Decl(classDeclarationCheckUsedBeforeDefinitionInItself.ts, 0, 10)) +>C3 : Symbol(C3, Decl(classDeclarationCheckUsedBeforeDefinitionInItself.ts, 0, 0)) +} diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.types b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.types new file mode 100644 index 0000000000..e4f36dda38 --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts === +class C3 { +>C3 : C3 + + static intance = new C3(); // ok +>intance : C3 +>new C3() : C3 +>C3 : typeof C3 +} diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js index c1642125fe..5b9892b9ab 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js @@ -1,16 +1,16 @@ //// [classDoesNotDependOnBaseTypes.ts] -var x: StringTree; -if (typeof x !== "string") { - x[0] = ""; - x[0] = new StringTreeCollection; -} - type StringTree = string | StringTreeCollection; class StringTreeCollectionBase { [n: number]: StringTree; } -class StringTreeCollection extends StringTreeCollectionBase { } +class StringTreeCollection extends StringTreeCollectionBase { } + +var x: StringTree; +if (typeof x !== "string") { + x[0] = ""; + x[0] = new StringTreeCollection; +} //// [classDoesNotDependOnBaseTypes.js] var __extends = (this && this.__extends) || (function () { @@ -23,11 +23,6 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var x; -if (typeof x !== "string") { - x[0] = ""; - x[0] = new StringTreeCollection; -} var StringTreeCollectionBase = (function () { function StringTreeCollectionBase() { } @@ -40,3 +35,8 @@ var StringTreeCollection = (function (_super) { } return StringTreeCollection; }(StringTreeCollectionBase)); +var x; +if (typeof x !== "string") { + x[0] = ""; + x[0] = new StringTreeCollection; +} diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.symbols b/tests/baselines/reference/classDoesNotDependOnBaseTypes.symbols index e45b00f1e8..a7a421ebf5 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.symbols +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.symbols @@ -1,32 +1,31 @@ === tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts === -var x: StringTree; ->x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3)) ->StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 4, 1)) - -if (typeof x !== "string") { ->x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3)) - - x[0] = ""; ->x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3)) - - x[0] = new StringTreeCollection; ->x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3)) ->StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 9, 1)) -} - type StringTree = string | StringTreeCollection; ->StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 4, 1)) ->StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 9, 1)) +>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 0, 0)) +>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 3, 1)) class StringTreeCollectionBase { ->StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 6, 48)) +>StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 0, 48)) [n: number]: StringTree; ->n : Symbol(n, Decl(classDoesNotDependOnBaseTypes.ts, 8, 5)) ->StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 4, 1)) +>n : Symbol(n, Decl(classDoesNotDependOnBaseTypes.ts, 2, 5)) +>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 0, 0)) } class StringTreeCollection extends StringTreeCollectionBase { } ->StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 9, 1)) ->StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 6, 48)) +>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 3, 1)) +>StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 0, 48)) +var x: StringTree; +>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3)) +>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 0, 0)) + +if (typeof x !== "string") { +>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3)) + + x[0] = ""; +>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3)) + + x[0] = new StringTreeCollection; +>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3)) +>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 3, 1)) +} diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types index 54b67dfd6a..16dc984dc8 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types @@ -1,4 +1,20 @@ === tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts === +type StringTree = string | StringTreeCollection; +>StringTree : StringTree +>StringTreeCollection : StringTreeCollection + +class StringTreeCollectionBase { +>StringTreeCollectionBase : StringTreeCollectionBase + + [n: number]: StringTree; +>n : number +>StringTree : StringTree +} + +class StringTreeCollection extends StringTreeCollectionBase { } +>StringTreeCollection : StringTreeCollection +>StringTreeCollectionBase : StringTreeCollectionBase + var x: StringTree; >x : StringTree >StringTree : StringTree @@ -24,20 +40,3 @@ if (typeof x !== "string") { >new StringTreeCollection : StringTreeCollection >StringTreeCollection : typeof StringTreeCollection } - -type StringTree = string | StringTreeCollection; ->StringTree : StringTree ->StringTreeCollection : StringTreeCollection - -class StringTreeCollectionBase { ->StringTreeCollectionBase : StringTreeCollectionBase - - [n: number]: StringTree; ->n : number ->StringTree : StringTree -} - -class StringTreeCollection extends StringTreeCollectionBase { } ->StringTreeCollection : StringTreeCollection ->StringTreeCollectionBase : StringTreeCollectionBase - diff --git a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt index c0f35f0388..8f54ef1805 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt @@ -1,15 +1,19 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(1,17): error TS2449: Class 'E' used before its declaration. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(3,7): error TS2506: 'D' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(5,7): error TS2506: 'E' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(7,7): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(7,21): error TS2449: Class 'E2' used before its declaration. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(9,7): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(11,7): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts (6 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts (8 errors) ==== class C extends E { foo: string; } // error ~ !!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'E' used before its declaration. class D extends C { bar: string; } ~ @@ -22,6 +26,8 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class C2 extends E2 { foo: T; } // error ~~ !!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. + ~~ +!!! error TS2449: Class 'E2' used before its declaration. class D2 extends C2 { bar: T; } ~~ diff --git a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt index 061770f9b7..48c787b54d 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt @@ -1,15 +1,19 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(1,19): error TS2449: Class 'E' used before its declaration. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(4,18): error TS2506: 'D' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(9,18): error TS2506: 'E' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(13,11): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(13,27): error TS2449: Class 'E2' used before its declaration. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(16,22): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(20,22): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts (6 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts (8 errors) ==== class C extends N.E { foo: string; } // error ~ !!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'E' used before its declaration. module M { export class D extends C { bar: string; } @@ -28,6 +32,8 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class C2 extends Q.E2 { foo: T; } // error ~~ !!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. + ~~ +!!! error TS2449: Class 'E2' used before its declaration. module P { export class D2 extends C2 { bar: T; } diff --git a/tests/baselines/reference/classInheritence.errors.txt b/tests/baselines/reference/classInheritence.errors.txt index cd95dedbfc..3bad3caf3d 100644 --- a/tests/baselines/reference/classInheritence.errors.txt +++ b/tests/baselines/reference/classInheritence.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/classInheritence.ts(1,17): error TS2690: A class must be declared after its base class. +tests/cases/compiler/classInheritence.ts(1,17): error TS2449: Class 'A' used before its declaration. tests/cases/compiler/classInheritence.ts(2,7): error TS2506: 'A' is referenced directly or indirectly in its own base expression. ==== tests/cases/compiler/classInheritence.ts (2 errors) ==== class B extends A { } ~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'A' used before its declaration. class A extends A { } ~ !!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classOrder2.errors.txt b/tests/baselines/reference/classOrder2.errors.txt index 7b5547f678..ce6dd9bd50 100644 --- a/tests/baselines/reference/classOrder2.errors.txt +++ b/tests/baselines/reference/classOrder2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/classOrder2.ts(1,17): error TS2690: A class must be declared after its base class. +tests/cases/compiler/classOrder2.ts(1,17): error TS2449: Class 'B' used before its declaration. ==== tests/cases/compiler/classOrder2.ts (1 errors) ==== class A extends B { ~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'B' used before its declaration. foo() { this.bar(); } diff --git a/tests/baselines/reference/classSideInheritance2.errors.txt b/tests/baselines/reference/classSideInheritance2.errors.txt index e286594ec2..7b27ee7c0f 100644 --- a/tests/baselines/reference/classSideInheritance2.errors.txt +++ b/tests/baselines/reference/classSideInheritance2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classSideInheritance2.ts(7,23): error TS2690: A class must be declared after its base class. +tests/cases/compiler/classSideInheritance2.ts(7,23): error TS2449: Class 'TextBase' used before its declaration. ==== tests/cases/compiler/classSideInheritance2.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/classSideInheritance2.ts(7,23): error TS2690: A class must class SubText extends TextBase { ~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'TextBase' used before its declaration. constructor(text: IText, span: TextSpan) { super(); diff --git a/tests/baselines/reference/classWithEmptyTypeParameter.errors.txt b/tests/baselines/reference/classWithEmptyTypeParameter.errors.txt new file mode 100644 index 0000000000..8114bbd7ba --- /dev/null +++ b/tests/baselines/reference/classWithEmptyTypeParameter.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/classWithEmptyTypeParameter.ts(1,8): error TS1098: Type parameter list cannot be empty. + + +==== tests/cases/compiler/classWithEmptyTypeParameter.ts (1 errors) ==== + class C<> { + ~~ +!!! error TS1098: Type parameter list cannot be empty. + } \ No newline at end of file diff --git a/tests/baselines/reference/classWithEmptyTypeParameter.js b/tests/baselines/reference/classWithEmptyTypeParameter.js new file mode 100644 index 0000000000..c25ace495b --- /dev/null +++ b/tests/baselines/reference/classWithEmptyTypeParameter.js @@ -0,0 +1,10 @@ +//// [classWithEmptyTypeParameter.ts] +class C<> { +} + +//// [classWithEmptyTypeParameter.js] +var C = (function () { + function C() { + } + return C; +}()); diff --git a/tests/baselines/reference/complexClassRelationships.errors.txt b/tests/baselines/reference/complexClassRelationships.errors.txt index 33413e496d..c978a36c03 100644 --- a/tests/baselines/reference/complexClassRelationships.errors.txt +++ b/tests/baselines/reference/complexClassRelationships.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/complexClassRelationships.ts(2,23): error TS2690: A class must be declared after its base class. +tests/cases/compiler/complexClassRelationships.ts(2,23): error TS2449: Class 'Base' used before its declaration. ==== tests/cases/compiler/complexClassRelationships.ts (1 errors) ==== // There should be no errors in this file class Derived extends Base { ~~~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'Base' used before its declaration. public static createEmpty(): Derived { var item = new Derived(); return item; diff --git a/tests/baselines/reference/deeplyNestedCheck.js b/tests/baselines/reference/deeplyNestedCheck.js new file mode 100644 index 0000000000..466ae94f12 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedCheck.js @@ -0,0 +1,14 @@ +//// [deeplyNestedCheck.ts] +// Repro from #14794 + +interface DataSnapshot { + child(path: string): DataSnapshot; +} + +interface Snapshot extends DataSnapshot { + child(path: U): Snapshot; +} + + +//// [deeplyNestedCheck.js] +// Repro from #14794 diff --git a/tests/baselines/reference/deeplyNestedCheck.symbols b/tests/baselines/reference/deeplyNestedCheck.symbols new file mode 100644 index 0000000000..a8b5af6088 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedCheck.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/deeplyNestedCheck.ts === +// Repro from #14794 + +interface DataSnapshot { +>DataSnapshot : Symbol(DataSnapshot, Decl(deeplyNestedCheck.ts, 0, 0)) +>X : Symbol(X, Decl(deeplyNestedCheck.ts, 2, 23)) + + child(path: string): DataSnapshot; +>child : Symbol(DataSnapshot.child, Decl(deeplyNestedCheck.ts, 2, 32)) +>path : Symbol(path, Decl(deeplyNestedCheck.ts, 3, 8)) +>DataSnapshot : Symbol(DataSnapshot, Decl(deeplyNestedCheck.ts, 0, 0)) +} + +interface Snapshot extends DataSnapshot { +>Snapshot : Symbol(Snapshot, Decl(deeplyNestedCheck.ts, 4, 1)) +>T : Symbol(T, Decl(deeplyNestedCheck.ts, 6, 19)) +>DataSnapshot : Symbol(DataSnapshot, Decl(deeplyNestedCheck.ts, 0, 0)) + + child(path: U): Snapshot; +>child : Symbol(Snapshot.child, Decl(deeplyNestedCheck.ts, 6, 44)) +>U : Symbol(U, Decl(deeplyNestedCheck.ts, 7, 8)) +>T : Symbol(T, Decl(deeplyNestedCheck.ts, 6, 19)) +>path : Symbol(path, Decl(deeplyNestedCheck.ts, 7, 27)) +>U : Symbol(U, Decl(deeplyNestedCheck.ts, 7, 8)) +>Snapshot : Symbol(Snapshot, Decl(deeplyNestedCheck.ts, 4, 1)) +>T : Symbol(T, Decl(deeplyNestedCheck.ts, 6, 19)) +>U : Symbol(U, Decl(deeplyNestedCheck.ts, 7, 8)) +} + diff --git a/tests/baselines/reference/deeplyNestedCheck.types b/tests/baselines/reference/deeplyNestedCheck.types new file mode 100644 index 0000000000..e500fc75ed --- /dev/null +++ b/tests/baselines/reference/deeplyNestedCheck.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/deeplyNestedCheck.ts === +// Repro from #14794 + +interface DataSnapshot { +>DataSnapshot : DataSnapshot +>X : X + + child(path: string): DataSnapshot; +>child : (path: string) => DataSnapshot<{}> +>path : string +>DataSnapshot : DataSnapshot +} + +interface Snapshot extends DataSnapshot { +>Snapshot : Snapshot +>T : T +>DataSnapshot : DataSnapshot + + child(path: U): Snapshot; +>child : (path: U) => Snapshot +>U : U +>T : T +>path : U +>U : U +>Snapshot : Snapshot +>T : T +>U : U +} + diff --git a/tests/baselines/reference/derivedClasses.errors.txt b/tests/baselines/reference/derivedClasses.errors.txt index fdd38d8c06..ff6946df2c 100644 --- a/tests/baselines/reference/derivedClasses.errors.txt +++ b/tests/baselines/reference/derivedClasses.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/derivedClasses.ts(1,19): error TS2690: A class must be declared after its base class. +tests/cases/compiler/derivedClasses.ts(1,19): error TS2449: Class 'Color' used before its declaration. ==== tests/cases/compiler/derivedClasses.ts (1 errors) ==== class Red extends Color { ~~~~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'Color' used before its declaration. public shade() { var getHue = () => { return this.hue(); }; return getHue() + " red"; diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types index 524f7c9b71..c375fb6f45 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types index c20e0d3501..e4be9f80d4 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types index b5230006f1..1232130a38 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types index 5d57519d14..0e43463990 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types index 2c3063eca5..9ebd2659ef 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types index 5eb09901ac..4e61c90322 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types index ab41ffd9c7..83d65ce524 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator ->async function * () { return 1;} : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> +>async function * () { return 1;} : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types index 424f09cf53..7d736b2327 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator ->async function * () { return 1;} : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> +>async function * () { return 1;} : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types index e4559e3ece..6c40f9cebb 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator ->async function * () { return 1;} : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> +>async function * () { return 1;} : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types index 0e89d9a1ca..59c5bcfa16 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/es2015/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } +>o7 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types index 4c8ae47b6a..3e7ead2f73 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/es5/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } +>o7 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types index 511cd7ec9e..9e5aad8af2 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/esnext/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } +>o7 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt b/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt new file mode 100644 index 0000000000..aea5366389 --- /dev/null +++ b/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/enumUsedBeforeDeclaration.ts(1,18): error TS2450: Enum 'Color' used before its declaration. +tests/cases/compiler/enumUsedBeforeDeclaration.ts(2,24): error TS2450: Enum 'ConstColor' used before its declaration. + + +==== tests/cases/compiler/enumUsedBeforeDeclaration.ts (2 errors) ==== + const v: Color = Color.Green; + ~~~~~ +!!! error TS2450: Enum 'Color' used before its declaration. + const v2: ConstColor = ConstColor.Green; + ~~~~~~~~~~ +!!! error TS2450: Enum 'ConstColor' used before its declaration. + enum Color { Red, Green, Blue } + const enum ConstColor { Red, Green, Blue } + + \ No newline at end of file diff --git a/tests/baselines/reference/enumUsedBeforeDeclaration.js b/tests/baselines/reference/enumUsedBeforeDeclaration.js new file mode 100644 index 0000000000..63fc38471b --- /dev/null +++ b/tests/baselines/reference/enumUsedBeforeDeclaration.js @@ -0,0 +1,17 @@ +//// [enumUsedBeforeDeclaration.ts] +const v: Color = Color.Green; +const v2: ConstColor = ConstColor.Green; +enum Color { Red, Green, Blue } +const enum ConstColor { Red, Green, Blue } + + + +//// [enumUsedBeforeDeclaration.js] +var v = Color.Green; +var v2 = 1 /* Green */; +var Color; +(function (Color) { + Color[Color["Red"] = 0] = "Red"; + Color[Color["Green"] = 1] = "Green"; + Color[Color["Blue"] = 2] = "Blue"; +})(Color || (Color = {})); diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt new file mode 100644 index 0000000000..951e8bbffd --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts(2,21): error TS2449: Class 'C' used before its declaration. + + +==== tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts (1 errors) ==== + + var before: C = new C(); + ~ +!!! error TS2449: Class 'C' used before its declaration. + + export default class C { + method(): C { + return new C(); + } + } + + var after: C = new C(); + + var t: typeof C = C; + + \ No newline at end of file diff --git a/tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt b/tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt new file mode 100644 index 0000000000..e484d4096b --- /dev/null +++ b/tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/exportAssignmentOfGenericType1_0.ts(1,10): error TS2449: Class 'T' used before its declaration. + + +==== tests/cases/compiler/exportAssignmentOfGenericType1_1.ts (0 errors) ==== + /// + import q = require("exportAssignmentOfGenericType1_0"); + + class M extends q { } + var m: M; + var r: string = m.foo; + +==== tests/cases/compiler/exportAssignmentOfGenericType1_0.ts (1 errors) ==== + export = T; + ~ +!!! error TS2449: Class 'T' used before its declaration. + class T { foo: X; } + \ No newline at end of file diff --git a/tests/baselines/reference/exportImport.errors.txt b/tests/baselines/reference/exportImport.errors.txt new file mode 100644 index 0000000000..fb5a41fe1e --- /dev/null +++ b/tests/baselines/reference/exportImport.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/w1.ts(2,1): error TS2449: Class 'Widget1' used before its declaration. +tests/cases/compiler/w1.ts(2,10): error TS2449: Class 'Widget1' used before its declaration. + + +==== tests/cases/compiler/consumer.ts (0 errors) ==== + import e = require('./exporter'); + + export function w(): e.w { // Should be OK + return new e.w(); + } +==== tests/cases/compiler/w1.ts (2 errors) ==== + + export = Widget1 + ~~~~~~~~~~~~~~~~ +!!! error TS2449: Class 'Widget1' used before its declaration. + ~~~~~~~ +!!! error TS2449: Class 'Widget1' used before its declaration. + class Widget1 { name = 'one'; } + +==== tests/cases/compiler/exporter.ts (0 errors) ==== + export import w = require('./w1'); + \ No newline at end of file diff --git a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt index 2678fdf866..64e5c7d3ef 100644 --- a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt +++ b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts(1,23): error TS2690: A class must be declared after its base class. +tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts(1,23): error TS2449: Class 'base' used before its declaration. ==== tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts (1 errors) ==== class derived extends base { } ~~~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'base' used before its declaration. class base { constructor (public n: number) { } } \ No newline at end of file diff --git a/tests/baselines/reference/for-of14.errors.txt b/tests/baselines/reference/for-of14.errors.txt index ab95d04268..d4ec79620d 100644 --- a/tests/baselines/reference/for-of14.errors.txt +++ b/tests/baselines/reference/for-of14.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/es6/for-ofStatements/for-of14.ts(2,11): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. +tests/cases/conformance/es6/for-ofStatements/for-of14.ts(8,11): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. ==== tests/cases/conformance/es6/for-ofStatements/for-of14.ts (1 errors) ==== - var v: string; - for (v of new StringIterator) { } // Should fail because the iterator is not iterable - ~~~~~~~~~~~~~~~~~~ -!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. - class StringIterator { next() { return ""; } - } \ No newline at end of file + } + + var v: string; + for (v of new StringIterator) { } // Should fail because the iterator is not iterable + ~~~~~~~~~~~~~~~~~~ +!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. \ No newline at end of file diff --git a/tests/baselines/reference/for-of14.js b/tests/baselines/reference/for-of14.js index 42832f8e58..ac3af1ff1d 100644 --- a/tests/baselines/reference/for-of14.js +++ b/tests/baselines/reference/for-of14.js @@ -1,18 +1,18 @@ //// [for-of14.ts] -var v: string; -for (v of new StringIterator) { } // Should fail because the iterator is not iterable - class StringIterator { next() { return ""; } -} +} + +var v: string; +for (v of new StringIterator) { } // Should fail because the iterator is not iterable //// [for-of14.js] -var v; -for (v of new StringIterator) { } // Should fail because the iterator is not iterable class StringIterator { next() { return ""; } } +var v; +for (v of new StringIterator) { } // Should fail because the iterator is not iterable diff --git a/tests/baselines/reference/for-of15.errors.txt b/tests/baselines/reference/for-of15.errors.txt index 20a4abe4bd..6d990aa01f 100644 --- a/tests/baselines/reference/for-of15.errors.txt +++ b/tests/baselines/reference/for-of15.errors.txt @@ -1,12 +1,7 @@ -tests/cases/conformance/es6/for-ofStatements/for-of15.ts(2,11): error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. +tests/cases/conformance/es6/for-ofStatements/for-of15.ts(11,11): error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. ==== tests/cases/conformance/es6/for-ofStatements/for-of15.ts (1 errors) ==== - var v: string; - for (v of new StringIterator) { } // Should fail - ~~~~~~~~~~~~~~~~~~ -!!! error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. - class StringIterator { next() { return ""; @@ -14,4 +9,9 @@ tests/cases/conformance/es6/for-ofStatements/for-of15.ts(2,11): error TS2490: Th [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var v: string; + for (v of new StringIterator) { } // Should fail + ~~~~~~~~~~~~~~~~~~ +!!! error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. \ No newline at end of file diff --git a/tests/baselines/reference/for-of15.js b/tests/baselines/reference/for-of15.js index 62232745c8..f88c864016 100644 --- a/tests/baselines/reference/for-of15.js +++ b/tests/baselines/reference/for-of15.js @@ -1,7 +1,4 @@ //// [for-of15.ts] -var v: string; -for (v of new StringIterator) { } // Should fail - class StringIterator { next() { return ""; @@ -9,11 +6,12 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +var v: string; +for (v of new StringIterator) { } // Should fail //// [for-of15.js] -var v; -for (v of new StringIterator) { } // Should fail class StringIterator { next() { return ""; @@ -22,3 +20,5 @@ class StringIterator { return this; } } +var v; +for (v of new StringIterator) { } // Should fail diff --git a/tests/baselines/reference/for-of16.errors.txt b/tests/baselines/reference/for-of16.errors.txt index 20e3e87653..7574f98e3d 100644 --- a/tests/baselines/reference/for-of16.errors.txt +++ b/tests/baselines/reference/for-of16.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/es6/for-ofStatements/for-of16.ts(2,11): error TS2489: An iterator must have a 'next()' method. +tests/cases/conformance/es6/for-ofStatements/for-of16.ts(8,11): error TS2489: An iterator must have a 'next()' method. ==== tests/cases/conformance/es6/for-ofStatements/for-of16.ts (1 errors) ==== - var v: string; - for (v of new StringIterator) { } // Should fail - ~~~~~~~~~~~~~~~~~~ -!!! error TS2489: An iterator must have a 'next()' method. - class StringIterator { [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var v: string; + for (v of new StringIterator) { } // Should fail + ~~~~~~~~~~~~~~~~~~ +!!! error TS2489: An iterator must have a 'next()' method. \ No newline at end of file diff --git a/tests/baselines/reference/for-of16.js b/tests/baselines/reference/for-of16.js index 974be239fd..2219e15a6f 100644 --- a/tests/baselines/reference/for-of16.js +++ b/tests/baselines/reference/for-of16.js @@ -1,18 +1,18 @@ //// [for-of16.ts] -var v: string; -for (v of new StringIterator) { } // Should fail - class StringIterator { [Symbol.iterator]() { return this; } -} +} + +var v: string; +for (v of new StringIterator) { } // Should fail //// [for-of16.js] -var v; -for (v of new StringIterator) { } // Should fail class StringIterator { [Symbol.iterator]() { return this; } } +var v; +for (v of new StringIterator) { } // Should fail diff --git a/tests/baselines/reference/for-of17.errors.txt b/tests/baselines/reference/for-of17.errors.txt index dfdeb8db00..5a77815369 100644 --- a/tests/baselines/reference/for-of17.errors.txt +++ b/tests/baselines/reference/for-of17.errors.txt @@ -1,12 +1,7 @@ -tests/cases/conformance/es6/for-ofStatements/for-of17.ts(2,6): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/es6/for-ofStatements/for-of17.ts(14,6): error TS2322: Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/es6/for-ofStatements/for-of17.ts (1 errors) ==== - var v: string; - for (v of new NumberIterator) { } // Should succeed - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. - class NumberIterator { next() { return { @@ -17,4 +12,9 @@ tests/cases/conformance/es6/for-ofStatements/for-of17.ts(2,6): error TS2322: Typ [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var v: string; + for (v of new NumberIterator) { } // Should succeed + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of17.js b/tests/baselines/reference/for-of17.js index a392764700..2cd6bbe0d2 100644 --- a/tests/baselines/reference/for-of17.js +++ b/tests/baselines/reference/for-of17.js @@ -1,7 +1,4 @@ //// [for-of17.ts] -var v: string; -for (v of new NumberIterator) { } // Should succeed - class NumberIterator { next() { return { @@ -12,11 +9,12 @@ class NumberIterator { [Symbol.iterator]() { return this; } -} +} + +var v: string; +for (v of new NumberIterator) { } // Should succeed //// [for-of17.js] -var v; -for (v of new NumberIterator) { } // Should succeed class NumberIterator { next() { return { @@ -28,3 +26,5 @@ class NumberIterator { return this; } } +var v; +for (v of new NumberIterator) { } // Should succeed diff --git a/tests/baselines/reference/for-of18.js b/tests/baselines/reference/for-of18.js index c31e6b6e8c..fb7a684098 100644 --- a/tests/baselines/reference/for-of18.js +++ b/tests/baselines/reference/for-of18.js @@ -1,7 +1,4 @@ //// [for-of18.ts] -var v: string; -for (v of new StringIterator) { } // Should succeed - class StringIterator { next() { return { @@ -12,11 +9,12 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +var v: string; +for (v of new StringIterator) { } // Should succeed //// [for-of18.js] -var v; -for (v of new StringIterator) { } // Should succeed class StringIterator { next() { return { @@ -28,3 +26,5 @@ class StringIterator { return this; } } +var v; +for (v of new StringIterator) { } // Should succeed diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index b9d3266271..8f552c2757 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -1,23 +1,16 @@ === tests/cases/conformance/es6/for-ofStatements/for-of18.ts === -var v: string; ->v : Symbol(v, Decl(for-of18.ts, 0, 3)) - -for (v of new StringIterator) { } // Should succeed ->v : Symbol(v, Decl(for-of18.ts, 0, 3)) ->StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) +>StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of18.ts, 3, 22)) +>next : Symbol(StringIterator.next, Decl(for-of18.ts, 0, 22)) return { value: "", ->value : Symbol(value, Decl(for-of18.ts, 5, 16)) +>value : Symbol(value, Decl(for-of18.ts, 2, 16)) done: false ->done : Symbol(done, Decl(for-of18.ts, 6, 22)) +>done : Symbol(done, Decl(for-of18.ts, 3, 22)) }; } @@ -27,6 +20,14 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) +>this : Symbol(StringIterator, Decl(for-of18.ts, 0, 0)) } } + +var v: string; +>v : Symbol(v, Decl(for-of18.ts, 12, 3)) + +for (v of new StringIterator) { } // Should succeed +>v : Symbol(v, Decl(for-of18.ts, 12, 3)) +>StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of18.types b/tests/baselines/reference/for-of18.types index 86978b62cc..8b70c44625 100644 --- a/tests/baselines/reference/for-of18.types +++ b/tests/baselines/reference/for-of18.types @@ -1,12 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of18.ts === -var v: string; ->v : string - -for (v of new StringIterator) { } // Should succeed ->v : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -35,3 +27,12 @@ class StringIterator { >this : this } } + +var v: string; +>v : string + +for (v of new StringIterator) { } // Should succeed +>v : string +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of19.js b/tests/baselines/reference/for-of19.js index d0f95caa1e..c0000d8d10 100644 --- a/tests/baselines/reference/for-of19.js +++ b/tests/baselines/reference/for-of19.js @@ -1,8 +1,4 @@ //// [for-of19.ts] -for (var v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,12 +10,13 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (var v of new FooIterator) { + v; } //// [for-of19.js] -for (var v of new FooIterator) { - v; -} class Foo { } class FooIterator { @@ -33,3 +30,6 @@ class FooIterator { return this; } } +for (var v of new FooIterator) { + v; +} diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index e1a129aa32..f36dd74f9b 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -1,28 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of19.ts === -for (var v of new FooIterator) { ->v : Symbol(v, Decl(for-of19.ts, 0, 8)) ->FooIterator : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) - - v; ->v : Symbol(v, Decl(for-of19.ts, 0, 8)) -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of19.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(for-of19.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of19.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of19.ts, 5, 19)) +>next : Symbol(FooIterator.next, Decl(for-of19.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of19.ts, 7, 16)) ->Foo : Symbol(Foo, Decl(for-of19.ts, 2, 1)) +>value : Symbol(value, Decl(for-of19.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of19.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of19.ts, 8, 27)) +>done : Symbol(done, Decl(for-of19.ts, 4, 27)) }; } @@ -32,6 +24,14 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) +>this : Symbol(FooIterator, Decl(for-of19.ts, 0, 13)) } } + +for (var v of new FooIterator) { +>v : Symbol(v, Decl(for-of19.ts, 13, 8)) +>FooIterator : Symbol(FooIterator, Decl(for-of19.ts, 0, 13)) + + v; +>v : Symbol(v, Decl(for-of19.ts, 13, 8)) +} diff --git a/tests/baselines/reference/for-of19.types b/tests/baselines/reference/for-of19.types index a2882ccf1a..a62b2d64c8 100644 --- a/tests/baselines/reference/for-of19.types +++ b/tests/baselines/reference/for-of19.types @@ -1,13 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of19.ts === -for (var v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - - v; ->v : Foo -} - class Foo { } >Foo : Foo @@ -40,3 +31,12 @@ class FooIterator { >this : this } } + +for (var v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + v; +>v : Foo +} diff --git a/tests/baselines/reference/for-of20.js b/tests/baselines/reference/for-of20.js index c098abd2f7..97259778d2 100644 --- a/tests/baselines/reference/for-of20.js +++ b/tests/baselines/reference/for-of20.js @@ -1,8 +1,4 @@ //// [for-of20.ts] -for (let v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,12 +10,13 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (let v of new FooIterator) { + v; } //// [for-of20.js] -for (let v of new FooIterator) { - v; -} class Foo { } class FooIterator { @@ -33,3 +30,6 @@ class FooIterator { return this; } } +for (let v of new FooIterator) { + v; +} diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 20b444e6bc..5fff9fd787 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -1,28 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of20.ts === -for (let v of new FooIterator) { ->v : Symbol(v, Decl(for-of20.ts, 0, 8)) ->FooIterator : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) - - v; ->v : Symbol(v, Decl(for-of20.ts, 0, 8)) -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of20.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(for-of20.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of20.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of20.ts, 5, 19)) +>next : Symbol(FooIterator.next, Decl(for-of20.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of20.ts, 7, 16)) ->Foo : Symbol(Foo, Decl(for-of20.ts, 2, 1)) +>value : Symbol(value, Decl(for-of20.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of20.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of20.ts, 8, 27)) +>done : Symbol(done, Decl(for-of20.ts, 4, 27)) }; } @@ -32,6 +24,14 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) +>this : Symbol(FooIterator, Decl(for-of20.ts, 0, 13)) } } + +for (let v of new FooIterator) { +>v : Symbol(v, Decl(for-of20.ts, 13, 8)) +>FooIterator : Symbol(FooIterator, Decl(for-of20.ts, 0, 13)) + + v; +>v : Symbol(v, Decl(for-of20.ts, 13, 8)) +} diff --git a/tests/baselines/reference/for-of20.types b/tests/baselines/reference/for-of20.types index 9274c7f4b9..e620b60310 100644 --- a/tests/baselines/reference/for-of20.types +++ b/tests/baselines/reference/for-of20.types @@ -1,13 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of20.ts === -for (let v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - - v; ->v : Foo -} - class Foo { } >Foo : Foo @@ -40,3 +31,12 @@ class FooIterator { >this : this } } + +for (let v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + v; +>v : Foo +} diff --git a/tests/baselines/reference/for-of21.js b/tests/baselines/reference/for-of21.js index 27da28e3b4..66791de89b 100644 --- a/tests/baselines/reference/for-of21.js +++ b/tests/baselines/reference/for-of21.js @@ -1,8 +1,4 @@ //// [for-of21.ts] -for (const v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,12 +10,13 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (const v of new FooIterator) { + v; } //// [for-of21.js] -for (const v of new FooIterator) { - v; -} class Foo { } class FooIterator { @@ -33,3 +30,6 @@ class FooIterator { return this; } } +for (const v of new FooIterator) { + v; +} diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index 71403edfc9..0068c9ef4a 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -1,28 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of21.ts === -for (const v of new FooIterator) { ->v : Symbol(v, Decl(for-of21.ts, 0, 10)) ->FooIterator : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) - - v; ->v : Symbol(v, Decl(for-of21.ts, 0, 10)) -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of21.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(for-of21.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of21.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of21.ts, 5, 19)) +>next : Symbol(FooIterator.next, Decl(for-of21.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of21.ts, 7, 16)) ->Foo : Symbol(Foo, Decl(for-of21.ts, 2, 1)) +>value : Symbol(value, Decl(for-of21.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of21.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of21.ts, 8, 27)) +>done : Symbol(done, Decl(for-of21.ts, 4, 27)) }; } @@ -32,6 +24,14 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) +>this : Symbol(FooIterator, Decl(for-of21.ts, 0, 13)) } } + +for (const v of new FooIterator) { +>v : Symbol(v, Decl(for-of21.ts, 13, 10)) +>FooIterator : Symbol(FooIterator, Decl(for-of21.ts, 0, 13)) + + v; +>v : Symbol(v, Decl(for-of21.ts, 13, 10)) +} diff --git a/tests/baselines/reference/for-of21.types b/tests/baselines/reference/for-of21.types index 1366cb1a42..59c66b2a41 100644 --- a/tests/baselines/reference/for-of21.types +++ b/tests/baselines/reference/for-of21.types @@ -1,13 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of21.ts === -for (const v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - - v; ->v : Foo -} - class Foo { } >Foo : Foo @@ -40,3 +31,12 @@ class FooIterator { >this : this } } + +for (const v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + v; +>v : Foo +} diff --git a/tests/baselines/reference/for-of22.js b/tests/baselines/reference/for-of22.js index 886e8dba7c..767ed1cc15 100644 --- a/tests/baselines/reference/for-of22.js +++ b/tests/baselines/reference/for-of22.js @@ -1,9 +1,4 @@ //// [for-of22.ts] -v; -for (var v of new FooIterator) { - -} - class Foo { } class FooIterator { next() { @@ -15,12 +10,14 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +v; +for (var v of new FooIterator) { + } //// [for-of22.js] -v; -for (var v of new FooIterator) { -} class Foo { } class FooIterator { @@ -34,3 +31,6 @@ class FooIterator { return this; } } +v; +for (var v of new FooIterator) { +} diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index 36a522759c..929cae4ed7 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -1,29 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of22.ts === -v; ->v : Symbol(v, Decl(for-of22.ts, 1, 8)) - -for (var v of new FooIterator) { ->v : Symbol(v, Decl(for-of22.ts, 1, 8)) ->FooIterator : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) - -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of22.ts, 3, 1)) +>Foo : Symbol(Foo, Decl(for-of22.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of22.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of22.ts, 6, 19)) +>next : Symbol(FooIterator.next, Decl(for-of22.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of22.ts, 8, 16)) ->Foo : Symbol(Foo, Decl(for-of22.ts, 3, 1)) +>value : Symbol(value, Decl(for-of22.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of22.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of22.ts, 9, 27)) +>done : Symbol(done, Decl(for-of22.ts, 4, 27)) }; } @@ -33,6 +24,15 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) +>this : Symbol(FooIterator, Decl(for-of22.ts, 0, 13)) } } + +v; +>v : Symbol(v, Decl(for-of22.ts, 14, 8)) + +for (var v of new FooIterator) { +>v : Symbol(v, Decl(for-of22.ts, 14, 8)) +>FooIterator : Symbol(FooIterator, Decl(for-of22.ts, 0, 13)) + +} diff --git a/tests/baselines/reference/for-of22.types b/tests/baselines/reference/for-of22.types index 80cd42b2b3..e1449875da 100644 --- a/tests/baselines/reference/for-of22.types +++ b/tests/baselines/reference/for-of22.types @@ -1,14 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of22.ts === -v; ->v : Foo - -for (var v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - -} - class Foo { } >Foo : Foo @@ -41,3 +31,13 @@ class FooIterator { >this : this } } + +v; +>v : Foo + +for (var v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + +} diff --git a/tests/baselines/reference/for-of23.js b/tests/baselines/reference/for-of23.js index f5649128c1..9ad03c0109 100644 --- a/tests/baselines/reference/for-of23.js +++ b/tests/baselines/reference/for-of23.js @@ -1,8 +1,4 @@ //// [for-of23.ts] -for (const v of new FooIterator) { - const v = 0; // new scope -} - class Foo { } class FooIterator { next() { @@ -14,12 +10,13 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (const v of new FooIterator) { + const v = 0; // new scope } //// [for-of23.js] -for (const v of new FooIterator) { - const v = 0; // new scope -} class Foo { } class FooIterator { @@ -33,3 +30,6 @@ class FooIterator { return this; } } +for (const v of new FooIterator) { + const v = 0; // new scope +} diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 3be07f4fd4..7a57e38baf 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -1,28 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of23.ts === -for (const v of new FooIterator) { ->v : Symbol(v, Decl(for-of23.ts, 0, 10)) ->FooIterator : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) - - const v = 0; // new scope ->v : Symbol(v, Decl(for-of23.ts, 1, 9)) -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of23.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(for-of23.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of23.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of23.ts, 5, 19)) +>next : Symbol(FooIterator.next, Decl(for-of23.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of23.ts, 7, 16)) ->Foo : Symbol(Foo, Decl(for-of23.ts, 2, 1)) +>value : Symbol(value, Decl(for-of23.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of23.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of23.ts, 8, 27)) +>done : Symbol(done, Decl(for-of23.ts, 4, 27)) }; } @@ -32,6 +24,14 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) +>this : Symbol(FooIterator, Decl(for-of23.ts, 0, 13)) } } + +for (const v of new FooIterator) { +>v : Symbol(v, Decl(for-of23.ts, 13, 10)) +>FooIterator : Symbol(FooIterator, Decl(for-of23.ts, 0, 13)) + + const v = 0; // new scope +>v : Symbol(v, Decl(for-of23.ts, 14, 9)) +} diff --git a/tests/baselines/reference/for-of23.types b/tests/baselines/reference/for-of23.types index ed74156f51..427eb57f5a 100644 --- a/tests/baselines/reference/for-of23.types +++ b/tests/baselines/reference/for-of23.types @@ -1,14 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of23.ts === -for (const v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - - const v = 0; // new scope ->v : 0 ->0 : 0 -} - class Foo { } >Foo : Foo @@ -41,3 +31,13 @@ class FooIterator { >this : this } } + +for (const v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + const v = 0; // new scope +>v : 0 +>0 : 0 +} diff --git a/tests/baselines/reference/for-of25.js b/tests/baselines/reference/for-of25.js index 5715f6e8a3..032efa52ae 100644 --- a/tests/baselines/reference/for-of25.js +++ b/tests/baselines/reference/for-of25.js @@ -1,18 +1,18 @@ //// [for-of25.ts] -var x: any; -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]() { return x; } -} +} + +var x: any; +for (var v of new StringIterator) { } //// [for-of25.js] -var x; -for (var v of new StringIterator) { } class StringIterator { [Symbol.iterator]() { return x; } } +var x; +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index e21348ba56..e9304e517b 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -1,13 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of25.ts === -var x: any; ->x : Symbol(x, Decl(for-of25.ts, 0, 3)) - -for (var v of new StringIterator) { } ->v : Symbol(v, Decl(for-of25.ts, 1, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) +>StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 0, 0)) [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) @@ -15,6 +8,14 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return x; ->x : Symbol(x, Decl(for-of25.ts, 0, 3)) +>x : Symbol(x, Decl(for-of25.ts, 6, 3)) } } + +var x: any; +>x : Symbol(x, Decl(for-of25.ts, 6, 3)) + +for (var v of new StringIterator) { } +>v : Symbol(v, Decl(for-of25.ts, 7, 8)) +>StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of25.types b/tests/baselines/reference/for-of25.types index c4d6b32aeb..7a11b7acf6 100644 --- a/tests/baselines/reference/for-of25.types +++ b/tests/baselines/reference/for-of25.types @@ -1,12 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of25.ts === -var x: any; ->x : any - -for (var v of new StringIterator) { } ->v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -19,3 +11,12 @@ class StringIterator { >x : any } } + +var x: any; +>x : any + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of26.js b/tests/baselines/reference/for-of26.js index 33319f50ef..ab9c4fdca9 100644 --- a/tests/baselines/reference/for-of26.js +++ b/tests/baselines/reference/for-of26.js @@ -1,7 +1,4 @@ //// [for-of26.ts] -var x: any; -for (var v of new StringIterator) { } - class StringIterator { next() { return x; @@ -9,11 +6,12 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +var x: any; +for (var v of new StringIterator) { } //// [for-of26.js] -var x; -for (var v of new StringIterator) { } class StringIterator { next() { return x; @@ -22,3 +20,5 @@ class StringIterator { return this; } } +var x; +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 947240bf8e..2047389825 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -1,19 +1,12 @@ === tests/cases/conformance/es6/for-ofStatements/for-of26.ts === -var x: any; ->x : Symbol(x, Decl(for-of26.ts, 0, 3)) - -for (var v of new StringIterator) { } ->v : Symbol(v, Decl(for-of26.ts, 1, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) +>StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of26.ts, 3, 22)) +>next : Symbol(StringIterator.next, Decl(for-of26.ts, 0, 22)) return x; ->x : Symbol(x, Decl(for-of26.ts, 0, 3)) +>x : Symbol(x, Decl(for-of26.ts, 9, 3)) } [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) @@ -21,6 +14,14 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) +>this : Symbol(StringIterator, Decl(for-of26.ts, 0, 0)) } } + +var x: any; +>x : Symbol(x, Decl(for-of26.ts, 9, 3)) + +for (var v of new StringIterator) { } +>v : Symbol(v, Decl(for-of26.ts, 10, 8)) +>StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of26.types b/tests/baselines/reference/for-of26.types index fe930e2e57..b0cfd89174 100644 --- a/tests/baselines/reference/for-of26.types +++ b/tests/baselines/reference/for-of26.types @@ -1,12 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of26.ts === -var x: any; ->x : any - -for (var v of new StringIterator) { } ->v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -25,3 +17,12 @@ class StringIterator { >this : this } } + +var x: any; +>x : any + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of27.js b/tests/baselines/reference/for-of27.js index 1ac3a1dfc4..6adc66e241 100644 --- a/tests/baselines/reference/for-of27.js +++ b/tests/baselines/reference/for-of27.js @@ -1,11 +1,11 @@ //// [for-of27.ts] -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]: any; -} +} + +for (var v of new StringIterator) { } //// [for-of27.js] -for (var v of new StringIterator) { } class StringIterator { } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index b2b733ab13..4799a13835 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -1,13 +1,14 @@ === tests/cases/conformance/es6/for-ofStatements/for-of27.ts === -for (var v of new StringIterator) { } ->v : Symbol(v, Decl(for-of27.ts, 0, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) +>StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 0)) [Symbol.iterator]: any; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) } + +for (var v of new StringIterator) { } +>v : Symbol(v, Decl(for-of27.ts, 4, 8)) +>StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of27.types b/tests/baselines/reference/for-of27.types index 8e9130ce27..f6115ccf8c 100644 --- a/tests/baselines/reference/for-of27.types +++ b/tests/baselines/reference/for-of27.types @@ -1,9 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of27.ts === -for (var v of new StringIterator) { } ->v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -12,3 +7,9 @@ class StringIterator { >Symbol : SymbolConstructor >iterator : symbol } + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of28.js b/tests/baselines/reference/for-of28.js index 78e8677481..e06e2fc6ab 100644 --- a/tests/baselines/reference/for-of28.js +++ b/tests/baselines/reference/for-of28.js @@ -1,17 +1,17 @@ //// [for-of28.ts] -for (var v of new StringIterator) { } - class StringIterator { next: any; [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of28.js] -for (var v of new StringIterator) { } class StringIterator { [Symbol.iterator]() { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index 52ed4fd745..ad5ea53a80 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -1,13 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of28.ts === -for (var v of new StringIterator) { } ->v : Symbol(v, Decl(for-of28.ts, 0, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) +>StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 0)) next: any; ->next : Symbol(StringIterator.next, Decl(for-of28.ts, 2, 22)) +>next : Symbol(StringIterator.next, Decl(for-of28.ts, 0, 22)) [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) @@ -15,6 +11,11 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) +>this : Symbol(StringIterator, Decl(for-of28.ts, 0, 0)) } } + +for (var v of new StringIterator) { } +>v : Symbol(v, Decl(for-of28.ts, 7, 8)) +>StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of28.types b/tests/baselines/reference/for-of28.types index 882d2df618..a454a0c448 100644 --- a/tests/baselines/reference/for-of28.types +++ b/tests/baselines/reference/for-of28.types @@ -1,9 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of28.ts === -for (var v of new StringIterator) { } ->v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -19,3 +14,9 @@ class StringIterator { >this : this } } + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of30.errors.txt b/tests/baselines/reference/for-of30.errors.txt index 6434b5294d..b0091c90b5 100644 --- a/tests/baselines/reference/for-of30.errors.txt +++ b/tests/baselines/reference/for-of30.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/for-ofStatements/for-of30.ts(1,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +tests/cases/conformance/es6/for-ofStatements/for-of30.ts(16,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. Types of property '[Symbol.iterator]' are incompatible. Type '() => StringIterator' is not assignable to type '() => Iterator'. Type 'StringIterator' is not assignable to type 'Iterator'. @@ -7,15 +7,6 @@ tests/cases/conformance/es6/for-ofStatements/for-of30.ts(1,15): error TS2322: Ty ==== tests/cases/conformance/es6/for-ofStatements/for-of30.ts (1 errors) ==== - for (var v of new StringIterator) { } - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. -!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. -!!! error TS2322: Types of property 'return' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type '(value?: any) => IteratorResult'. - class StringIterator { next() { return { @@ -29,4 +20,13 @@ tests/cases/conformance/es6/for-ofStatements/for-of30.ts(1,15): error TS2322: Ty [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. +!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Types of property 'return' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type '(value?: any) => IteratorResult'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of30.js b/tests/baselines/reference/for-of30.js index 37316774c9..935944db64 100644 --- a/tests/baselines/reference/for-of30.js +++ b/tests/baselines/reference/for-of30.js @@ -1,6 +1,4 @@ //// [for-of30.ts] -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -14,10 +12,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of30.js] -for (var v of new StringIterator) { } class StringIterator { constructor() { this.return = 0; @@ -32,3 +31,4 @@ class StringIterator { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of31.errors.txt b/tests/baselines/reference/for-of31.errors.txt index 6d5f6e816b..bf38e0f500 100644 --- a/tests/baselines/reference/for-of31.errors.txt +++ b/tests/baselines/reference/for-of31.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +tests/cases/conformance/es6/for-ofStatements/for-of31.ts(14,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. Types of property '[Symbol.iterator]' are incompatible. Type '() => StringIterator' is not assignable to type '() => Iterator'. Type 'StringIterator' is not assignable to type 'Iterator'. @@ -9,17 +9,6 @@ tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Ty ==== tests/cases/conformance/es6/for-ofStatements/for-of31.ts (1 errors) ==== - for (var v of new StringIterator) { } - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. -!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. -!!! error TS2322: Type '{ value: string; }' is not assignable to type 'IteratorResult'. -!!! error TS2322: Property 'done' is missing in type '{ value: string; }'. - class StringIterator { next() { return { @@ -31,4 +20,15 @@ tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Ty [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. +!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type '{ value: string; }' is not assignable to type 'IteratorResult'. +!!! error TS2322: Property 'done' is missing in type '{ value: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of31.js b/tests/baselines/reference/for-of31.js index a92e827b91..84e24bed5a 100644 --- a/tests/baselines/reference/for-of31.js +++ b/tests/baselines/reference/for-of31.js @@ -1,6 +1,4 @@ //// [for-of31.ts] -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -12,10 +10,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of31.js] -for (var v of new StringIterator) { } class StringIterator { next() { return { @@ -27,3 +26,4 @@ class StringIterator { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of33.errors.txt b/tests/baselines/reference/for-of33.errors.txt index ff1feacd7b..eba30ce9bf 100644 --- a/tests/baselines/reference/for-of33.errors.txt +++ b/tests/baselines/reference/for-of33.errors.txt @@ -1,16 +1,16 @@ -tests/cases/conformance/es6/for-ofStatements/for-of33.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/es6/for-ofStatements/for-of33.ts(4,5): error TS7023: '[Symbol.iterator]' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +tests/cases/conformance/es6/for-ofStatements/for-of33.ts(2,5): error TS7023: '[Symbol.iterator]' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +tests/cases/conformance/es6/for-ofStatements/for-of33.ts(7,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. ==== tests/cases/conformance/es6/for-ofStatements/for-of33.ts (2 errors) ==== - for (var v of new StringIterator) { } - ~ -!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - class StringIterator { [Symbol.iterator]() { ~~~~~~~~~~~~~~~~~ !!! error TS7023: '[Symbol.iterator]' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. return v; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of33.js b/tests/baselines/reference/for-of33.js index b63aeedf77..e77d3cf5de 100644 --- a/tests/baselines/reference/for-of33.js +++ b/tests/baselines/reference/for-of33.js @@ -1,16 +1,16 @@ //// [for-of33.ts] -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]() { return v; } -} +} + +for (var v of new StringIterator) { } //// [for-of33.js] -for (var v of new StringIterator) { } class StringIterator { [Symbol.iterator]() { return v; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of34.errors.txt b/tests/baselines/reference/for-of34.errors.txt index c378a8f5bb..2d53ecb0a2 100644 --- a/tests/baselines/reference/for-of34.errors.txt +++ b/tests/baselines/reference/for-of34.errors.txt @@ -1,12 +1,8 @@ -tests/cases/conformance/es6/for-ofStatements/for-of34.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/es6/for-ofStatements/for-of34.ts(4,5): error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +tests/cases/conformance/es6/for-ofStatements/for-of34.ts(2,5): error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +tests/cases/conformance/es6/for-ofStatements/for-of34.ts(11,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. ==== tests/cases/conformance/es6/for-ofStatements/for-of34.ts (2 errors) ==== - for (var v of new StringIterator) { } - ~ -!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - class StringIterator { next() { ~~~~ @@ -17,4 +13,8 @@ tests/cases/conformance/es6/for-ofStatements/for-of34.ts(4,5): error TS7023: 'ne [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of34.js b/tests/baselines/reference/for-of34.js index f61f04ea95..2d9af61d1a 100644 --- a/tests/baselines/reference/for-of34.js +++ b/tests/baselines/reference/for-of34.js @@ -1,6 +1,4 @@ //// [for-of34.ts] -for (var v of new StringIterator) { } - class StringIterator { next() { return v; @@ -9,10 +7,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of34.js] -for (var v of new StringIterator) { } class StringIterator { next() { return v; @@ -21,3 +20,4 @@ class StringIterator { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of35.errors.txt b/tests/baselines/reference/for-of35.errors.txt index 58fb5056fd..6f14a24fb9 100644 --- a/tests/baselines/reference/for-of35.errors.txt +++ b/tests/baselines/reference/for-of35.errors.txt @@ -1,12 +1,8 @@ -tests/cases/conformance/es6/for-ofStatements/for-of35.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/es6/for-ofStatements/for-of35.ts(4,5): error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +tests/cases/conformance/es6/for-ofStatements/for-of35.ts(2,5): error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +tests/cases/conformance/es6/for-ofStatements/for-of35.ts(14,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. ==== tests/cases/conformance/es6/for-ofStatements/for-of35.ts (2 errors) ==== - for (var v of new StringIterator) { } - ~ -!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - class StringIterator { next() { ~~~~ @@ -20,4 +16,8 @@ tests/cases/conformance/es6/for-ofStatements/for-of35.ts(4,5): error TS7023: 'ne [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of35.js b/tests/baselines/reference/for-of35.js index c7d7c5890d..a73f873d7c 100644 --- a/tests/baselines/reference/for-of35.js +++ b/tests/baselines/reference/for-of35.js @@ -1,6 +1,4 @@ //// [for-of35.ts] -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -12,10 +10,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of35.js] -for (var v of new StringIterator) { } class StringIterator { next() { return { @@ -27,3 +26,4 @@ class StringIterator { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/generatorTypeCheck14.types b/tests/baselines/reference/generatorTypeCheck14.types index 48565fe2be..28401e6856 100644 --- a/tests/baselines/reference/generatorTypeCheck14.types +++ b/tests/baselines/reference/generatorTypeCheck14.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator<0 | ""> yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck15.types b/tests/baselines/reference/generatorTypeCheck15.types index eb14208009..3851d8e56a 100644 --- a/tests/baselines/reference/generatorTypeCheck15.types +++ b/tests/baselines/reference/generatorTypeCheck15.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<""> return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck34.types b/tests/baselines/reference/generatorTypeCheck34.types index 2ca1117721..239c5ff149 100644 --- a/tests/baselines/reference/generatorTypeCheck34.types +++ b/tests/baselines/reference/generatorTypeCheck34.types @@ -7,7 +7,7 @@ function* g() { >0 : 0 function* g2() { ->g2 : () => IterableIterator +>g2 : () => IterableIterator<""> return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck62.js b/tests/baselines/reference/generatorTypeCheck62.js new file mode 100644 index 0000000000..3086472221 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck62.js @@ -0,0 +1,63 @@ +//// [generatorTypeCheck62.ts] + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing1: Strategy = strategy("Nothing", function*(state: State) { + return state; +}); + +export const Nothing2: Strategy = strategy("Nothing", function*(state: State) { + yield state; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield ; + return state; +}); + + +//// [generatorTypeCheck62.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function strategy(stratName, gen) { + return function* (state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + }; +} +exports.strategy = strategy; +exports.Nothing1 = strategy("Nothing", function* (state) { + return state; +}); +exports.Nothing2 = strategy("Nothing", function* (state) { + yield state; +}); +exports.Nothing3 = strategy("Nothing", function* (state) { + yield; + return state; +}); diff --git a/tests/baselines/reference/generatorTypeCheck62.symbols b/tests/baselines/reference/generatorTypeCheck62.symbols new file mode 100644 index 0000000000..580ab20884 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck62.symbols @@ -0,0 +1,106 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts === + +export interface StrategicState { +>StrategicState : Symbol(StrategicState, Decl(generatorTypeCheck62.ts, 0, 0)) + + lastStrategyApplied?: string; +>lastStrategyApplied : Symbol(StrategicState.lastStrategyApplied, Decl(generatorTypeCheck62.ts, 1, 33)) +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { +>strategy : Symbol(strategy, Decl(generatorTypeCheck62.ts, 3, 1)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) +>StrategicState : Symbol(StrategicState, Decl(generatorTypeCheck62.ts, 0, 0)) +>stratName : Symbol(stratName, Decl(generatorTypeCheck62.ts, 5, 51)) +>gen : Symbol(gen, Decl(generatorTypeCheck62.ts, 5, 69)) +>a : Symbol(a, Decl(generatorTypeCheck62.ts, 5, 76)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) +>a : Symbol(a, Decl(generatorTypeCheck62.ts, 5, 120)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) + + return function*(state) { +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 6, 21)) + + for (const next of gen(state)) { +>next : Symbol(next, Decl(generatorTypeCheck62.ts, 7, 18)) +>gen : Symbol(gen, Decl(generatorTypeCheck62.ts, 5, 69)) +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 6, 21)) + + if (next) { +>next : Symbol(next, Decl(generatorTypeCheck62.ts, 7, 18)) + + next.lastStrategyApplied = stratName; +>next.lastStrategyApplied : Symbol(StrategicState.lastStrategyApplied, Decl(generatorTypeCheck62.ts, 1, 33)) +>next : Symbol(next, Decl(generatorTypeCheck62.ts, 7, 18)) +>lastStrategyApplied : Symbol(StrategicState.lastStrategyApplied, Decl(generatorTypeCheck62.ts, 1, 33)) +>stratName : Symbol(stratName, Decl(generatorTypeCheck62.ts, 5, 51)) + } + yield next; +>next : Symbol(next, Decl(generatorTypeCheck62.ts, 7, 18)) + } + } +} + +export interface Strategy { +>Strategy : Symbol(Strategy, Decl(generatorTypeCheck62.ts, 14, 1)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 16, 26)) + + (a: T): IterableIterator; +>a : Symbol(a, Decl(generatorTypeCheck62.ts, 17, 5)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 16, 26)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 16, 26)) +} + +export interface State extends StrategicState { +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) +>StrategicState : Symbol(StrategicState, Decl(generatorTypeCheck62.ts, 0, 0)) + + foo: number; +>foo : Symbol(State.foo, Decl(generatorTypeCheck62.ts, 20, 47)) +} + +export const Nothing1: Strategy = strategy("Nothing", function*(state: State) { +>Nothing1 : Symbol(Nothing1, Decl(generatorTypeCheck62.ts, 24, 12)) +>Strategy : Symbol(Strategy, Decl(generatorTypeCheck62.ts, 14, 1)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) +>strategy : Symbol(strategy, Decl(generatorTypeCheck62.ts, 3, 1)) +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 24, 71)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) + + return state; +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 24, 71)) + +}); + +export const Nothing2: Strategy = strategy("Nothing", function*(state: State) { +>Nothing2 : Symbol(Nothing2, Decl(generatorTypeCheck62.ts, 28, 12)) +>Strategy : Symbol(Strategy, Decl(generatorTypeCheck62.ts, 14, 1)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) +>strategy : Symbol(strategy, Decl(generatorTypeCheck62.ts, 3, 1)) +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 28, 71)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) + + yield state; +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 28, 71)) + +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { +>Nothing3 : Symbol(Nothing3, Decl(generatorTypeCheck62.ts, 32, 12)) +>Strategy : Symbol(Strategy, Decl(generatorTypeCheck62.ts, 14, 1)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) +>strategy : Symbol(strategy, Decl(generatorTypeCheck62.ts, 3, 1)) +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 32, 72)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) + + yield ; + return state; +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 32, 72)) + +}); + diff --git a/tests/baselines/reference/generatorTypeCheck62.types b/tests/baselines/reference/generatorTypeCheck62.types new file mode 100644 index 0000000000..289d33dc7d --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck62.types @@ -0,0 +1,122 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts === + +export interface StrategicState { +>StrategicState : StrategicState + + lastStrategyApplied?: string; +>lastStrategyApplied : string +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { +>strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator +>T : T +>StrategicState : StrategicState +>stratName : string +>gen : (a: T) => IterableIterator +>a : T +>T : T +>IterableIterator : IterableIterator +>T : T +>a : T +>T : T +>IterableIterator : IterableIterator +>T : T + + return function*(state) { +>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => IterableIterator +>state : T + + for (const next of gen(state)) { +>next : T +>gen(state) : IterableIterator +>gen : (a: T) => IterableIterator +>state : T + + if (next) { +>next : T + + next.lastStrategyApplied = stratName; +>next.lastStrategyApplied = stratName : string +>next.lastStrategyApplied : string +>next : T +>lastStrategyApplied : string +>stratName : string + } + yield next; +>yield next : any +>next : T + } + } +} + +export interface Strategy { +>Strategy : Strategy +>T : T + + (a: T): IterableIterator; +>a : T +>T : T +>IterableIterator : IterableIterator +>T : T +} + +export interface State extends StrategicState { +>State : State +>StrategicState : StrategicState + + foo: number; +>foo : number +} + +export const Nothing1: Strategy = strategy("Nothing", function*(state: State) { +>Nothing1 : Strategy +>Strategy : Strategy +>State : State +>strategy("Nothing", function*(state: State) { return state;}) : (a: State) => IterableIterator +>strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator +>"Nothing" : "Nothing" +>function*(state: State) { return state;} : (state: State) => IterableIterator +>state : State +>State : State + + return state; +>state : State + +}); + +export const Nothing2: Strategy = strategy("Nothing", function*(state: State) { +>Nothing2 : Strategy +>Strategy : Strategy +>State : State +>strategy("Nothing", function*(state: State) { yield state;}) : (a: State) => IterableIterator +>strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator +>"Nothing" : "Nothing" +>function*(state: State) { yield state;} : (state: State) => IterableIterator +>state : State +>State : State + + yield state; +>yield state : any +>state : State + +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { +>Nothing3 : Strategy +>Strategy : Strategy +>State : State +>strategy("Nothing", function* (state: State) { yield ; return state;}) : (a: State) => IterableIterator +>strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator +>"Nothing" : "Nothing" +>function* (state: State) { yield ; return state;} : (state: State) => IterableIterator +>state : State +>State : State + + yield ; +>yield : any + + return state; +>state : State + +}); + diff --git a/tests/baselines/reference/generatorTypeCheck63.errors.txt b/tests/baselines/reference/generatorTypeCheck63.errors.txt new file mode 100644 index 0000000000..46e722a0dd --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck63.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(25,14): error TS2322: Type '(a: State | 1) => IterableIterator' is not assignable to type 'Strategy'. + Type 'IterableIterator' is not assignable to type 'IterableIterator'. + Type 'State | 1' is not assignable to type 'State'. + Type '1' is not assignable to type 'State'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(30,70): error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(33,42): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. + Type argument candidate 'State' is not a valid type argument because it is not a supertype of candidate '1'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(37,14): error TS2322: Type '(a: State | 1) => IterableIterator' is not assignable to type 'Strategy'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts (4 errors) ==== + + export interface StrategicState { + lastStrategyApplied?: string; + } + + export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } + } + + export interface Strategy { + (a: T): IterableIterator; + } + + export interface State extends StrategicState { + foo: number; + } + + export const Nothing: Strategy = strategy("Nothing", function* (state: State) { + ~~~~~~~ +!!! error TS2322: Type '(a: State | 1) => IterableIterator' is not assignable to type 'Strategy'. +!!! error TS2322: Type 'IterableIterator' is not assignable to type 'IterableIterator'. +!!! error TS2322: Type 'State | 1' is not assignable to type 'State'. +!!! error TS2322: Type '1' is not assignable to type 'State'. + yield 1; + return state; + }); + + export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { + ~ +!!! error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. + }); + + export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { + ~~~~~~~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'State' is not a valid type argument because it is not a supertype of candidate '1'. + return 1; + }); + + export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + ~~~~~~~~ +!!! error TS2322: Type '(a: State | 1) => IterableIterator' is not assignable to type 'Strategy'. + yield state; + return 1; + }); \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck63.js b/tests/baselines/reference/generatorTypeCheck63.js new file mode 100644 index 0000000000..92cf2f867f --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck63.js @@ -0,0 +1,69 @@ +//// [generatorTypeCheck63.ts] + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing: Strategy = strategy("Nothing", function* (state: State) { + yield 1; + return state; +}); + +export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { +}); + +export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { + return 1; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield state; + return 1; +}); + +//// [generatorTypeCheck63.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function strategy(stratName, gen) { + return function* (state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + }; +} +exports.strategy = strategy; +exports.Nothing = strategy("Nothing", function* (state) { + yield 1; + return state; +}); +exports.Nothing1 = strategy("Nothing", function* (state) { +}); +exports.Nothing2 = strategy("Nothing", function* (state) { + return 1; +}); +exports.Nothing3 = strategy("Nothing", function* (state) { + yield state; + return 1; +}); diff --git a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt index 1962576abc..d259a2d2e2 100644 --- a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt +++ b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(1,17): error TS2690: A class must be declared after its base class. -tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(2,20): error TS2690: A class must be declared after its base class. +tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(1,17): error TS2449: Class 'B' used before its declaration. +tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(2,20): error TS2449: Class 'C' used before its declaration. ==== tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts (2 errors) ==== class A extends B { } - ~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~ +!!! error TS2449: Class 'B' used before its declaration. class B extends C { } ~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'C' used before its declaration. class C { constructor(p: string) { } } \ No newline at end of file diff --git a/tests/baselines/reference/genericDefaultsJs.symbols b/tests/baselines/reference/genericDefaultsJs.symbols new file mode 100644 index 0000000000..633e4cc8fe --- /dev/null +++ b/tests/baselines/reference/genericDefaultsJs.symbols @@ -0,0 +1,226 @@ +=== tests/cases/compiler/decls.d.ts === +declare function f0(x?: T): T; +>f0 : Symbol(f0, Decl(decls.d.ts, 0, 0)) +>T : Symbol(T, Decl(decls.d.ts, 0, 20)) +>x : Symbol(x, Decl(decls.d.ts, 0, 23)) +>T : Symbol(T, Decl(decls.d.ts, 0, 20)) +>T : Symbol(T, Decl(decls.d.ts, 0, 20)) + +declare function f1(x?: T): [T, U]; +>f1 : Symbol(f1, Decl(decls.d.ts, 0, 33)) +>T : Symbol(T, Decl(decls.d.ts, 1, 20)) +>U : Symbol(U, Decl(decls.d.ts, 1, 22)) +>x : Symbol(x, Decl(decls.d.ts, 1, 35)) +>T : Symbol(T, Decl(decls.d.ts, 1, 20)) +>T : Symbol(T, Decl(decls.d.ts, 1, 20)) +>U : Symbol(U, Decl(decls.d.ts, 1, 22)) + +declare class C0 { +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) +>T : Symbol(T, Decl(decls.d.ts, 2, 17)) + + y: T; +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>T : Symbol(T, Decl(decls.d.ts, 2, 17)) + + constructor(x?: T); +>x : Symbol(x, Decl(decls.d.ts, 4, 16)) +>T : Symbol(T, Decl(decls.d.ts, 2, 17)) +} +declare class C1 { +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) +>T : Symbol(T, Decl(decls.d.ts, 6, 17)) +>U : Symbol(U, Decl(decls.d.ts, 6, 19)) + + y: [T, U]; +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>T : Symbol(T, Decl(decls.d.ts, 6, 17)) +>U : Symbol(U, Decl(decls.d.ts, 6, 19)) + + constructor(x?: T); +>x : Symbol(x, Decl(decls.d.ts, 8, 16)) +>T : Symbol(T, Decl(decls.d.ts, 6, 17)) +} +=== tests/cases/compiler/main.js === +const f0_v0 = f0(); +>f0_v0 : Symbol(f0_v0, Decl(main.js, 0, 5)) +>f0 : Symbol(f0, Decl(decls.d.ts, 0, 0)) + +const f0_v1 = f0(1); +>f0_v1 : Symbol(f0_v1, Decl(main.js, 1, 5)) +>f0 : Symbol(f0, Decl(decls.d.ts, 0, 0)) + +const f1_c0 = f1(); +>f1_c0 : Symbol(f1_c0, Decl(main.js, 3, 5)) +>f1 : Symbol(f1, Decl(decls.d.ts, 0, 33)) + +const f1_c1 = f1(1); +>f1_c1 : Symbol(f1_c1, Decl(main.js, 4, 5)) +>f1 : Symbol(f1, Decl(decls.d.ts, 0, 33)) + +const C0_v0 = new C0(); +>C0_v0 : Symbol(C0_v0, Decl(main.js, 6, 5)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + +const C0_v0_y = C0_v0.y; +>C0_v0_y : Symbol(C0_v0_y, Decl(main.js, 7, 5)) +>C0_v0.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_v0 : Symbol(C0_v0, Decl(main.js, 6, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C0_v1 = new C0(1); +>C0_v1 : Symbol(C0_v1, Decl(main.js, 9, 5)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + +const C0_v1_y = C0_v1.y; +>C0_v1_y : Symbol(C0_v1_y, Decl(main.js, 10, 5)) +>C0_v1.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_v1 : Symbol(C0_v1, Decl(main.js, 9, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C1_v0 = new C1(); +>C1_v0 : Symbol(C1_v0, Decl(main.js, 12, 5)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + +const C1_v0_y = C1_v0.y; +>C1_v0_y : Symbol(C1_v0_y, Decl(main.js, 13, 5)) +>C1_v0.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_v0 : Symbol(C1_v0, Decl(main.js, 12, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +const C1_v1 = new C1(1); +>C1_v1 : Symbol(C1_v1, Decl(main.js, 15, 5)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + +const C1_v1_y = C1_v1.y; +>C1_v1_y : Symbol(C1_v1_y, Decl(main.js, 16, 5)) +>C1_v1.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_v1 : Symbol(C1_v1, Decl(main.js, 15, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +class C0_B0 extends C0 {} +>C0_B0 : Symbol(C0_B0, Decl(main.js, 16, 24)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + +class C0_B1 extends C0 { +>C0_B1 : Symbol(C0_B1, Decl(main.js, 18, 25)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + + constructor() { + super(); +>super : Symbol(C0, Decl(decls.d.ts, 1, 50)) + } +} +class C0_B2 extends C0 { +>C0_B2 : Symbol(C0_B2, Decl(main.js, 23, 1)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + + constructor() { + super(1); +>super : Symbol(C0, Decl(decls.d.ts, 1, 50)) + } +} + +const C0_B0_v0 = new C0_B0(); +>C0_B0_v0 : Symbol(C0_B0_v0, Decl(main.js, 30, 5)) +>C0_B0 : Symbol(C0_B0, Decl(main.js, 16, 24)) + +const C0_B0_v0_y = C0_B0_v0.y; +>C0_B0_v0_y : Symbol(C0_B0_v0_y, Decl(main.js, 31, 5)) +>C0_B0_v0.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_B0_v0 : Symbol(C0_B0_v0, Decl(main.js, 30, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C0_B0_v1 = new C0_B0(1); +>C0_B0_v1 : Symbol(C0_B0_v1, Decl(main.js, 33, 5)) +>C0_B0 : Symbol(C0_B0, Decl(main.js, 16, 24)) + +const C0_B0_v1_y = C0_B0_v1.y; +>C0_B0_v1_y : Symbol(C0_B0_v1_y, Decl(main.js, 34, 5)) +>C0_B0_v1.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_B0_v1 : Symbol(C0_B0_v1, Decl(main.js, 33, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C0_B1_v0 = new C0_B1(); +>C0_B1_v0 : Symbol(C0_B1_v0, Decl(main.js, 36, 5)) +>C0_B1 : Symbol(C0_B1, Decl(main.js, 18, 25)) + +const C0_B1_v0_y = C0_B1_v0.y; +>C0_B1_v0_y : Symbol(C0_B1_v0_y, Decl(main.js, 37, 5)) +>C0_B1_v0.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_B1_v0 : Symbol(C0_B1_v0, Decl(main.js, 36, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C0_B2_v0 = new C0_B2(); +>C0_B2_v0 : Symbol(C0_B2_v0, Decl(main.js, 39, 5)) +>C0_B2 : Symbol(C0_B2, Decl(main.js, 23, 1)) + +const C0_B2_v0_y = C0_B2_v0.y; +>C0_B2_v0_y : Symbol(C0_B2_v0_y, Decl(main.js, 40, 5)) +>C0_B2_v0.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_B2_v0 : Symbol(C0_B2_v0, Decl(main.js, 39, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +class C1_B0 extends C1 {} +>C1_B0 : Symbol(C1_B0, Decl(main.js, 40, 30)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + +class C1_B1 extends C1 { +>C1_B1 : Symbol(C1_B1, Decl(main.js, 42, 25)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + + constructor() { + super(); +>super : Symbol(C1, Decl(decls.d.ts, 5, 1)) + } +} +class C1_B2 extends C1 { +>C1_B2 : Symbol(C1_B2, Decl(main.js, 47, 1)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + + constructor() { + super(1); +>super : Symbol(C1, Decl(decls.d.ts, 5, 1)) + } +} + +const C1_B0_v0 = new C1_B0(); +>C1_B0_v0 : Symbol(C1_B0_v0, Decl(main.js, 54, 5)) +>C1_B0 : Symbol(C1_B0, Decl(main.js, 40, 30)) + +const C1_B0_v0_y = C1_B0_v0.y; +>C1_B0_v0_y : Symbol(C1_B0_v0_y, Decl(main.js, 55, 5)) +>C1_B0_v0.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_B0_v0 : Symbol(C1_B0_v0, Decl(main.js, 54, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +const C1_B0_v1 = new C1_B0(1); +>C1_B0_v1 : Symbol(C1_B0_v1, Decl(main.js, 57, 5)) +>C1_B0 : Symbol(C1_B0, Decl(main.js, 40, 30)) + +const C1_B0_v1_y = C1_B0_v1.y; +>C1_B0_v1_y : Symbol(C1_B0_v1_y, Decl(main.js, 58, 5)) +>C1_B0_v1.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_B0_v1 : Symbol(C1_B0_v1, Decl(main.js, 57, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +const C1_B1_v0 = new C1_B1(); +>C1_B1_v0 : Symbol(C1_B1_v0, Decl(main.js, 60, 5)) +>C1_B1 : Symbol(C1_B1, Decl(main.js, 42, 25)) + +const C1_B1_v0_y = C1_B1_v0.y; +>C1_B1_v0_y : Symbol(C1_B1_v0_y, Decl(main.js, 61, 5)) +>C1_B1_v0.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_B1_v0 : Symbol(C1_B1_v0, Decl(main.js, 60, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +const C1_B2_v0 = new C1_B2(); +>C1_B2_v0 : Symbol(C1_B2_v0, Decl(main.js, 63, 5)) +>C1_B2 : Symbol(C1_B2, Decl(main.js, 47, 1)) + +const C1_B2_v0_y = C1_B2_v0.y; +>C1_B2_v0_y : Symbol(C1_B2_v0_y, Decl(main.js, 64, 5)) +>C1_B2_v0.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_B2_v0 : Symbol(C1_B2_v0, Decl(main.js, 63, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + diff --git a/tests/baselines/reference/genericDefaultsJs.types b/tests/baselines/reference/genericDefaultsJs.types new file mode 100644 index 0000000000..3275e757d7 --- /dev/null +++ b/tests/baselines/reference/genericDefaultsJs.types @@ -0,0 +1,254 @@ +=== tests/cases/compiler/decls.d.ts === +declare function f0(x?: T): T; +>f0 : (x?: T) => T +>T : T +>x : T +>T : T +>T : T + +declare function f1(x?: T): [T, U]; +>f1 : (x?: T) => [T, U] +>T : T +>U : U +>x : T +>T : T +>T : T +>U : U + +declare class C0 { +>C0 : C0 +>T : T + + y: T; +>y : T +>T : T + + constructor(x?: T); +>x : T +>T : T +} +declare class C1 { +>C1 : C1 +>T : T +>U : U + + y: [T, U]; +>y : [T, U] +>T : T +>U : U + + constructor(x?: T); +>x : T +>T : T +} +=== tests/cases/compiler/main.js === +const f0_v0 = f0(); +>f0_v0 : any +>f0() : any +>f0 : (x?: T) => T + +const f0_v1 = f0(1); +>f0_v1 : 1 +>f0(1) : 1 +>f0 : (x?: T) => T +>1 : 1 + +const f1_c0 = f1(); +>f1_c0 : [any, number] +>f1() : [any, number] +>f1 : (x?: T) => [T, U] + +const f1_c1 = f1(1); +>f1_c1 : [number, number] +>f1(1) : [number, number] +>f1 : (x?: T) => [T, U] +>1 : 1 + +const C0_v0 = new C0(); +>C0_v0 : C0 +>new C0() : C0 +>C0 : typeof C0 + +const C0_v0_y = C0_v0.y; +>C0_v0_y : any +>C0_v0.y : any +>C0_v0 : C0 +>y : any + +const C0_v1 = new C0(1); +>C0_v1 : C0 +>new C0(1) : C0 +>C0 : typeof C0 +>1 : 1 + +const C0_v1_y = C0_v1.y; +>C0_v1_y : number +>C0_v1.y : number +>C0_v1 : C0 +>y : number + +const C1_v0 = new C1(); +>C1_v0 : C1 +>new C1() : C1 +>C1 : typeof C1 + +const C1_v0_y = C1_v0.y; +>C1_v0_y : [any, number] +>C1_v0.y : [any, number] +>C1_v0 : C1 +>y : [any, number] + +const C1_v1 = new C1(1); +>C1_v1 : C1 +>new C1(1) : C1 +>C1 : typeof C1 +>1 : 1 + +const C1_v1_y = C1_v1.y; +>C1_v1_y : [number, number] +>C1_v1.y : [number, number] +>C1_v1 : C1 +>y : [number, number] + +class C0_B0 extends C0 {} +>C0_B0 : C0_B0 +>C0 : C0 + +class C0_B1 extends C0 { +>C0_B1 : C0_B1 +>C0 : C0 + + constructor() { + super(); +>super() : void +>super : typeof C0 + } +} +class C0_B2 extends C0 { +>C0_B2 : C0_B2 +>C0 : C0 + + constructor() { + super(1); +>super(1) : void +>super : typeof C0 +>1 : 1 + } +} + +const C0_B0_v0 = new C0_B0(); +>C0_B0_v0 : C0_B0 +>new C0_B0() : C0_B0 +>C0_B0 : typeof C0_B0 + +const C0_B0_v0_y = C0_B0_v0.y; +>C0_B0_v0_y : any +>C0_B0_v0.y : any +>C0_B0_v0 : C0_B0 +>y : any + +const C0_B0_v1 = new C0_B0(1); +>C0_B0_v1 : C0_B0 +>new C0_B0(1) : C0_B0 +>C0_B0 : typeof C0_B0 +>1 : 1 + +const C0_B0_v1_y = C0_B0_v1.y; +>C0_B0_v1_y : any +>C0_B0_v1.y : any +>C0_B0_v1 : C0_B0 +>y : any + +const C0_B1_v0 = new C0_B1(); +>C0_B1_v0 : C0_B1 +>new C0_B1() : C0_B1 +>C0_B1 : typeof C0_B1 + +const C0_B1_v0_y = C0_B1_v0.y; +>C0_B1_v0_y : any +>C0_B1_v0.y : any +>C0_B1_v0 : C0_B1 +>y : any + +const C0_B2_v0 = new C0_B2(); +>C0_B2_v0 : C0_B2 +>new C0_B2() : C0_B2 +>C0_B2 : typeof C0_B2 + +const C0_B2_v0_y = C0_B2_v0.y; +>C0_B2_v0_y : any +>C0_B2_v0.y : any +>C0_B2_v0 : C0_B2 +>y : any + +class C1_B0 extends C1 {} +>C1_B0 : C1_B0 +>C1 : C1 + +class C1_B1 extends C1 { +>C1_B1 : C1_B1 +>C1 : C1 + + constructor() { + super(); +>super() : void +>super : typeof C1 + } +} +class C1_B2 extends C1 { +>C1_B2 : C1_B2 +>C1 : C1 + + constructor() { + super(1); +>super(1) : void +>super : typeof C1 +>1 : 1 + } +} + +const C1_B0_v0 = new C1_B0(); +>C1_B0_v0 : C1_B0 +>new C1_B0() : C1_B0 +>C1_B0 : typeof C1_B0 + +const C1_B0_v0_y = C1_B0_v0.y; +>C1_B0_v0_y : [any, number] +>C1_B0_v0.y : [any, number] +>C1_B0_v0 : C1_B0 +>y : [any, number] + +const C1_B0_v1 = new C1_B0(1); +>C1_B0_v1 : C1_B0 +>new C1_B0(1) : C1_B0 +>C1_B0 : typeof C1_B0 +>1 : 1 + +const C1_B0_v1_y = C1_B0_v1.y; +>C1_B0_v1_y : [any, number] +>C1_B0_v1.y : [any, number] +>C1_B0_v1 : C1_B0 +>y : [any, number] + +const C1_B1_v0 = new C1_B1(); +>C1_B1_v0 : C1_B1 +>new C1_B1() : C1_B1 +>C1_B1 : typeof C1_B1 + +const C1_B1_v0_y = C1_B1_v0.y; +>C1_B1_v0_y : [any, number] +>C1_B1_v0.y : [any, number] +>C1_B1_v0 : C1_B1 +>y : [any, number] + +const C1_B2_v0 = new C1_B2(); +>C1_B2_v0 : C1_B2 +>new C1_B2() : C1_B2 +>C1_B2 : typeof C1_B2 + +const C1_B2_v0_y = C1_B2_v0.y; +>C1_B2_v0_y : [any, number] +>C1_B2_v0.y : [any, number] +>C1_B2_v0 : C1_B2 +>y : [any, number] + diff --git a/tests/baselines/reference/indexedAccessRelation.js b/tests/baselines/reference/indexedAccessRelation.js new file mode 100644 index 0000000000..c58c214e69 --- /dev/null +++ b/tests/baselines/reference/indexedAccessRelation.js @@ -0,0 +1,56 @@ +//// [indexedAccessRelation.ts] +// Repro from #14723 + +class Component { + setState(state: Pick) {} +} + +export interface State { + a?: T; +} + +class Foo {} + +class Comp extends Component> +{ + foo(a: T) { + this.setState({ a: a }); + } +} + + +//// [indexedAccessRelation.js] +// Repro from #14723 +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var Component = (function () { + function Component() { + } + Component.prototype.setState = function (state) { }; + return Component; +}()); +var Foo = (function () { + function Foo() { + } + return Foo; +}()); +var Comp = (function (_super) { + __extends(Comp, _super); + function Comp() { + return _super !== null && _super.apply(this, arguments) || this; + } + Comp.prototype.foo = function (a) { + this.setState({ a: a }); + }; + return Comp; +}(Component)); diff --git a/tests/baselines/reference/indexedAccessRelation.symbols b/tests/baselines/reference/indexedAccessRelation.symbols new file mode 100644 index 0000000000..40fa52652f --- /dev/null +++ b/tests/baselines/reference/indexedAccessRelation.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/indexedAccessRelation.ts === +// Repro from #14723 + +class Component { +>Component : Symbol(Component, Decl(indexedAccessRelation.ts, 0, 0)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 2, 16)) + + setState(state: Pick) {} +>setState : Symbol(Component.setState, Decl(indexedAccessRelation.ts, 2, 20)) +>K : Symbol(K, Decl(indexedAccessRelation.ts, 3, 13)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 2, 16)) +>state : Symbol(state, Decl(indexedAccessRelation.ts, 3, 32)) +>Pick : Symbol(Pick, Decl(lib.d.ts, --, --)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 2, 16)) +>K : Symbol(K, Decl(indexedAccessRelation.ts, 3, 13)) +} + +export interface State { +>State : Symbol(State, Decl(indexedAccessRelation.ts, 4, 1)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 6, 23)) + + a?: T; +>a : Symbol(State.a, Decl(indexedAccessRelation.ts, 6, 27)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 6, 23)) +} + +class Foo {} +>Foo : Symbol(Foo, Decl(indexedAccessRelation.ts, 8, 1)) + +class Comp extends Component> +>Comp : Symbol(Comp, Decl(indexedAccessRelation.ts, 10, 12)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 12, 11)) +>Foo : Symbol(Foo, Decl(indexedAccessRelation.ts, 8, 1)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 12, 25)) +>Component : Symbol(Component, Decl(indexedAccessRelation.ts, 0, 0)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 12, 25)) +>State : Symbol(State, Decl(indexedAccessRelation.ts, 4, 1)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 12, 11)) +{ + foo(a: T) { +>foo : Symbol(Comp.foo, Decl(indexedAccessRelation.ts, 13, 1)) +>a : Symbol(a, Decl(indexedAccessRelation.ts, 14, 8)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 12, 11)) + + this.setState({ a: a }); +>this.setState : Symbol(Component.setState, Decl(indexedAccessRelation.ts, 2, 20)) +>this : Symbol(Comp, Decl(indexedAccessRelation.ts, 10, 12)) +>setState : Symbol(Component.setState, Decl(indexedAccessRelation.ts, 2, 20)) +>a : Symbol(a, Decl(indexedAccessRelation.ts, 15, 23)) +>a : Symbol(a, Decl(indexedAccessRelation.ts, 14, 8)) + } +} + diff --git a/tests/baselines/reference/indexedAccessRelation.types b/tests/baselines/reference/indexedAccessRelation.types new file mode 100644 index 0000000000..2564a82702 --- /dev/null +++ b/tests/baselines/reference/indexedAccessRelation.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/indexedAccessRelation.ts === +// Repro from #14723 + +class Component { +>Component : Component +>S : S + + setState(state: Pick) {} +>setState : (state: Pick) => void +>K : K +>S : S +>state : Pick +>Pick : Pick +>S : S +>K : K +} + +export interface State { +>State : State +>T : T + + a?: T; +>a : T +>T : T +} + +class Foo {} +>Foo : Foo + +class Comp extends Component> +>Comp : Comp +>T : T +>Foo : Foo +>S : S +>Component : Component> +>S : S +>State : State +>T : T +{ + foo(a: T) { +>foo : (a: T) => void +>a : T +>T : T + + this.setState({ a: a }); +>this.setState({ a: a }) : void +>this.setState : )>(state: Pick, K>) => void +>this : this +>setState : )>(state: Pick, K>) => void +>{ a: a } : { a: T; } +>a : T +>a : T + } +} + diff --git a/tests/baselines/reference/indirectSelfReference.errors.txt b/tests/baselines/reference/indirectSelfReference.errors.txt index 3f7d3d47f1..0339dd8ed0 100644 --- a/tests/baselines/reference/indirectSelfReference.errors.txt +++ b/tests/baselines/reference/indirectSelfReference.errors.txt @@ -1,11 +1,14 @@ tests/cases/compiler/indirectSelfReference.ts(1,7): error TS2506: 'a' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/indirectSelfReference.ts(1,17): error TS2449: Class 'b' used before its declaration. tests/cases/compiler/indirectSelfReference.ts(2,7): error TS2506: 'b' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/indirectSelfReference.ts (2 errors) ==== +==== tests/cases/compiler/indirectSelfReference.ts (3 errors) ==== class a extends b{ } ~ !!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'b' used before its declaration. class b extends a{ } ~ !!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt index 5a6aeed5de..d1cdbf1da5 100644 --- a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt +++ b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt @@ -1,11 +1,14 @@ tests/cases/compiler/indirectSelfReferenceGeneric.ts(1,7): error TS2506: 'a' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/indirectSelfReferenceGeneric.ts(1,20): error TS2449: Class 'b' used before its declaration. tests/cases/compiler/indirectSelfReferenceGeneric.ts(2,7): error TS2506: 'b' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/indirectSelfReferenceGeneric.ts (2 errors) ==== +==== tests/cases/compiler/indirectSelfReferenceGeneric.ts (3 errors) ==== class a extends b { } ~ !!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'b' used before its declaration. class b extends a { } ~ !!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern1.js b/tests/baselines/reference/iterableArrayPattern1.js index b45ac92d1f..6061b9950d 100644 --- a/tests/baselines/reference/iterableArrayPattern1.js +++ b/tests/baselines/reference/iterableArrayPattern1.js @@ -1,5 +1,4 @@ //// [iterableArrayPattern1.ts] -var [a, b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -11,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var [a, b] = new SymbolIterator; //// [iterableArrayPattern1.js] -var [a, b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -26,3 +26,4 @@ class SymbolIterator { return this; } } +var [a, b] = new SymbolIterator; diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index 4921fc8ec9..b901b43b7b 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -1,22 +1,17 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts === -var [a, b] = new SymbolIterator; ->a : Symbol(a, Decl(iterableArrayPattern1.ts, 0, 5)) ->b : Symbol(b, Decl(iterableArrayPattern1.ts, 0, 7)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iterableArrayPattern1.ts, 1, 22)) +>next : Symbol(SymbolIterator.next, Decl(iterableArrayPattern1.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) +>value : Symbol(value, Decl(iterableArrayPattern1.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) +>done : Symbol(done, Decl(iterableArrayPattern1.ts, 3, 28)) }; } @@ -27,6 +22,12 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) +>this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 0)) } } + +var [a, b] = new SymbolIterator; +>a : Symbol(a, Decl(iterableArrayPattern1.ts, 13, 5)) +>b : Symbol(b, Decl(iterableArrayPattern1.ts, 13, 7)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 0)) + diff --git a/tests/baselines/reference/iterableArrayPattern1.types b/tests/baselines/reference/iterableArrayPattern1.types index 816ce7ac6c..e7d307b2cb 100644 --- a/tests/baselines/reference/iterableArrayPattern1.types +++ b/tests/baselines/reference/iterableArrayPattern1.types @@ -1,10 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts === -var [a, b] = new SymbolIterator; ->a : symbol ->b : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -35,3 +29,10 @@ class SymbolIterator { >this : this } } + +var [a, b] = new SymbolIterator; +>a : symbol +>b : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iterableArrayPattern10.errors.txt b/tests/baselines/reference/iterableArrayPattern10.errors.txt index f06c4d7de1..f0b3e14c9f 100644 --- a/tests/baselines/reference/iterableArrayPattern10.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern10.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts(17,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'. Property '0' is missing in type 'FooIterator'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts (1 errors) ==== - function fun([a, b]) { } - fun(new FooIterator); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'. -!!! error TS2345: Property '0' is missing in type 'FooIterator'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts(2,5): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun([a, b]) { } + fun(new FooIterator); + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'. +!!! error TS2345: Property '0' is missing in type 'FooIterator'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern10.js b/tests/baselines/reference/iterableArrayPattern10.js index c8d37e3f89..530a21d6a1 100644 --- a/tests/baselines/reference/iterableArrayPattern10.js +++ b/tests/baselines/reference/iterableArrayPattern10.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern10.ts] -function fun([a, b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, b]) { } +fun(new FooIterator); //// [iterableArrayPattern10.js] -function fun([a, b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun([a, b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern11.js b/tests/baselines/reference/iterableArrayPattern11.js index 85ed4ab971..92a9d9e200 100644 --- a/tests/baselines/reference/iterableArrayPattern11.js +++ b/tests/baselines/reference/iterableArrayPattern11.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern11.ts] -function fun([a, b] = new FooIterator) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,13 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, b] = new FooIterator) { } +fun(new FooIterator); + //// [iterableArrayPattern11.js] -function fun([a, b] = new FooIterator) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +34,5 @@ class FooIterator { return this; } } +function fun([a, b] = new FooIterator) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index e1b3713f9d..36871283fb 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -1,36 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts === -function fun([a, b] = new FooIterator) { } ->fun : Symbol(fun, Decl(iterableArrayPattern11.ts, 0, 0)) ->a : Symbol(a, Decl(iterableArrayPattern11.ts, 0, 14)) ->b : Symbol(b, Decl(iterableArrayPattern11.ts, 0, 16)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) - -fun(new FooIterator); ->fun : Symbol(fun, Decl(iterableArrayPattern11.ts, 0, 0)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern11.ts, 1, 21)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern11.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern11.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern11.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern11.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern11.ts, 1, 21)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern11.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern11.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern11.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern11.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern11.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern11.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern11.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern11.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern11.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern11.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern11.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern11.ts, 5, 27)) }; } @@ -41,6 +31,17 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 1, 27)) } } + +function fun([a, b] = new FooIterator) { } +>fun : Symbol(fun, Decl(iterableArrayPattern11.ts, 13, 1)) +>a : Symbol(a, Decl(iterableArrayPattern11.ts, 15, 14)) +>b : Symbol(b, Decl(iterableArrayPattern11.ts, 15, 16)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 1, 27)) + +fun(new FooIterator); +>fun : Symbol(fun, Decl(iterableArrayPattern11.ts, 13, 1)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern11.types b/tests/baselines/reference/iterableArrayPattern11.types index 0acadd7cfc..d3fa43d2f1 100644 --- a/tests/baselines/reference/iterableArrayPattern11.types +++ b/tests/baselines/reference/iterableArrayPattern11.types @@ -1,17 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts === -function fun([a, b] = new FooIterator) { } ->fun : ([a, b]?: FooIterator) => void ->a : Foo ->b : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - -fun(new FooIterator); ->fun(new FooIterator) : void ->fun : ([a, b]?: FooIterator) => void ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -51,3 +38,17 @@ class FooIterator { >this : this } } + +function fun([a, b] = new FooIterator) { } +>fun : ([a, b]?: FooIterator) => void +>a : Foo +>b : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + +fun(new FooIterator); +>fun(new FooIterator) : void +>fun : ([a, b]?: FooIterator) => void +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern12.js b/tests/baselines/reference/iterableArrayPattern12.js index 4856af9cb4..89694ffa0c 100644 --- a/tests/baselines/reference/iterableArrayPattern12.js +++ b/tests/baselines/reference/iterableArrayPattern12.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern12.ts] -function fun([a, ...b] = new FooIterator) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, ...b] = new FooIterator) { } +fun(new FooIterator); //// [iterableArrayPattern12.js] -function fun([a, ...b] = new FooIterator) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun([a, ...b] = new FooIterator) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index 4044544d17..cb87637087 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -1,36 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts === -function fun([a, ...b] = new FooIterator) { } ->fun : Symbol(fun, Decl(iterableArrayPattern12.ts, 0, 0)) ->a : Symbol(a, Decl(iterableArrayPattern12.ts, 0, 14)) ->b : Symbol(b, Decl(iterableArrayPattern12.ts, 0, 16)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) - -fun(new FooIterator); ->fun : Symbol(fun, Decl(iterableArrayPattern12.ts, 0, 0)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern12.ts, 1, 21)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern12.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern12.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern12.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern12.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern12.ts, 1, 21)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern12.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern12.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern12.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern12.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern12.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern12.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern12.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern12.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern12.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern12.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern12.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern12.ts, 5, 27)) }; } @@ -41,6 +31,17 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 1, 27)) } } + +function fun([a, ...b] = new FooIterator) { } +>fun : Symbol(fun, Decl(iterableArrayPattern12.ts, 13, 1)) +>a : Symbol(a, Decl(iterableArrayPattern12.ts, 15, 14)) +>b : Symbol(b, Decl(iterableArrayPattern12.ts, 15, 16)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 1, 27)) + +fun(new FooIterator); +>fun : Symbol(fun, Decl(iterableArrayPattern12.ts, 13, 1)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern12.types b/tests/baselines/reference/iterableArrayPattern12.types index c00e1daae8..3c50058b3e 100644 --- a/tests/baselines/reference/iterableArrayPattern12.types +++ b/tests/baselines/reference/iterableArrayPattern12.types @@ -1,17 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts === -function fun([a, ...b] = new FooIterator) { } ->fun : ([a, ...b]?: FooIterator) => void ->a : Foo ->b : Foo[] ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - -fun(new FooIterator); ->fun(new FooIterator) : void ->fun : ([a, ...b]?: FooIterator) => void ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -51,3 +38,17 @@ class FooIterator { >this : this } } + +function fun([a, ...b] = new FooIterator) { } +>fun : ([a, ...b]?: FooIterator) => void +>a : Foo +>b : Foo[] +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + +fun(new FooIterator); +>fun(new FooIterator) : void +>fun : ([a, ...b]?: FooIterator) => void +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern13.js b/tests/baselines/reference/iterableArrayPattern13.js index 06f9901a85..efbce2bfd1 100644 --- a/tests/baselines/reference/iterableArrayPattern13.js +++ b/tests/baselines/reference/iterableArrayPattern13.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern13.ts] -function fun([a, ...b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, ...b]) { } +fun(new FooIterator); //// [iterableArrayPattern13.js] -function fun([a, ...b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun([a, ...b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index c04d66fa6d..25241ab24b 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -1,35 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts === -function fun([a, ...b]) { } ->fun : Symbol(fun, Decl(iterableArrayPattern13.ts, 0, 0)) ->a : Symbol(a, Decl(iterableArrayPattern13.ts, 0, 14)) ->b : Symbol(b, Decl(iterableArrayPattern13.ts, 0, 16)) - -fun(new FooIterator); ->fun : Symbol(fun, Decl(iterableArrayPattern13.ts, 0, 0)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern13.ts, 1, 21)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern13.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern13.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern13.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern13.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern13.ts, 1, 21)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern13.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern13.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern13.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern13.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern13.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern13.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern13.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern13.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern13.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern13.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern13.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern13.ts, 5, 27)) }; } @@ -40,6 +31,16 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 1, 27)) } } + +function fun([a, ...b]) { } +>fun : Symbol(fun, Decl(iterableArrayPattern13.ts, 13, 1)) +>a : Symbol(a, Decl(iterableArrayPattern13.ts, 15, 14)) +>b : Symbol(b, Decl(iterableArrayPattern13.ts, 15, 16)) + +fun(new FooIterator); +>fun : Symbol(fun, Decl(iterableArrayPattern13.ts, 13, 1)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern13.types b/tests/baselines/reference/iterableArrayPattern13.types index 04dab57748..724a0795ef 100644 --- a/tests/baselines/reference/iterableArrayPattern13.types +++ b/tests/baselines/reference/iterableArrayPattern13.types @@ -1,15 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts === -function fun([a, ...b]) { } ->fun : ([a, ...b]: Iterable) => void ->a : any ->b : any[] - -fun(new FooIterator); ->fun(new FooIterator) : void ->fun : ([a, ...b]: Iterable) => void ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -49,3 +38,15 @@ class FooIterator { >this : this } } + +function fun([a, ...b]) { } +>fun : ([a, ...b]: Iterable) => void +>a : any +>b : any[] + +fun(new FooIterator); +>fun(new FooIterator) : void +>fun : ([a, ...b]: Iterable) => void +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern14.errors.txt b/tests/baselines/reference/iterableArrayPattern14.errors.txt index a14ddc4502..664f73e13a 100644 --- a/tests/baselines/reference/iterableArrayPattern14.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern14.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. +tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts (1 errors) ==== - function fun(...[a, ...b]) { } - ~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts(1,17): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun(...[a, ...b]) { } + ~~~~~~~~~ +!!! error TS2501: A rest element cannot contain a binding pattern. + fun(new FooIterator); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern14.js b/tests/baselines/reference/iterableArrayPattern14.js index a3595b0df0..bb1d416f4f 100644 --- a/tests/baselines/reference/iterableArrayPattern14.js +++ b/tests/baselines/reference/iterableArrayPattern14.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern14.ts] -function fun(...[a, ...b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun(...[a, ...b]) { } +fun(new FooIterator); //// [iterableArrayPattern14.js] -function fun(...[a, ...b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun(...[a, ...b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern15.errors.txt b/tests/baselines/reference/iterableArrayPattern15.errors.txt index bb2d1eb096..ce7559de94 100644 --- a/tests/baselines/reference/iterableArrayPattern15.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern15.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. +tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts (1 errors) ==== - function fun(...[a, b]: Bar[]) { } - ~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(...new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts(1,17): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun(...[a, b]: Bar[]) { } + ~~~~~~ +!!! error TS2501: A rest element cannot contain a binding pattern. + fun(...new FooIterator); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern15.js b/tests/baselines/reference/iterableArrayPattern15.js index 1c2050129c..d14fd1b364 100644 --- a/tests/baselines/reference/iterableArrayPattern15.js +++ b/tests/baselines/reference/iterableArrayPattern15.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern15.ts] -function fun(...[a, b]: Bar[]) { } -fun(...new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun(...[a, b]: Bar[]) { } +fun(...new FooIterator); //// [iterableArrayPattern15.js] -function fun(...[a, b]) { } -fun(...new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun(...[a, b]) { } +fun(...new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern16.errors.txt b/tests/baselines/reference/iterableArrayPattern16.errors.txt index e03d0a799d..ba5531a0a5 100644 --- a/tests/baselines/reference/iterableArrayPattern16.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern16.errors.txt @@ -1,9 +1,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'. Property '0' is missing in type 'FooIterator'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,12): error TS2449: Class 'FooIteratorIterator' used before its declaration. -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts (3 errors) ==== function fun(...[a, b]: [Bar, Bar][]) { } ~~~~~~ !!! error TS2501: A rest element cannot contain a binding pattern. @@ -11,6 +12,8 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,5): error ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'. !!! error TS2345: Property '0' is missing in type 'FooIterator'. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2449: Class 'FooIteratorIterator' used before its declaration. class Bar { x } class Foo extends Bar { y } class FooIterator { diff --git a/tests/baselines/reference/iterableArrayPattern17.errors.txt b/tests/baselines/reference/iterableArrayPattern17.errors.txt index 3cc04fadd1..d22d8580c7 100644 --- a/tests/baselines/reference/iterableArrayPattern17.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern17.errors.txt @@ -1,16 +1,9 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. -tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. +tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(17,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. Property 'x' is missing in type 'FooIterator'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts (2 errors) ==== - function fun(...[a, b]: Bar[]) { } - ~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(new FooIterator); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. -!!! error TS2345: Property 'x' is missing in type 'FooIterator'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -24,4 +17,12 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(2,5): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun(...[a, b]: Bar[]) { } + ~~~~~~ +!!! error TS2501: A rest element cannot contain a binding pattern. + fun(new FooIterator); + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. +!!! error TS2345: Property 'x' is missing in type 'FooIterator'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern17.js b/tests/baselines/reference/iterableArrayPattern17.js index c6274aabcd..e9979380af 100644 --- a/tests/baselines/reference/iterableArrayPattern17.js +++ b/tests/baselines/reference/iterableArrayPattern17.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern17.ts] -function fun(...[a, b]: Bar[]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun(...[a, b]: Bar[]) { } +fun(new FooIterator); //// [iterableArrayPattern17.js] -function fun(...[a, b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun(...[a, b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern18.errors.txt b/tests/baselines/reference/iterableArrayPattern18.errors.txt index c6f8c5e28b..a3f8b6f840 100644 --- a/tests/baselines/reference/iterableArrayPattern18.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern18.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts(17,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'. Property 'length' is missing in type 'FooIterator'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts (1 errors) ==== - function fun([a, b]: Bar[]) { } - fun(new FooIterator); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'. -!!! error TS2345: Property 'length' is missing in type 'FooIterator'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts(2,5): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun([a, b]: Bar[]) { } + fun(new FooIterator); + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'. +!!! error TS2345: Property 'length' is missing in type 'FooIterator'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern18.js b/tests/baselines/reference/iterableArrayPattern18.js index e2016c4769..93b038cd32 100644 --- a/tests/baselines/reference/iterableArrayPattern18.js +++ b/tests/baselines/reference/iterableArrayPattern18.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern18.ts] -function fun([a, b]: Bar[]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, b]: Bar[]) { } +fun(new FooIterator); //// [iterableArrayPattern18.js] -function fun([a, b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun([a, b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern19.errors.txt b/tests/baselines/reference/iterableArrayPattern19.errors.txt index 3f8b550d28..f4a9fac0a0 100644 --- a/tests/baselines/reference/iterableArrayPattern19.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern19.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts(2,5): error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts(17,5): error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'. Property 'length' is missing in type 'FooArrayIterator'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts (1 errors) ==== - function fun([[a], b]: Bar[][]) { } - fun(new FooArrayIterator); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'. -!!! error TS2345: Property 'length' is missing in type 'FooArrayIterator'. class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts(2,5): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun([[a], b]: Bar[][]) { } + fun(new FooArrayIterator); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'. +!!! error TS2345: Property 'length' is missing in type 'FooArrayIterator'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern19.js b/tests/baselines/reference/iterableArrayPattern19.js index bc3cf33afc..3c930957f4 100644 --- a/tests/baselines/reference/iterableArrayPattern19.js +++ b/tests/baselines/reference/iterableArrayPattern19.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern19.ts] -function fun([[a], b]: Bar[][]) { } -fun(new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -14,11 +12,12 @@ class FooArrayIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([[a], b]: Bar[][]) { } +fun(new FooArrayIterator); //// [iterableArrayPattern19.js] -function fun([[a], b]) { } -fun(new FooArrayIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooArrayIterator { return this; } } +function fun([[a], b]) { } +fun(new FooArrayIterator); diff --git a/tests/baselines/reference/iterableArrayPattern2.js b/tests/baselines/reference/iterableArrayPattern2.js index 7392db7d6b..aab7ad9ec6 100644 --- a/tests/baselines/reference/iterableArrayPattern2.js +++ b/tests/baselines/reference/iterableArrayPattern2.js @@ -1,5 +1,4 @@ //// [iterableArrayPattern2.ts] -var [a, ...b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -11,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var [a, ...b] = new SymbolIterator; //// [iterableArrayPattern2.js] -var [a, ...b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -26,3 +26,4 @@ class SymbolIterator { return this; } } +var [a, ...b] = new SymbolIterator; diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index 50d3352b9e..db700cdd57 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -1,22 +1,17 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts === -var [a, ...b] = new SymbolIterator; ->a : Symbol(a, Decl(iterableArrayPattern2.ts, 0, 5)) ->b : Symbol(b, Decl(iterableArrayPattern2.ts, 0, 7)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iterableArrayPattern2.ts, 1, 22)) +>next : Symbol(SymbolIterator.next, Decl(iterableArrayPattern2.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) +>value : Symbol(value, Decl(iterableArrayPattern2.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) +>done : Symbol(done, Decl(iterableArrayPattern2.ts, 3, 28)) }; } @@ -27,6 +22,12 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) +>this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 0)) } } + +var [a, ...b] = new SymbolIterator; +>a : Symbol(a, Decl(iterableArrayPattern2.ts, 13, 5)) +>b : Symbol(b, Decl(iterableArrayPattern2.ts, 13, 7)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 0)) + diff --git a/tests/baselines/reference/iterableArrayPattern2.types b/tests/baselines/reference/iterableArrayPattern2.types index 63786a1d35..6a1bc9eb6f 100644 --- a/tests/baselines/reference/iterableArrayPattern2.types +++ b/tests/baselines/reference/iterableArrayPattern2.types @@ -1,10 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts === -var [a, ...b] = new SymbolIterator; ->a : symbol ->b : symbol[] ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -35,3 +29,10 @@ class SymbolIterator { >this : this } } + +var [a, ...b] = new SymbolIterator; +>a : symbol +>b : symbol[] +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iterableArrayPattern20.errors.txt b/tests/baselines/reference/iterableArrayPattern20.errors.txt index 4451a814bd..23f133238c 100644 --- a/tests/baselines/reference/iterableArrayPattern20.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern20.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. +tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts (1 errors) ==== - function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(...new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts(1,17): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2501: A rest element cannot contain a binding pattern. + fun(...new FooArrayIterator); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern20.js b/tests/baselines/reference/iterableArrayPattern20.js index 489f97a29f..a327cb3e47 100644 --- a/tests/baselines/reference/iterableArrayPattern20.js +++ b/tests/baselines/reference/iterableArrayPattern20.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern20.ts] -function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } -fun(...new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -14,11 +12,12 @@ class FooArrayIterator { [Symbol.iterator]() { return this; } -} +} + +function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } +fun(...new FooArrayIterator); //// [iterableArrayPattern20.js] -function fun(...[[a = new Foo], b = [new Foo]]) { } -fun(...new FooArrayIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooArrayIterator { return this; } } +function fun(...[[a = new Foo], b = [new Foo]]) { } +fun(...new FooArrayIterator); diff --git a/tests/baselines/reference/iterableArrayPattern3.js b/tests/baselines/reference/iterableArrayPattern3.js index 7136c6ab20..e29a67af73 100644 --- a/tests/baselines/reference/iterableArrayPattern3.js +++ b/tests/baselines/reference/iterableArrayPattern3.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern3.ts] -var a: Bar, b: Bar; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: Bar; +[a, b] = new FooIterator; //// [iterableArrayPattern3.js] -var a, b; -[a, b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 6cf0980138..a82c5f5e02 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -1,37 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts === -var a: Bar, b: Bar; ->a : Symbol(a, Decl(iterableArrayPattern3.ts, 0, 3)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 1, 25)) ->b : Symbol(b, Decl(iterableArrayPattern3.ts, 0, 11)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 1, 25)) - -[a, b] = new FooIterator; ->a : Symbol(a, Decl(iterableArrayPattern3.ts, 0, 3)) ->b : Symbol(b, Decl(iterableArrayPattern3.ts, 0, 11)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 1, 25)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern3.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern3.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern3.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 1, 25)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern3.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern3.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern3.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern3.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern3.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern3.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern3.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern3.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern3.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern3.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern3.ts, 5, 27)) }; } @@ -42,6 +31,18 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 1, 27)) } } + +var a: Bar, b: Bar; +>a : Symbol(a, Decl(iterableArrayPattern3.ts, 15, 3)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 0, 0)) +>b : Symbol(b, Decl(iterableArrayPattern3.ts, 15, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 0, 0)) + +[a, b] = new FooIterator; +>a : Symbol(a, Decl(iterableArrayPattern3.ts, 15, 3)) +>b : Symbol(b, Decl(iterableArrayPattern3.ts, 15, 11)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern3.types b/tests/baselines/reference/iterableArrayPattern3.types index a21e702526..b138c8629d 100644 --- a/tests/baselines/reference/iterableArrayPattern3.types +++ b/tests/baselines/reference/iterableArrayPattern3.types @@ -1,18 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts === -var a: Bar, b: Bar; ->a : Bar ->Bar : Bar ->b : Bar ->Bar : Bar - -[a, b] = new FooIterator; ->[a, b] = new FooIterator : FooIterator ->[a, b] : [Bar, Bar] ->a : Bar ->b : Bar ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -52,3 +38,18 @@ class FooIterator { >this : this } } + +var a: Bar, b: Bar; +>a : Bar +>Bar : Bar +>b : Bar +>Bar : Bar + +[a, b] = new FooIterator; +>[a, b] = new FooIterator : FooIterator +>[a, b] : [Bar, Bar] +>a : Bar +>b : Bar +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern4.js b/tests/baselines/reference/iterableArrayPattern4.js index 6e60dadbd7..c53b6ef416 100644 --- a/tests/baselines/reference/iterableArrayPattern4.js +++ b/tests/baselines/reference/iterableArrayPattern4.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern4.ts] -var a: Bar, b: Bar[]; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: Bar[]; +[a, ...b] = new FooIterator //// [iterableArrayPattern4.js] -var a, b; -[a, ...b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, ...b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index 651c60cf08..6a3526a348 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -1,37 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts === -var a: Bar, b: Bar[]; ->a : Symbol(a, Decl(iterableArrayPattern4.ts, 0, 3)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 1, 28)) ->b : Symbol(b, Decl(iterableArrayPattern4.ts, 0, 11)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 1, 28)) - -[a, ...b] = new FooIterator; ->a : Symbol(a, Decl(iterableArrayPattern4.ts, 0, 3)) ->b : Symbol(b, Decl(iterableArrayPattern4.ts, 0, 11)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 1, 28)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern4.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern4.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern4.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 1, 28)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern4.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern4.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern4.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern4.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern4.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern4.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern4.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern4.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern4.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern4.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern4.ts, 5, 27)) }; } @@ -42,6 +31,18 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 1, 27)) } } + +var a: Bar, b: Bar[]; +>a : Symbol(a, Decl(iterableArrayPattern4.ts, 15, 3)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 0, 0)) +>b : Symbol(b, Decl(iterableArrayPattern4.ts, 15, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 0, 0)) + +[a, ...b] = new FooIterator +>a : Symbol(a, Decl(iterableArrayPattern4.ts, 15, 3)) +>b : Symbol(b, Decl(iterableArrayPattern4.ts, 15, 11)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern4.types b/tests/baselines/reference/iterableArrayPattern4.types index a3be411449..1024f4c967 100644 --- a/tests/baselines/reference/iterableArrayPattern4.types +++ b/tests/baselines/reference/iterableArrayPattern4.types @@ -1,19 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts === -var a: Bar, b: Bar[]; ->a : Bar ->Bar : Bar ->b : Bar[] ->Bar : Bar - -[a, ...b] = new FooIterator; ->[a, ...b] = new FooIterator : FooIterator ->[a, ...b] : Bar[] ->a : Bar ->...b : Bar ->b : Bar[] ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -53,3 +38,19 @@ class FooIterator { >this : this } } + +var a: Bar, b: Bar[]; +>a : Bar +>Bar : Bar +>b : Bar[] +>Bar : Bar + +[a, ...b] = new FooIterator +>[a, ...b] = new FooIterator : FooIterator +>[a, ...b] : Bar[] +>a : Bar +>...b : Bar +>b : Bar[] +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern5.errors.txt b/tests/baselines/reference/iterableArrayPattern5.errors.txt index ca540d805b..1bbbe268e6 100644 --- a/tests/baselines/reference/iterableArrayPattern5.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern5.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts(2,5): error TS2322: Type 'Foo' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts(17,5): error TS2322: Type 'Foo' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts (1 errors) ==== - var a: Bar, b: string; - [a, b] = new FooIterator; - ~ -!!! error TS2322: Type 'Foo' is not assignable to type 'string'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts(2,5): error T [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var a: Bar, b: string; + [a, b] = new FooIterator; + ~ +!!! error TS2322: Type 'Foo' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern5.js b/tests/baselines/reference/iterableArrayPattern5.js index 77e71cac6d..56ed70b137 100644 --- a/tests/baselines/reference/iterableArrayPattern5.js +++ b/tests/baselines/reference/iterableArrayPattern5.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern5.ts] -var a: Bar, b: string; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: string; +[a, b] = new FooIterator; //// [iterableArrayPattern5.js] -var a, b; -[a, b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern6.errors.txt b/tests/baselines/reference/iterableArrayPattern6.errors.txt index e0a546d154..3a20f1f52c 100644 --- a/tests/baselines/reference/iterableArrayPattern6.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern6.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts(2,8): error TS2322: Type 'Foo[]' is not assignable to type 'string[]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts(17,8): error TS2322: Type 'Foo[]' is not assignable to type 'string[]'. Type 'Foo' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts (1 errors) ==== - var a: Bar, b: string[]; - [a, ...b] = new FooIterator; - ~ -!!! error TS2322: Type 'Foo[]' is not assignable to type 'string[]'. -!!! error TS2322: Type 'Foo' is not assignable to type 'string'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts(2,8): error T [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var a: Bar, b: string[]; + [a, ...b] = new FooIterator; + ~ +!!! error TS2322: Type 'Foo[]' is not assignable to type 'string[]'. +!!! error TS2322: Type 'Foo' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern6.js b/tests/baselines/reference/iterableArrayPattern6.js index 8c797e819f..1053cced9c 100644 --- a/tests/baselines/reference/iterableArrayPattern6.js +++ b/tests/baselines/reference/iterableArrayPattern6.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern6.ts] -var a: Bar, b: string[]; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: string[]; +[a, ...b] = new FooIterator; //// [iterableArrayPattern6.js] -var a, b; -[a, ...b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, ...b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern7.errors.txt b/tests/baselines/reference/iterableArrayPattern7.errors.txt index 997cc21f38..972de74039 100644 --- a/tests/baselines/reference/iterableArrayPattern7.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern7.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts(2,5): error TS2322: Type 'Foo' is not assignable to type 'string[]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts(17,5): error TS2322: Type 'Foo' is not assignable to type 'string[]'. Property 'length' is missing in type 'Foo'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts (1 errors) ==== - var a: Bar, b: string[]; - [a, b] = new FooIterator; - ~ -!!! error TS2322: Type 'Foo' is not assignable to type 'string[]'. -!!! error TS2322: Property 'length' is missing in type 'Foo'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts(2,5): error T [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var a: Bar, b: string[]; + [a, b] = new FooIterator; + ~ +!!! error TS2322: Type 'Foo' is not assignable to type 'string[]'. +!!! error TS2322: Property 'length' is missing in type 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern7.js b/tests/baselines/reference/iterableArrayPattern7.js index 3f79e6bfba..74b25f1ec6 100644 --- a/tests/baselines/reference/iterableArrayPattern7.js +++ b/tests/baselines/reference/iterableArrayPattern7.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern7.ts] -var a: Bar, b: string[]; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: string[]; +[a, b] = new FooIterator; //// [iterableArrayPattern7.js] -var a, b; -[a, b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern8.errors.txt b/tests/baselines/reference/iterableArrayPattern8.errors.txt index c06e0c9543..94c6e9593e 100644 --- a/tests/baselines/reference/iterableArrayPattern8.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern8.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts(2,8): error TS2322: Type 'Foo[]' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts(17,8): error TS2322: Type 'Foo[]' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts (1 errors) ==== - var a: Bar, b: string; - [a, ...b] = new FooIterator; - ~ -!!! error TS2322: Type 'Foo[]' is not assignable to type 'string'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts(2,8): error T [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var a: Bar, b: string; + [a, ...b] = new FooIterator; + ~ +!!! error TS2322: Type 'Foo[]' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern8.js b/tests/baselines/reference/iterableArrayPattern8.js index dd1c76c1f5..b943953b15 100644 --- a/tests/baselines/reference/iterableArrayPattern8.js +++ b/tests/baselines/reference/iterableArrayPattern8.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern8.ts] -var a: Bar, b: string; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: string; +[a, ...b] = new FooIterator; //// [iterableArrayPattern8.js] -var a, b; -[a, ...b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, ...b] = new FooIterator; diff --git a/tests/baselines/reference/iteratorSpreadInArray.js b/tests/baselines/reference/iteratorSpreadInArray.js index 8e25a2e7ec..0b64eb4b40 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.js +++ b/tests/baselines/reference/iteratorSpreadInArray.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray.ts] -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,10 +10,12 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...new SymbolIterator]; + //// [iteratorSpreadInArray.js] -var array = [...new SymbolIterator]; class SymbolIterator { next() { return { @@ -27,3 +27,4 @@ class SymbolIterator { return this; } } +var array = [...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index 7fc2d469ea..6d6656f0f7 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -1,21 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts === -var array = [...new SymbolIterator]; ->array : Symbol(array, Decl(iteratorSpreadInArray.ts, 0, 3)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray.ts, 2, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray.ts, 3, 28)) }; } @@ -26,6 +22,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 0)) } } + +var array = [...new SymbolIterator]; +>array : Symbol(array, Decl(iteratorSpreadInArray.ts, 13, 3)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray.types b/tests/baselines/reference/iteratorSpreadInArray.types index 4b5a63e5d5..9d43fa57b0 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.types +++ b/tests/baselines/reference/iteratorSpreadInArray.types @@ -1,11 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts === -var array = [...new SymbolIterator]; ->array : symbol[] ->[...new SymbolIterator] : symbol[] ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -36,3 +29,11 @@ class SymbolIterator { >this : this } } + +var array = [...new SymbolIterator]; +>array : symbol[] +>[...new SymbolIterator] : symbol[] +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray10.errors.txt b/tests/baselines/reference/iteratorSpreadInArray10.errors.txt index 90cde7d03b..28a878ac43 100644 --- a/tests/baselines/reference/iteratorSpreadInArray10.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray10.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts(1,17): error TS2489: An iterator must have a 'next()' method. +tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts(7,17): error TS2489: An iterator must have a 'next()' method. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts (1 errors) ==== - var array = [...new SymbolIterator]; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2489: An iterator must have a 'next()' method. - class SymbolIterator { [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var array = [...new SymbolIterator]; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2489: An iterator must have a 'next()' method. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray10.js b/tests/baselines/reference/iteratorSpreadInArray10.js index 1004dbd7b3..196ca7c714 100644 --- a/tests/baselines/reference/iteratorSpreadInArray10.js +++ b/tests/baselines/reference/iteratorSpreadInArray10.js @@ -1,16 +1,16 @@ //// [iteratorSpreadInArray10.ts] -var array = [...new SymbolIterator]; - class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...new SymbolIterator]; //// [iteratorSpreadInArray10.js] -var array = [...new SymbolIterator]; class SymbolIterator { [Symbol.iterator]() { return this; } } +var array = [...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray2.js b/tests/baselines/reference/iteratorSpreadInArray2.js index aa4a1099a4..e766016389 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.js +++ b/tests/baselines/reference/iteratorSpreadInArray2.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray2.ts] -var array = [...new NumberIterator, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -25,10 +23,12 @@ class NumberIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...new NumberIterator, ...new SymbolIterator]; + //// [iteratorSpreadInArray2.js] -var array = [...new NumberIterator, ...new SymbolIterator]; class SymbolIterator { next() { return { @@ -51,3 +51,4 @@ class NumberIterator { return this; } } +var array = [...new NumberIterator, ...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index 8d39834c17..6fd22547ee 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -1,22 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts === -var array = [...new NumberIterator, ...new SymbolIterator]; ->array : Symbol(array, Decl(iteratorSpreadInArray2.ts, 0, 3)) ->NumberIterator : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray2.ts, 2, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray2.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 3, 28)) }; } @@ -27,22 +22,22 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 0)) } } class NumberIterator { ->NumberIterator : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) +>NumberIterator : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 11, 1)) next() { ->next : Symbol(NumberIterator.next, Decl(iteratorSpreadInArray2.ts, 15, 22)) +>next : Symbol(NumberIterator.next, Decl(iteratorSpreadInArray2.ts, 13, 22)) return { value: 0, ->value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 17, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 15, 16)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 18, 21)) +>done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 16, 21)) }; } @@ -53,6 +48,12 @@ class NumberIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) +>this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 11, 1)) } } + +var array = [...new NumberIterator, ...new SymbolIterator]; +>array : Symbol(array, Decl(iteratorSpreadInArray2.ts, 26, 3)) +>NumberIterator : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 11, 1)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray2.types b/tests/baselines/reference/iteratorSpreadInArray2.types index 19bf5eab00..440a2bebcf 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.types +++ b/tests/baselines/reference/iteratorSpreadInArray2.types @@ -1,14 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts === -var array = [...new NumberIterator, ...new SymbolIterator]; ->array : (number | symbol)[] ->[...new NumberIterator, ...new SymbolIterator] : (number | symbol)[] ->...new NumberIterator : number ->new NumberIterator : NumberIterator ->NumberIterator : typeof NumberIterator ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -69,3 +59,14 @@ class NumberIterator { >this : this } } + +var array = [...new NumberIterator, ...new SymbolIterator]; +>array : (number | symbol)[] +>[...new NumberIterator, ...new SymbolIterator] : (number | symbol)[] +>...new NumberIterator : number +>new NumberIterator : NumberIterator +>NumberIterator : typeof NumberIterator +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray3.js b/tests/baselines/reference/iteratorSpreadInArray3.js index 1d468e4483..239a95020f 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.js +++ b/tests/baselines/reference/iteratorSpreadInArray3.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray3.ts] -var array = [...[0, 1], ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...[0, 1], ...new SymbolIterator]; //// [iteratorSpreadInArray3.js] -var array = [...[0, 1], ...new SymbolIterator]; class SymbolIterator { next() { return { @@ -27,3 +26,4 @@ class SymbolIterator { return this; } } +var array = [...[0, 1], ...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index c110733dd6..ff6bc66e9d 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -1,21 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts === -var array = [...[0, 1], ...new SymbolIterator]; ->array : Symbol(array, Decl(iteratorSpreadInArray3.ts, 0, 3)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray3.ts, 2, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray3.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 3, 28)) }; } @@ -26,6 +22,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 0)) } } + +var array = [...[0, 1], ...new SymbolIterator]; +>array : Symbol(array, Decl(iteratorSpreadInArray3.ts, 13, 3)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray3.types b/tests/baselines/reference/iteratorSpreadInArray3.types index 1fd29bb238..b4c8f36f6d 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.types +++ b/tests/baselines/reference/iteratorSpreadInArray3.types @@ -1,15 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts === -var array = [...[0, 1], ...new SymbolIterator]; ->array : (number | symbol)[] ->[...[0, 1], ...new SymbolIterator] : (number | symbol)[] ->...[0, 1] : number ->[0, 1] : number[] ->0 : 0 ->1 : 1 ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -40,3 +29,15 @@ class SymbolIterator { >this : this } } + +var array = [...[0, 1], ...new SymbolIterator]; +>array : (number | symbol)[] +>[...[0, 1], ...new SymbolIterator] : (number | symbol)[] +>...[0, 1] : number +>[0, 1] : number[] +>0 : 0 +>1 : 1 +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray4.js b/tests/baselines/reference/iteratorSpreadInArray4.js index 82a08bfa96..95443f760c 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.js +++ b/tests/baselines/reference/iteratorSpreadInArray4.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray4.ts] -var array = [0, 1, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [0, 1, ...new SymbolIterator]; //// [iteratorSpreadInArray4.js] -var array = [0, 1, ...new SymbolIterator]; class SymbolIterator { next() { return { @@ -27,3 +26,4 @@ class SymbolIterator { return this; } } +var array = [0, 1, ...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index e1159ee0e9..16fa1c62c6 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -1,21 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts === -var array = [0, 1, ...new SymbolIterator]; ->array : Symbol(array, Decl(iteratorSpreadInArray4.ts, 0, 3)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray4.ts, 2, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray4.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 3, 28)) }; } @@ -26,6 +22,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 0)) } } + +var array = [0, 1, ...new SymbolIterator]; +>array : Symbol(array, Decl(iteratorSpreadInArray4.ts, 13, 3)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray4.types b/tests/baselines/reference/iteratorSpreadInArray4.types index 6024e79dee..d473416113 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.types +++ b/tests/baselines/reference/iteratorSpreadInArray4.types @@ -1,13 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts === -var array = [0, 1, ...new SymbolIterator]; ->array : (number | symbol)[] ->[0, 1, ...new SymbolIterator] : (number | symbol)[] ->0 : 0 ->1 : 1 ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -38,3 +29,13 @@ class SymbolIterator { >this : this } } + +var array = [0, 1, ...new SymbolIterator]; +>array : (number | symbol)[] +>[0, 1, ...new SymbolIterator] : (number | symbol)[] +>0 : 0 +>1 : 1 +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray5.errors.txt b/tests/baselines/reference/iteratorSpreadInArray5.errors.txt index 498cc7d48e..02049824c4 100644 --- a/tests/baselines/reference/iteratorSpreadInArray5.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray5.errors.txt @@ -1,15 +1,9 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts(1,5): error TS2322: Type '(number | symbol)[]' is not assignable to type 'number[]'. +tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts(14,5): error TS2322: Type '(number | symbol)[]' is not assignable to type 'number[]'. Type 'number | symbol' is not assignable to type 'number'. Type 'symbol' is not assignable to type 'number'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts (1 errors) ==== - var array: number[] = [0, 1, ...new SymbolIterator]; - ~~~~~ -!!! error TS2322: Type '(number | symbol)[]' is not assignable to type 'number[]'. -!!! error TS2322: Type 'number | symbol' is not assignable to type 'number'. -!!! error TS2322: Type 'symbol' is not assignable to type 'number'. - class SymbolIterator { next() { return { @@ -21,4 +15,10 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts(1,5): error TS2322: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var array: number[] = [0, 1, ...new SymbolIterator]; + ~~~~~ +!!! error TS2322: Type '(number | symbol)[]' is not assignable to type 'number[]'. +!!! error TS2322: Type 'number | symbol' is not assignable to type 'number'. +!!! error TS2322: Type 'symbol' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray5.js b/tests/baselines/reference/iteratorSpreadInArray5.js index 0aa158a5dc..ee0bf11676 100644 --- a/tests/baselines/reference/iteratorSpreadInArray5.js +++ b/tests/baselines/reference/iteratorSpreadInArray5.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray5.ts] -var array: number[] = [0, 1, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array: number[] = [0, 1, ...new SymbolIterator]; //// [iteratorSpreadInArray5.js] -var array = [0, 1, ...new SymbolIterator]; class SymbolIterator { next() { return { @@ -27,3 +26,4 @@ class SymbolIterator { return this; } } +var array = [0, 1, ...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray6.errors.txt b/tests/baselines/reference/iteratorSpreadInArray6.errors.txt index 8148ce43de..e9b6954e6e 100644 --- a/tests/baselines/reference/iteratorSpreadInArray6.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray6.errors.txt @@ -1,16 +1,9 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(2,14): error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. +tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(15,14): error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. Type 'symbol[]' is not assignable to type 'number[]'. Type 'symbol' is not assignable to type 'number'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts (1 errors) ==== - var array: number[] = [0, 1]; - array.concat([...new SymbolIterator]); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. -!!! error TS2345: Type 'symbol[]' is not assignable to type 'number[]'. -!!! error TS2345: Type 'symbol' is not assignable to type 'number'. - class SymbolIterator { next() { return { @@ -22,4 +15,11 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(2,14): error TS2345 [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var array: number[] = [0, 1]; + array.concat([...new SymbolIterator]); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. +!!! error TS2345: Type 'symbol[]' is not assignable to type 'number[]'. +!!! error TS2345: Type 'symbol' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray6.js b/tests/baselines/reference/iteratorSpreadInArray6.js index 02d1c435b8..36b5fcf5cf 100644 --- a/tests/baselines/reference/iteratorSpreadInArray6.js +++ b/tests/baselines/reference/iteratorSpreadInArray6.js @@ -1,7 +1,4 @@ //// [iteratorSpreadInArray6.ts] -var array: number[] = [0, 1]; -array.concat([...new SymbolIterator]); - class SymbolIterator { next() { return { @@ -13,11 +10,12 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array: number[] = [0, 1]; +array.concat([...new SymbolIterator]); //// [iteratorSpreadInArray6.js] -var array = [0, 1]; -array.concat([...new SymbolIterator]); class SymbolIterator { next() { return { @@ -29,3 +27,5 @@ class SymbolIterator { return this; } } +var array = [0, 1]; +array.concat([...new SymbolIterator]); diff --git a/tests/baselines/reference/iteratorSpreadInArray7.js b/tests/baselines/reference/iteratorSpreadInArray7.js index 72a614ae4e..aa209609b2 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.js +++ b/tests/baselines/reference/iteratorSpreadInArray7.js @@ -1,7 +1,4 @@ //// [iteratorSpreadInArray7.ts] -var array: symbol[]; -array.concat([...new SymbolIterator]); - class SymbolIterator { next() { return { @@ -13,11 +10,12 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array: symbol[]; +array.concat([...new SymbolIterator]); //// [iteratorSpreadInArray7.js] -var array; -array.concat([...new SymbolIterator]); class SymbolIterator { next() { return { @@ -29,3 +27,5 @@ class SymbolIterator { return this; } } +var array; +array.concat([...new SymbolIterator]); diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index 57774bcd7e..534741a62a 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -1,26 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts === -var array: symbol[]; ->array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3)) - -array.concat([...new SymbolIterator]); ->array.concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3)) ->concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray7.ts, 3, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray7.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 3, 28)) }; } @@ -31,6 +22,16 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 0, 0)) } } + +var array: symbol[]; +>array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 13, 3)) + +array.concat([...new SymbolIterator]); +>array.concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 13, 3)) +>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray7.types b/tests/baselines/reference/iteratorSpreadInArray7.types index ef0e3898e0..b102c72486 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.types +++ b/tests/baselines/reference/iteratorSpreadInArray7.types @@ -1,17 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts === -var array: symbol[]; ->array : symbol[] - -array.concat([...new SymbolIterator]); ->array.concat([...new SymbolIterator]) : symbol[] ->array.concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; } ->array : symbol[] ->concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; } ->[...new SymbolIterator] : symbol[] ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -42,3 +29,17 @@ class SymbolIterator { >this : this } } + +var array: symbol[]; +>array : symbol[] + +array.concat([...new SymbolIterator]); +>array.concat([...new SymbolIterator]) : symbol[] +>array.concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; } +>array : symbol[] +>concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; } +>[...new SymbolIterator] : symbol[] +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray8.errors.txt b/tests/baselines/reference/iteratorSpreadInArray8.errors.txt index 365bc8db9c..1f8c962942 100644 --- a/tests/baselines/reference/iteratorSpreadInArray8.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray8.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts(1,17): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. +tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts(10,17): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts (1 errors) ==== - var array = [...new SymbolIterator]; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. - class SymbolIterator { next() { return { @@ -13,4 +9,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts(1,17): error TS2488 done: false }; } - } \ No newline at end of file + } + + var array = [...new SymbolIterator]; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray8.js b/tests/baselines/reference/iteratorSpreadInArray8.js index 0837869912..c2a0becb0d 100644 --- a/tests/baselines/reference/iteratorSpreadInArray8.js +++ b/tests/baselines/reference/iteratorSpreadInArray8.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray8.ts] -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -8,10 +6,11 @@ class SymbolIterator { done: false }; } -} +} + +var array = [...new SymbolIterator]; //// [iteratorSpreadInArray8.js] -var array = [...new SymbolIterator]; class SymbolIterator { next() { return { @@ -20,3 +19,4 @@ class SymbolIterator { }; } } +var array = [...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray9.errors.txt b/tests/baselines/reference/iteratorSpreadInArray9.errors.txt index 90b8bdbeb4..5f43bb4f5a 100644 --- a/tests/baselines/reference/iteratorSpreadInArray9.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterable'. +tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(13,17): error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterable'. Types of property '[Symbol.iterator]' are incompatible. Type '() => SymbolIterator' is not assignable to type '() => Iterator'. Type 'SymbolIterator' is not assignable to type 'Iterator'. @@ -9,17 +9,6 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322 ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts (1 errors) ==== - var array = [...new SymbolIterator]; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterable'. -!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2322: Type '() => SymbolIterator' is not assignable to type '() => Iterator'. -!!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. -!!! error TS2322: Type '{ value: symbol; }' is not assignable to type 'IteratorResult'. -!!! error TS2322: Property 'done' is missing in type '{ value: symbol; }'. - class SymbolIterator { next() { return { @@ -30,4 +19,15 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322 [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var array = [...new SymbolIterator]; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterable'. +!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. +!!! error TS2322: Type '() => SymbolIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type '{ value: symbol; }' is not assignable to type 'IteratorResult'. +!!! error TS2322: Property 'done' is missing in type '{ value: symbol; }'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray9.js b/tests/baselines/reference/iteratorSpreadInArray9.js index ed0a9b4ebe..8b3a02e5e1 100644 --- a/tests/baselines/reference/iteratorSpreadInArray9.js +++ b/tests/baselines/reference/iteratorSpreadInArray9.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray9.ts] -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -11,10 +9,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...new SymbolIterator]; //// [iteratorSpreadInArray9.js] -var array = [...new SymbolIterator]; class SymbolIterator { next() { return { @@ -25,3 +24,4 @@ class SymbolIterator { return this; } } +var array = [...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInCall.errors.txt b/tests/baselines/reference/iteratorSpreadInCall.errors.txt index 614153192d..d26f9ab644 100644 --- a/tests/baselines/reference/iteratorSpreadInCall.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ==== - foo(...new SymbolIterator); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - function foo(s: symbol) { } class SymbolIterator { next() { @@ -18,4 +14,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(1,1): error TS2346: S [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall.js b/tests/baselines/reference/iteratorSpreadInCall.js index f3bf17c032..a4b17cfb5e 100644 --- a/tests/baselines/reference/iteratorSpreadInCall.js +++ b/tests/baselines/reference/iteratorSpreadInCall.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall.ts] -foo(...new SymbolIterator); - function foo(s: symbol) { } class SymbolIterator { next() { @@ -13,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall.js] -foo(...new SymbolIterator); function foo(s) { } class SymbolIterator { next() { @@ -29,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt index 04d9045e86..bf478012c5 100644 --- a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ==== - foo(...new SymbolIterator); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - function foo(s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -19,4 +14,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(1,1): error TS2346: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall10.js b/tests/baselines/reference/iteratorSpreadInCall10.js index 14a08c9700..9fb1cf20a6 100644 --- a/tests/baselines/reference/iteratorSpreadInCall10.js +++ b/tests/baselines/reference/iteratorSpreadInCall10.js @@ -1,8 +1,5 @@ //// [iteratorSpreadInCall10.ts] -foo(...new SymbolIterator); - function foo(s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -14,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall10.js] -foo(...new SymbolIterator); function foo(s) { return s[0]; } class SymbolIterator { next() { @@ -30,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall11.js b/tests/baselines/reference/iteratorSpreadInCall11.js index d01eb259ef..adfbb03d71 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.js +++ b/tests/baselines/reference/iteratorSpreadInCall11.js @@ -1,8 +1,5 @@ //// [iteratorSpreadInCall11.ts] -foo(...new SymbolIterator); - function foo(...s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -14,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall11.js] -foo(...new SymbolIterator); function foo(...s) { return s[0]; } class SymbolIterator { next() { @@ -30,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index 098a7b9b9c..b6db07942d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -1,28 +1,24 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts === -foo(...new SymbolIterator); ->foo : Symbol(foo, Decl(iteratorSpreadInCall11.ts, 0, 27)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) - function foo(...s: T[]) { return s[0] } ->foo : Symbol(foo, Decl(iteratorSpreadInCall11.ts, 0, 27)) ->T : Symbol(T, Decl(iteratorSpreadInCall11.ts, 2, 13)) ->s : Symbol(s, Decl(iteratorSpreadInCall11.ts, 2, 16)) ->T : Symbol(T, Decl(iteratorSpreadInCall11.ts, 2, 13)) ->s : Symbol(s, Decl(iteratorSpreadInCall11.ts, 2, 16)) +>foo : Symbol(foo, Decl(iteratorSpreadInCall11.ts, 0, 0)) +>T : Symbol(T, Decl(iteratorSpreadInCall11.ts, 0, 13)) +>s : Symbol(s, Decl(iteratorSpreadInCall11.ts, 0, 16)) +>T : Symbol(T, Decl(iteratorSpreadInCall11.ts, 0, 13)) +>s : Symbol(s, Decl(iteratorSpreadInCall11.ts, 0, 16)) class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 0, 42)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall11.ts, 4, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall11.ts, 1, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 3, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) +>done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 4, 28)) }; } @@ -33,6 +29,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 0, 42)) } } + +foo(...new SymbolIterator); +>foo : Symbol(foo, Decl(iteratorSpreadInCall11.ts, 0, 0)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 0, 42)) + diff --git a/tests/baselines/reference/iteratorSpreadInCall11.types b/tests/baselines/reference/iteratorSpreadInCall11.types index 5990b26df6..4a3d73d36d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.types +++ b/tests/baselines/reference/iteratorSpreadInCall11.types @@ -1,11 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts === -foo(...new SymbolIterator); ->foo(...new SymbolIterator) : symbol ->foo : (...s: T[]) => T ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - function foo(...s: T[]) { return s[0] } >foo : (...s: T[]) => T >T : T @@ -45,3 +38,11 @@ class SymbolIterator { >this : this } } + +foo(...new SymbolIterator); +>foo(...new SymbolIterator) : symbol +>foo : (...s: T[]) => T +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInCall12.js b/tests/baselines/reference/iteratorSpreadInCall12.js index b138192826..ba8149e29d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.js +++ b/tests/baselines/reference/iteratorSpreadInCall12.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall12.ts] -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); - class Foo { constructor(...s: T[]) { } } @@ -29,10 +27,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); //// [iteratorSpreadInCall12.js] -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); class Foo { constructor(...s) { } } @@ -58,3 +57,4 @@ class StringIterator { return this; } } +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index f989860f04..983ab8fcd9 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -1,31 +1,26 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts === -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); ->Foo : Symbol(Foo, Decl(iteratorSpreadInCall12.ts, 0, 64)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) - class Foo { ->Foo : Symbol(Foo, Decl(iteratorSpreadInCall12.ts, 0, 64)) ->T : Symbol(T, Decl(iteratorSpreadInCall12.ts, 2, 10)) +>Foo : Symbol(Foo, Decl(iteratorSpreadInCall12.ts, 0, 0)) +>T : Symbol(T, Decl(iteratorSpreadInCall12.ts, 0, 10)) constructor(...s: T[]) { } ->s : Symbol(s, Decl(iteratorSpreadInCall12.ts, 3, 16)) ->T : Symbol(T, Decl(iteratorSpreadInCall12.ts, 2, 10)) +>s : Symbol(s, Decl(iteratorSpreadInCall12.ts, 1, 16)) +>T : Symbol(T, Decl(iteratorSpreadInCall12.ts, 0, 10)) } class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 2, 1)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall12.ts, 6, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall12.ts, 4, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 6, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) +>done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 7, 28)) }; } @@ -36,22 +31,22 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 2, 1)) } } class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) +>StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall12.ts, 19, 22)) +>next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall12.ts, 17, 22)) return { value: "", ->value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 21, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 19, 16)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 22, 22)) +>done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 20, 22)) }; } @@ -62,6 +57,12 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) +>this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) } } + +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); +>Foo : Symbol(Foo, Decl(iteratorSpreadInCall12.ts, 0, 0)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 2, 1)) +>StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) + diff --git a/tests/baselines/reference/iteratorSpreadInCall12.types b/tests/baselines/reference/iteratorSpreadInCall12.types index b614fdde16..55986b5764 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.types +++ b/tests/baselines/reference/iteratorSpreadInCall12.types @@ -1,18 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts === -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); ->new Foo(...[...new SymbolIterator, ...[...new StringIterator]]) : Foo ->Foo : typeof Foo ->...[...new SymbolIterator, ...[...new StringIterator]] : string | symbol ->[...new SymbolIterator, ...[...new StringIterator]] : (string | symbol)[] ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator ->...[...new StringIterator] : string ->[...new StringIterator] : string[] ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class Foo { >Foo : Foo >T : T @@ -82,3 +68,18 @@ class StringIterator { >this : this } } + +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); +>new Foo(...[...new SymbolIterator, ...[...new StringIterator]]) : Foo +>Foo : typeof Foo +>...[...new SymbolIterator, ...[...new StringIterator]] : string | symbol +>[...new SymbolIterator, ...[...new StringIterator]] : (string | symbol)[] +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator +>...[...new StringIterator] : string +>[...new StringIterator] : string[] +>...new StringIterator : string +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt index bd994ab37b..abf8fc71ed 100644 --- a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ==== - foo(...new SymbolIterator); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - function foo(s: symbol[]) { } class SymbolIterator { next() { @@ -18,4 +14,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(1,1): error TS2346: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall2.js b/tests/baselines/reference/iteratorSpreadInCall2.js index 6c3517857d..e858a7cd72 100644 --- a/tests/baselines/reference/iteratorSpreadInCall2.js +++ b/tests/baselines/reference/iteratorSpreadInCall2.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall2.ts] -foo(...new SymbolIterator); - function foo(s: symbol[]) { } class SymbolIterator { next() { @@ -13,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall2.js] -foo(...new SymbolIterator); function foo(s) { } class SymbolIterator { next() { @@ -29,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall3.js b/tests/baselines/reference/iteratorSpreadInCall3.js index b33ceae7bf..9dd0c23add 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.js +++ b/tests/baselines/reference/iteratorSpreadInCall3.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall3.ts] -foo(...new SymbolIterator); - function foo(...s: symbol[]) { } class SymbolIterator { next() { @@ -13,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall3.js] -foo(...new SymbolIterator); function foo(...s) { } class SymbolIterator { next() { @@ -29,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index 8557b6c831..d8f414bcd7 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -1,25 +1,21 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts === -foo(...new SymbolIterator); ->foo : Symbol(foo, Decl(iteratorSpreadInCall3.ts, 0, 27)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) - function foo(...s: symbol[]) { } ->foo : Symbol(foo, Decl(iteratorSpreadInCall3.ts, 0, 27)) ->s : Symbol(s, Decl(iteratorSpreadInCall3.ts, 2, 13)) +>foo : Symbol(foo, Decl(iteratorSpreadInCall3.ts, 0, 0)) +>s : Symbol(s, Decl(iteratorSpreadInCall3.ts, 0, 13)) class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 0, 32)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall3.ts, 3, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall3.ts, 1, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 3, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) +>done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 4, 28)) }; } @@ -30,6 +26,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 0, 32)) } } + +foo(...new SymbolIterator); +>foo : Symbol(foo, Decl(iteratorSpreadInCall3.ts, 0, 0)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 0, 32)) + diff --git a/tests/baselines/reference/iteratorSpreadInCall3.types b/tests/baselines/reference/iteratorSpreadInCall3.types index 56b7f6db6d..fef9f7dcab 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.types +++ b/tests/baselines/reference/iteratorSpreadInCall3.types @@ -1,11 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts === -foo(...new SymbolIterator); ->foo(...new SymbolIterator) : void ->foo : (...s: symbol[]) => void ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - function foo(...s: symbol[]) { } >foo : (...s: symbol[]) => void >s : symbol[] @@ -40,3 +33,11 @@ class SymbolIterator { >this : this } } + +foo(...new SymbolIterator); +>foo(...new SymbolIterator) : void +>foo : (...s: symbol[]) => void +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt index 0e0a40a512..3beaf2ce65 100644 --- a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts (1 errors) ==== - foo(...new SymbolIterator); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - function foo(s1: symbol, ...s: symbol[]) { } class SymbolIterator { next() { @@ -18,4 +14,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(1,1): error TS2346: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall4.js b/tests/baselines/reference/iteratorSpreadInCall4.js index 7819a1ba6f..a0d655c25a 100644 --- a/tests/baselines/reference/iteratorSpreadInCall4.js +++ b/tests/baselines/reference/iteratorSpreadInCall4.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall4.ts] -foo(...new SymbolIterator); - function foo(s1: symbol, ...s: symbol[]) { } class SymbolIterator { next() { @@ -13,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall4.js] -foo(...new SymbolIterator); function foo(s1, ...s) { } class SymbolIterator { next() { @@ -29,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall5.js b/tests/baselines/reference/iteratorSpreadInCall5.js index a4a30ee016..b17054363e 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.js +++ b/tests/baselines/reference/iteratorSpreadInCall5.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall5.ts] -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: (symbol | string)[]) { } class SymbolIterator { next() { @@ -26,10 +24,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator, ...new StringIterator); //// [iteratorSpreadInCall5.js] -foo(...new SymbolIterator, ...new StringIterator); function foo(...s) { } class SymbolIterator { next() { @@ -53,3 +52,4 @@ class StringIterator { return this; } } +foo(...new SymbolIterator, ...new StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 0ed608e058..81143b79f2 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -1,26 +1,21 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts === -foo(...new SymbolIterator, ...new StringIterator); ->foo : Symbol(foo, Decl(iteratorSpreadInCall5.ts, 0, 50)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) - function foo(...s: (symbol | string)[]) { } ->foo : Symbol(foo, Decl(iteratorSpreadInCall5.ts, 0, 50)) ->s : Symbol(s, Decl(iteratorSpreadInCall5.ts, 2, 13)) +>foo : Symbol(foo, Decl(iteratorSpreadInCall5.ts, 0, 0)) +>s : Symbol(s, Decl(iteratorSpreadInCall5.ts, 0, 13)) class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 0, 43)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall5.ts, 3, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall5.ts, 1, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 3, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) +>done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 4, 28)) }; } @@ -31,22 +26,22 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 0, 43)) } } class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) +>StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall5.ts, 16, 22)) +>next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall5.ts, 14, 22)) return { value: "", ->value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 18, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 16, 16)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 19, 22)) +>done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 17, 22)) }; } @@ -57,6 +52,12 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) +>this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) } } + +foo(...new SymbolIterator, ...new StringIterator); +>foo : Symbol(foo, Decl(iteratorSpreadInCall5.ts, 0, 0)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 0, 43)) +>StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) + diff --git a/tests/baselines/reference/iteratorSpreadInCall5.types b/tests/baselines/reference/iteratorSpreadInCall5.types index 9542a76daf..a4f16829d5 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.types +++ b/tests/baselines/reference/iteratorSpreadInCall5.types @@ -1,14 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts === -foo(...new SymbolIterator, ...new StringIterator); ->foo(...new SymbolIterator, ...new StringIterator) : void ->foo : (...s: (string | symbol)[]) => void ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - function foo(...s: (symbol | string)[]) { } >foo : (...s: (string | symbol)[]) => void >s : (string | symbol)[] @@ -73,3 +63,14 @@ class StringIterator { >this : this } } + +foo(...new SymbolIterator, ...new StringIterator); +>foo(...new SymbolIterator, ...new StringIterator) : void +>foo : (...s: (string | symbol)[]) => void +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator +>...new StringIterator : string +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/iteratorSpreadInCall6.errors.txt b/tests/baselines/reference/iteratorSpreadInCall6.errors.txt index 93aaec8c33..2c89c7bb49 100644 --- a/tests/baselines/reference/iteratorSpreadInCall6.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall6.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(1,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. +tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(28,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts (1 errors) ==== - foo(...new SymbolIterator, ...new StringIterator); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. - function foo(...s: (symbol | number)[]) { } class SymbolIterator { next() { @@ -31,4 +27,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(1,28): error TS2345: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator, ...new StringIterator); + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall6.js b/tests/baselines/reference/iteratorSpreadInCall6.js index 8ad60be911..161f420ce0 100644 --- a/tests/baselines/reference/iteratorSpreadInCall6.js +++ b/tests/baselines/reference/iteratorSpreadInCall6.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall6.ts] -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: (symbol | number)[]) { } class SymbolIterator { next() { @@ -26,10 +24,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator, ...new StringIterator); //// [iteratorSpreadInCall6.js] -foo(...new SymbolIterator, ...new StringIterator); function foo(...s) { } class SymbolIterator { next() { @@ -53,3 +52,4 @@ class StringIterator { return this; } } +foo(...new SymbolIterator, ...new StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall7.errors.txt b/tests/baselines/reference/iteratorSpreadInCall7.errors.txt index 51cae1d72b..30096c90db 100644 --- a/tests/baselines/reference/iteratorSpreadInCall7.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall7.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(1,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(28,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts (1 errors) ==== - foo(...new SymbolIterator, ...new StringIterator); - ~~~ -!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. - function foo(...s: T[]) { return s[0]; } class SymbolIterator { next() { @@ -33,4 +28,9 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(1,1): error TS2453: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator, ...new StringIterator); + ~~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall7.js b/tests/baselines/reference/iteratorSpreadInCall7.js index 4a56b75d23..e7c354413d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall7.js +++ b/tests/baselines/reference/iteratorSpreadInCall7.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall7.ts] -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: T[]) { return s[0]; } class SymbolIterator { next() { @@ -26,10 +24,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator, ...new StringIterator); //// [iteratorSpreadInCall7.js] -foo(...new SymbolIterator, ...new StringIterator); function foo(...s) { return s[0]; } class SymbolIterator { next() { @@ -53,3 +52,4 @@ class StringIterator { return this; } } +foo(...new SymbolIterator, ...new StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall8.errors.txt b/tests/baselines/reference/iteratorSpreadInCall8.errors.txt index d7913458b6..5fd0b43ce5 100644 --- a/tests/baselines/reference/iteratorSpreadInCall8.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall8.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(1,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(31,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts (1 errors) ==== - new Foo(...new SymbolIterator, ...new StringIterator); - ~~~ -!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. - class Foo { constructor(...s: T[]) { } } @@ -36,4 +31,9 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(1,5): error TS2453: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + new Foo(...new SymbolIterator, ...new StringIterator); + ~~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall8.js b/tests/baselines/reference/iteratorSpreadInCall8.js index 3871ff83bc..a591fd363a 100644 --- a/tests/baselines/reference/iteratorSpreadInCall8.js +++ b/tests/baselines/reference/iteratorSpreadInCall8.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall8.ts] -new Foo(...new SymbolIterator, ...new StringIterator); - class Foo { constructor(...s: T[]) { } } @@ -29,10 +27,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +new Foo(...new SymbolIterator, ...new StringIterator); //// [iteratorSpreadInCall8.js] -new Foo(...new SymbolIterator, ...new StringIterator); class Foo { constructor(...s) { } } @@ -58,3 +57,4 @@ class StringIterator { return this; } } +new Foo(...new SymbolIterator, ...new StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall9.errors.txt b/tests/baselines/reference/iteratorSpreadInCall9.errors.txt index da2ee7f8ef..59854bd36a 100644 --- a/tests/baselines/reference/iteratorSpreadInCall9.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall9.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(1,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(31,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts (1 errors) ==== - new Foo(...new SymbolIterator, ...[...new StringIterator]); - ~~~ -!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. - class Foo { constructor(...s: T[]) { } } @@ -36,4 +31,10 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(1,5): error TS2453: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + new Foo(...new SymbolIterator, ...[...new StringIterator]); + ~~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall9.js b/tests/baselines/reference/iteratorSpreadInCall9.js index da80c461b1..3f54728fd8 100644 --- a/tests/baselines/reference/iteratorSpreadInCall9.js +++ b/tests/baselines/reference/iteratorSpreadInCall9.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall9.ts] -new Foo(...new SymbolIterator, ...[...new StringIterator]); - class Foo { constructor(...s: T[]) { } } @@ -29,10 +27,12 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +new Foo(...new SymbolIterator, ...[...new StringIterator]); + //// [iteratorSpreadInCall9.js] -new Foo(...new SymbolIterator, ...[...new StringIterator]); class Foo { constructor(...s) { } } @@ -58,3 +58,4 @@ class StringIterator { return this; } } +new Foo(...new SymbolIterator, ...[...new StringIterator]); diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index 3eda1c1178..c2384f151b 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -1,39 +1,71 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(11,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. Type 'T[string]' is not assignable to type 'U[keyof T]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(16,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(20,5): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,5): error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. Type 'T[string]' is not assignable to type 'U[keyof U]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof U]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,12): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(25,5): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,12): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(30,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. + Type 'undefined' is not assignable to type 'T[string]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(35,5): error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[K]'. + Type 'undefined' is not assignable to type 'T[string]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(40,5): error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. + Type 'undefined' is not assignable to type 'T[string]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. Type 'T[string]' is not assignable to type 'U[keyof T]'. - Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. - Type 'T[string]' is not assignable to type 'U[keyof T]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(45,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[K]'. + Type 'undefined' is not assignable to type 'T[string]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. Type 'T[string]' is not assignable to type 'U[K] | undefined'. Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[K]'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(51,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(56,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2542: Index signature in type 'Readonly' only permits reading. @@ -44,7 +76,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(125,5): error TS tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(141,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. Type 'T[P]' is not assignable to type 'U[P]'. Type 'T[string]' is not assignable to type 'U[P]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[P]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(146,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. Type 'keyof U' is not assignable to type 'keyof T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(151,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. @@ -56,7 +92,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(161,5): error TS tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. Type 'T[P]' is not assignable to type 'U[P]'. Type 'T[string]' is not assignable to type 'U[P]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[P]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. ==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (27 errors) ==== @@ -74,7 +114,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS ~~~~ !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f4(x: T, y: U, k: K) { @@ -83,7 +127,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f5(x: T, y: U, k: keyof U) { @@ -94,7 +142,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS ~~~~ !!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof U]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. } @@ -107,7 +159,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'K' cannot be used to index type 'T'. } @@ -117,6 +173,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS ~~~~ !!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. !!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; } @@ -125,6 +182,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS ~~~~ !!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. !!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; } @@ -133,14 +191,21 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS ~~~~ !!! error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. !!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f13(x: T, y: Partial, k: K) { @@ -148,14 +213,21 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS ~~~~ !!! error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. !!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f20(x: T, y: Readonly, k: keyof T) { @@ -269,7 +341,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS !!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[P]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { @@ -311,6 +387,10 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(166,5): error TS !!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[P]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForIn.js b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.js new file mode 100644 index 0000000000..c5f4319c74 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.js @@ -0,0 +1,13 @@ +//// [nonPrimitiveIndexingWithForIn.ts] +var a: object; + +for (var key in a) { + var value = a[key]; +} + + +//// [nonPrimitiveIndexingWithForIn.js] +var a; +for (var key in a) { + var value = a[key]; +} diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForIn.symbols b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.symbols new file mode 100644 index 0000000000..3cb4126954 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts === +var a: object; +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForIn.ts, 0, 3)) + +for (var key in a) { +>key : Symbol(key, Decl(nonPrimitiveIndexingWithForIn.ts, 2, 8)) +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForIn.ts, 0, 3)) + + var value = a[key]; +>value : Symbol(value, Decl(nonPrimitiveIndexingWithForIn.ts, 3, 7)) +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForIn.ts, 0, 3)) +>key : Symbol(key, Decl(nonPrimitiveIndexingWithForIn.ts, 2, 8)) +} + diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForIn.types b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.types new file mode 100644 index 0000000000..44e2b3f4d5 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts === +var a: object; +>a : object + +for (var key in a) { +>key : string +>a : object + + var value = a[key]; +>value : any +>a[key] : any +>a : object +>key : string +} + diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.errors.txt b/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.errors.txt new file mode 100644 index 0000000000..f7f2ee3db1 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts(4,17): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts (1 errors) ==== + var a: object; + + for (var key in a) { + var value = a[key]; // error + ~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.js b/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.js new file mode 100644 index 0000000000..e105e5ba9b --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.js @@ -0,0 +1,13 @@ +//// [nonPrimitiveIndexingWithForInNoImplicitAny.ts] +var a: object; + +for (var key in a) { + var value = a[key]; // error +} + + +//// [nonPrimitiveIndexingWithForInNoImplicitAny.js] +var a; +for (var key in a) { + var value = a[key]; // error +} diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.js b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.js new file mode 100644 index 0000000000..ce575b2a4d --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.js @@ -0,0 +1,13 @@ +//// [nonPrimitiveIndexingWithForInSupressError.ts] +var a: object; + +for (var key in a) { + var value = a[key]; +} + + +//// [nonPrimitiveIndexingWithForInSupressError.js] +var a; +for (var key in a) { + var value = a[key]; +} diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.symbols b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.symbols new file mode 100644 index 0000000000..4e52e66b1c --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts === +var a: object; +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 0, 3)) + +for (var key in a) { +>key : Symbol(key, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 2, 8)) +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 0, 3)) + + var value = a[key]; +>value : Symbol(value, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 3, 7)) +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 0, 3)) +>key : Symbol(key, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 2, 8)) +} + diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.types b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.types new file mode 100644 index 0000000000..3fafa40b59 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts === +var a: object; +>a : object + +for (var key in a) { +>key : string +>a : object + + var value = a[key]; +>value : any +>a[key] : any +>a : object +>key : string +} + diff --git a/tests/baselines/reference/parserRealSource10.errors.txt b/tests/baselines/reference/parserRealSource10.errors.txt index d6199636e6..ae48cd79b5 100644 --- a/tests/baselines/reference/parserRealSource10.errors.txt +++ b/tests/baselines/reference/parserRealSource10.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(127,33): error TS2449: Class 'TokenInfo' used before its declaration. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(127,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,36): error TS2304: Cannot find name 'string'. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. @@ -342,7 +343,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(356,53): error tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -==== tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts (342 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts (343 errors) ==== // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. @@ -472,6 +473,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,40): error } export var tokenTable = new TokenInfo[]; + ~~~~~~~~~ +!!! error TS2449: Class 'TokenInfo' used before its declaration. ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. export var nodeTypeTable = new string[]; diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt new file mode 100644 index 0000000000..2945950068 --- /dev/null +++ b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts(1,1): error TS2449: Class 'Foo' used before its declaration. +tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts(1,10): error TS2449: Class 'Foo' used before its declaration. + + +==== tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts (0 errors) ==== + import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); + export = Bar; + interface Bar { + foo: Foo; + } +==== tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts (2 errors) ==== + export = Foo; + ~~~~~~~~~~~~~ +!!! error TS2449: Class 'Foo' used before its declaration. + ~~~ +!!! error TS2449: Class 'Foo' used before its declaration. + class Foo { + constructor(public a: A) { } + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt index 56ca5158e0..23559cd9a3 100644 --- a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt +++ b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/privacyClassExtendsClauseDeclFile_GlobalFile.ts(16,67): error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(16,67): error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. -tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(19,63): error TS2690: A class must be declared after its base class. +tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(19,77): error TS2449: Class 'publicClassInPrivateModule' used before its declaration. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(21,69): error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. -tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(21,69): error TS2690: A class must be declared after its base class. +tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(21,83): error TS2449: Class 'publicClassInPrivateModule' used before its declaration. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(63,55): error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClass' has or is using private name 'privateClass'. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(68,65): error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. @@ -29,14 +29,14 @@ tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(68,65): } class privateClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2449: Class 'publicClassInPrivateModule' used before its declaration. } export class publicClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { // Should error ~~~~~~~~~~~~~ !!! error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2449: Class 'publicClassInPrivateModule' used before its declaration. } } diff --git a/tests/baselines/reference/recursiveBaseCheck3.errors.txt b/tests/baselines/reference/recursiveBaseCheck3.errors.txt index 97f7cadc3d..ba0ea669c5 100644 --- a/tests/baselines/reference/recursiveBaseCheck3.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck3.errors.txt @@ -1,12 +1,15 @@ tests/cases/compiler/recursiveBaseCheck3.ts(1,7): error TS2506: 'A' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck3.ts(1,20): error TS2449: Class 'C' used before its declaration. tests/cases/compiler/recursiveBaseCheck3.ts(2,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. tests/cases/compiler/recursiveBaseCheck3.ts(4,9): error TS2339: Property 'blah' does not exist on type 'C<{}>'. -==== tests/cases/compiler/recursiveBaseCheck3.ts (3 errors) ==== +==== tests/cases/compiler/recursiveBaseCheck3.ts (4 errors) ==== class A extends C { } ~ !!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'C' used before its declaration. class C extends A { } ~ !!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js index 704c39891e..616d5392c8 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js @@ -1,13 +1,13 @@ //// [recursiveClassInstantiationsWithDefaultConstructors.ts] -var a = new TypeScript2.MemberNameArray() module TypeScript2 { -export class MemberName { -public prefix: string = ""; + export class MemberName { + public prefix: string = ""; + } + export class MemberNameArray extends MemberName { + } } -export class MemberNameArray extends MemberName { -} -} - + +var a = new TypeScript2.MemberNameArray() //// [recursiveClassInstantiationsWithDefaultConstructors.js] var __extends = (this && this.__extends) || (function () { @@ -20,7 +20,6 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var a = new TypeScript2.MemberNameArray(); var TypeScript2; (function (TypeScript2) { var MemberName = (function () { @@ -39,3 +38,4 @@ var TypeScript2; }(MemberName)); TypeScript2.MemberNameArray = MemberNameArray; })(TypeScript2 || (TypeScript2 = {})); +var a = new TypeScript2.MemberNameArray(); diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.symbols b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.symbols index c722d8ef8f..7d87f5ec91 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.symbols +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.symbols @@ -1,22 +1,22 @@ === tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts === -var a = new TypeScript2.MemberNameArray() ->a : Symbol(a, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 3)) ->TypeScript2.MemberNameArray : Symbol(TypeScript2.MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 4, 1)) ->TypeScript2 : Symbol(TypeScript2, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 41)) ->MemberNameArray : Symbol(TypeScript2.MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 4, 1)) - module TypeScript2 { ->TypeScript2 : Symbol(TypeScript2, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 41)) +>TypeScript2 : Symbol(TypeScript2, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 0)) -export class MemberName { ->MemberName : Symbol(MemberName, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 1, 20)) + export class MemberName { +>MemberName : Symbol(MemberName, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 20)) -public prefix: string = ""; ->prefix : Symbol(MemberName.prefix, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 2, 25)) -} -export class MemberNameArray extends MemberName { ->MemberNameArray : Symbol(MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 4, 1)) ->MemberName : Symbol(MemberName, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 1, 20)) -} + public prefix: string = ""; +>prefix : Symbol(MemberName.prefix, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 1, 29)) + } + export class MemberNameArray extends MemberName { +>MemberNameArray : Symbol(MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 3, 5)) +>MemberName : Symbol(MemberName, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 20)) + } } +var a = new TypeScript2.MemberNameArray() +>a : Symbol(a, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 8, 3)) +>TypeScript2.MemberNameArray : Symbol(TypeScript2.MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 3, 5)) +>TypeScript2 : Symbol(TypeScript2, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 0)) +>MemberNameArray : Symbol(TypeScript2.MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 3, 5)) + diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types index 3e74ba7f57..f1cf5894cd 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types @@ -1,4 +1,20 @@ === tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts === +module TypeScript2 { +>TypeScript2 : typeof TypeScript2 + + export class MemberName { +>MemberName : MemberName + + public prefix: string = ""; +>prefix : string +>"" : "" + } + export class MemberNameArray extends MemberName { +>MemberNameArray : MemberNameArray +>MemberName : MemberName + } +} + var a = new TypeScript2.MemberNameArray() >a : TypeScript2.MemberNameArray >new TypeScript2.MemberNameArray() : TypeScript2.MemberNameArray @@ -6,19 +22,3 @@ var a = new TypeScript2.MemberNameArray() >TypeScript2 : typeof TypeScript2 >MemberNameArray : typeof TypeScript2.MemberNameArray -module TypeScript2 { ->TypeScript2 : typeof TypeScript2 - -export class MemberName { ->MemberName : MemberName - -public prefix: string = ""; ->prefix : string ->"" : "" -} -export class MemberNameArray extends MemberName { ->MemberNameArray : MemberNameArray ->MemberName : MemberName -} -} - diff --git a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.errors.txt b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.errors.txt index b9e650b644..bfb9a5127f 100644 --- a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.errors.txt +++ b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(2,35): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(9,44): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(45,39): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(60,34): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(96,33): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(114,40): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(126,34): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(182,42): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(199,39): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(247,35): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(272,30): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(301,33): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(403,44): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(436,45): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(469,44): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(490,34): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(495,39): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(500,38): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(534,42): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(549,41): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(580,45): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(589,44): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(605,46): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42): error TS2690: A class must be declared after its base class. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(2,45): error TS2449: Class 'nitidus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(9,56): error TS2449: Class 'mixtus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(45,48): error TS2449: Class 'psilurus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(60,44): error TS2449: Class 'jugularis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(96,44): error TS2449: Class 'aurata' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(114,48): error TS2449: Class 'gilbertii' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(126,43): error TS2449: Class 'johorensis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(182,54): error TS2449: Class 'falconeri' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(199,47): error TS2449: Class 'pygmaea' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(247,46): error TS2449: Class 'ciliolabrum' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(272,35): error TS2449: Class 'coludo' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(301,41): error TS2449: Class 'oreas' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(403,53): error TS2449: Class 'johorensis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(436,55): error TS2449: Class 'punicus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(469,52): error TS2449: Class 'stolzmanni' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(490,42): error TS2449: Class 'portoricensis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(495,50): error TS2449: Class 'pelurus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(500,49): error TS2449: Class 'lasiurus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(534,50): error TS2449: Class 'stolzmanni' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(549,53): error TS2449: Class 'daphaenodon' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(580,54): error TS2449: Class 'johorensis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(589,52): error TS2449: Class 'stolzmanni' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(605,55): error TS2449: Class 'psilurus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,53): error TS2449: Class 'lasiurus' used before its declaration. ==== tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts (24 errors) ==== module rionegrensis { export class caniventer extends Lanthanum.nitidus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~ +!!! error TS2449: Class 'nitidus' used before its declaration. salomonseni() : caniventer { var x : caniventer; () => { var y = this; }; return x; } uchidai() : lavali.xanthognathus { var x : lavali.xanthognathus; () => { var y = this; }; return x; } raffrayana() : lavali.otion { var x : lavali.otion; () => { var y = this; }; return x; } @@ -36,8 +36,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 nayaur() : gabriellae.amicus { var x : gabriellae.amicus; () => { var y = this; }; return x; } } export class veraecrucis extends trivirgatus.mixtus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~ +!!! error TS2449: Class 'mixtus' used before its declaration. naso() : panamensis.setulosus> { var x : panamensis.setulosus>; () => { var y = this; }; return x; } vancouverensis() : imperfecta.ciliolabrum { var x : imperfecta.ciliolabrum; () => { var y = this; }; return x; } africana() : argurus.gilbertii, sagitta.cinereus> { var x : argurus.gilbertii, sagitta.cinereus>; () => { var y = this; }; return x; } @@ -74,8 +74,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 porcellus() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } } export class oralis extends caurinus.psilurus { - ~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~ +!!! error TS2449: Class 'psilurus' used before its declaration. cepapi() : caurinus.psilurus { var x : caurinus.psilurus; () => { var y = this; }; return x; } porteri() : lavali.thaeleri { var x : lavali.thaeleri; () => { var y = this; }; return x; } bindi() : caurinus.mahaganus> { var x : caurinus.mahaganus>; () => { var y = this; }; return x; } @@ -91,8 +91,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 eisentrauti() : rendalli.zuluensis { var x : rendalli.zuluensis; () => { var y = this; }; return x; } } export class sumatrana extends Lanthanum.jugularis { - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~ +!!! error TS2449: Class 'jugularis' used before its declaration. wolffsohni() : Lanthanum.suillus { var x : Lanthanum.suillus; () => { var y = this; }; return x; } geata() : ruatanica.hector { var x : ruatanica.hector; () => { var y = this; }; return x; } awashensis() : petrophilus.minutilla { var x : petrophilus.minutilla; () => { var y = this; }; return x; } @@ -129,8 +129,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 olchonensis() : rendalli.crenulata { var x : rendalli.crenulata; () => { var y = this; }; return x; } } export class durangae extends dogramacii.aurata { - ~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~ +!!! error TS2449: Class 'aurata' used before its declaration. Californium() : panamensis.setulosus { var x : panamensis.setulosus; () => { var y = this; }; return x; } Flerovium() : howi.angulatus { var x : howi.angulatus; () => { var y = this; }; return x; } phrudus() : sagitta.stolzmanni { var x : sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -149,8 +149,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 anatolicus() : julianae.steerii { var x : julianae.steerii; () => { var y = this; }; return x; } } export class nitidus extends argurus.gilbertii { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~ +!!! error TS2449: Class 'gilbertii' used before its declaration. granatensis() : quasiater.bobrinskoi { var x : quasiater.bobrinskoi; () => { var y = this; }; return x; } negligens() : minutus.inez { var x : minutus.inez; () => { var y = this; }; return x; } lewisi() : julianae.oralis { var x : julianae.oralis; () => { var y = this; }; return x; } @@ -163,8 +163,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 bicornis() : dogramacii.kaiseri { var x : dogramacii.kaiseri; () => { var y = this; }; return x; } } export class megalonyx extends caurinus.johorensis { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'johorensis' used before its declaration. phillipsii() : macrorhinos.konganensis { var x : macrorhinos.konganensis; () => { var y = this; }; return x; } melanogaster() : rionegrensis.veraecrucis { var x : rionegrensis.veraecrucis; () => { var y = this; }; return x; } elaphus() : nitidus { var x : nitidus; () => { var y = this; }; return x; } @@ -221,8 +221,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 biacensis() : howi.coludo { var x : howi.coludo; () => { var y = this; }; return x; } } export class crenulata extends trivirgatus.falconeri { - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~ +!!! error TS2449: Class 'falconeri' used before its declaration. salvanius() : howi.coludo { var x : howi.coludo; () => { var y = this; }; return x; } maritimus() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } edax() : lutreolus.cor>, rionegrensis.caniventer> { var x : lutreolus.cor>, rionegrensis.caniventer>; () => { var y = this; }; return x; } @@ -240,8 +240,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 vallinus() : sagitta.sicarius { var x : sagitta.sicarius; () => { var y = this; }; return x; } } export class mixtus extends argurus.pygmaea> { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~ +!!! error TS2449: Class 'pygmaea' used before its declaration. ochrogaster() : dogramacii.aurata { var x : dogramacii.aurata; () => { var y = this; }; return x; } bryophilus() : macrorhinos.marmosurus>> { var x : macrorhinos.marmosurus>>; () => { var y = this; }; return x; } liechtensteini() : rendalli.zuluensis { var x : rendalli.zuluensis; () => { var y = this; }; return x; } @@ -290,8 +290,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module ruatanica { export class americanus extends imperfecta.ciliolabrum { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~ +!!! error TS2449: Class 'ciliolabrum' used before its declaration. nasoloi() : macrorhinos.konganensis { var x : macrorhinos.konganensis; () => { var y = this; }; return x; } mystacalis() : howi.angulatus { var x : howi.angulatus; () => { var y = this; }; return x; } fardoulisi() : trivirgatus.oconnelli { var x : trivirgatus.oconnelli; () => { var y = this; }; return x; } @@ -317,8 +317,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 export class beisa { } export class otion extends howi.coludo { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~ +!!! error TS2449: Class 'coludo' used before its declaration. bonaerensis() : provocax.melanoleuca { var x : provocax.melanoleuca; () => { var y = this; }; return x; } dussumieri() : nigra.gracilis { var x : nigra.gracilis; () => { var y = this; }; return x; } osvaldoreigi() : julianae.albidens { var x : julianae.albidens; () => { var y = this; }; return x; } @@ -348,8 +348,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 coyhaiquensis() : caurinus.mahaganus, panglima.abidi>, lutreolus.punicus> { var x : caurinus.mahaganus, panglima.abidi>, lutreolus.punicus>; () => { var y = this; }; return x; } } export class thaeleri extends argurus.oreas { - ~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~ +!!! error TS2449: Class 'oreas' used before its declaration. coromandra() : julianae.galapagoensis { var x : julianae.galapagoensis; () => { var y = this; }; return x; } parvipes() : nigra.dolichurus { var x : nigra.dolichurus; () => { var y = this; }; return x; } sponsorius() : rionegrensis.veraecrucis, julianae.steerii> { var x : rionegrensis.veraecrucis, julianae.steerii>; () => { var y = this; }; return x; } @@ -452,8 +452,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module panglima { export class amphibius extends caurinus.johorensis, Lanthanum.jugularis> { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'johorensis' used before its declaration. bottegi(): macrorhinos.marmosurus, gabriellae.echinatus>, sagitta.stolzmanni> { var x: macrorhinos.marmosurus, gabriellae.echinatus>, sagitta.stolzmanni>; () => { var y = this; }; return x; } jerdoni(): macrorhinos.daphaenodon { var x: macrorhinos.daphaenodon; () => { var y = this; }; return x; } camtschatica(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } @@ -487,8 +487,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module minutus { export class himalayana extends lutreolus.punicus { - ~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~ +!!! error TS2449: Class 'punicus' used before its declaration. simoni(): argurus.netscheri> { var x: argurus.netscheri>; () => { var y = this; }; return x; } lobata(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } rusticus(): dogramacii.aurata { var x: dogramacii.aurata; () => { var y = this; }; return x; } @@ -522,8 +522,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module howi { export class angulatus extends sagitta.stolzmanni { - ~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'stolzmanni' used before its declaration. pennatus(): howi.marcanoi { var x: howi.marcanoi; () => { var y = this; }; return x; } } } @@ -545,22 +545,22 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module sagitta { export class walkeri extends minutus.portoricensis { - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~~~ +!!! error TS2449: Class 'portoricensis' used before its declaration. maracajuensis(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } } } module minutus { export class inez extends samarensis.pelurus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~ +!!! error TS2449: Class 'pelurus' used before its declaration. vexillaris(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } } } module macrorhinos { export class konganensis extends imperfecta.lasiurus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~ +!!! error TS2449: Class 'lasiurus' used before its declaration. } } module panamensis { @@ -595,8 +595,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module samarensis { export class pelurus extends sagitta.stolzmanni { - ~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'stolzmanni' used before its declaration. Palladium(): panamensis.linulus { var x: panamensis.linulus; () => { var y = this; }; return x; } castanea(): argurus.netscheri, julianae.oralis> { var x: argurus.netscheri, julianae.oralis>; () => { var y = this; }; return x; } chamek(): argurus.pygmaea { var x: argurus.pygmaea; () => { var y = this; }; return x; } @@ -612,8 +612,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 olitor(): rionegrensis.veraecrucis { var x: rionegrensis.veraecrucis; () => { var y = this; }; return x; } } export class fuscus extends macrorhinos.daphaenodon { - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~ +!!! error TS2449: Class 'daphaenodon' used before its declaration. planifrons(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } badia(): julianae.sumatrana { var x: julianae.sumatrana; () => { var y = this; }; return x; } prymnolopha(): sagitta.walkeri { var x: sagitta.walkeri; () => { var y = this; }; return x; } @@ -645,8 +645,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module sagitta { export class leptoceros extends caurinus.johorensis> { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'johorensis' used before its declaration. victus(): rionegrensis.caniventer { var x: rionegrensis.caniventer; () => { var y = this; }; return x; } hoplomyoides(): panglima.fundatus, nigra.gracilis> { var x: panglima.fundatus, nigra.gracilis>; () => { var y = this; }; return x; } gratiosus(): lavali.lepturus { var x: lavali.lepturus; () => { var y = this; }; return x; } @@ -656,8 +656,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module daubentonii { export class nigricans extends sagitta.stolzmanni { - ~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'stolzmanni' used before its declaration. woosnami(): dogramacii.robustulus { var x: dogramacii.robustulus; () => { var y = this; }; return x; } } } @@ -674,8 +674,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module chrysaeolus { export class sarasinorum extends caurinus.psilurus { - ~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~ +!!! error TS2449: Class 'psilurus' used before its declaration. belzebul(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } hinpoon(): nigra.caucasica { var x: nigra.caucasica; () => { var y = this; }; return x; } kandti(): quasiater.wattsi { var x: quasiater.wattsi; () => { var y = this; }; return x; } @@ -840,8 +840,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module gabriellae { export class klossii extends imperfecta.lasiurus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~ +!!! error TS2449: Class 'lasiurus' used before its declaration. } export class amicus { pirrensis(): argurus.luctuosa { var x: argurus.luctuosa; () => { var y = this; }; return x; } diff --git a/tests/baselines/reference/symbolProperty33.errors.txt b/tests/baselines/reference/symbolProperty33.errors.txt index b1dab90db3..a8e95fc5bd 100644 --- a/tests/baselines/reference/symbolProperty33.errors.txt +++ b/tests/baselines/reference/symbolProperty33.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/Symbols/symbolProperty33.ts(1,18): error TS2690: A class must be declared after its base class. +tests/cases/conformance/es6/Symbols/symbolProperty33.ts(1,18): error TS2449: Class 'C2' used before its declaration. tests/cases/conformance/es6/Symbols/symbolProperty33.ts(7,6): error TS1023: An index signature parameter type must be 'string' or 'number'. ==== tests/cases/conformance/es6/Symbols/symbolProperty33.ts (2 errors) ==== class C1 extends C2 { ~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'C2' used before its declaration. [Symbol.toStringTag]() { return { x: "" }; } diff --git a/tests/baselines/reference/symbolProperty34.errors.txt b/tests/baselines/reference/symbolProperty34.errors.txt index 98a9875bd5..3ff62c12ad 100644 --- a/tests/baselines/reference/symbolProperty34.errors.txt +++ b/tests/baselines/reference/symbolProperty34.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/Symbols/symbolProperty34.ts(1,18): error TS2690: A class must be declared after its base class. +tests/cases/conformance/es6/Symbols/symbolProperty34.ts(1,18): error TS2449: Class 'C2' used before its declaration. tests/cases/conformance/es6/Symbols/symbolProperty34.ts(7,6): error TS1023: An index signature parameter type must be 'string' or 'number'. ==== tests/cases/conformance/es6/Symbols/symbolProperty34.ts (2 errors) ==== class C1 extends C2 { ~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'C2' used before its declaration. [Symbol.toStringTag]() { return { x: "" }; } diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index a4c1c44909..97f59dea8e 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -1,8 +1,53 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "strict": true, - "sourceMap": false - } + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 23061360bc..b90e3fc6c5 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -1,9 +1,53 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "strict": true, - "sourceMap": false, - "noUnusedLocals": true - } + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + "noUnusedLocals": true /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 16535c7960..482cfa6a9d 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -1,9 +1,53 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "strict": true, - "sourceMap": false, - "jsx": "react" - } + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 133de87dc1..c6a26629da 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -1,13 +1,58 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "strict": true, - "sourceMap": false - }, - "files": [ - "file0.st", - "file1.ts", - "file2.ts" - ] + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + }, + "files": [ + "file0.st", + "file1.ts", + "file2.ts" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 2ab8d9412e..72289dd178 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -1,12 +1,53 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "strict": true, - "sourceMap": false, - "lib": [ - "es5", - "es2015.promise" - ] - } + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + "lib": ["es5","es2015.promise"], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index a4c1c44909..97f59dea8e 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -1,8 +1,53 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "strict": true, - "sourceMap": false - } + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 5716902e02..1ac7c8c54d 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -1,12 +1,53 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "strict": true, - "sourceMap": false, - "lib": [ - "es5", - "es2015.core" - ] - } + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + "lib": ["es5","es2015.core"], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 4fc209f9b9..33a9ecc5cd 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -1,12 +1,53 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "strict": true, - "sourceMap": false, - "types": [ - "jquery", - "mocha" - ] - } + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + "types": ["jquery","mocha"] /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsxSfcReturnNull.js b/tests/baselines/reference/tsxSfcReturnNull.js new file mode 100644 index 0000000000..8a332a7057 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNull.js @@ -0,0 +1,24 @@ +//// [file.tsx] + +import React = require('react'); + +const Foo = (props: any) => null; + +function Greet(x: {name?: string}) { + return null; +} + +const foo = ; +const G = ; + +//// [file.jsx] +define(["require", "exports", "react"], function (require, exports, React) { + "use strict"; + exports.__esModule = true; + var Foo = function (props) { return null; }; + function Greet(x) { + return null; + } + var foo = ; + var G = ; +}); diff --git a/tests/baselines/reference/tsxSfcReturnNull.symbols b/tests/baselines/reference/tsxSfcReturnNull.symbols new file mode 100644 index 0000000000..483b7db6c5 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNull.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +const Foo = (props: any) => null; +>Foo : Symbol(Foo, Decl(file.tsx, 3, 5)) +>props : Symbol(props, Decl(file.tsx, 3, 13)) + +function Greet(x: {name?: string}) { +>Greet : Symbol(Greet, Decl(file.tsx, 3, 33)) +>x : Symbol(x, Decl(file.tsx, 5, 15)) +>name : Symbol(name, Decl(file.tsx, 5, 19)) + + return null; +} + +const foo = ; +>foo : Symbol(foo, Decl(file.tsx, 9, 5)) +>Foo : Symbol(Foo, Decl(file.tsx, 3, 5)) + +const G = ; +>G : Symbol(G, Decl(file.tsx, 10, 5)) +>Greet : Symbol(Greet, Decl(file.tsx, 3, 33)) + diff --git a/tests/baselines/reference/tsxSfcReturnNull.types b/tests/baselines/reference/tsxSfcReturnNull.types new file mode 100644 index 0000000000..edc346b03e --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNull.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : typeof React + +const Foo = (props: any) => null; +>Foo : (props: any) => any +>(props: any) => null : (props: any) => any +>props : any +>null : null + +function Greet(x: {name?: string}) { +>Greet : (x: { name?: string; }) => any +>x : { name?: string; } +>name : string + + return null; +>null : null +} + +const foo = ; +>foo : JSX.Element +> : JSX.Element +>Foo : (props: any) => any + +const G = ; +>G : JSX.Element +> : JSX.Element +>Greet : (x: { name?: string; }) => any + diff --git a/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.js b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.js new file mode 100644 index 0000000000..8a332a7057 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.js @@ -0,0 +1,24 @@ +//// [file.tsx] + +import React = require('react'); + +const Foo = (props: any) => null; + +function Greet(x: {name?: string}) { + return null; +} + +const foo = ; +const G = ; + +//// [file.jsx] +define(["require", "exports", "react"], function (require, exports, React) { + "use strict"; + exports.__esModule = true; + var Foo = function (props) { return null; }; + function Greet(x) { + return null; + } + var foo = ; + var G = ; +}); diff --git a/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.symbols b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.symbols new file mode 100644 index 0000000000..483b7db6c5 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +const Foo = (props: any) => null; +>Foo : Symbol(Foo, Decl(file.tsx, 3, 5)) +>props : Symbol(props, Decl(file.tsx, 3, 13)) + +function Greet(x: {name?: string}) { +>Greet : Symbol(Greet, Decl(file.tsx, 3, 33)) +>x : Symbol(x, Decl(file.tsx, 5, 15)) +>name : Symbol(name, Decl(file.tsx, 5, 19)) + + return null; +} + +const foo = ; +>foo : Symbol(foo, Decl(file.tsx, 9, 5)) +>Foo : Symbol(Foo, Decl(file.tsx, 3, 5)) + +const G = ; +>G : Symbol(G, Decl(file.tsx, 10, 5)) +>Greet : Symbol(Greet, Decl(file.tsx, 3, 33)) + diff --git a/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.types b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.types new file mode 100644 index 0000000000..5268592b8d --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : typeof React + +const Foo = (props: any) => null; +>Foo : (props: any) => null +>(props: any) => null : (props: any) => null +>props : any +>null : null + +function Greet(x: {name?: string}) { +>Greet : (x: { name?: string | undefined; }) => null +>x : { name?: string | undefined; } +>name : string | undefined + + return null; +>null : null +} + +const foo = ; +>foo : JSX.Element +> : JSX.Element +>Foo : (props: any) => null + +const G = ; +>G : JSX.Element +> : JSX.Element +>Greet : (x: { name?: string | undefined; }) => null + diff --git a/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.errors.txt b/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.errors.txt new file mode 100644 index 0000000000..127eb4b0d4 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/jsx/file.tsx(10,13): error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements. +tests/cases/conformance/jsx/file.tsx(11,11): error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements. + + +==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== + + import React = require('react'); + + const Foo = (props: any) => undefined; + function Greet(x: {name?: string}) { + return undefined; + } + + // Error + const foo = ; + ~~~~~~~ +!!! error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements. + const G = ; + ~~~~~~~~~ +!!! error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements. \ No newline at end of file diff --git a/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.js b/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.js new file mode 100644 index 0000000000..0fcaa2f168 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.js @@ -0,0 +1,25 @@ +//// [file.tsx] + +import React = require('react'); + +const Foo = (props: any) => undefined; +function Greet(x: {name?: string}) { + return undefined; +} + +// Error +const foo = ; +const G = ; + +//// [file.jsx] +define(["require", "exports", "react"], function (require, exports, React) { + "use strict"; + exports.__esModule = true; + var Foo = function (props) { return undefined; }; + function Greet(x) { + return undefined; + } + // Error + var foo = ; + var G = ; +}); diff --git a/tests/baselines/reference/typeArgumentInferenceOrdering.js b/tests/baselines/reference/typeArgumentInferenceOrdering.js index d6e5666b55..f7a46c8438 100644 --- a/tests/baselines/reference/typeArgumentInferenceOrdering.js +++ b/tests/baselines/reference/typeArgumentInferenceOrdering.js @@ -1,7 +1,4 @@ //// [typeArgumentInferenceOrdering.ts] -function foo(f: { y: T }): T { return null } -var x = foo(new C()).x; // was Error that property x does not exist on type {} - class C { y: I; } @@ -13,13 +10,15 @@ interface I { interface Goo { p: string; } - + +function foo(f: { y: T }): T { return null } +var x = foo(new C()).x; // was Error that property x does not exist on type {} //// [typeArgumentInferenceOrdering.js] -function foo(f) { return null; } -var x = foo(new C()).x; // was Error that property x does not exist on type {} var C = (function () { function C() { } return C; }()); +function foo(f) { return null; } +var x = foo(new C()).x; // was Error that property x does not exist on type {} diff --git a/tests/baselines/reference/typeArgumentInferenceOrdering.symbols b/tests/baselines/reference/typeArgumentInferenceOrdering.symbols index 630aebcf18..0c01b4d8a5 100644 --- a/tests/baselines/reference/typeArgumentInferenceOrdering.symbols +++ b/tests/baselines/reference/typeArgumentInferenceOrdering.symbols @@ -1,39 +1,39 @@ === tests/cases/compiler/typeArgumentInferenceOrdering.ts === -function foo(f: { y: T }): T { return null } ->foo : Symbol(foo, Decl(typeArgumentInferenceOrdering.ts, 0, 0)) ->T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 0, 13)) ->f : Symbol(f, Decl(typeArgumentInferenceOrdering.ts, 0, 16)) ->y : Symbol(y, Decl(typeArgumentInferenceOrdering.ts, 0, 20)) ->T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 0, 13)) ->T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 0, 13)) - -var x = foo(new C()).x; // was Error that property x does not exist on type {} ->x : Symbol(x, Decl(typeArgumentInferenceOrdering.ts, 1, 3)) ->foo(new C()).x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 7, 13)) ->foo : Symbol(foo, Decl(typeArgumentInferenceOrdering.ts, 0, 0)) ->C : Symbol(C, Decl(typeArgumentInferenceOrdering.ts, 1, 23)) ->x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 7, 13)) - class C { ->C : Symbol(C, Decl(typeArgumentInferenceOrdering.ts, 1, 23)) +>C : Symbol(C, Decl(typeArgumentInferenceOrdering.ts, 0, 0)) y: I; ->y : Symbol(C.y, Decl(typeArgumentInferenceOrdering.ts, 3, 9)) ->I : Symbol(I, Decl(typeArgumentInferenceOrdering.ts, 5, 1)) +>y : Symbol(C.y, Decl(typeArgumentInferenceOrdering.ts, 0, 9)) +>I : Symbol(I, Decl(typeArgumentInferenceOrdering.ts, 2, 1)) } interface I { ->I : Symbol(I, Decl(typeArgumentInferenceOrdering.ts, 5, 1)) +>I : Symbol(I, Decl(typeArgumentInferenceOrdering.ts, 2, 1)) x(): Goo; ->x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 7, 13)) ->Goo : Symbol(Goo, Decl(typeArgumentInferenceOrdering.ts, 9, 1)) +>x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 4, 13)) +>Goo : Symbol(Goo, Decl(typeArgumentInferenceOrdering.ts, 6, 1)) } interface Goo { ->Goo : Symbol(Goo, Decl(typeArgumentInferenceOrdering.ts, 9, 1)) +>Goo : Symbol(Goo, Decl(typeArgumentInferenceOrdering.ts, 6, 1)) p: string; ->p : Symbol(Goo.p, Decl(typeArgumentInferenceOrdering.ts, 11, 15)) +>p : Symbol(Goo.p, Decl(typeArgumentInferenceOrdering.ts, 8, 15)) } +function foo(f: { y: T }): T { return null } +>foo : Symbol(foo, Decl(typeArgumentInferenceOrdering.ts, 10, 1)) +>T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 12, 13)) +>f : Symbol(f, Decl(typeArgumentInferenceOrdering.ts, 12, 16)) +>y : Symbol(y, Decl(typeArgumentInferenceOrdering.ts, 12, 20)) +>T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 12, 13)) +>T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 12, 13)) + +var x = foo(new C()).x; // was Error that property x does not exist on type {} +>x : Symbol(x, Decl(typeArgumentInferenceOrdering.ts, 13, 3)) +>foo(new C()).x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 4, 13)) +>foo : Symbol(foo, Decl(typeArgumentInferenceOrdering.ts, 10, 1)) +>C : Symbol(C, Decl(typeArgumentInferenceOrdering.ts, 0, 0)) +>x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 4, 13)) + diff --git a/tests/baselines/reference/typeArgumentInferenceOrdering.types b/tests/baselines/reference/typeArgumentInferenceOrdering.types index 1bbeadcf4d..788ab2285a 100644 --- a/tests/baselines/reference/typeArgumentInferenceOrdering.types +++ b/tests/baselines/reference/typeArgumentInferenceOrdering.types @@ -1,22 +1,4 @@ === tests/cases/compiler/typeArgumentInferenceOrdering.ts === -function foo(f: { y: T }): T { return null } ->foo : (f: { y: T; }) => T ->T : T ->f : { y: T; } ->y : T ->T : T ->T : T ->null : null - -var x = foo(new C()).x; // was Error that property x does not exist on type {} ->x : () => Goo ->foo(new C()).x : () => Goo ->foo(new C()) : I ->foo : (f: { y: T; }) => T ->new C() : C ->C : typeof C ->x : () => Goo - class C { >C : C @@ -40,3 +22,21 @@ interface Goo { >p : string } +function foo(f: { y: T }): T { return null } +>foo : (f: { y: T; }) => T +>T : T +>f : { y: T; } +>y : T +>T : T +>T : T +>null : null + +var x = foo(new C()).x; // was Error that property x does not exist on type {} +>x : () => Goo +>foo(new C()).x : () => Goo +>foo(new C()) : I +>foo : (f: { y: T; }) => T +>new C() : C +>C : typeof C +>x : () => Goo + diff --git a/tests/baselines/reference/typeParameterListWithTrailingComma1.errors.txt b/tests/baselines/reference/typeParameterListWithTrailingComma1.errors.txt new file mode 100644 index 0000000000..ac20e82696 --- /dev/null +++ b/tests/baselines/reference/typeParameterListWithTrailingComma1.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/typeParameterListWithTrailingComma1.ts(1,10): error TS1009: Trailing comma not allowed. + + +==== tests/cases/compiler/typeParameterListWithTrailingComma1.ts (1 errors) ==== + class C { + ~ +!!! error TS1009: Trailing comma not allowed. + } \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles.ts b/tests/cases/compiler/checkJsFiles.ts new file mode 100644 index 0000000000..62e2eb3301 --- /dev/null +++ b/tests/cases/compiler/checkJsFiles.ts @@ -0,0 +1,7 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @fileName: a.js +var x = "string"; +x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles2.ts b/tests/cases/compiler/checkJsFiles2.ts new file mode 100644 index 0000000000..2e4d4396e4 --- /dev/null +++ b/tests/cases/compiler/checkJsFiles2.ts @@ -0,0 +1,8 @@ +// @allowJs: true +// @checkJs: false +// @noEmit: true + +// @fileName: a.js +// @ts-check +var x = "string"; +x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles3.ts b/tests/cases/compiler/checkJsFiles3.ts new file mode 100644 index 0000000000..885bf1979f --- /dev/null +++ b/tests/cases/compiler/checkJsFiles3.ts @@ -0,0 +1,7 @@ +// @allowJs: true +// @noEmit: true + +// @fileName: a.js +// @ts-check +var x = "string"; +x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles4.ts b/tests/cases/compiler/checkJsFiles4.ts new file mode 100644 index 0000000000..2e4d4396e4 --- /dev/null +++ b/tests/cases/compiler/checkJsFiles4.ts @@ -0,0 +1,8 @@ +// @allowJs: true +// @checkJs: false +// @noEmit: true + +// @fileName: a.js +// @ts-check +var x = "string"; +x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles5.ts b/tests/cases/compiler/checkJsFiles5.ts new file mode 100644 index 0000000000..10f59aed17 --- /dev/null +++ b/tests/cases/compiler/checkJsFiles5.ts @@ -0,0 +1,8 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @fileName: a.js +// @ts-nocheck +var x = "string"; +x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles6.ts b/tests/cases/compiler/checkJsFiles6.ts new file mode 100644 index 0000000000..358704ae22 --- /dev/null +++ b/tests/cases/compiler/checkJsFiles6.ts @@ -0,0 +1,6 @@ +// @allowJs: false +// @checkJs: true +// @noEmit: true + +// @fileName: a.js +var x; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts b/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts new file mode 100644 index 0000000000..48364c6a59 --- /dev/null +++ b/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts @@ -0,0 +1,33 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @fileName: a.js +var x = 0; + + +/// @ts-ignore +x(); + +/// @ts-ignore +x(); + +/// @ts-ignore +x( + 2, + 3); + + + +// @ts-ignore +// come comment +// some other comment + +// @anohter + +x(); + + + +// @ts-ignore: no call signature +x(); \ No newline at end of file diff --git a/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts b/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts new file mode 100644 index 0000000000..cf09163ed5 --- /dev/null +++ b/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts @@ -0,0 +1,4 @@ +function f() { + new C2(); // OK +} +class C2 { } \ No newline at end of file diff --git a/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts b/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts new file mode 100644 index 0000000000..389c669e74 --- /dev/null +++ b/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts @@ -0,0 +1,4 @@ +// @target: es6 +class C3 { + static intance = new C3(); // ok +} \ No newline at end of file diff --git a/tests/cases/compiler/classWithEmptyTypeParameter.ts b/tests/cases/compiler/classWithEmptyTypeParameter.ts new file mode 100644 index 0000000000..42541c8e46 --- /dev/null +++ b/tests/cases/compiler/classWithEmptyTypeParameter.ts @@ -0,0 +1,2 @@ +class C<> { +} \ No newline at end of file diff --git a/tests/cases/compiler/deeplyNestedCheck.ts b/tests/cases/compiler/deeplyNestedCheck.ts new file mode 100644 index 0000000000..e95233af98 --- /dev/null +++ b/tests/cases/compiler/deeplyNestedCheck.ts @@ -0,0 +1,9 @@ +// Repro from #14794 + +interface DataSnapshot { + child(path: string): DataSnapshot; +} + +interface Snapshot extends DataSnapshot { + child(path: U): Snapshot; +} diff --git a/tests/cases/compiler/enumUsedBeforeDeclaration.ts b/tests/cases/compiler/enumUsedBeforeDeclaration.ts new file mode 100644 index 0000000000..98f5fca86f --- /dev/null +++ b/tests/cases/compiler/enumUsedBeforeDeclaration.ts @@ -0,0 +1,5 @@ +const v: Color = Color.Green; +const v2: ConstColor = ConstColor.Green; +enum Color { Red, Green, Blue } +const enum ConstColor { Red, Green, Blue } + diff --git a/tests/cases/compiler/genericDefaultsJs.ts b/tests/cases/compiler/genericDefaultsJs.ts new file mode 100644 index 0000000000..6aa3640d96 --- /dev/null +++ b/tests/cases/compiler/genericDefaultsJs.ts @@ -0,0 +1,80 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true +// @filename: decls.d.ts +declare function f0(x?: T): T; +declare function f1(x?: T): [T, U]; +declare class C0 { + y: T; + constructor(x?: T); +} +declare class C1 { + y: [T, U]; + constructor(x?: T); +} +// @filename: main.js +const f0_v0 = f0(); +const f0_v1 = f0(1); + +const f1_c0 = f1(); +const f1_c1 = f1(1); + +const C0_v0 = new C0(); +const C0_v0_y = C0_v0.y; + +const C0_v1 = new C0(1); +const C0_v1_y = C0_v1.y; + +const C1_v0 = new C1(); +const C1_v0_y = C1_v0.y; + +const C1_v1 = new C1(1); +const C1_v1_y = C1_v1.y; + +class C0_B0 extends C0 {} +class C0_B1 extends C0 { + constructor() { + super(); + } +} +class C0_B2 extends C0 { + constructor() { + super(1); + } +} + +const C0_B0_v0 = new C0_B0(); +const C0_B0_v0_y = C0_B0_v0.y; + +const C0_B0_v1 = new C0_B0(1); +const C0_B0_v1_y = C0_B0_v1.y; + +const C0_B1_v0 = new C0_B1(); +const C0_B1_v0_y = C0_B1_v0.y; + +const C0_B2_v0 = new C0_B2(); +const C0_B2_v0_y = C0_B2_v0.y; + +class C1_B0 extends C1 {} +class C1_B1 extends C1 { + constructor() { + super(); + } +} +class C1_B2 extends C1 { + constructor() { + super(1); + } +} + +const C1_B0_v0 = new C1_B0(); +const C1_B0_v0_y = C1_B0_v0.y; + +const C1_B0_v1 = new C1_B0(1); +const C1_B0_v1_y = C1_B0_v1.y; + +const C1_B1_v0 = new C1_B1(); +const C1_B1_v0_y = C1_B1_v0.y; + +const C1_B2_v0 = new C1_B2(); +const C1_B2_v0_y = C1_B2_v0.y; diff --git a/tests/cases/compiler/indexedAccessRelation.ts b/tests/cases/compiler/indexedAccessRelation.ts new file mode 100644 index 0000000000..ccfcd559e2 --- /dev/null +++ b/tests/cases/compiler/indexedAccessRelation.ts @@ -0,0 +1,18 @@ +// Repro from #14723 + +class Component { + setState(state: Pick) {} +} + +export interface State { + a?: T; +} + +class Foo {} + +class Comp extends Component> +{ + foo(a: T) { + this.setState({ a: a }); + } +} diff --git a/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts b/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts index 1f76e4e6b5..9f008cd2b1 100644 --- a/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts +++ b/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts @@ -1,8 +1,9 @@ -var a = new TypeScript2.MemberNameArray() module TypeScript2 { -export class MemberName { -public prefix: string = ""; -} -export class MemberNameArray extends MemberName { -} + export class MemberName { + public prefix: string = ""; + } + export class MemberNameArray extends MemberName { + } } + +var a = new TypeScript2.MemberNameArray() \ No newline at end of file diff --git a/tests/cases/compiler/typeArgumentInferenceOrdering.ts b/tests/cases/compiler/typeArgumentInferenceOrdering.ts index 6887f7455d..faa7b45a4a 100644 --- a/tests/cases/compiler/typeArgumentInferenceOrdering.ts +++ b/tests/cases/compiler/typeArgumentInferenceOrdering.ts @@ -1,6 +1,3 @@ -function foo(f: { y: T }): T { return null } -var x = foo(new C()).x; // was Error that property x does not exist on type {} - class C { y: I; } @@ -12,3 +9,6 @@ interface I { interface Goo { p: string; } + +function foo(f: { y: T }): T { return null } +var x = foo(new C()).x; // was Error that property x does not exist on type {} \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts index 7b3be0365e..7a4cd1a2e4 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts @@ -1,5 +1,4 @@ //@target: ES6 -var [a, b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -11,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var [a, b] = new SymbolIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts index 35d05ef1f9..591cdd2b6a 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, b]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts index ed93b5175d..83ab94dece 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, b] = new FooIterator) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, b] = new FooIterator) { } +fun(new FooIterator); diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts index b7e763694e..079eb25df4 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, ...b] = new FooIterator) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, ...b] = new FooIterator) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts index f0b9b142f4..f4909547e2 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, ...b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, ...b]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts index c327efa3ec..976c514823 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun(...[a, ...b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun(...[a, ...b]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts index 21d632fd54..ecc686b634 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun(...[a, b]: Bar[]) { } -fun(...new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun(...[a, b]: Bar[]) { } +fun(...new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts index 90db0e5edb..b81114cab2 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun(...[a, b]: Bar[]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun(...[a, b]: Bar[]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts index e6e5ad617b..a03713037d 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, b]: Bar[]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, b]: Bar[]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts index 8513dd0764..32024e83b1 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([[a], b]: Bar[][]) { } -fun(new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -14,4 +12,7 @@ class FooArrayIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([[a], b]: Bar[][]) { } +fun(new FooArrayIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts index 587f1f0b05..d5543c0aed 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts @@ -1,5 +1,4 @@ //@target: ES6 -var [a, ...b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -11,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var [a, ...b] = new SymbolIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts index b5be67b393..6a0e912673 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } -fun(...new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -14,4 +12,7 @@ class FooArrayIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } +fun(...new FooArrayIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts index 31656b5661..ff63aa7417 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: Bar; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: Bar; +[a, b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts index edd95be159..b5aef9003b 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: Bar[]; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: Bar[]; +[a, ...b] = new FooIterator \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts index b51d0f09d0..a3911b1f5e 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: string; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: string; +[a, b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts index fc9395ed6a..057b9aeaff 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: string[]; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: string[]; +[a, ...b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts index 85b2f2e54e..965b715767 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: string[]; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: string[]; +[a, b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts index dd49205d6e..5638b4c49c 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: string; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: string; +[a, ...b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of14.ts b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts index 84fbda4825..f79794d59d 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of14.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts @@ -1,9 +1,9 @@ //@target: ES6 -var v: string; -for (v of new StringIterator) { } // Should fail because the iterator is not iterable - class StringIterator { next() { return ""; } -} \ No newline at end of file +} + +var v: string; +for (v of new StringIterator) { } // Should fail because the iterator is not iterable \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of15.ts b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts index 1973e7ff95..b2e788bdef 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of15.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts @@ -1,7 +1,4 @@ //@target: ES6 -var v: string; -for (v of new StringIterator) { } // Should fail - class StringIterator { next() { return ""; @@ -9,4 +6,7 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var v: string; +for (v of new StringIterator) { } // Should fail \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of16.ts b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts index 8f7bd6d848..fe78bae2ae 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of16.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts @@ -1,9 +1,9 @@ //@target: ES6 -var v: string; -for (v of new StringIterator) { } // Should fail - class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var v: string; +for (v of new StringIterator) { } // Should fail \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of17.ts b/tests/cases/conformance/es6/for-ofStatements/for-of17.ts index 431f066d47..b7270cbb81 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of17.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of17.ts @@ -1,7 +1,4 @@ //@target: ES6 -var v: string; -for (v of new NumberIterator) { } // Should succeed - class NumberIterator { next() { return { @@ -12,4 +9,7 @@ class NumberIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var v: string; +for (v of new NumberIterator) { } // Should succeed \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of18.ts b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts index 407ad7f0ed..647ae314b4 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of18.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts @@ -1,7 +1,4 @@ //@target: ES6 -var v: string; -for (v of new StringIterator) { } // Should succeed - class StringIterator { next() { return { @@ -12,4 +9,7 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var v: string; +for (v of new StringIterator) { } // Should succeed \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of19.ts b/tests/cases/conformance/es6/for-ofStatements/for-of19.ts index ff80b2690e..be51d219dc 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of19.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of19.ts @@ -1,8 +1,4 @@ //@target: ES6 -for (var v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,4 +10,8 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (var v of new FooIterator) { + v; } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of20.ts b/tests/cases/conformance/es6/for-ofStatements/for-of20.ts index 615f514937..3aa537a9f6 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of20.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of20.ts @@ -1,8 +1,4 @@ //@target: ES6 -for (let v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,4 +10,8 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (let v of new FooIterator) { + v; } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of21.ts b/tests/cases/conformance/es6/for-ofStatements/for-of21.ts index 4e4621034e..ab1e6fff26 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of21.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of21.ts @@ -1,8 +1,4 @@ //@target: ES6 -for (const v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,4 +10,8 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (const v of new FooIterator) { + v; } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of22.ts b/tests/cases/conformance/es6/for-ofStatements/for-of22.ts index 10a96502cd..c9a8834079 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of22.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of22.ts @@ -1,9 +1,4 @@ //@target: ES6 -v; -for (var v of new FooIterator) { - -} - class Foo { } class FooIterator { next() { @@ -15,4 +10,9 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +v; +for (var v of new FooIterator) { + } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of23.ts b/tests/cases/conformance/es6/for-ofStatements/for-of23.ts index 81227cd066..df73418107 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of23.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of23.ts @@ -1,8 +1,4 @@ //@target: ES6 -for (const v of new FooIterator) { - const v = 0; // new scope -} - class Foo { } class FooIterator { next() { @@ -14,4 +10,8 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (const v of new FooIterator) { + const v = 0; // new scope } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of25.ts b/tests/cases/conformance/es6/for-ofStatements/for-of25.ts index a1698bd282..61e6a58ce3 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of25.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of25.ts @@ -1,9 +1,9 @@ //@target: ES6 -var x: any; -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]() { return x; } -} \ No newline at end of file +} + +var x: any; +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of26.ts b/tests/cases/conformance/es6/for-ofStatements/for-of26.ts index 0ab564a4f5..4414fdc159 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of26.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of26.ts @@ -1,7 +1,4 @@ //@target: ES6 -var x: any; -for (var v of new StringIterator) { } - class StringIterator { next() { return x; @@ -9,4 +6,7 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var x: any; +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of27.ts b/tests/cases/conformance/es6/for-ofStatements/for-of27.ts index 8f2b84cbe1..f7244eed34 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of27.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of27.ts @@ -1,6 +1,6 @@ //@target: ES6 -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]: any; -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of28.ts b/tests/cases/conformance/es6/for-ofStatements/for-of28.ts index 8c693193b0..e1b86f6135 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of28.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of28.ts @@ -1,9 +1,9 @@ //@target: ES6 -for (var v of new StringIterator) { } - class StringIterator { next: any; [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of30.ts b/tests/cases/conformance/es6/for-ofStatements/for-of30.ts index 03b97c2313..67e1e3da70 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of30.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of30.ts @@ -1,6 +1,4 @@ //@target: ES6 -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -14,4 +12,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of31.ts b/tests/cases/conformance/es6/for-ofStatements/for-of31.ts index 307f9b7cd4..701fcb50ed 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of31.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of31.ts @@ -1,6 +1,4 @@ //@target: ES6 -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -12,4 +10,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of33.ts b/tests/cases/conformance/es6/for-ofStatements/for-of33.ts index b73d2daee8..f0af5c4a40 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of33.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of33.ts @@ -1,9 +1,9 @@ //@target: ES6 //@noImplicitAny: true -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]() { return v; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of34.ts b/tests/cases/conformance/es6/for-ofStatements/for-of34.ts index d00f5ccde2..63b8822399 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of34.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of34.ts @@ -1,7 +1,5 @@ //@target: ES6 //@noImplicitAny: true -for (var v of new StringIterator) { } - class StringIterator { next() { return v; @@ -10,4 +8,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of35.ts b/tests/cases/conformance/es6/for-ofStatements/for-of35.ts index 0d66ce39ed..ab6e26d6d6 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of35.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of35.ts @@ -1,7 +1,5 @@ //@target: ES6 //@noImplicitAny: true -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -13,4 +11,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts index 4b4f3e8cc1..88a85a4b88 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...new SymbolIterator]; diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts index f8549b82b7..56ff08e79f 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts @@ -1,8 +1,8 @@ //@target: ES6 -var array = [...new SymbolIterator]; - class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts index 9db5d01087..e267386a50 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...new NumberIterator, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -25,4 +23,6 @@ class NumberIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...new NumberIterator, ...new SymbolIterator]; diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts index 174c97de7c..8ef12250ce 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...[0, 1], ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...[0, 1], ...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts index 47c2e63370..ec9faa78fe 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [0, 1, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [0, 1, ...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts index e6a8041a96..d4df51739c 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array: number[] = [0, 1, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array: number[] = [0, 1, ...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts index 7495ca6aac..1d021ca612 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts @@ -1,7 +1,4 @@ //@target: ES6 -var array: number[] = [0, 1]; -array.concat([...new SymbolIterator]); - class SymbolIterator { next() { return { @@ -13,4 +10,7 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array: number[] = [0, 1]; +array.concat([...new SymbolIterator]); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts index 12ca478c73..2f96507c09 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts @@ -1,7 +1,4 @@ //@target: ES6 -var array: symbol[]; -array.concat([...new SymbolIterator]); - class SymbolIterator { next() { return { @@ -13,4 +10,7 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array: symbol[]; +array.concat([...new SymbolIterator]); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts index 0e2258aa5e..8cc56068f8 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -8,4 +6,6 @@ class SymbolIterator { done: false }; } -} \ No newline at end of file +} + +var array = [...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts index 2b8d93c9cc..5bb80fd0c7 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -11,4 +9,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts index 85d07e5699..34f6a7eb8f 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(s: symbol) { } class SymbolIterator { next() { @@ -13,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts index bf8ad336fb..aeb9aabde5 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts @@ -1,8 +1,5 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -14,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts index 182e454cfc..795e9603be 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts @@ -1,8 +1,5 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(...s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -14,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts index a0bd1ede19..06bceec84f 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts @@ -1,6 +1,4 @@ //@target: ES6 -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); - class Foo { constructor(...s: T[]) { } } @@ -29,4 +27,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts index 4a8fd9ff38..e6d7277594 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(s: symbol[]) { } class SymbolIterator { next() { @@ -13,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts index b6e8fe0c86..0391dfdad0 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(...s: symbol[]) { } class SymbolIterator { next() { @@ -13,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts index 2a73fd6f3c..f3747f2586 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(s1: symbol, ...s: symbol[]) { } class SymbolIterator { next() { @@ -13,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts index c17c4156e6..53b0e66037 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: (symbol | string)[]) { } class SymbolIterator { next() { @@ -26,4 +24,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts index 2c6150f804..c48260e97e 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: (symbol | number)[]) { } class SymbolIterator { next() { @@ -26,4 +24,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts index 56fb7936eb..6893cd9d8a 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: T[]) { return s[0]; } class SymbolIterator { next() { @@ -26,4 +24,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts index e5b969456b..c81a475d7d 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts @@ -1,6 +1,4 @@ //@target: ES6 -new Foo(...new SymbolIterator, ...new StringIterator); - class Foo { constructor(...s: T[]) { } } @@ -29,4 +27,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +new Foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts index 470f99844b..41ee21a564 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts @@ -1,6 +1,4 @@ //@target: ES6 -new Foo(...new SymbolIterator, ...[...new StringIterator]); - class Foo { constructor(...s: T[]) { } } @@ -29,4 +27,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +new Foo(...new SymbolIterator, ...[...new StringIterator]); diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts new file mode 100644 index 0000000000..2f30fe9d90 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts @@ -0,0 +1,40 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: true + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing1: Strategy = strategy("Nothing", function*(state: State) { + return state; +}); + +export const Nothing2: Strategy = strategy("Nothing", function*(state: State) { + yield state; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield ; + return state; +}); + \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts new file mode 100644 index 0000000000..58411e409b --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts @@ -0,0 +1,43 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: true + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing: Strategy = strategy("Nothing", function* (state: State) { + yield 1; + return state; +}); + +export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { +}); + +export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { + return 1; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield state; + return 1; +}); \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxSfcReturnNull.tsx b/tests/cases/conformance/jsx/tsxSfcReturnNull.tsx new file mode 100644 index 0000000000..436b361eaf --- /dev/null +++ b/tests/cases/conformance/jsx/tsxSfcReturnNull.tsx @@ -0,0 +1,16 @@ +// @filename: file.tsx +// @jsx: preserve +// @module: amd +// @noLib: true +// @libFiles: react.d.ts,lib.d.ts + +import React = require('react'); + +const Foo = (props: any) => null; + +function Greet(x: {name?: string}) { + return null; +} + +const foo = ; +const G = ; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxSfcReturnNullStrictNullChecks.tsx b/tests/cases/conformance/jsx/tsxSfcReturnNullStrictNullChecks.tsx new file mode 100644 index 0000000000..cbc7218698 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxSfcReturnNullStrictNullChecks.tsx @@ -0,0 +1,17 @@ +// @filename: file.tsx +// @jsx: preserve +// @module: amd +// @noLib: true +// @strictNullChecks: true +// @libFiles: react.d.ts,lib.d.ts + +import React = require('react'); + +const Foo = (props: any) => null; + +function Greet(x: {name?: string}) { + return null; +} + +const foo = ; +const G = ; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxSfcReturnUndefinedStrictNullChecks.tsx b/tests/cases/conformance/jsx/tsxSfcReturnUndefinedStrictNullChecks.tsx new file mode 100644 index 0000000000..cb0c6444e7 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxSfcReturnUndefinedStrictNullChecks.tsx @@ -0,0 +1,17 @@ +// @filename: file.tsx +// @jsx: preserve +// @module: amd +// @noLib: true +// @strictNullChecks: true +// @libFiles: react.d.ts,lib.d.ts + +import React = require('react'); + +const Foo = (props: any) => undefined; +function Greet(x: {name?: string}) { + return undefined; +} + +// Error +const foo = ; +const G = ; \ No newline at end of file diff --git a/tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts b/tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts index 185641d080..b832d57855 100644 --- a/tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts +++ b/tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts @@ -1,5 +1,4 @@ //@target: ES5 -for (var v of new StringIterator) { } // In ES3/5, you cannot for...of over an arbitrary iterable. class StringIterator { @@ -12,4 +11,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts new file mode 100644 index 0000000000..2ec8cf83cb --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts @@ -0,0 +1,5 @@ +var a: object; + +for (var key in a) { + var value = a[key]; +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts new file mode 100644 index 0000000000..1050cdea49 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts @@ -0,0 +1,6 @@ +// @noImplicitAny: true +var a: object; + +for (var key in a) { + var value = a[key]; // error +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts new file mode 100644 index 0000000000..3f63faee60 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts @@ -0,0 +1,7 @@ +// @noImplicitAny: true +// @suppressImplicitAnyIndexErrors: true +var a: object; + +for (var key in a) { + var value = a[key]; +} diff --git a/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts b/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts index 98f94718f3..4cc3a72395 100644 --- a/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts +++ b/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts @@ -1,12 +1,12 @@ -var x: StringTree; -if (typeof x !== "string") { - x[0] = ""; - x[0] = new StringTreeCollection; -} - type StringTree = string | StringTreeCollection; class StringTreeCollectionBase { [n: number]: StringTree; } -class StringTreeCollection extends StringTreeCollectionBase { } \ No newline at end of file +class StringTreeCollection extends StringTreeCollectionBase { } + +var x: StringTree; +if (typeof x !== "string") { + x[0] = ""; + x[0] = new StringTreeCollection; +} \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember.ts b/tests/cases/fourslash/codeFixAddMissingMember.ts new file mode 100644 index 0000000000..43c0bc3b76 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember.ts @@ -0,0 +1,14 @@ +/// + +////[|class C { +//// method() { +//// this.foo = 10; +//// } +////}|] + +verify.rangeAfterCodeFix(`class C { + foo: number; + method() { + this.foo = 10; + } +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember2.ts b/tests/cases/fourslash/codeFixAddMissingMember2.ts new file mode 100644 index 0000000000..7b64fde8c0 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember2.ts @@ -0,0 +1,14 @@ +/// + +////[|class C { +//// method() { +//// this.foo = 10; +//// } +////}|] + +verify.rangeAfterCodeFix(`class C { + [x:string]: number; + method() { + this.foo = 10; + } +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 1); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember3.ts b/tests/cases/fourslash/codeFixAddMissingMember3.ts new file mode 100644 index 0000000000..5864c9c102 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember3.ts @@ -0,0 +1,14 @@ +/// + +////[|class C { +//// static method() { +//// this.foo = 10; +//// } +////}|] + +verify.rangeAfterCodeFix(`class C { + static foo: number; + static method() { + this.foo = 10; + } +}`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember4.ts b/tests/cases/fourslash/codeFixAddMissingMember4.ts new file mode 100644 index 0000000000..08df9ccabc --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember4.ts @@ -0,0 +1,22 @@ +/// + +// @checkJs: true +// @allowJs: true + +// @Filename: a.js +////[|class C { +//// constructor() { +//// } +//// method() { +//// this.foo === 10; +//// } +////}|] + +verify.rangeAfterCodeFix(`class C { + constructor() { + this.foo = undefined; +} + method() { + this.foo === 10; + } +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember5.ts b/tests/cases/fourslash/codeFixAddMissingMember5.ts new file mode 100644 index 0000000000..cbabc0ba6c --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember5.ts @@ -0,0 +1,19 @@ +/// + +// @checkJs: true +// @allowJs: true + +// @Filename: a.js +////[|class C { +//// static method() { +//// ()=>{ this.foo === 10 }; +//// } +////} +////|] + +verify.rangeAfterCodeFix(`class C { + static method() { + ()=>{ this.foo === 10 }; + } +} +C.foo = undefined;`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember6.ts b/tests/cases/fourslash/codeFixAddMissingMember6.ts new file mode 100644 index 0000000000..2f3911d779 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember6.ts @@ -0,0 +1,18 @@ +/// + +// @checkJs: true +// @allowJs: true + +// @Filename: a.js +////[|class C { +//// constructor() { +//// } +//// prop = ()=>{ this.foo === 10 }; +////}|] + +verify.rangeAfterCodeFix(`class C { + constructor() { + this.foo = undefined; + } + prop = ()=>{ this.foo === 10 }; +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember7.ts b/tests/cases/fourslash/codeFixAddMissingMember7.ts new file mode 100644 index 0000000000..0e937a3ab6 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember7.ts @@ -0,0 +1,15 @@ +/// + +// @checkJs: true +// @allowJs: true + +// @Filename: a.js +////[|class C { +//// static p = ()=>{ this.foo === 10 }; +////} +////|] + +verify.rangeAfterCodeFix(`class C { + static p = ()=>{ this.foo === 10 }; +} +C.foo = undefined;`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 2); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts b/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts index bdf8ea3bd2..2568111fb9 100644 --- a/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts +++ b/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts @@ -8,6 +8,6 @@ verify.rangeAfterCodeFix(` f(): void{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts index 4bddfb799f..bc437c93bc 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts @@ -28,4 +28,4 @@ verify.rangeAfterCodeFix(` e: this; f: A; g: string; -`); \ No newline at end of file +`); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts index 344a7ee3f2..7e51e2216d 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts @@ -5,6 +5,7 @@ //// abstract f(a: number, b: string): this; //// abstract f(a: string, b: number): Function; //// abstract f(a: string): Function; +//// abstract foo(): number; //// } //// //// class C extends A {[| |]} @@ -15,6 +16,9 @@ verify.rangeAfterCodeFix(` f(a: string, b: number): Function; f(a: string): Function; f(a: any, b?: any) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); + } + foo(): number { + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts index 55b3ad4b77..a462ac9812 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts @@ -8,6 +8,6 @@ verify.rangeAfterCodeFix(` f(): this { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts index bdf198b89e..c1a55e8803 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts @@ -4,10 +4,9 @@ //// abstract f(x: T): T; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} verify.rangeAfterCodeFix(`f(x: number): number{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts index 647a533c1c..c2ec5ff803 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts @@ -4,10 +4,9 @@ //// abstract f(x: T): T; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} verify.rangeAfterCodeFix(`f(x: U): U{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts index d395272b36..b8f6b3d81e 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts @@ -4,8 +4,7 @@ //// private abstract x: number; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} // We don't know how to fix this problem. We can: // 1) Make x protected, and then insert. diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts index b7300acf5a..701903d677 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts @@ -4,17 +4,12 @@ //// abstract x: number; //// abstract y: this; //// abstract z: A; -//// abstract foo(): number; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} verify.rangeAfterCodeFix(` x: number; y: this; z: A; - foo(): number { - throw new Error('Method not implemented.'); - } `); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts index 6d0571fce6..d2532ef16d 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts @@ -4,8 +4,7 @@ //// protected abstract x: number; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} verify.rangeAfterCodeFix(` protected x: number; diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts index 917f75051f..495d661ec7 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts @@ -4,8 +4,8 @@ //// public abstract x: number; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} + verify.rangeAfterCodeFix(` public x: number; diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts b/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts index b6dd679bb7..fb66a04cd5 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts @@ -6,8 +6,8 @@ //// abstract z: number; //// } //// -//// class C extends A {[| |] -//// constructor(public x: number) { super(); } +//// class C extends A {[| +//// |]constructor(public x: number) { super(); } //// y: number; //// } diff --git a/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts index d9b9f57d4d..b8fdace9f7 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts @@ -8,6 +8,6 @@ verify.rangeAfterCodeFix(` f(): void{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts b/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts new file mode 100644 index 0000000000..ee8b8cafff --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts @@ -0,0 +1,13 @@ +/// + +//// class A { +//// foo() { +//// return class { x: number; } +//// } +//// bar() { +//// return new class { x: number; } +//// } +//// } +//// class C implements A {[| |]} + +verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts index 4365a16053..57372dd7e8 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts @@ -8,11 +8,11 @@ //// //// } //// -//// class C3 implements C2 {[| +//// class C3 implements C2 {[| //// |]f2(){} //// } verify.rangeAfterCodeFix(`f1(): void{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts index 82ecde6c41..2e8dc316b3 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts @@ -9,6 +9,6 @@ verify.rangeAfterCodeFix(` method(a: number, b: string): boolean; method(a: string | number, b?: string | number): boolean | Function { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts index f187e0ca0f..463b10c450 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts @@ -13,6 +13,6 @@ verify.rangeAfterCodeFix(` method(a: string, b: number): Function; method(a: string): Function; method(a: string | number, b?: string | number): boolean | Function { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts b/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts new file mode 100644 index 0000000000..4a5663a8ba --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts @@ -0,0 +1,10 @@ +/// + +//// class A { +//// A: typeof A; +//// } +//// class D implements A {[| |]} + +verify.rangeAfterCodeFix(` + A: typeof A; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts index e8b199b21a..f11dc29395 100644 --- a/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts +++ b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts @@ -24,8 +24,7 @@ //// } //// //// interface I6 extends C4 {} -//// class C5 implements I6 {[| -//// |]} +//// class C5 implements I6 {[| |]} /** diff --git a/tests/cases/fourslash/codeFixClassImplementInterface36.ts b/tests/cases/fourslash/codeFixClassImplementInterface36.ts deleted file mode 100644 index f9fc48991f..0000000000 --- a/tests/cases/fourslash/codeFixClassImplementInterface36.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -//// abstract class C1 { -//// -//// } -//// -//// abstract class C2 { -//// abstract f1(); -//// } -//// -//// interface I1 extends C1, C2 {} -//// -//// class C3 implements I1 {[| -//// -//// |]} - -verify.rangeAfterCodeFix(`f1(){ - throw new Error('Method not implemented.'); -} -`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts new file mode 100644 index 0000000000..4550e5ca31 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts @@ -0,0 +1,15 @@ +/// + +//// interface I { +//// x: number[]; +//// y: Array; +//// z: [number, string, I]; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` +x: number[]; +y: number[]; +z: [number, string, I]; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceCallSignature.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceCallSignature.ts new file mode 100644 index 0000000000..4b47268396 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceCallSignature.ts @@ -0,0 +1,10 @@ +/// + +//// interface I { +//// (x: number, b: string): number; +//// } +//// class C implements I {[| |]} + +verify.not.codeFixAvailable(); + + diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts new file mode 100644 index 0000000000..f082074f16 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts @@ -0,0 +1,27 @@ +/// + +// @lib: es2017 + +//// namespace N { +//// /**enum prefix */ +//// export enum /**enum identifier prefix */ E /**open-brace prefix*/ { +//// /* literal prefix */ a /** comma prefix */, +//// /* literal prefix */ b /** comma prefix */, +//// /* literal prefix */ c +//// /** close brace prefix */ } +//// /** interface prefix */ +//// export interface /**interface name prefix */ I /**open-brace prefix*/ { +//// /** property prefix */ a /** colon prefix */: /** enum literal prefix 1*/ E /** dot prefix */. /** enum literal prefix 2*/a; +//// /** property prefix */ b /** colon prefix */: /** enum prefix */ E; +//// /**method signature prefix */foo /**open angle prefix */< /**type parameter name prefix */ X /** closing angle prefix */> /**open paren prefix */(/** parameter prefix */ a/** colon prefix */: /** parameter type prefix */ X /** close paren prefix */) /** colon prefix */: /** return type prefix */ string /** semicolon prefix */; +//// /**close-brace prefix*/ } +//// /**close-brace prefix*/ } +//// class C implements N.I {[| |]} + +verify.rangeAfterCodeFix(` + a: N.E.a; + b: N.E; + foo(a: X): string { + throw new Error("Method not implemented."); + } +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts index 341b4e5981..7d77c5b9af 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts @@ -7,15 +7,15 @@ //// [2]: boolean; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` ["foo"](o: any): boolean { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } ["x"]: boolean; [1](): string { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [2]: boolean; `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts index 7c1156acd7..31fc167bb9 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts @@ -17,35 +17,34 @@ //// [Symbol.toStringTag]: string; //// [Symbol.unscopables]: any; //// } -//// //// class C implements I {[| |]} verify.rangeAfterCodeFix(` [Symbol.hasInstance](o: any): boolean { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.isConcatSpreadable]: boolean; [Symbol.iterator]() { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.match]: boolean; [Symbol.replace](...args: {}) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.search](str: string): number { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.species](): number { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.split](str: string, limit?: number): {} { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.toPrimitive](hint: "number"): number; [Symbol.toPrimitive](hint: "default"): number; [Symbol.toPrimitive](hint: "string"): string; [Symbol.toPrimitive](hint: any) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.toStringTag]: string; [Symbol.unscopables]: any; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceConstructSignature.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceConstructSignature.ts new file mode 100644 index 0000000000..1700f7ec88 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceConstructSignature.ts @@ -0,0 +1,10 @@ +/// + +//// interface I { +//// new (x: number, b: string); +//// } +//// class C implements I {[| |]} + +verify.not.codeFixAvailable(); + + diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts index a2154de567..bea14ae404 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts @@ -7,7 +7,6 @@ //// x: number; //// } //// -//// class C implements I1,I2 {[| -//// |]} +//// class C implements I1,I2 {[| |]} verify.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceEmptyTypeLiteral.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceEmptyTypeLiteral.ts new file mode 100644 index 0000000000..9805901709 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceEmptyTypeLiteral.ts @@ -0,0 +1,13 @@ +/// + +//// interface I { +//// x: {}; +//// } +//// +//// class C implements I {[| +//// |]constructor() { } +//// } + +verify.rangeAfterCodeFix(` +x: {}; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterface39.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts similarity index 67% rename from tests/cases/fourslash/codeFixClassImplementInterface39.ts rename to tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts index f81dea4978..e4e1cf3608 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterface39.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts @@ -9,10 +9,9 @@ //// f1(); //// } //// -//// class C1 implements N1.I1 {[| -//// |]} +//// class C1 implements N1.I1 {[| |]} verify.rangeAfterCodeFix(`f1(): string{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts index 0f14344253..82cc53570f 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts @@ -3,9 +3,7 @@ //// interface I { //// [x: number]: I; //// } -//// -//// class C implements I {[| -//// |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` [x: number]: I; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts new file mode 100644 index 0000000000..ed5ea06ebb --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts @@ -0,0 +1,10 @@ +/// + +//// interface I { +//// x: keyof X; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` +x: keyof Y; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts new file mode 100644 index 0000000000..c141592823 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts @@ -0,0 +1,13 @@ +/// + +//// abstract class C1 { } +//// abstract class C2 { +//// abstract f1(); +//// } +//// interface I1 extends C1, C2 { } +//// class C3 implements I1 {[| |]} + +verify.rangeAfterCodeFix(`f1(){ + throw new Error("Method not implemented."); +} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts new file mode 100644 index 0000000000..64676bce86 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts @@ -0,0 +1,10 @@ +/// + +//// interface I { +//// x: { readonly [K in keyof X]: X[K] }; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` +x: { readonly [K in keyof X]: Y[K]; }; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts new file mode 100644 index 0000000000..dbfd623be1 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts @@ -0,0 +1,58 @@ +/// + +// @lib: es2017 + +//// /** asdf */ +//// interface I { +//// 1; +//// 2; +//// 3; +//// 4; +//// 5; +//// 6; +//// 7; +//// 8; +//// 9; +//// 10; +//// 11; +//// 12; +//// 13; +//// 14; +//// 15; +//// 16; +//// 17; +//// 18; +//// 19; +//// 20; +//// 21; +//// 22; +//// /** a nice safe prime */ +//// 23; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + 1: any; + 2: any; + 3: any; + 4: any; + 5: any; + 6: any; + 7: any; + 8: any; + 9: any; + 10: any; + 11: any; + 12: any; + 13: any; + 14: any; + 15: any; + 16: any; + 17: any; + 18: any; + 19: any; + 20: any; + 21: any; + 22: any; + 23: any; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts index 95cc3476bf..b8225f31e0 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts @@ -4,11 +4,10 @@ //// f(x: number, y: this): I //// } //// -//// class C implements I {[| -//// |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` f(x: number,y: this): I { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts new file mode 100644 index 0000000000..2eb6c2fabc --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts @@ -0,0 +1,16 @@ +/// + +//// interface I { +//// f(i: any): i is I; +//// f(): this is I; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` +f(i: any): i is I; +f(): this is I; +f(i?: any) { + throw new Error("Method not implemented."); +} +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts index c8d61227c4..13d58d0ad6 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts @@ -8,12 +8,11 @@ //// } //// //// class C implements I1,I2 {[| -//// y: number; -//// |]} +//// |]y: number; +//// } verify.rangeAfterCodeFix(` x: number; -y: number; `); verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts index d29b23998b..e5100b88f6 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts @@ -8,12 +8,11 @@ //// } //// //// class C implements I1,I2 {[| -//// x: number; -//// |]} +//// |]x: number; +//// } verify.rangeAfterCodeFix(` y: number; -x: number; `); verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts index 321d41e463..cac1038eb1 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts @@ -7,7 +7,6 @@ //// x: string; //// } //// -//// class C implements I1,I2 {[| -//// |]} +//// class C implements I1,I2 {[| |]} verify.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts index beab89c06a..66cdb1f545 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts @@ -9,20 +9,19 @@ //// h(); //// } //// -//// class C1 implements I1 {[| -//// |]} +//// class C1 implements I1 {[| |]} verify.rangeAfterCodeFix(` x: number; y: number; z: number; f() { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } g() { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } h() { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts index bda58b3767..583dda1305 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts @@ -13,6 +13,6 @@ verify.rangeAfterCodeFix(` method(a: string, b: number): Function; method(a: string): Function; method(a: any, b?: any) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts index 6e0a272a42..132c63ae0f 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts @@ -13,6 +13,6 @@ verify.rangeAfterCodeFix(` method(a: string, ...b: number[]): Function; method(a: string): Function; method(a: any, ...b?: any[]) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts index 7ba7ae2c98..b4e9a8ff91 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts @@ -13,6 +13,6 @@ verify.rangeAfterCodeFix(` method(a: string, b: number): Function; method(a: string): Function; method(a: any, b?: any, ...rest?: any[]) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts index 4fea72aa48..1d71ce3c47 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts @@ -8,9 +8,7 @@ //// interface I1 { //// f1(); //// } -//// -//// class C1 implements N1.I1 {[| -//// |]} +//// class C1 implements N1.I1 {[| |]} verify.rangeAfterCodeFix(` x: number; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts new file mode 100644 index 0000000000..53cfce5ff6 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts @@ -0,0 +1,19 @@ +/// + +// @lib: es2017 + +//// enum E { a,b,c } +//// interface I { +//// x: E; +//// y: E.a +//// z: symbol; +//// w: object; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + x: E; + y: E.a; + z: symbol; + w: object; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts index 2a4ca4df92..acda59513a 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts @@ -4,7 +4,7 @@ //// constructor(public x: number) { } //// } //// -//// class B implements A {[| |]} +//// class B implements A {[| |]} verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts new file mode 100644 index 0000000000..9438241005 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts @@ -0,0 +1,34 @@ +/// + +//// interface I { +//// a0: {}; +//// a1: { (b1: number, c1: string): number; }; +//// a2: (b2: number, c2: string) => number; +//// a3: { (b3: number, c3: string): number, x: number }; +//// +//// a4: { new (b1: number, c1: string): number; }; +//// a5: new (b2: number, c2: string) => number; +//// a6: { new (b3: number, c3: string): number, x: number }; +//// +//// a7: { foo(b7: number, c7: string): number }; +//// +//// a8: { (b81: number, c81: string): number, new (b82: number, c82: string): number; }; +//// +//// a9: { (b9: number, c9: string): number; [d9: number]: I }; +//// a10: { (b10: number, c10: string): number; [d10: string]: I }; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + a0: {}; + a1: (b1: number, c1: string) => number; + a2: (b2: number, c2: string) => number; + a3: { (b3: number, c3: string): number; x: number; }; + a4: new (b1: number, c1: string) => number; + a5: new (b2: number, c2: string) => number; + a6: { new (b3: number, c3: string): number; x: number; }; + a7: { foo(b7: number, c7: string): number; }; + a8: { (b81: number, c81: string): number; new (b82: number, c82: string): number; }; + a9: { (b9: number, c9: string): number; [d9: number]: I; }; + a10: { (b10: number, c10: string): number; [d10: string]: I; }; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts new file mode 100644 index 0000000000..e29f4501b1 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts @@ -0,0 +1,12 @@ +/// + +//// namespace N { +//// export interface I { +//// y: I; +//// } +//// } +//// class C1 implements N.I {[| |]} + +verify.rangeAfterCodeFix(` +y: N.I; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts index 6e0658019f..e667783b99 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts @@ -6,8 +6,8 @@ //// z: number & { __iBrand: any }; //// } //// -//// class C implements I {[| |] -//// constructor(public x: number) { } +//// class C implements I {[| +//// |]constructor(public x: number) { } //// y: number; //// } diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts index f76bd5dae9..acccafe0fc 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts @@ -4,7 +4,7 @@ //// x: { y: T, z: T[] }; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` x: { y: number; z: number[]; }; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts index af0e7a162e..a11101c7f4 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts @@ -4,7 +4,7 @@ //// x: T; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` x: number; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts index 45fa3fd40c..298ee0704f 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts @@ -4,7 +4,7 @@ //// x: T; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` x: T; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts index 16c35f4177..3f1da116f4 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts @@ -4,7 +4,7 @@ //// x: T; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` x: U; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts index 4d6afaefed..9bcd4b8845 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts @@ -7,6 +7,6 @@ //// class C implements I {[| |]} verify.rangeAfterCodeFix(`f(x: T){ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile.ts new file mode 100644 index 0000000000..070712c252 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile.ts @@ -0,0 +1,11 @@ +/// + +// @allowjs: true +// @noEmit: true + +// @Filename: a.js +////[|// @ts-check|] +////var x = ""; +////x = 1; + +verify.rangeAfterCodeFix("// @ts-nocheck", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile2.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile2.ts new file mode 100644 index 0000000000..4a55f2ba44 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile2.ts @@ -0,0 +1,15 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////[|var x = ""; +////x = 1;|] + +// Disable checking for the whole file +verify.rangeAfterCodeFix(`// @ts-nocheck +var x = ""; +x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts new file mode 100644 index 0000000000..5cace44485 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts @@ -0,0 +1,14 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////[|var x = ""; +////x = 1;|] + +// Disable checking for next line +verify.rangeAfterCodeFix(`var x = ""; +// @ts-ignore +x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts new file mode 100644 index 0000000000..1319325a3d --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts @@ -0,0 +1,18 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = ""; +//// +////[|"test \ +////"; x = 1;|] + +// Disable checking for next line +verify.rangeAfterCodeFix(`"test \\ +"; +// @ts-ignore +x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts new file mode 100644 index 0000000000..3a4b619a7f --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts @@ -0,0 +1,17 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = ""; +//// +////[|/** comment */ +////x = 1;|] + +// Disable checking for next line +verify.rangeAfterCodeFix(`/** comment */ +// @ts-ignore +x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts new file mode 100644 index 0000000000..5b93f4953d --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts @@ -0,0 +1,17 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = 0; +//// +////function f(_a) { +//// [|f(x());|] +////} + +// Disable checking for next line +verify.rangeAfterCodeFix(`// @ts-ignore + f(x());`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts new file mode 100644 index 0000000000..767fa98430 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts @@ -0,0 +1,17 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = 0; +//// +////function f(_a) { +//// [|x();|] +////} + +// Disable checking for next line +verify.rangeAfterCodeFix(`// @ts-ignore + x();`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts new file mode 100644 index 0000000000..3df5864f19 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts @@ -0,0 +1,19 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = 0; +//// +////function f(_a) { +//// /** comment for f */ +//// [|f(x());|] +////} + +// Disable checking for next line +verify.rangeAfterCodeFix(`f( + // @ts-ignore + x());`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + diff --git a/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts b/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts index 2e49a8184e..0a2b0ee799 100644 --- a/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts +++ b/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts @@ -8,7 +8,7 @@ verify.rangeAfterCodeFix(` class A { - [name: string]: number; + [x: string]: number; constructor() { this.x = 10; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index ab83752d93..418066fb6f 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -296,6 +296,7 @@ declare namespace FourSlashInterface { printCurrentQuickInfo(): void; printCurrentSignatureHelp(): void; printCompletionListMembers(): void; + printAvailableCodeFixes(): void; printBreakpointLocation(pos: number): void; printBreakpointAtCurrentLocation(): void; printNameOrDottedNameSpans(pos: number): void; diff --git a/tests/cases/fourslash_old/callOrderDependence.ts b/tests/cases/fourslash_old/callOrderDependence.ts deleted file mode 100644 index 3e7100068f..0000000000 --- a/tests/cases/fourslash_old/callOrderDependence.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -/////**/ - -diagnostics.setEditValidation(IncrementalEditValidation.None); -edit.replace(0, 0, "function foo(bar) {\n b\n}\n"); -goTo.position(27); -FourSlash.currentTestState.getCompletionListAtCaret().entries - .forEach(entry => FourSlash.currentTestState.getCompletionEntryDetails(entry.name)); diff --git a/tests/cases/fourslash_old/chainedFunctionCallsErrorSpan.ts b/tests/cases/fourslash_old/chainedFunctionCallsErrorSpan.ts deleted file mode 100644 index e4a56c546b..0000000000 --- a/tests/cases/fourslash_old/chainedFunctionCallsErrorSpan.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// - -////'foo'.replace('o', '3')./*1*/replace/*2*/('f', 5); - -verify.errorExistsBetweenMarkers('1', '2'); diff --git a/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts b/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts deleted file mode 100644 index 92d288dcb2..0000000000 --- a/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// - -////interface IBar { -////} -//// -////class BarWrapper { -//// private value: /*1*/; -//// public getValue(v: /*2*/T): /*3*/ { -//// } -////} -////function foo(p1: T, p2: /*21*/U) : /*22*/ { -//// var x : /*23*/ -////} -////class MethodTest { -//// public method(p1: T, p2: U, p3:/*31*/ M): Array { -//// return null; -//// } -////} - -goTo.eachMarker(() => { - verify.memberListContains("T"); - verify.memberListContains("U"); - verify.memberListContains("M"); - }); diff --git a/tests/cases/fourslash_old/completionListInTypedObjectLiterals.ts b/tests/cases/fourslash_old/completionListInTypedObjectLiterals.ts deleted file mode 100644 index ce9c34df64..0000000000 --- a/tests/cases/fourslash_old/completionListInTypedObjectLiterals.ts +++ /dev/null @@ -1,142 +0,0 @@ -/// - -////interface MyPoint { -//// x1: number; -//// y1: number; -////} -////var p1: MyPoint = { -//// /*1*/ -////}; -////var p2: MyPoint = { -//// /*2*/x1: 5, -//// /*3*/ -////}; -////var p3: MyPoint = { -//// x1: /*4*/ -////}; -////var p4: any = { -//// /*5*/ -////} -/////// Cast expressions -////var x = ({ -//// /*6*/x1: 0, -////}); -////// Call expression -////function bar(e: MyPoint) { } -////bar({ -//// /*7*/ -////}); -////// New Expression -////class bar2 { -//// constructor(e: MyPoint) { } -////} -//// -////new bar2({ -//// x1: 0, -//// /*8*/ -////}); -////interface Foo { -//// x: { a: number }; -////} -////var aaa: Foo; -////aaa = {/*9*/ -////aaa.x = { /*10*/ -////var bbb = { /*11*/ -////var bbb = { x: { /*12*/ -////var ccc: Foo = { func: () => ({ /*13*/ }) -////var ddd: Foo = { -//// -//// /*14*/ -////var p15: MyPoint = { -//// "x1": 5, -//// /*15*/ -////}; -////// return statements -////function foo(): MyPoint { -//// return { -//// /*16*/ }; -////} -////interface MyPointCreator { -//// create(): MyPoint; -////} -//// -////function getMyPointCreator(): MyPointCreator { -//// return { -//// create: () => { -//// return { -//// x1: 5, -//// /*17*/ -//// }; -//// }, -//// } -////} -//// var eee:Foo = { /*18*/ - -////interface Foo { -//// x: { a: number }; -////} -//// var fff:Foo = { x: { /*19*/ - -goTo.marker("1"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("2"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("3"); -verify.not.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("4"); -verify.not.memberListContains("x1"); -verify.not.memberListContains("y1"); - -goTo.marker("5"); -verify.completionListIsEmpty(); - -goTo.marker("6"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("7"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("8"); -verify.not.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("11"); -verify.memberListContains("x"); -verify.memberListCount(1); - -goTo.marker("12"); -verify.memberListContains("a"); -verify.memberListCount(1); - -goTo.marker("13"); -verify.memberListCount(0); - -goTo.marker("14"); -verify.memberListContains("x"); -verify.memberListCount(1); - -goTo.marker("16"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); -verify.memberListCount(2); - -goTo.marker("17"); -verify.not.memberListContains("x1"); -verify.memberListContains("y1"); -verify.memberListCount(1); - -goTo.marker("18"); -verify.memberListContains("x"); -verify.memberListCount(1); - -goTo.marker("19"); -verify.memberListContains("a"); -verify.memberListCount(1); \ No newline at end of file diff --git a/tests/cases/fourslash_old/constructorOverloadWithoutImplementation.ts b/tests/cases/fourslash_old/constructorOverloadWithoutImplementation.ts deleted file mode 100644 index 79af7af77b..0000000000 --- a/tests/cases/fourslash_old/constructorOverloadWithoutImplementation.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -////class C { -//// constructor(); -//// constructor(x); -//// /*1*/constructor/*2*/(x, y); -////} - -verify.errorExistsBetweenMarkers('1', '2'); \ No newline at end of file diff --git a/tests/cases/fourslash_old/constructorOverloadWithoutImplementation2.ts b/tests/cases/fourslash_old/constructorOverloadWithoutImplementation2.ts deleted file mode 100644 index 22ec5dd79c..0000000000 --- a/tests/cases/fourslash_old/constructorOverloadWithoutImplementation2.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -////class C { -//// constructor(); -//// constructor(x); -//// /*1*/foo/*2*/(x, y) { } -////} - -verify.errorExistsBetweenMarkers('1', '2'); \ No newline at end of file diff --git a/tests/cases/fourslash_old/exportEqualIncremental.ts b/tests/cases/fourslash_old/exportEqualIncremental.ts deleted file mode 100644 index ee6ed886a4..0000000000 --- a/tests/cases/fourslash_old/exportEqualIncremental.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -////interface IPoint { -//// getDist(): number; -////} -////module Shapes { -//// export class Point implements /*1*/IPoint/*2*/ { -//// constructor (public x: number, public y: number) { } -//// getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } -//// static origin = new Point(0, 0); -//// } -////} -////var p: IPoint = new Shapes.Point(3, 4); -////var dist = p.getDist(); - -verify.numberOfErrorsInCurrentFile(0); -goTo.eof(); -edit.insertLine("export = Shapes"); -verify.numberOfErrorsInCurrentFile(1); -verify.errorExistsBetweenMarkers("1", "2"); diff --git a/tests/cases/fourslash_old/findReferences.ts b/tests/cases/fourslash_old/findReferences.ts deleted file mode 100644 index 71efcf1d14..0000000000 --- a/tests/cases/fourslash_old/findReferences.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// - -////class [|{| "name" : "className" |}foo|] { -//// constructor() { -//// } -//// public get [|{| "name" : "barMethodName" |}bar|]() { -//// return 0; -//// } -//// static [|{| "name" : "staticMethodName" |}method|]() { } -////} -////var n: [|{| "name" : "varTypeName" |}foo|] = new [|{| "name" : "ctorInvocation" |}foo|](); -////var x = n.[|{| "name" : "barMethodInvocation" |}bar|](); -////[|{| "name" : "classNameMethodInvocation" |}foo|].[|{| "name" : "staticMethodInvocation" |}method|](); - -var foo1: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "className")[0]; -var bar1: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "barMethodName")[0]; -var method1: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "staticMethodName")[0]; -var foo2: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "varTypeName")[0]; -var foo3: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "ctorInvocation")[0]; -var bar2: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "barMethodInvocation")[0]; -var foo4: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "classNameMethodInvocation")[0]; -var method2: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "staticMethodInvocation")[0]; - -goTo.marker('className'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); -verify.occurrencesAtPositionContains(foo4); - -goTo.marker('barMethodName'); -verify.occurrencesAtPositionContains(bar1); -verify.occurrencesAtPositionContains(bar2); - -goTo.marker('staticMethodName'); -verify.occurrencesAtPositionContains(method1); -verify.occurrencesAtPositionContains(method2); - -goTo.marker('varTypeName'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); -verify.occurrencesAtPositionContains(foo4); - -goTo.marker('ctorInvocation'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); -verify.occurrencesAtPositionContains(foo4); - -goTo.marker('barMethodInvocation'); -verify.occurrencesAtPositionContains(bar1); -verify.occurrencesAtPositionContains(bar2); - -goTo.marker('classNameMethodInvocation'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); -verify.occurrencesAtPositionContains(foo4); - -goTo.marker('staticMethodInvocation'); -verify.occurrencesAtPositionContains(method1); -verify.occurrencesAtPositionContains(method2); \ No newline at end of file diff --git a/tests/cases/fourslash_old/findReferences1.ts b/tests/cases/fourslash_old/findReferences1.ts deleted file mode 100644 index 3d06cacee2..0000000000 --- a/tests/cases/fourslash_old/findReferences1.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -//// interface I { -//// (): void; -//// } -//// -//// var i: I; -//// var [|{| "name" : "varName" |}o|]: Object; -//// [|{| "name" : "varName1" |}o|] = i; -//// i = [|{| "name" : "varName2" |}o|]; -//// -//// var a: { -//// (): void -//// } -//// [|{| "name" : "varName3" |}o|] = a; -//// a = [|{| "name" : "varName4" |}o|]; - -var varName: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName")[0]; -var varName1: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName1")[0]; -var varName2: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName2")[0]; -var varName3: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName3")[0]; -var varName4: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName4")[0]; - -goTo.marker('varName'); -verify.occurrencesAtPositionContains(varName1); -verify.occurrencesAtPositionContains(varName2); -verify.occurrencesAtPositionContains(varName3); -verify.occurrencesAtPositionContains(varName4); diff --git a/tests/cases/fourslash_old/findReferencesAliases1.ts b/tests/cases/fourslash_old/findReferencesAliases1.ts deleted file mode 100644 index 0bee382e2b..0000000000 --- a/tests/cases/fourslash_old/findReferencesAliases1.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -////declare module mod { -//// class Customer { -//// constructor(name: string); -//// } -////} -////import [|{| "name" : "aliasName1" |}c|] = mod.Customer; -////[|{| "name" : "aliasName2" |}c|].prototype; - -var name1: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "aliasName1")[0]; -var name2: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "aliasName2")[0]; - -goTo.marker('aliasName1'); -verify.occurrencesAtPositionContains(name1); -verify.occurrencesAtPositionContains(name2); - -goTo.marker('aliasName2'); -verify.occurrencesAtPositionContains(name1); -verify.occurrencesAtPositionContains(name2); \ No newline at end of file diff --git a/tests/cases/fourslash_old/findReferencesModules1.ts b/tests/cases/fourslash_old/findReferencesModules1.ts deleted file mode 100644 index 5956bd3693..0000000000 --- a/tests/cases/fourslash_old/findReferencesModules1.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -////module [|{| "name" : "moduleName1" |}foo|] { -//// export class Point { -//// constructor(public x: number, public y: number) { } -//// } -////} -////var p: [|{| "name" : "moduleName2" |}foo|].Point = new [|{| "name" : "moduleName3" |}foo|].Point(1, 1); - -var foo1: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "moduleName1")[0]; -var foo2: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "moduleName2")[0]; -var foo3: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "moduleName3")[0]; - -goTo.marker('moduleName1'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); - -goTo.marker('moduleName2'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); - -goTo.marker('moduleName3'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); \ No newline at end of file diff --git a/tests/cases/fourslash_old/funduleDefinedInADifferentFile.ts b/tests/cases/fourslash_old/funduleDefinedInADifferentFile.ts deleted file mode 100644 index c605ca0077..0000000000 --- a/tests/cases/fourslash_old/funduleDefinedInADifferentFile.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -////function E() { } -////module E { -//// export interface I {} -//// export var value = 1; -////} - -////var x: E.I; -////var y/**/ = E.value; -goTo.marker(); -verify.numberOfErrorsInCurrentFile(0); \ No newline at end of file diff --git a/tests/cases/fourslash_old/funduleDefinedInADifferentFile2.ts b/tests/cases/fourslash_old/funduleDefinedInADifferentFile2.ts deleted file mode 100644 index 5c7aff2bfc..0000000000 --- a/tests/cases/fourslash_old/funduleDefinedInADifferentFile2.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -// @Filename: f1.ts -////declare module "q" { -//// export = Q; -////} -////declare function Q(value: T): void; -////declare module Q { -//// -//// interface Deferred { -//// // promise: Promise; -//// resolve(value: T): void; -//// reject(reason: any): void; -//// notify(value: any): void; -//// makeNodeResolver(): (reason: any, value: T) => void; -//// } -//// -////export function defer(): Deferred; -////} - -// @Filename: f2.ts -/////// -////import q = require('q'); -////Q.defer/**/(); - - -goTo.marker(); -verify.completionListContains('defer'); -verify.numberOfErrorsInCurrentFile(0); diff --git a/tests/cases/fourslash_old/genericIncrementalParse.ts b/tests/cases/fourslash_old/genericIncrementalParse.ts deleted file mode 100644 index 73c4c888b1..0000000000 --- a/tests/cases/fourslash_old/genericIncrementalParse.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - - -//// class C { // it is error to reference T in constraint -//// constructor() { } -//// foo(a: T) { -//// } -//// } -//// -//// interface I1 { -//// a: number; -//// }; -//// -//// interface I2 { -//// a: number; -//// b: string; -//// } -//// -//// var x = new C< { a: number; }, { a: number; b: string; }>(); -//// var y = new C(); -//// /*1*/ - -verify.numberOfErrorsInCurrentFile(1); - -goTo.marker("1"); -edit.insert("var z = new C < I2"); -verify.numberOfErrorsInCurrentFile(2); - -edit.insert(",I1>()"); -verify.numberOfErrorsInCurrentFile(2); diff --git a/tests/cases/fourslash_old/genericStructuralTypeConstraint.ts b/tests/cases/fourslash_old/genericStructuralTypeConstraint.ts deleted file mode 100644 index 458aaaa580..0000000000 --- a/tests/cases/fourslash_old/genericStructuralTypeConstraint.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// - - -//// class C { // it is error to reference T in constraint -//// constructor() { } -//// foo(a: T) { -//// } -//// } -//// -//// interface I1 { -//// a: string;/*1*/ -//// }; -//// -//// interface I2 { -//// a: number; -//// b: string; -//// } -//// -//// var x = new C< { a: number; }, { a: number; b: string; }>(); -//// var y = new C(); -//// var z = new C() -//// /*2*/ - -goTo.marker("2"); -edit.insertLine(""); -// y fails due to a: string in I1, z fails due to I1 not being assignment compatible to I2 -verify.numberOfErrorsInCurrentFile(3); - -goTo.marker("1"); -edit.backspace(10); -edit.insertLine(""); -verify.numberOfErrorsInCurrentFile(2); -// y should be OK now member a is gone, z fails due to I1 not being assignment compatible to I2 - -edit.insert("a: number;"); -// y should be OK with member a the correct type, z still fails due to I1 not being assignment compatible to I2 -verify.numberOfErrorsInCurrentFile(2); diff --git a/tests/cases/fourslash_old/getTypeOfUnresolvedGenericExtension.ts b/tests/cases/fourslash_old/getTypeOfUnresolvedGenericExtension.ts deleted file mode 100644 index 0faf4cbb95..0000000000 --- a/tests/cases/fourslash_old/getTypeOfUnresolvedGenericExtension.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -//// class S18 extends S18< A[], { }[] > -//// { -//// } -//// (new S18(123))./**/S18 ; -//// - -goTo.marker(); -diagnostics.validateTypeAtCurrentPosition(); diff --git a/tests/cases/fourslash_old/overloadResolutionErrors.ts b/tests/cases/fourslash_old/overloadResolutionErrors.ts deleted file mode 100644 index ac3a4def8c..0000000000 --- a/tests/cases/fourslash_old/overloadResolutionErrors.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// - -// Tests that the error spans are correct for a signature mismatch - -/////*1*/'foo'.replace('o', '3')./*2*/replace/*3*/('f', 5)/*4*/; -//// -/////*5*/('foo'.replace('o', '3')./*55*/replace/*6*/)/*65*/('f', 5); -////var foo = { -//// fun: () => false, -//// fun2: function () { return true; } -////}; -/////*7*/foo./*8*/fun/*9*/(1); -/////*10*/foo./*11*/fun2/*12*/(1); -//// -////module M { -//// export class C { -//// constructor(x: number) { } -//// public method(x: string); -//// public method(x: number); -//// public method(x) { } -//// } -////} -////var c: M.C = new /*13*/M./*14*/C/*15*/(""); -/////*16*/c./*17*/method/*18*/(c); -/////*19*/(c./*195*/method/*20*/)/*21*/(c); - - -verify.errorExistsBetweenMarkers('2', '3'); -verify.errorExistsBetweenMarkers('8', '9'); -verify.errorExistsBetweenMarkers('11', '12'); -verify.errorExistsBetweenMarkers('14', '15'); -verify.errorExistsBetweenMarkers('17', '18'); -verify.not.errorExistsBetweenMarkers('1', '2'); -verify.not.errorExistsBetweenMarkers('3', '4'); -verify.not.errorExistsBetweenMarkers('7', '8'); -verify.not.errorExistsBetweenMarkers('10', '11'); -verify.not.errorExistsBetweenMarkers('13', '14'); -verify.not.errorExistsBetweenMarkers('16', '17'); diff --git a/tests/cases/fourslash_old/thisRefGotoDef.ts b/tests/cases/fourslash_old/thisRefGotoDef.ts deleted file mode 100644 index ba16a6aa31..0000000000 --- a/tests/cases/fourslash_old/thisRefGotoDef.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// class Greeter { -//// /*def*/element: HTMLElement; -//// span: HTMLElement; -//// timerToken: number; -//// constructor(element: HTMLElement) { -//// this.element/*ref*/ = element; -//// } -//// } - -verify.goToDefinition("ref", "def");