diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 9449d1dd9fe..b3bca4a3857 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -234,8 +234,8 @@ namespace ts { if (node.name.kind === SyntaxKind.ComputedPropertyName) { const nameExpression = (node.name).expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (isStringOrNumericLiteral(nameExpression.kind)) { - return (nameExpression).text; + if (isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; } Debug.assert(isWellKnownSymbolSyntactically(nameExpression)); @@ -3209,7 +3209,7 @@ namespace ts { break; case SyntaxKind.SpreadAssignment: - transformFlags |= TransformFlags.AssertESNext | TransformFlags.ContainsSpread | TransformFlags.ContainsObjectSpread; + transformFlags |= TransformFlags.AssertESNext | TransformFlags.ContainsObjectSpread; break; case SyntaxKind.SuperKeyword: @@ -3261,10 +3261,10 @@ namespace ts { transformFlags |= TransformFlags.ContainsLexicalThis; } - if (subtreeFlags & TransformFlags.ContainsSpread) { + if (subtreeFlags & TransformFlags.ContainsObjectSpread) { // If an ObjectLiteralExpression contains a spread element, then it // is an ES next node. - transformFlags |= TransformFlags.AssertESNext | TransformFlags.ContainsObjectSpread; + transformFlags |= TransformFlags.AssertESNext; } break; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 730a435e67f..21563f48e8a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3030,7 +3030,7 @@ namespace ts { } function isComputedNonLiteralName(name: PropertyName): boolean { - return name.kind === SyntaxKind.ComputedPropertyName && !isStringOrNumericLiteral((name).expression.kind); + return name.kind === SyntaxKind.ComputedPropertyName && !isStringOrNumericLiteral((name).expression); } function getRestType(source: Type, properties: PropertyName[], symbol: Symbol): Type { @@ -8907,7 +8907,7 @@ namespace ts { return type; } - function getTypeOfDestructuredProperty(type: Type, name: Identifier | LiteralExpression | ComputedPropertyName) { + function getTypeOfDestructuredProperty(type: Type, name: PropertyName) { const text = getTextOfPropertyName(name); return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && getIndexTypeOfType(type, IndexKind.Number) || @@ -9936,8 +9936,7 @@ namespace ts { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (languageVersion === ScriptTarget.ES2015 - && declaration.kind === SyntaxKind.ClassDeclaration + if (declaration.kind === SyntaxKind.ClassDeclaration && nodeIsDecorated(declaration)) { let container = getContainingClass(node); while (container !== undefined) { @@ -11165,10 +11164,10 @@ namespace ts { return links.resolvedType; } - function getObjectLiteralIndexInfo(node: ObjectLiteralExpression, properties: Symbol[], kind: IndexKind): IndexInfo { + function getObjectLiteralIndexInfo(propertyNodes: NodeArray, offset: number, properties: Symbol[], kind: IndexKind): IndexInfo { const propTypes: Type[] = []; for (let i = 0; i < properties.length; i++) { - if (kind === IndexKind.String || isNumericName(node.properties[i].name)) { + if (kind === IndexKind.String || isNumericName(propertyNodes[i + offset].name)) { propTypes.push(getTypeOfSymbol(properties[i])); } } @@ -11194,7 +11193,9 @@ namespace ts { let hasComputedStringProperty = false; let hasComputedNumberProperty = false; - for (const memberDecl of node.properties) { + let offset = 0; + for (let i = 0; i < node.properties.length; i++) { + const memberDecl = node.properties[i]; let member = memberDecl.symbol; if (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment || @@ -11263,6 +11264,7 @@ namespace ts { return unknownType; } spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + offset = i + 1; continue; } else { @@ -11316,8 +11318,8 @@ namespace ts { return createObjectLiteralType(); function createObjectLiteralType() { - const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.String) : undefined; - const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined; + const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.String) : undefined; + const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; result.flags |= TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); @@ -14501,6 +14503,8 @@ namespace ts { case SyntaxKind.LessThanEqualsToken: case SyntaxKind.GreaterThanEqualsToken: if (checkForDisallowedESSymbolOperand(operator)) { + leftType = getBaseTypeOfLiteralType(leftType); + rightType = getBaseTypeOfLiteralType(rightType); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a18146bdaa1..eacfd1f0b67 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -38,6 +38,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; };`; @@ -45,8 +48,11 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { const restHelper = ` var __rest = (this && this.__rest) || function (s, e) { var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; return t; };`; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 44db12f7b6c..ef9f8bd876a 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -102,12 +102,12 @@ namespace ts { // Literals - export function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange): StringLiteral; + export function createLiteral(textSource: StringLiteral | NumericLiteral | Identifier, location?: TextRange): StringLiteral; export function createLiteral(value: string, location?: TextRange): StringLiteral; export function createLiteral(value: number, location?: TextRange): NumericLiteral; export function createLiteral(value: boolean, location?: TextRange): BooleanLiteral; export function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression; - export function createLiteral(value: string | number | boolean | StringLiteral | Identifier, location?: TextRange): PrimaryExpression { + export function createLiteral(value: string | number | boolean | StringLiteral | NumericLiteral | Identifier, location?: TextRange): PrimaryExpression { if (typeof value === "number") { const node = createNode(SyntaxKind.NumericLiteral, location, /*flags*/ undefined); node.text = value.toString(); @@ -3259,7 +3259,10 @@ namespace ts { // `"a"` in `let { "a": b } = ...` // `1` in `let { 1: b } = ...` if ((bindingElement).propertyName) { - return (bindingElement).propertyName; + const propertyName = (bindingElement).propertyName; + return isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) + ? propertyName.expression + : propertyName; } break; @@ -3270,7 +3273,10 @@ namespace ts { // `"a"` in `({ "a": b } = ...)` // `1` in `({ 1: b } = ...)` if ((bindingElement).name) { - return (bindingElement).name; + const propertyName = (bindingElement).name; + return isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) + ? propertyName.expression + : propertyName; } break; @@ -3282,7 +3288,9 @@ namespace ts { const target = getTargetOfBindingOrAssignmentElement(bindingElement); if (target && isPropertyName(target)) { - return target; + return isComputedPropertyName(target) && isStringOrNumericLiteral(target.expression) + ? target.expression + : target; } Debug.fail("Invalid property name for binding element."); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f798507081e..b08f75b0f5b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1168,7 +1168,7 @@ namespace ts { function parsePropertyNameWorker(allowComputedPropertyNames: boolean): PropertyName { if (token() === SyntaxKind.StringLiteral || token() === SyntaxKind.NumericLiteral) { - return parseLiteralNode(/*internName*/ true); + return parseLiteralNode(/*internName*/ true); } if (allowComputedPropertyNames && token() === SyntaxKind.OpenBracketToken) { return parseComputedPropertyName(); @@ -5514,7 +5514,7 @@ namespace ts { node.flags |= NodeFlags.GlobalAugmentation; } else { - node.name = parseLiteralNode(/*internName*/ true); + node.name = parseLiteralNode(/*internName*/ true); } if (token() === SyntaxKind.OpenBraceToken) { diff --git a/src/compiler/transformers/destructuring.ts b/src/compiler/transformers/destructuring.ts index 30484ffaf5c..af950ce688c 100644 --- a/src/compiler/transformers/destructuring.ts +++ b/src/compiler/transformers/destructuring.ts @@ -244,12 +244,15 @@ namespace ts { boundValue = ensureIdentifier(host, boundValue, reuseIdentifierExpressions, location); } let bindingElements: BindingOrAssignmentElement[]; + let computedTempVariables: Expression[]; for (let i = 0; i < numElements; i++) { const element = elements[i]; if (!getRestIndicatorOfBindingOrAssignmentElement(element)) { + const propertyName = getPropertyNameOfBindingOrAssignmentElement(element); if (host.level >= FlattenLevel.ObjectRest && !(element.transformFlags & (TransformFlags.ContainsRest | TransformFlags.ContainsObjectRest)) - && !(getTargetOfBindingOrAssignmentElement(element).transformFlags & (TransformFlags.ContainsRest | TransformFlags.ContainsObjectRest))) { + && !(getTargetOfBindingOrAssignmentElement(element).transformFlags & (TransformFlags.ContainsRest | TransformFlags.ContainsObjectRest)) + && !isComputedPropertyName(propertyName)) { bindingElements = append(bindingElements, element); } else { @@ -257,8 +260,10 @@ namespace ts { host.emitBindingOrAssignment(host.createObjectBindingOrAssignmentPattern(bindingElements), boundValue, location, bindingTarget); bindingElements = undefined; } - const propertyName = getPropertyNameOfBindingOrAssignmentElement(element); const value = createDestructuringPropertyAccess(host, boundValue, propertyName); + if (isComputedPropertyName(propertyName)) { + computedTempVariables = append(computedTempVariables, (value as ElementAccessExpression).argumentExpression); + } flattenBindingOrAssignmentElement(host, element, value, /*location*/ element); } } @@ -267,7 +272,7 @@ namespace ts { host.emitBindingOrAssignment(host.createObjectBindingOrAssignmentPattern(bindingElements), boundValue, location, bindingTarget); bindingElements = undefined; } - const value = createRestCall(boundValue, elements, bindingTarget); + const value = createRestCall(boundValue, elements, computedTempVariables, bindingTarget); flattenBindingOrAssignmentElement(host, element, value, element); } } @@ -433,17 +438,28 @@ namespace ts { /** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`*/ - function createRestCall(value: Expression, elements: BindingOrAssignmentElement[], location: TextRange): Expression { - const propertyNames: LiteralExpression[] = []; + function createRestCall(value: Expression, elements: BindingOrAssignmentElement[], computedTempVariables: Expression[], location: TextRange): Expression { + const propertyNames: Expression[] = []; for (let i = 0; i < elements.length - 1; i++) { - if (isOmittedExpression(elements[i])) { - continue; + const propertyName = getPropertyNameOfBindingOrAssignmentElement(elements[i]); + if (propertyName) { + if (isComputedPropertyName(propertyName)) { + // get the temp name and put that in there instead, like `_tmp + ""` + const temp = computedTempVariables.shift(); + propertyNames.push( + createConditional( + createStrictEquality(createTypeOf(temp), createLiteral("symbol")), + createToken(SyntaxKind.QuestionToken), + temp, + createToken(SyntaxKind.ColonToken), + createAdd(temp, createLiteral("")) + ) + ); + } + else { + propertyNames.push(createLiteral(propertyName)); + } } - const str = createSynthesizedNode(SyntaxKind.StringLiteral); - str.pos = location.pos; - str.end = location.end; - str.text = getTextOfPropertyName(getPropertyNameOfBindingOrAssignmentElement(elements[i])); - propertyNames.push(str); } const args = createSynthesizedNodeArray([value, createArrayLiteral(propertyNames, location)]); return createCall(createIdentifier("__rest"), undefined, args); diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 0085fcef1bc..431a638db6b 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -1011,7 +1011,20 @@ namespace ts { // Return the result if we have an immediate super() call on the last statement. if (superCallExpression && statementOffset === ctorStatements.length - 1) { - statements.push(createReturn(superCallExpression)); + const returnStatement = createReturn(superCallExpression); + + if (superCallExpression.kind !== SyntaxKind.BinaryExpression + || (superCallExpression as BinaryExpression).left.kind !== SyntaxKind.CallExpression) { + Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); + } + + // Shift comments from the original super call to the return statement. + setCommentRange(returnStatement, getCommentRange( + setEmitFlags( + (superCallExpression as BinaryExpression).left, + EmitFlags.NoComments))); + + statements.push(returnStatement); return SuperCaptureResult.ReplaceWithReturn; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b22fba32da9..f99a644137a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -579,9 +579,9 @@ namespace ts { export type EntityName = Identifier | QualifiedName; - export type PropertyName = Identifier | LiteralExpression | ComputedPropertyName; + export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - export type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; + export type DeclarationName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | BindingPattern; export interface Declaration extends Node { _declarationBrand: any; @@ -589,7 +589,7 @@ namespace ts { } export interface DeclarationStatement extends Declaration, Statement { - name?: Identifier | LiteralExpression; + name?: Identifier | StringLiteral | NumericLiteral; } export interface ComputedPropertyName extends Node { @@ -919,7 +919,7 @@ namespace ts { export interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; - /* @internal */ textSourceNode?: Identifier | StringLiteral; // Allows a StringLiteral to get its text from another node (used by transforms). + /* @internal */ textSourceNode?: Identifier | StringLiteral | NumericLiteral; // Allows a StringLiteral to get its text from another node (used by transforms). } // Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing. @@ -1746,7 +1746,7 @@ namespace ts { export interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; - name: Identifier | LiteralExpression; + name: Identifier | StringLiteral; body?: ModuleBlock | NamespaceDeclaration | JSDocNamespaceDeclaration | Identifier; } @@ -1952,7 +1952,7 @@ namespace ts { export interface JSDocRecordMember extends PropertySignature { kind: SyntaxKind.JSDocRecordMember; - name: Identifier | LiteralExpression; + name: Identifier | StringLiteral | NumericLiteral; type?: JSDocType; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index dd2afc38cbf..455ca0ff740 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -493,7 +493,7 @@ namespace ts { case SyntaxKind.NumericLiteral: return (name).text; case SyntaxKind.ComputedPropertyName: - if (isStringOrNumericLiteral((name).expression.kind)) { + if (isStringOrNumericLiteral((name).expression)) { return ((name).expression).text; } } @@ -1262,6 +1262,7 @@ namespace ts { case SyntaxKind.Decorator: case SyntaxKind.JsxExpression: case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.SpreadAssignment: return true; case SyntaxKind.ExpressionWithTypeArguments: return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); @@ -1879,8 +1880,10 @@ namespace ts { return isFunctionLike(node) && hasModifier(node, ModifierFlags.Async) && !isAccessor(node); } - export function isStringOrNumericLiteral(kind: SyntaxKind): boolean { - return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NumericLiteral; + export function isStringOrNumericLiteral(node: Node): node is StringLiteral | NumericLiteral { + const kind = node.kind; + return kind === SyntaxKind.StringLiteral + || kind === SyntaxKind.NumericLiteral; } /** @@ -1896,7 +1899,7 @@ namespace ts { export function isDynamicName(name: DeclarationName): boolean { return name.kind === SyntaxKind.ComputedPropertyName && - !isStringOrNumericLiteral((name).expression.kind) && + !isStringOrNumericLiteral((name).expression) && !isWellKnownSymbolSyntactically((name).expression); } @@ -1909,7 +1912,7 @@ namespace ts { return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); } - export function getPropertyNameForPropertyNameNode(name: DeclarationName): string { + export function getPropertyNameForPropertyNameNode(name: DeclarationName | ParameterDeclaration): string { if (name.kind === SyntaxKind.Identifier || name.kind === SyntaxKind.StringLiteral || name.kind === SyntaxKind.NumericLiteral || name.kind === SyntaxKind.Parameter) { return (name).text; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 6ff4dccdee3..f4fc7b8f009 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2013,13 +2013,13 @@ namespace FourSlash { this.raiseError("Errors expected."); } - if (diagnostics.length > 1 && errorCode !== undefined) { + if (diagnostics.length > 1 && errorCode === undefined) { this.raiseError("When there's more than one error, you must specify the errror to fix."); } const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode); - return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]); + return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.start + diagnostic.length, [diagnostic.code]); } public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) { diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts index d64a99ca1b9..ae13a965838 100644 --- a/src/services/codefixes/fixes.ts +++ b/src/services/codefixes/fixes.ts @@ -1 +1,2 @@ /// +/// \ No newline at end of file diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts new file mode 100644 index 00000000000..8e14bdcb73e --- /dev/null +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -0,0 +1,167 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: [ + Diagnostics._0_is_declared_but_never_used.code, + Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: (context: CodeFixContext) => { + const sourceFile = context.sourceFile; + const start = context.span.start; + + let token = getTokenAtPosition(sourceFile, start); + + // this handles var ["computed"] = 12; + if (token.kind === SyntaxKind.OpenBracketToken) { + token = getTokenAtPosition(sourceFile, start + 1); + } + + switch (token.kind) { + case ts.SyntaxKind.Identifier: + switch (token.parent.kind) { + case ts.SyntaxKind.VariableDeclaration: + switch (token.parent.parent.parent.kind) { + case SyntaxKind.ForStatement: + const forStatement = token.parent.parent.parent; + const forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + + case SyntaxKind.ForOfStatement: + const forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { + const forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + + case SyntaxKind.ForInStatement: + // There is no valid fix in the case of: + // for .. in + return undefined; + + case SyntaxKind.CatchClause: + const catchClause = token.parent.parent; + const parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + + default: + const variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + const declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + + case SyntaxKind.TypeParameter: + const typeParameters = (token.parent.parent).typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + + case ts.SyntaxKind.Parameter: + const functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + + // handle case where 'import a = A;' + case SyntaxKind.ImportEqualsDeclaration: + const importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + + case SyntaxKind.ImportSpecifier: + const namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + // Only 1 import and it is unused. So the entire declaration should be removed. + const importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + + // handle case where "import d, * as ns from './file'" + // or "'import {a, b as ns} from './file'" + case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' + const importClause = token.parent; + if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| + const importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { // import |d,| * as ns from './file' + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + + case SyntaxKind.NamespaceImport: + const namespaceImport = token.parent; + if (namespaceImport.name == token && !(namespaceImport.parent).name) { + const importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + const start = (namespaceImport.parent).name.end; + return createCodeFix("", start, (namespaceImport.parent).namedBindings.end - start); + } + } + break; + + case SyntaxKind.PropertyDeclaration: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + + case SyntaxKind.NamespaceImport: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + + function findImportDeclaration(token: Node): Node { + let importDecl = token; + while (importDecl.kind != SyntaxKind.ImportDeclaration && importDecl.parent) { + importDecl = importDecl.parent; + } + + return importDecl; + } + + function createCodeFix(newText: string, start: number, length: number): CodeAction[] { + return [{ + description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText, span: { start, length } }] + }] + }]; + } + + function removeSingleItem(elements: NodeArray, token: T): CodeAction[] { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); +} \ No newline at end of file diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 9765780ee7c..313a3d2ea3e 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1188,7 +1188,7 @@ namespace ts.FindAllReferences { if (node.name.kind === SyntaxKind.ComputedPropertyName) { const nameExpression = (node.name).expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (isStringOrNumericLiteral(nameExpression.kind)) { + if (isStringOrNumericLiteral(nameExpression)) { return (nameExpression).text; } return undefined; diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index a419877bcd8..502381b8be8 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -1,4 +1,4 @@ -{ +{ "compilerOptions": { "noImplicitAny": true, "noImplicitThis": true, diff --git a/src/services/utilities.ts b/src/services/utilities.ts index cfb6aae010b..82b13f82327 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1282,7 +1282,7 @@ namespace ts { if (isImportOrExportSpecifierName(location)) { return location.getText(); } - else if (isStringOrNumericLiteral(location.kind) && + else if (isStringOrNumericLiteral(location) && location.parent.kind === SyntaxKind.ComputedPropertyName) { return (location).text; } diff --git a/tests/baselines/reference/capturedLetConstInLoop1.errors.txt b/tests/baselines/reference/capturedLetConstInLoop1.errors.txt deleted file mode 100644 index a10b380bcf9..00000000000 --- a/tests/baselines/reference/capturedLetConstInLoop1.errors.txt +++ /dev/null @@ -1,128 +0,0 @@ -tests/cases/compiler/capturedLetConstInLoop1.ts(69,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop1.ts(86,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop1.ts(92,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop1.ts(109,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. - - -==== tests/cases/compiler/capturedLetConstInLoop1.ts (4 errors) ==== - //==== let - for (let x in {}) { - (function() { return x}); - (() => x); - } - - for (let x of []) { - (function() { return x}); - (() => x); - } - - for (let x = 0; x < 1; ++x) { - (function() { return x}); - (() => x); - } - - while (1 === 1) { - let x; - (function() { return x}); - (() => x); - } - - do { - let x; - (function() { return x}); - (() => x); - } while (1 === 1) - - for (let y = 0; y < 1; ++y) { - let x = 1; - (function() { return x}); - (() => x); - } - - for (let x = 0, y = 1; x < 1; ++x) { - (function() { return x + y}); - (() => x + y); - } - - while (1 === 1) { - let x, y; - (function() { return x + y}); - (() => x + y); - } - - do { - let x, y; - (function() { return x + y}); - (() => x + y); - } while (1 === 1) - - for (let y = 0; y < 1; ++y) { - let x = 1; - (function() { return x + y}); - (() => x + y); - } - - //=========const - for (const x in {}) { - (function() { return x}); - (() => x); - } - - for (const x of []) { - (function() { return x}); - (() => x); - } - - for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - (function() { return x}); - (() => x); - } - - while (1 === 1) { - const x = 1; - (function() { return x}); - (() => x); - } - - do { - const x = 1; - (function() { return x}); - (() => x); - } while (1 === 1) - - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - (function() { return x}); - (() => x); - } - - for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - (function() { return x + y}); - (() => x + y); - } - - while (1 === 1) { - const x = 1, y = 1; - (function() { return x + y}); - (() => x + y); - } - - do { - const x = 1, y = 1; - (function() { return x + y}); - (() => x + y); - } while (1 === 1) - - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - (function() { return x + y}); - (() => x + y); - } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop1.types b/tests/baselines/reference/capturedLetConstInLoop1.types index c60ac25ce1f..45d4a1c9368 100644 --- a/tests/baselines/reference/capturedLetConstInLoop1.types +++ b/tests/baselines/reference/capturedLetConstInLoop1.types @@ -32,10 +32,10 @@ for (let x of []) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -90,16 +90,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x}); >(function() { return x}) : () => number @@ -114,12 +114,12 @@ for (let y = 0; y < 1; ++y) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -188,16 +188,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number @@ -246,21 +246,21 @@ for (const x of []) { } for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 0 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 0 } while (1 === 1) { @@ -269,34 +269,34 @@ while (1 === 1) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } while (1 === 1) >1 === 1 : boolean @@ -304,49 +304,49 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 } while (1 === 1) { @@ -355,46 +355,46 @@ while (1 === 1) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 } do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 } while (1 === 1) >1 === 1 : boolean @@ -402,27 +402,27 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 } diff --git a/tests/baselines/reference/capturedLetConstInLoop1_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop1_ES6.errors.txt deleted file mode 100644 index 24c5ddf17b6..00000000000 --- a/tests/baselines/reference/capturedLetConstInLoop1_ES6.errors.txt +++ /dev/null @@ -1,128 +0,0 @@ -tests/cases/compiler/capturedLetConstInLoop1_ES6.ts(69,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop1_ES6.ts(86,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop1_ES6.ts(92,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop1_ES6.ts(109,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. - - -==== tests/cases/compiler/capturedLetConstInLoop1_ES6.ts (4 errors) ==== - //==== let - for (let x in {}) { - (function() { return x}); - (() => x); - } - - for (let x of []) { - (function() { return x}); - (() => x); - } - - for (let x = 0; x < 1; ++x) { - (function() { return x}); - (() => x); - } - - while (1 === 1) { - let x; - (function() { return x}); - (() => x); - } - - do { - let x; - (function() { return x}); - (() => x); - } while (1 === 1) - - for (let y = 0; y < 1; ++y) { - let x = 1; - (function() { return x}); - (() => x); - } - - for (let x = 0, y = 1; x < 1; ++x) { - (function() { return x + y}); - (() => x + y); - } - - while (1 === 1) { - let x, y; - (function() { return x + y}); - (() => x + y); - } - - do { - let x, y; - (function() { return x + y}); - (() => x + y); - } while (1 === 1) - - for (let y = 0; y < 1; ++y) { - let x = 1; - (function() { return x + y}); - (() => x + y); - } - - //=========const - for (const x in {}) { - (function() { return x}); - (() => x); - } - - for (const x of []) { - (function() { return x}); - (() => x); - } - - for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - (function() { return x}); - (() => x); - } - - while (1 === 1) { - const x = 1; - (function() { return x}); - (() => x); - } - - do { - const x = 1; - (function() { return x}); - (() => x); - } while (1 === 1) - - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - (function() { return x}); - (() => x); - } - - for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - (function() { return x + y}); - (() => x + y); - } - - while (1 === 1) { - const x = 1, y = 1; - (function() { return x + y}); - (() => x + y); - } - - do { - const x = 1, y = 1; - (function() { return x + y}); - (() => x + y); - } while (1 === 1) - - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - (function() { return x + y}); - (() => x + y); - } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop1_ES6.types b/tests/baselines/reference/capturedLetConstInLoop1_ES6.types index cee71c0d5cd..5e803b35863 100644 --- a/tests/baselines/reference/capturedLetConstInLoop1_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop1_ES6.types @@ -32,10 +32,10 @@ for (let x of []) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -90,16 +90,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x}); >(function() { return x}) : () => number @@ -114,12 +114,12 @@ for (let y = 0; y < 1; ++y) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -188,16 +188,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number @@ -246,21 +246,21 @@ for (const x of []) { } for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 0 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 0 } while (1 === 1) { @@ -269,34 +269,34 @@ while (1 === 1) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } while (1 === 1) >1 === 1 : boolean @@ -304,49 +304,49 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 } while (1 === 1) { @@ -355,46 +355,46 @@ while (1 === 1) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 } do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 } while (1 === 1) >1 === 1 : boolean @@ -402,27 +402,27 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 } diff --git a/tests/baselines/reference/capturedLetConstInLoop2.errors.txt b/tests/baselines/reference/capturedLetConstInLoop2.errors.txt deleted file mode 100644 index 9125a87ecfe..00000000000 --- a/tests/baselines/reference/capturedLetConstInLoop2.errors.txt +++ /dev/null @@ -1,191 +0,0 @@ -tests/cases/compiler/capturedLetConstInLoop2.ts(108,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop2.ts(133,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop2.ts(142,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop2.ts(170,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. - - -==== tests/cases/compiler/capturedLetConstInLoop2.ts (4 errors) ==== - - - // ========let - function foo0(x) { - for (let x of []) { - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo0_1(x) { - for (let x in []) { - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo1(x) { - for (let x = 0; x < 1; ++x) { - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo2(x) { - while (1 === 1) { - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo3(x) { - do { - let x; - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } while (1 === 1) - } - - function foo4(x) { - for (let y = 0; y < 1; ++y) { - let a = arguments.length; - let x = 1; - (function() { return x + a }); - (() => x + a); - } - } - - function foo5(x) { - for (let x = 0, y = 1; x < 1; ++x) { - let a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - - - function foo6(x) { - while (1 === 1) { - let x, y; - let a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - - function foo7(x) { - do { - let x, y; - let a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } while (1 === 1) - } - - - function foo8(x) { - for (let y = 0; y < 1; ++y) { - let x = 1; - let a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - ///=======const - function foo0_c(x) { - for (const x of []) { - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo0_1_c(x) { - for (const x in []) { - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo1_c(x) { - for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo2_c(x) { - while (1 === 1) { - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo3_c(x) { - do { - const x = 1; - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } while (1 === 1) - } - - function foo4_c(x) { - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const a = arguments.length; - const x = 1; - (function() { return x + a }); - (() => x + a); - } - } - - function foo5_c(x) { - for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - - - function foo6_c(x) { - while (1 === 1) { - const x = 1, y =1 ; - const a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - - function foo7_c(x) { - do { - const x = 1, y = 1; - const a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } while (1 === 1) - } - - - function foo8_c(x) { - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - const a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop2.types b/tests/baselines/reference/capturedLetConstInLoop2.types index f4f7a926f89..4f819d3c3f9 100644 --- a/tests/baselines/reference/capturedLetConstInLoop2.types +++ b/tests/baselines/reference/capturedLetConstInLoop2.types @@ -68,10 +68,10 @@ function foo1(x) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -168,10 +168,10 @@ function foo4(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number @@ -183,7 +183,7 @@ function foo4(x) { let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + a }); >(function() { return x + a }) : () => number @@ -207,12 +207,12 @@ function foo5(x) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -328,16 +328,16 @@ function foo8(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 let a = arguments.length; >a : number @@ -430,11 +430,11 @@ function foo1_c(x) { >x : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 const a = arguments.length; >a : number @@ -446,14 +446,14 @@ function foo1_c(x) { >(function() { return x + a }) : () => number >function() { return x + a } : () => number >x + a : number ->x : number +>x : 0 >a : number (() => x + a); >(() => x + a) : () => number >() => x + a : () => number >x + a : number ->x : number +>x : 0 >a : number } } @@ -495,8 +495,8 @@ function foo3_c(x) { do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 const a = arguments.length; >a : number @@ -508,14 +508,14 @@ function foo3_c(x) { >(function() { return x + a }) : () => number >function() { return x + a } : () => number >x + a : number ->x : number +>x : 1 >a : number (() => x + a); >(() => x + a) : () => number >() => x + a : () => number >x + a : number ->x : number +>x : 1 >a : number } while (1 === 1) @@ -529,11 +529,11 @@ function foo4_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const a = arguments.length; >a : number @@ -542,21 +542,21 @@ function foo4_c(x) { >length : number const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + a }); >(function() { return x + a }) : () => number >function() { return x + a } : () => number >x + a : number ->x : number +>x : 1 >a : number (() => x + a); >(() => x + a) : () => number >() => x + a : () => number >x + a : number ->x : number +>x : 1 >a : number } } @@ -566,13 +566,13 @@ function foo5_c(x) { >x : any for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 const a = arguments.length; >a : number @@ -585,8 +585,8 @@ function foo5_c(x) { >function() { return x + y + a } : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >a : number (() => x + y + a); @@ -594,8 +594,8 @@ function foo5_c(x) { >() => x + y + a : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >a : number } } @@ -611,10 +611,10 @@ function foo6_c(x) { >1 : 1 const x = 1, y =1 ; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 const a = arguments.length; >a : number @@ -627,8 +627,8 @@ function foo6_c(x) { >function() { return x + y + a } : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >a : number (() => x + y + a); @@ -636,8 +636,8 @@ function foo6_c(x) { >() => x + y + a : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >a : number } } @@ -648,10 +648,10 @@ function foo7_c(x) { do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 const a = arguments.length; >a : number @@ -664,8 +664,8 @@ function foo7_c(x) { >function() { return x + y + a } : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >a : number (() => x + y + a); @@ -673,8 +673,8 @@ function foo7_c(x) { >() => x + y + a : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >a : number } while (1 === 1) @@ -689,15 +689,15 @@ function foo8_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 const a = arguments.length; >a : number @@ -710,8 +710,8 @@ function foo8_c(x) { >function() { return x + y + a } : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >a : number (() => x + y + a); @@ -719,8 +719,8 @@ function foo8_c(x) { >() => x + y + a : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >a : number } } diff --git a/tests/baselines/reference/capturedLetConstInLoop2_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop2_ES6.errors.txt deleted file mode 100644 index d61bf3619c7..00000000000 --- a/tests/baselines/reference/capturedLetConstInLoop2_ES6.errors.txt +++ /dev/null @@ -1,190 +0,0 @@ -tests/cases/compiler/capturedLetConstInLoop2_ES6.ts(107,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop2_ES6.ts(132,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop2_ES6.ts(141,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop2_ES6.ts(169,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. - - -==== tests/cases/compiler/capturedLetConstInLoop2_ES6.ts (4 errors) ==== - - // ========let - function foo0(x) { - for (let x of []) { - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo0_1(x) { - for (let x in []) { - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo1(x) { - for (let x = 0; x < 1; ++x) { - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo2(x) { - while (1 === 1) { - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo3(x) { - do { - let x; - let a = arguments.length; - (function() { return x + a }); - (() => x + a); - } while (1 === 1) - } - - function foo4(x) { - for (let y = 0; y < 1; ++y) { - let a = arguments.length; - let x = 1; - (function() { return x + a }); - (() => x + a); - } - } - - function foo5(x) { - for (let x = 0, y = 1; x < 1; ++x) { - let a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - - - function foo6(x) { - while (1 === 1) { - let x, y; - let a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - - function foo7(x) { - do { - let x, y; - let a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } while (1 === 1) - } - - - function foo8(x) { - for (let y = 0; y < 1; ++y) { - let x = 1; - let a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - ///=======const - function foo0_c(x) { - for (const x of []) { - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo0_1_c(x) { - for (const x in []) { - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo1_c(x) { - for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo2_c(x) { - while (1 === 1) { - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } - } - - function foo3_c(x) { - do { - const x = 1; - const a = arguments.length; - (function() { return x + a }); - (() => x + a); - } while (1 === 1) - } - - function foo4_c(x) { - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const a = arguments.length; - const x = 1; - (function() { return x + a }); - (() => x + a); - } - } - - function foo5_c(x) { - for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - - - function foo6_c(x) { - while (1 === 1) { - const x = 1, y =1 ; - const a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } - - function foo7_c(x) { - do { - const x = 1, y = 1; - const a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } while (1 === 1) - } - - - function foo8_c(x) { - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - const a = arguments.length; - (function() { return x + y + a }); - (() => x + y + a); - } - } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop2_ES6.types b/tests/baselines/reference/capturedLetConstInLoop2_ES6.types index 80e455e44ce..e72221d85cd 100644 --- a/tests/baselines/reference/capturedLetConstInLoop2_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop2_ES6.types @@ -67,10 +67,10 @@ function foo1(x) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -167,10 +167,10 @@ function foo4(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number @@ -182,7 +182,7 @@ function foo4(x) { let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + a }); >(function() { return x + a }) : () => number @@ -206,12 +206,12 @@ function foo5(x) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -327,16 +327,16 @@ function foo8(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 let a = arguments.length; >a : number @@ -429,11 +429,11 @@ function foo1_c(x) { >x : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 const a = arguments.length; >a : number @@ -445,14 +445,14 @@ function foo1_c(x) { >(function() { return x + a }) : () => number >function() { return x + a } : () => number >x + a : number ->x : number +>x : 0 >a : number (() => x + a); >(() => x + a) : () => number >() => x + a : () => number >x + a : number ->x : number +>x : 0 >a : number } } @@ -494,8 +494,8 @@ function foo3_c(x) { do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 const a = arguments.length; >a : number @@ -507,14 +507,14 @@ function foo3_c(x) { >(function() { return x + a }) : () => number >function() { return x + a } : () => number >x + a : number ->x : number +>x : 1 >a : number (() => x + a); >(() => x + a) : () => number >() => x + a : () => number >x + a : number ->x : number +>x : 1 >a : number } while (1 === 1) @@ -528,11 +528,11 @@ function foo4_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const a = arguments.length; >a : number @@ -541,21 +541,21 @@ function foo4_c(x) { >length : number const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + a }); >(function() { return x + a }) : () => number >function() { return x + a } : () => number >x + a : number ->x : number +>x : 1 >a : number (() => x + a); >(() => x + a) : () => number >() => x + a : () => number >x + a : number ->x : number +>x : 1 >a : number } } @@ -565,13 +565,13 @@ function foo5_c(x) { >x : any for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 const a = arguments.length; >a : number @@ -584,8 +584,8 @@ function foo5_c(x) { >function() { return x + y + a } : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >a : number (() => x + y + a); @@ -593,8 +593,8 @@ function foo5_c(x) { >() => x + y + a : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >a : number } } @@ -610,10 +610,10 @@ function foo6_c(x) { >1 : 1 const x = 1, y =1 ; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 const a = arguments.length; >a : number @@ -626,8 +626,8 @@ function foo6_c(x) { >function() { return x + y + a } : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >a : number (() => x + y + a); @@ -635,8 +635,8 @@ function foo6_c(x) { >() => x + y + a : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >a : number } } @@ -647,10 +647,10 @@ function foo7_c(x) { do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 const a = arguments.length; >a : number @@ -663,8 +663,8 @@ function foo7_c(x) { >function() { return x + y + a } : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >a : number (() => x + y + a); @@ -672,8 +672,8 @@ function foo7_c(x) { >() => x + y + a : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >a : number } while (1 === 1) @@ -688,15 +688,15 @@ function foo8_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 const a = arguments.length; >a : number @@ -709,8 +709,8 @@ function foo8_c(x) { >function() { return x + y + a } : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >a : number (() => x + y + a); @@ -718,8 +718,8 @@ function foo8_c(x) { >() => x + y + a : () => number >x + y + a : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >a : number } } diff --git a/tests/baselines/reference/capturedLetConstInLoop3.errors.txt b/tests/baselines/reference/capturedLetConstInLoop3.errors.txt deleted file mode 100644 index ecc9dbcccc5..00000000000 --- a/tests/baselines/reference/capturedLetConstInLoop3.errors.txt +++ /dev/null @@ -1,232 +0,0 @@ -tests/cases/compiler/capturedLetConstInLoop3.ts(132,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop3.ts(164,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop3.ts(175,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop3.ts(209,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. - - -==== tests/cases/compiler/capturedLetConstInLoop3.ts (4 errors) ==== - ///=========let - declare function use(a: any); - function foo0(x) { - for (let x of []) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo0_1(x) { - for (let x in []) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo1(x) { - for (let x = 0; x < 1; ++x) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo2(x) { - while (1 === 1) { - let x = 1; - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo3(x) { - do { - let x; - var v; - (function() { return x + v }); - (() => x + v); - } while (1 === 1); - - use(v); - } - - function foo4(x) { - for (let y = 0; y < 1; ++y) { - var v = y; - let x = 1; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo5(x) { - for (let x = 0, y = 1; x < 1; ++x) { - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v); - } - - - function foo6(x) { - while (1 === 1) { - let x, y; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v) - } - - function foo7(x) { - do { - let x, y; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } while (1 === 1); - - use(v); - } - - - function foo8(x) { - for (let y = 0; y < 1; ++y) { - let x = 1; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v); - } - //===const - function foo0_c(x) { - for (const x of []) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo0_1_c(x) { - for (const x in []) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo1_c(x) { - for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo2_c(x) { - while (1 === 1) { - const x = 1; - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo3_c(x) { - do { - const x = 1; - var v; - (function() { return x + v }); - (() => x + v); - } while (1 === 1); - - use(v); - } - - function foo4_c(x) { - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v = y; - const x = 1; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo5_c(x) { - for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v); - } - - - function foo6_c(x) { - while (1 === 1) { - const x = 1, y = 1; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v) - } - - function foo7_c(x) { - do { - const x = 1, y = 1; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } while (1 === 1); - - use(v); - } - - - function foo8_c(x) { - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v); - } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop3.types b/tests/baselines/reference/capturedLetConstInLoop3.types index 3f35072fdb2..1fee8db67c4 100644 --- a/tests/baselines/reference/capturedLetConstInLoop3.types +++ b/tests/baselines/reference/capturedLetConstInLoop3.types @@ -76,10 +76,10 @@ function foo1(x) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -119,7 +119,7 @@ function foo2(x) { let x = 1; >x : number ->1 : number +>1 : 1 var v = x; >v : number @@ -179,7 +179,7 @@ function foo3(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : undefined } function foo4(x) { @@ -188,10 +188,10 @@ function foo4(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number @@ -201,7 +201,7 @@ function foo4(x) { let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + v }); >(function() { return x + v }) : () => number @@ -230,12 +230,12 @@ function foo5(x) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -283,8 +283,8 @@ function foo6(x) { >y : any var v = x; ->v : any ->x : any +>v : undefined +>x : undefined (function() { return x + y + v }); >(function() { return x + y + v }) : () => any @@ -293,7 +293,7 @@ function foo6(x) { >x + y : any >x : any >y : any ->v : any +>v : undefined (() => x + y + v); >(() => x + y + v) : () => any @@ -302,13 +302,13 @@ function foo6(x) { >x + y : any >x : any >y : any ->v : any +>v : undefined } use(v) >use(v) : any >use : (a: any) => any ->v : any +>v : undefined } function foo7(x) { @@ -321,8 +321,8 @@ function foo7(x) { >y : any var v = x; ->v : any ->x : any +>v : undefined +>x : undefined (function() { return x + y + v }); >(function() { return x + y + v }) : () => any @@ -331,7 +331,7 @@ function foo7(x) { >x + y : any >x : any >y : any ->v : any +>v : undefined (() => x + y + v); >(() => x + y + v) : () => any @@ -340,7 +340,7 @@ function foo7(x) { >x + y : any >x : any >y : any ->v : any +>v : undefined } while (1 === 1); >1 === 1 : boolean @@ -350,7 +350,7 @@ function foo7(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : undefined } @@ -360,16 +360,16 @@ function foo8(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 var v = x; >v : number @@ -471,28 +471,28 @@ function foo1_c(x) { >x : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v = x; >v : number ->x : number +>x : 0 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 0 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 0 >v : number } @@ -512,25 +512,25 @@ function foo2_c(x) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 1 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 1 >v : number } @@ -546,8 +546,8 @@ function foo3_c(x) { do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v; >v : any @@ -556,14 +556,14 @@ function foo3_c(x) { >(function() { return x + v }) : () => any >function() { return x + v } : () => any >x + v : any ->x : number +>x : 1 >v : any (() => x + v); >(() => x + v) : () => any >() => x + v : () => any >x + v : any ->x : number +>x : 1 >v : any } while (1 === 1); @@ -574,7 +574,7 @@ function foo3_c(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : undefined } function foo4_c(x) { @@ -582,32 +582,32 @@ function foo4_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 var v = y; >v : number ->y : number +>y : 0 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 1 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 1 >v : number } @@ -622,25 +622,25 @@ function foo5_c(x) { >x : any for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v = x; >v : number ->x : number +>x : 0 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v : number (() => x + y + v); @@ -648,8 +648,8 @@ function foo5_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v : number } @@ -670,22 +670,22 @@ function foo6_c(x) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number (() => x + y + v); @@ -693,8 +693,8 @@ function foo6_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number } @@ -710,22 +710,22 @@ function foo7_c(x) { do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number (() => x + y + v); @@ -733,8 +733,8 @@ function foo7_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number } while (1 === 1); @@ -754,27 +754,27 @@ function foo8_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v : number (() => x + y + v); @@ -782,8 +782,8 @@ function foo8_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v : number } diff --git a/tests/baselines/reference/capturedLetConstInLoop3_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop3_ES6.errors.txt deleted file mode 100644 index 487c47e32a5..00000000000 --- a/tests/baselines/reference/capturedLetConstInLoop3_ES6.errors.txt +++ /dev/null @@ -1,233 +0,0 @@ -tests/cases/compiler/capturedLetConstInLoop3_ES6.ts(133,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop3_ES6.ts(165,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop3_ES6.ts(176,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop3_ES6.ts(210,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. - - -==== tests/cases/compiler/capturedLetConstInLoop3_ES6.ts (4 errors) ==== - - ///=========let - declare function use(a: any); - function foo0(x) { - for (let x of []) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo0_1(x) { - for (let x in []) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo1(x) { - for (let x = 0; x < 1; ++x) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo2(x) { - while (1 === 1) { - let x = 1; - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo3(x) { - do { - let x; - var v; - (function() { return x + v }); - (() => x + v); - } while (1 === 1); - - use(v); - } - - function foo4(x) { - for (let y = 0; y < 1; ++y) { - var v = y; - let x = 1; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo5(x) { - for (let x = 0, y = 1; x < 1; ++x) { - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v); - } - - - function foo6(x) { - while (1 === 1) { - let x, y; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v) - } - - function foo7(x) { - do { - let x, y; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } while (1 === 1); - - use(v); - } - - - function foo8(x) { - for (let y = 0; y < 1; ++y) { - let x = 1; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v); - } - //===const - function foo0_c(x) { - for (const x of []) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo0_1_c(x) { - for (const x in []) { - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo1_c(x) { - for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo2_c(x) { - while (1 === 1) { - const x = 1; - var v = x; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo3_c(x) { - do { - const x = 1; - var v; - (function() { return x + v }); - (() => x + v); - } while (1 === 1); - - use(v); - } - - function foo4_c(x) { - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v = y; - const x = 1; - (function() { return x + v }); - (() => x + v); - } - - use(v); - } - - function foo5_c(x) { - for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v); - } - - - function foo6_c(x) { - while (1 === 1) { - const x = 1, y = 1; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v) - } - - function foo7_c(x) { - do { - const x = 1, y = 1; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } while (1 === 1); - - use(v); - } - - - function foo8_c(x) { - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - var v = x; - (function() { return x + y + v }); - (() => x + y + v); - } - - use(v); - } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop3_ES6.types b/tests/baselines/reference/capturedLetConstInLoop3_ES6.types index 3c7776a6651..bfd279afdff 100644 --- a/tests/baselines/reference/capturedLetConstInLoop3_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop3_ES6.types @@ -77,10 +77,10 @@ function foo1(x) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -120,7 +120,7 @@ function foo2(x) { let x = 1; >x : number ->1 : number +>1 : 1 var v = x; >v : number @@ -180,7 +180,7 @@ function foo3(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : undefined } function foo4(x) { @@ -189,10 +189,10 @@ function foo4(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number @@ -202,7 +202,7 @@ function foo4(x) { let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + v }); >(function() { return x + v }) : () => number @@ -231,12 +231,12 @@ function foo5(x) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -284,8 +284,8 @@ function foo6(x) { >y : any var v = x; ->v : any ->x : any +>v : undefined +>x : undefined (function() { return x + y + v }); >(function() { return x + y + v }) : () => any @@ -294,7 +294,7 @@ function foo6(x) { >x + y : any >x : any >y : any ->v : any +>v : undefined (() => x + y + v); >(() => x + y + v) : () => any @@ -303,13 +303,13 @@ function foo6(x) { >x + y : any >x : any >y : any ->v : any +>v : undefined } use(v) >use(v) : any >use : (a: any) => any ->v : any +>v : undefined } function foo7(x) { @@ -322,8 +322,8 @@ function foo7(x) { >y : any var v = x; ->v : any ->x : any +>v : undefined +>x : undefined (function() { return x + y + v }); >(function() { return x + y + v }) : () => any @@ -332,7 +332,7 @@ function foo7(x) { >x + y : any >x : any >y : any ->v : any +>v : undefined (() => x + y + v); >(() => x + y + v) : () => any @@ -341,7 +341,7 @@ function foo7(x) { >x + y : any >x : any >y : any ->v : any +>v : undefined } while (1 === 1); >1 === 1 : boolean @@ -351,7 +351,7 @@ function foo7(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : undefined } @@ -361,16 +361,16 @@ function foo8(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 var v = x; >v : number @@ -472,28 +472,28 @@ function foo1_c(x) { >x : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v = x; >v : number ->x : number +>x : 0 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 0 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 0 >v : number } @@ -513,25 +513,25 @@ function foo2_c(x) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 1 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 1 >v : number } @@ -547,8 +547,8 @@ function foo3_c(x) { do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v; >v : any @@ -557,14 +557,14 @@ function foo3_c(x) { >(function() { return x + v }) : () => any >function() { return x + v } : () => any >x + v : any ->x : number +>x : 1 >v : any (() => x + v); >(() => x + v) : () => any >() => x + v : () => any >x + v : any ->x : number +>x : 1 >v : any } while (1 === 1); @@ -575,7 +575,7 @@ function foo3_c(x) { use(v); >use(v) : any >use : (a: any) => any ->v : any +>v : undefined } function foo4_c(x) { @@ -583,32 +583,32 @@ function foo4_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 var v = y; >v : number ->y : number +>y : 0 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 1 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 1 >v : number } @@ -623,25 +623,25 @@ function foo5_c(x) { >x : any for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v = x; >v : number ->x : number +>x : 0 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v : number (() => x + y + v); @@ -649,8 +649,8 @@ function foo5_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v : number } @@ -671,22 +671,22 @@ function foo6_c(x) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number (() => x + y + v); @@ -694,8 +694,8 @@ function foo6_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number } @@ -711,22 +711,22 @@ function foo7_c(x) { do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number (() => x + y + v); @@ -734,8 +734,8 @@ function foo7_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number } while (1 === 1); @@ -755,27 +755,27 @@ function foo8_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v : number (() => x + y + v); @@ -783,8 +783,8 @@ function foo8_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v : number } diff --git a/tests/baselines/reference/capturedLetConstInLoop4.errors.txt b/tests/baselines/reference/capturedLetConstInLoop4.errors.txt deleted file mode 100644 index 000286537b8..00000000000 --- a/tests/baselines/reference/capturedLetConstInLoop4.errors.txt +++ /dev/null @@ -1,158 +0,0 @@ -tests/cases/compiler/capturedLetConstInLoop4.ts(90,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop4.ts(110,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop4.ts(117,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop4.ts(137,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. - - -==== tests/cases/compiler/capturedLetConstInLoop4.ts (4 errors) ==== - - //======let - export function exportedFoo() { - return v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8; - } - - for (let x of []) { - var v0 = x; - (function() { return x + v0}); - (() => x); - } - - for (let x in []) { - var v00 = x; - (function() { return x + v00}); - (() => x); - } - - for (let x = 0; x < 1; ++x) { - var v1 = x; - (function() { return x + v1}); - (() => x); - } - - while (1 === 1) { - let x; - var v2 = x; - (function() { return x + v2}); - (() => x); - } - - do { - let x; - var v3 = x; - (function() { return x + v3}); - (() => x); - } while (1 === 1) - - for (let y = 0; y < 1; ++y) { - let x = 1; - var v4 = x; - (function() { return x + v4}); - (() => x); - } - - for (let x = 0, y = 1; x < 1; ++x) { - var v5 = x; - (function() { return x + y + v5}); - (() => x + y); - } - - while (1 === 1) { - let x, y; - var v6 = x; - (function() { return x + y + v6}); - (() => x + y); - } - - do { - let x, y; - var v7 = x; - (function() { return x + y + v7}); - (() => x + y); - } while (1 === 1) - - for (let y = 0; y < 1; ++y) { - let x = 1; - var v8 = x; - (function() { return x + y + v8}); - (() => x + y); - } - - //======const - export function exportedFoo2() { - return v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c; - } - - for (const x of []) { - var v0_c = x; - (function() { return x + v0_c}); - (() => x); - } - - for (const x in []) { - var v00_c = x; - (function() { return x + v00}); - (() => x); - } - - for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v1_c = x; - (function() { return x + v1_c}); - (() => x); - } - - while (1 === 1) { - const x =1; - var v2_c = x; - (function() { return x + v2_c}); - (() => x); - } - - do { - const x = 1; - var v3_c = x; - (function() { return x + v3_c}); - (() => x); - } while (1 === 1) - - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - var v4_c = x; - (function() { return x + v4_c}); - (() => x); - } - - for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v5_c = x; - (function() { return x + y + v5_c}); - (() => x + y); - } - - while (1 === 1) { - const x = 1, y = 1; - var v6_c = x; - (function() { return x + y + v6_c}); - (() => x + y); - } - - do { - const x = 1, y = 1; - var v7_c = x; - (function() { return x + y + v7_c}); - (() => x + y); - } while (1 === 1) - - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - var v8_c = x; - (function() { return x + y + v8_c}); - (() => x + y); - } - \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop4.types b/tests/baselines/reference/capturedLetConstInLoop4.types index 16226243c53..0feff77f604 100644 --- a/tests/baselines/reference/capturedLetConstInLoop4.types +++ b/tests/baselines/reference/capturedLetConstInLoop4.types @@ -17,12 +17,12 @@ export function exportedFoo() { >v0 : any >v00 : string >v1 : number ->v2 : any ->v3 : any +>v2 : undefined +>v3 : undefined >v4 : number >v5 : number ->v6 : any ->v7 : any +>v6 : undefined +>v7 : undefined >v8 : number } @@ -70,10 +70,10 @@ for (let x in []) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -103,15 +103,15 @@ while (1 === 1) { >x : any var v2 = x; ->v2 : any ->x : any +>v2 : undefined +>x : undefined (function() { return x + v2}); >(function() { return x + v2}) : () => any >function() { return x + v2} : () => any >x + v2 : any >x : any ->v2 : any +>v2 : undefined (() => x); >(() => x) : () => any @@ -124,15 +124,15 @@ do { >x : any var v3 = x; ->v3 : any ->x : any +>v3 : undefined +>x : undefined (function() { return x + v3}); >(function() { return x + v3}) : () => any >function() { return x + v3} : () => any >x + v3 : any >x : any ->v3 : any +>v3 : undefined (() => x); >(() => x) : () => any @@ -146,16 +146,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 var v4 = x; >v4 : number @@ -176,12 +176,12 @@ for (let y = 0; y < 1; ++y) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -216,8 +216,8 @@ while (1 === 1) { >y : any var v6 = x; ->v6 : any ->x : any +>v6 : undefined +>x : undefined (function() { return x + y + v6}); >(function() { return x + y + v6}) : () => any @@ -226,7 +226,7 @@ while (1 === 1) { >x + y : any >x : any >y : any ->v6 : any +>v6 : undefined (() => x + y); >(() => x + y) : () => any @@ -242,8 +242,8 @@ do { >y : any var v7 = x; ->v7 : any ->x : any +>v7 : undefined +>x : undefined (function() { return x + y + v7}); >(function() { return x + y + v7}) : () => any @@ -252,7 +252,7 @@ do { >x + y : any >x : any >y : any ->v7 : any +>v7 : undefined (() => x + y); >(() => x + y) : () => any @@ -268,16 +268,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 var v8 = x; >v8 : number @@ -369,27 +369,27 @@ for (const x in []) { } for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v1_c = x; >v1_c : number ->x : number +>x : 0 (function() { return x + v1_c}); >(function() { return x + v1_c}) : () => number >function() { return x + v1_c} : () => number >x + v1_c : number ->x : number +>x : 0 >v1_c : number (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 0 } while (1 === 1) { @@ -398,46 +398,46 @@ while (1 === 1) { >1 : 1 const x =1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v2_c = x; >v2_c : number ->x : number +>x : 1 (function() { return x + v2_c}); >(function() { return x + v2_c}) : () => number >function() { return x + v2_c} : () => number >x + v2_c : number ->x : number +>x : 1 >v2_c : number (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v3_c = x; >v3_c : number ->x : number +>x : 1 (function() { return x + v3_c}); >(function() { return x + v3_c}) : () => number >function() { return x + v3_c} : () => number >x + v3_c : number ->x : number +>x : 1 >v3_c : number (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } while (1 === 1) >1 === 1 : boolean @@ -445,61 +445,61 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v4_c = x; >v4_c : number ->x : number +>x : 1 (function() { return x + v4_c}); >(function() { return x + v4_c}) : () => number >function() { return x + v4_c} : () => number >x + v4_c : number ->x : number +>x : 1 >v4_c : number (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v5_c = x; >v5_c : number ->x : number +>x : 0 (function() { return x + y + v5_c}); >(function() { return x + y + v5_c}) : () => number >function() { return x + y + v5_c} : () => number >x + y + v5_c : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v5_c : number (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 } while (1 === 1) { @@ -508,58 +508,58 @@ while (1 === 1) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v6_c = x; >v6_c : number ->x : number +>x : 1 (function() { return x + y + v6_c}); >(function() { return x + y + v6_c}) : () => number >function() { return x + y + v6_c} : () => number >x + y + v6_c : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v6_c : number (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 } do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v7_c = x; >v7_c : number ->x : number +>x : 1 (function() { return x + y + v7_c}); >(function() { return x + y + v7_c}) : () => number >function() { return x + y + v7_c} : () => number >x + y + v7_c : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v7_c : number (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 } while (1 === 1) >1 === 1 : boolean @@ -567,34 +567,34 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v8_c = x; >v8_c : number ->x : number +>x : 1 (function() { return x + y + v8_c}); >(function() { return x + y + v8_c}) : () => number >function() { return x + y + v8_c} : () => number >x + y + v8_c : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v8_c : number (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 } diff --git a/tests/baselines/reference/capturedLetConstInLoop4_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop4_ES6.errors.txt deleted file mode 100644 index a83bb1d414f..00000000000 --- a/tests/baselines/reference/capturedLetConstInLoop4_ES6.errors.txt +++ /dev/null @@ -1,158 +0,0 @@ -tests/cases/compiler/capturedLetConstInLoop4_ES6.ts(90,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop4_ES6.ts(110,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop4_ES6.ts(117,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop4_ES6.ts(137,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. - - -==== tests/cases/compiler/capturedLetConstInLoop4_ES6.ts (4 errors) ==== - - //======let - export function exportedFoo() { - return v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8; - } - - for (let x of []) { - var v0 = x; - (function() { return x + v0}); - (() => x); - } - - for (let x in []) { - var v00 = x; - (function() { return x + v00}); - (() => x); - } - - for (let x = 0; x < 1; ++x) { - var v1 = x; - (function() { return x + v1}); - (() => x); - } - - while (1 === 1) { - let x; - var v2 = x; - (function() { return x + v2}); - (() => x); - } - - do { - let x; - var v3 = x; - (function() { return x + v3}); - (() => x); - } while (1 === 1) - - for (let y = 0; y < 1; ++y) { - let x = 1; - var v4 = x; - (function() { return x + v4}); - (() => x); - } - - for (let x = 0, y = 1; x < 1; ++x) { - var v5 = x; - (function() { return x + y + v5}); - (() => x + y); - } - - while (1 === 1) { - let x, y; - var v6 = x; - (function() { return x + y + v6}); - (() => x + y); - } - - do { - let x, y; - var v7 = x; - (function() { return x + y + v7}); - (() => x + y); - } while (1 === 1) - - for (let y = 0; y < 1; ++y) { - let x = 1; - var v8 = x; - (function() { return x + y + v8}); - (() => x + y); - } - - //======const - export function exportedFoo2() { - return v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c; - } - - for (const x of []) { - var v0_c = x; - (function() { return x + v0_c}); - (() => x); - } - - for (const x in []) { - var v00_c = x; - (function() { return x + v00}); - (() => x); - } - - for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v1_c = x; - (function() { return x + v1_c}); - (() => x); - } - - while (1 === 1) { - const x =1; - var v2_c = x; - (function() { return x + v2_c}); - (() => x); - } - - do { - const x = 1; - var v3_c = x; - (function() { return x + v3_c}); - (() => x); - } while (1 === 1) - - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - var v4_c = x; - (function() { return x + v4_c}); - (() => x); - } - - for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - var v5_c = x; - (function() { return x + y + v5_c}); - (() => x + y); - } - - while (1 === 1) { - const x = 1, y = 1; - var v6_c = x; - (function() { return x + y + v6_c}); - (() => x + y); - } - - do { - const x = 1, y = 1; - var v7_c = x; - (function() { return x + y + v7_c}); - (() => x + y); - } while (1 === 1) - - for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. - const x = 1; - var v8_c = x; - (function() { return x + y + v8_c}); - (() => x + y); - } - \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop4_ES6.types b/tests/baselines/reference/capturedLetConstInLoop4_ES6.types index fba7d88ec48..301a6ef90f1 100644 --- a/tests/baselines/reference/capturedLetConstInLoop4_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop4_ES6.types @@ -17,12 +17,12 @@ export function exportedFoo() { >v0 : any >v00 : string >v1 : number ->v2 : any ->v3 : any +>v2 : undefined +>v3 : undefined >v4 : number >v5 : number ->v6 : any ->v7 : any +>v6 : undefined +>v7 : undefined >v8 : number } @@ -70,10 +70,10 @@ for (let x in []) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -103,15 +103,15 @@ while (1 === 1) { >x : any var v2 = x; ->v2 : any ->x : any +>v2 : undefined +>x : undefined (function() { return x + v2}); >(function() { return x + v2}) : () => any >function() { return x + v2} : () => any >x + v2 : any >x : any ->v2 : any +>v2 : undefined (() => x); >(() => x) : () => any @@ -124,15 +124,15 @@ do { >x : any var v3 = x; ->v3 : any ->x : any +>v3 : undefined +>x : undefined (function() { return x + v3}); >(function() { return x + v3}) : () => any >function() { return x + v3} : () => any >x + v3 : any >x : any ->v3 : any +>v3 : undefined (() => x); >(() => x) : () => any @@ -146,16 +146,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 var v4 = x; >v4 : number @@ -176,12 +176,12 @@ for (let y = 0; y < 1; ++y) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -216,8 +216,8 @@ while (1 === 1) { >y : any var v6 = x; ->v6 : any ->x : any +>v6 : undefined +>x : undefined (function() { return x + y + v6}); >(function() { return x + y + v6}) : () => any @@ -226,7 +226,7 @@ while (1 === 1) { >x + y : any >x : any >y : any ->v6 : any +>v6 : undefined (() => x + y); >(() => x + y) : () => any @@ -242,8 +242,8 @@ do { >y : any var v7 = x; ->v7 : any ->x : any +>v7 : undefined +>x : undefined (function() { return x + y + v7}); >(function() { return x + y + v7}) : () => any @@ -252,7 +252,7 @@ do { >x + y : any >x : any >y : any ->v7 : any +>v7 : undefined (() => x + y); >(() => x + y) : () => any @@ -268,16 +268,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 var v8 = x; >v8 : number @@ -369,27 +369,27 @@ for (const x in []) { } for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v1_c = x; >v1_c : number ->x : number +>x : 0 (function() { return x + v1_c}); >(function() { return x + v1_c}) : () => number >function() { return x + v1_c} : () => number >x + v1_c : number ->x : number +>x : 0 >v1_c : number (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 0 } while (1 === 1) { @@ -398,46 +398,46 @@ while (1 === 1) { >1 : 1 const x =1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v2_c = x; >v2_c : number ->x : number +>x : 1 (function() { return x + v2_c}); >(function() { return x + v2_c}) : () => number >function() { return x + v2_c} : () => number >x + v2_c : number ->x : number +>x : 1 >v2_c : number (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v3_c = x; >v3_c : number ->x : number +>x : 1 (function() { return x + v3_c}); >(function() { return x + v3_c}) : () => number >function() { return x + v3_c} : () => number >x + v3_c : number ->x : number +>x : 1 >v3_c : number (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } while (1 === 1) >1 === 1 : boolean @@ -445,61 +445,61 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v4_c = x; >v4_c : number ->x : number +>x : 1 (function() { return x + v4_c}); >(function() { return x + v4_c}) : () => number >function() { return x + v4_c} : () => number >x + v4_c : number ->x : number +>x : 1 >v4_c : number (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 } for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v5_c = x; >v5_c : number ->x : number +>x : 0 (function() { return x + y + v5_c}); >(function() { return x + y + v5_c}) : () => number >function() { return x + y + v5_c} : () => number >x + y + v5_c : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v5_c : number (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 } while (1 === 1) { @@ -508,58 +508,58 @@ while (1 === 1) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v6_c = x; >v6_c : number ->x : number +>x : 1 (function() { return x + y + v6_c}); >(function() { return x + y + v6_c}) : () => number >function() { return x + y + v6_c} : () => number >x + y + v6_c : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v6_c : number (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 } do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v7_c = x; >v7_c : number ->x : number +>x : 1 (function() { return x + y + v7_c}); >(function() { return x + y + v7_c}) : () => number >function() { return x + y + v7_c} : () => number >x + y + v7_c : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v7_c : number (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 } while (1 === 1) >1 === 1 : boolean @@ -567,34 +567,34 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v8_c = x; >v8_c : number ->x : number +>x : 1 (function() { return x + y + v8_c}); >(function() { return x + y + v8_c}) : () => number >function() { return x + y + v8_c} : () => number >x + y + v8_c : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v8_c : number (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 } diff --git a/tests/baselines/reference/capturedLetConstInLoop5.errors.txt b/tests/baselines/reference/capturedLetConstInLoop5.errors.txt index b182d8347de..cb641af478d 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop5.errors.txt @@ -1,12 +1,8 @@ -tests/cases/compiler/capturedLetConstInLoop5.ts(170,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop5.ts(174,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop5.ts(211,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop5.ts(225,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop5.ts(229,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop5.ts(268,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -==== tests/cases/compiler/capturedLetConstInLoop5.ts (6 errors) ==== +==== tests/cases/compiler/capturedLetConstInLoop5.ts (2 errors) ==== declare function use(a: any); //====let @@ -177,8 +173,6 @@ tests/cases/compiler/capturedLetConstInLoop5.ts(268,23): error TS2365: Operator function foo1_c(x) { for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. var v = x; (function() { return x + v }); (() => x + v); @@ -222,8 +216,6 @@ tests/cases/compiler/capturedLetConstInLoop5.ts(268,23): error TS2365: Operator function foo4_c(x) { for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. var v = y; let x = 1; (function() { return x + v }); @@ -238,8 +230,6 @@ tests/cases/compiler/capturedLetConstInLoop5.ts(268,23): error TS2365: Operator function foo5_c(x) { for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. var v = x; (function() { return x + y + v }); (() => x + y + v); @@ -285,8 +275,6 @@ tests/cases/compiler/capturedLetConstInLoop5.ts(268,23): error TS2365: Operator function foo8_c(x) { for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; var v = x; (function() { return x + y + v }); diff --git a/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt index 05eb0626e2d..a9a4742631a 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt @@ -1,12 +1,8 @@ -tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(171,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(175,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(212,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(226,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(230,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(269,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -==== tests/cases/compiler/capturedLetConstInLoop5_ES6.ts (6 errors) ==== +==== tests/cases/compiler/capturedLetConstInLoop5_ES6.ts (2 errors) ==== declare function use(a: any); @@ -178,8 +174,6 @@ tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(269,23): error TS2365: Opera function foo1_c(x) { for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. var v = x; (function() { return x + v }); (() => x + v); @@ -223,8 +217,6 @@ tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(269,23): error TS2365: Opera function foo4_c(x) { for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. var v = y; let x = 1; (function() { return x + v }); @@ -239,8 +231,6 @@ tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(269,23): error TS2365: Opera function foo5_c(x) { for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. var v = x; (function() { return x + y + v }); (() => x + y + v); @@ -286,8 +276,6 @@ tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(269,23): error TS2365: Opera function foo8_c(x) { for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; var v = x; (function() { return x + y + v }); diff --git a/tests/baselines/reference/capturedLetConstInLoop6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop6.errors.txt index c332c5b7323..cc5d238e7af 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop6.errors.txt @@ -1,14 +1,10 @@ -tests/cases/compiler/capturedLetConstInLoop6.ts(144,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop6.ts(147,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop6.ts(150,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop6.ts(179,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop6.ts(191,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop6.ts(194,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop6.ts(197,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop6.ts(226,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -==== tests/cases/compiler/capturedLetConstInLoop6.ts (8 errors) ==== +==== tests/cases/compiler/capturedLetConstInLoop6.ts (4 errors) ==== // ====let for (let x of []) { (function() { return x}); @@ -153,8 +149,6 @@ tests/cases/compiler/capturedLetConstInLoop6.ts(226,19): error TS2365: Operator for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x}); (() => x); if (x == 1) { @@ -194,8 +188,6 @@ tests/cases/compiler/capturedLetConstInLoop6.ts(226,19): error TS2365: Operator } while (1 === 1) for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; (function() { return x}); (() => x); @@ -208,8 +200,6 @@ tests/cases/compiler/capturedLetConstInLoop6.ts(226,19): error TS2365: Operator } for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x + y}); (() => x + y); if (x == 1) { @@ -249,8 +239,6 @@ tests/cases/compiler/capturedLetConstInLoop6.ts(226,19): error TS2365: Operator } while (1 === 1) for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; (function() { return x + y}); (() => x + y); diff --git a/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt index 18ecfe7c666..4e563153ac9 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt @@ -1,14 +1,10 @@ -tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(144,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(147,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(150,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(179,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(191,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(194,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(197,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(226,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -==== tests/cases/compiler/capturedLetConstInLoop6_ES6.ts (8 errors) ==== +==== tests/cases/compiler/capturedLetConstInLoop6_ES6.ts (4 errors) ==== // ====let for (let x of []) { (function() { return x}); @@ -153,8 +149,6 @@ tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(226,19): error TS2365: Opera for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x}); (() => x); if (x == 1) { @@ -194,8 +188,6 @@ tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(226,19): error TS2365: Opera } while (1 === 1) for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; (function() { return x}); (() => x); @@ -208,8 +200,6 @@ tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(226,19): error TS2365: Opera } for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x + y}); (() => x + y); if (x == 1) { @@ -249,8 +239,6 @@ tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(226,19): error TS2365: Opera } while (1 === 1) for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; (function() { return x + y}); (() => x + y); diff --git a/tests/baselines/reference/capturedLetConstInLoop7.errors.txt b/tests/baselines/reference/capturedLetConstInLoop7.errors.txt index 29e6fbca6cd..4b8e512f41a 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop7.errors.txt @@ -1,18 +1,14 @@ -tests/cases/compiler/capturedLetConstInLoop7.ts(227,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7.ts(230,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7.ts(233,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7.ts(236,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. tests/cases/compiler/capturedLetConstInLoop7.ts(239,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7.ts(283,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7.ts(302,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7.ts(305,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7.ts(308,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7.ts(311,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. tests/cases/compiler/capturedLetConstInLoop7.ts(314,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7.ts(359,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -==== tests/cases/compiler/capturedLetConstInLoop7.ts (12 errors) ==== +==== tests/cases/compiler/capturedLetConstInLoop7.ts (8 errors) ==== //===let l0: for (let x of []) { @@ -240,8 +236,6 @@ tests/cases/compiler/capturedLetConstInLoop7.ts(359,19): error TS2365: Operator l1_c: for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x}); (() => x); if (x == 1) { @@ -306,8 +300,6 @@ tests/cases/compiler/capturedLetConstInLoop7.ts(359,19): error TS2365: Operator l4_c: for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; (function() { return x}); (() => x); @@ -327,8 +319,6 @@ tests/cases/compiler/capturedLetConstInLoop7.ts(359,19): error TS2365: Operator l5_c: for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x + y}); (() => x + y); if (x == 1) { @@ -394,8 +384,6 @@ tests/cases/compiler/capturedLetConstInLoop7.ts(359,19): error TS2365: Operator l8_c: for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; (function() { return x + y}); (() => x + y); diff --git a/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt index a2001dc09b3..30e2db6a253 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt @@ -1,18 +1,14 @@ -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(227,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(230,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(233,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(236,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(239,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(283,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(302,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(305,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(308,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(311,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(314,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. -tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(359,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -==== tests/cases/compiler/capturedLetConstInLoop7_ES6.ts (12 errors) ==== +==== tests/cases/compiler/capturedLetConstInLoop7_ES6.ts (8 errors) ==== //===let l0: for (let x of []) { @@ -240,8 +236,6 @@ tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(359,19): error TS2365: Opera l1_c: for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x}); (() => x); if (x == 1) { @@ -306,8 +300,6 @@ tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(359,19): error TS2365: Opera l4_c: for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; (function() { return x}); (() => x); @@ -327,8 +319,6 @@ tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(359,19): error TS2365: Opera l5_c: for (const x = 0, y = 1; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x + y}); (() => x + y); if (x == 1) { @@ -394,8 +384,6 @@ tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(359,19): error TS2365: Opera l8_c: for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. const x = 1; (function() { return x + y}); (() => x + y); diff --git a/tests/baselines/reference/capturedLetConstInLoop8.errors.txt b/tests/baselines/reference/capturedLetConstInLoop8.errors.txt index c3743feaf90..d54c79dfebb 100644 --- a/tests/baselines/reference/capturedLetConstInLoop8.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop8.errors.txt @@ -1,6 +1,3 @@ -tests/cases/compiler/capturedLetConstInLoop8.ts(66,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8.ts(68,27): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8.ts(70,31): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop8.ts(73,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop8.ts(76,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop8.ts(79,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. @@ -19,7 +16,7 @@ tests/cases/compiler/capturedLetConstInLoop8.ts(117,17): error TS2365: Operator tests/cases/compiler/capturedLetConstInLoop8.ts(120,17): error TS2365: Operator '==' cannot be applied to types '0' and '3'. -==== tests/cases/compiler/capturedLetConstInLoop8.ts (19 errors) ==== +==== tests/cases/compiler/capturedLetConstInLoop8.ts (16 errors) ==== function foo() { l0: for (let z = 0; z < 1; ++z) { @@ -86,16 +83,10 @@ tests/cases/compiler/capturedLetConstInLoop8.ts(120,17): error TS2365: Operator function foo_c() { l0: for (const z = 0; z < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. l1: for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. ll1: for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x + y }); (() => x + y); if (y == 1) { diff --git a/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt index da6947884fa..b8e856b66bf 100644 --- a/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt +++ b/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt @@ -1,6 +1,3 @@ -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(66,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(68,27): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(70,31): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(73,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(76,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(79,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. @@ -19,7 +16,7 @@ tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(117,17): error TS2365: Opera tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(120,17): error TS2365: Operator '==' cannot be applied to types '0' and '3'. -==== tests/cases/compiler/capturedLetConstInLoop8_ES6.ts (19 errors) ==== +==== tests/cases/compiler/capturedLetConstInLoop8_ES6.ts (16 errors) ==== function foo() { l0: for (let z = 0; z < 1; ++z) { @@ -86,16 +83,10 @@ tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(120,17): error TS2365: Opera function foo_c() { l0: for (const z = 0; z < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. l1: for (const x = 0; x < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. ll1: for (const y = 0; y < 1;) { - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. (function() { return x + y }); (() => x + y); if (y == 1) { diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt deleted file mode 100644 index d863ca29090..00000000000 --- a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt +++ /dev/null @@ -1,58 +0,0 @@ -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(5,1): error TS2365: Operator '>' cannot be applied to types 'BrandedNum' and '0'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(10,1): error TS2365: Operator '<' cannot be applied to types 'BrandedNum' and '0'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(15,1): error TS2365: Operator '>=' cannot be applied to types 'BrandedNum' and '0'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(20,1): error TS2365: Operator '<=' cannot be applied to types 'BrandedNum' and '0'. - - -==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts (4 errors) ==== - type BrandedNum = number & { __numberBrand: any }; - var x : BrandedNum; - - // operator > - x > 0; - ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'BrandedNum' and '0'. - x > 0; - x > 0; - - // operator < - x < 0; - ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'BrandedNum' and '0'. - x < 0; - x < 0; - - // operator >= - x >= 0; - ~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'BrandedNum' and '0'. - x >= 0; - x >= 0; - - // operator <= - x <= 0; - ~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'BrandedNum' and '0'. - x <= 0; - x <= 0; - - // operator == - x == 0; - x == 0; - x == 0; - - // operator != - x != 0; - x != 0; - x != 0; - - // operator === - x === 0; - x === 0; - x === 0; - - // operator !== - x !== 0; - x !== 0; - x !== 0; - \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.symbols b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.symbols new file mode 100644 index 00000000000..0511f88b2a8 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.symbols @@ -0,0 +1,97 @@ +=== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts === +type BrandedNum = number & { __numberBrand: any }; +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) +>__numberBrand : Symbol(__numberBrand, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 28)) + +var x : BrandedNum; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) + +// operator > +x > 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x > 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x > 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) + +// operator < +x < 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x < 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x < 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) + +// operator >= +x >= 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x >= 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x >= 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) + +// operator <= +x <= 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x <= 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x <= 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) + +// operator == +x == 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x == 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x == 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) + +// operator != +x != 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x != 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x != 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) + +// operator === +x === 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x === 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x === 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) + +// operator !== +x !== 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x !== 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) + +x !== 0; +>x : Symbol(x, Decl(comparisonOperatorWithNumericLiteral.ts, 1, 3)) +>BrandedNum : Symbol(BrandedNum, Decl(comparisonOperatorWithNumericLiteral.ts, 0, 0)) + diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.types b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.types new file mode 100644 index 00000000000..31f7aadfec2 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.types @@ -0,0 +1,161 @@ +=== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts === +type BrandedNum = number & { __numberBrand: any }; +>BrandedNum : BrandedNum +>__numberBrand : any + +var x : BrandedNum; +>x : BrandedNum +>BrandedNum : BrandedNum + +// operator > +x > 0; +>x > 0 : boolean +>x : BrandedNum +>0 : 0 + +x > 0; +>x > 0 : boolean +>x : BrandedNum +>0 : number +>0 : 0 + +x > 0; +>x > 0 : boolean +>x : BrandedNum +>0 : BrandedNum +>BrandedNum : BrandedNum +>0 : 0 + +// operator < +x < 0; +>x < 0 : boolean +>x : BrandedNum +>0 : 0 + +x < 0; +>x < 0 : boolean +>x : BrandedNum +>0 : number +>0 : 0 + +x < 0; +>x < 0 : boolean +>x : BrandedNum +>0 : BrandedNum +>BrandedNum : BrandedNum +>0 : 0 + +// operator >= +x >= 0; +>x >= 0 : boolean +>x : BrandedNum +>0 : 0 + +x >= 0; +>x >= 0 : boolean +>x : BrandedNum +>0 : number +>0 : 0 + +x >= 0; +>x >= 0 : boolean +>x : BrandedNum +>0 : BrandedNum +>BrandedNum : BrandedNum +>0 : 0 + +// operator <= +x <= 0; +>x <= 0 : boolean +>x : BrandedNum +>0 : 0 + +x <= 0; +>x <= 0 : boolean +>x : BrandedNum +>0 : number +>0 : 0 + +x <= 0; +>x <= 0 : boolean +>x : BrandedNum +>0 : BrandedNum +>BrandedNum : BrandedNum +>0 : 0 + +// operator == +x == 0; +>x == 0 : boolean +>x : BrandedNum +>0 : 0 + +x == 0; +>x == 0 : boolean +>x : BrandedNum +>0 : number +>0 : 0 + +x == 0; +>x == 0 : boolean +>x : BrandedNum +>0 : BrandedNum +>BrandedNum : BrandedNum +>0 : 0 + +// operator != +x != 0; +>x != 0 : boolean +>x : BrandedNum +>0 : 0 + +x != 0; +>x != 0 : boolean +>x : BrandedNum +>0 : number +>0 : 0 + +x != 0; +>x != 0 : boolean +>x : BrandedNum +>0 : BrandedNum +>BrandedNum : BrandedNum +>0 : 0 + +// operator === +x === 0; +>x === 0 : boolean +>x : BrandedNum +>0 : 0 + +x === 0; +>x === 0 : boolean +>x : BrandedNum +>0 : number +>0 : 0 + +x === 0; +>x === 0 : boolean +>x : BrandedNum +>0 : BrandedNum +>BrandedNum : BrandedNum +>0 : 0 + +// operator !== +x !== 0; +>x !== 0 : boolean +>x : BrandedNum +>0 : 0 + +x !== 0; +>x !== 0 : boolean +>x : BrandedNum +>0 : number +>0 : 0 + +x !== 0; +>x !== 0 : boolean +>x : BrandedNum +>0 : BrandedNum +>BrandedNum : BrandedNum +>0 : 0 + diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1.js b/tests/baselines/reference/computedPropertiesInDestructuring1.js index b0dc33a4b4e..e4f15e6b8bf 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1.js +++ b/tests/baselines/reference/computedPropertiesInDestructuring1.js @@ -41,13 +41,13 @@ let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; // destructuring in variable declarations var foo = "bar"; var _a = foo, bar = { bar: "bar" }[_a]; -var _b = "bar", bar2 = { bar: "bar" }[_b]; +var bar2 = { bar: "bar" }["bar"]; var foo2 = function () { return "bar"; }; -var _c = foo2(), bar3 = { bar: "bar" }[_c]; -var _d = foo, bar4 = [{ bar: "bar" }][0][_d]; -var _e = foo2(), bar5 = [{ bar: "bar" }][0][_e]; +var _b = foo2(), bar3 = { bar: "bar" }[_b]; +var _c = foo, bar4 = [{ bar: "bar" }][0][_c]; +var _d = foo2(), bar5 = [{ bar: "bar" }][0][_d]; function f1(_a) { - var _b = "bar", x = _a[_b]; + var x = _a["bar"]; } function f2(_a) { var _b = foo, x = _a[_b]; @@ -62,14 +62,14 @@ function f5(_a) { var _b = foo2(), x = _a[0][_b]; } // report errors on type errors in computed properties used in destructuring -var _f = foo(), bar6 = [{ bar: "bar" }][0][_f]; -var _g = foo.toExponential(), bar7 = [{ bar: "bar" }][0][_g]; +var _e = foo(), bar6 = [{ bar: "bar" }][0][_e]; +var _f = foo.toExponential(), bar7 = [{ bar: "bar" }][0][_f]; // destructuring assignment -(_h = foo, bar = { bar: "bar" }[_h]); -(_j = "bar", bar2 = { bar: "bar" }[_j]); -(_k = foo2(), bar3 = { bar: "bar" }[_k]); -_l = foo, bar4 = [{ bar: "bar" }][0][_l]; -_m = foo2(), bar5 = [{ bar: "bar" }][0][_m]; -_o = foo(), bar4 = [{ bar: "bar" }][0][_o]; -_p = (1 + {}), bar4 = [{ bar: "bar" }][0][_p]; -var _h, _j, _k, _l, _m, _o, _p; +(_g = foo, bar = { bar: "bar" }[_g]); +(bar2 = { bar: "bar" }["bar"]); +(_h = foo2(), bar3 = { bar: "bar" }[_h]); +_j = foo, bar4 = [{ bar: "bar" }][0][_j]; +_k = foo2(), bar5 = [{ bar: "bar" }][0][_k]; +_l = foo(), bar4 = [{ bar: "bar" }][0][_l]; +_m = (1 + {}), bar4 = [{ bar: "bar" }][0][_m]; +var _g, _h, _j, _k, _l, _m; diff --git a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.errors.txt b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.errors.txt deleted file mode 100644 index 25153c1ba15..00000000000 --- a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.errors.txt +++ /dev/null @@ -1,71 +0,0 @@ -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorConditionIsBooleanType.ts(35,1): error TS2365: Operator '>' cannot be applied to types '2' and '1'. -tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorConditionIsBooleanType.ts(58,23): error TS2365: Operator '>' cannot be applied to types '2' and '1'. - - -==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorConditionIsBooleanType.ts (2 errors) ==== - //Cond ? Expr1 : Expr2, Cond is of boolean type, Expr1 and Expr2 have the same type - var condBoolean: boolean; - - var exprAny1: any; - var exprBoolean1: boolean; - var exprNumber1: number; - var exprString1: string; - var exprIsObject1: Object; - - var exprAny2: any; - var exprBoolean2: boolean; - var exprNumber2: number; - var exprString2: string; - var exprIsObject2: Object; - - //Cond is a boolean type variable - condBoolean ? exprAny1 : exprAny2; - condBoolean ? exprBoolean1 : exprBoolean2; - condBoolean ? exprNumber1 : exprNumber2; - condBoolean ? exprString1 : exprString2; - condBoolean ? exprIsObject1 : exprIsObject2; - condBoolean ? exprString1 : exprBoolean1; // union - - //Cond is a boolean type literal - true ? exprAny1 : exprAny2; - false ? exprBoolean1 : exprBoolean2; - true ? exprNumber1 : exprNumber2; - false ? exprString1 : exprString2; - true ? exprIsObject1 : exprIsObject2; - true ? exprString1 : exprBoolean1; // union - - //Cond is a boolean type expression - !true ? exprAny1 : exprAny2; - typeof "123" == "string" ? exprBoolean1 : exprBoolean2; - 2 > 1 ? exprNumber1 : exprNumber2; - ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types '2' and '1'. - null === undefined ? exprString1 : exprString2; - true || false ? exprIsObject1 : exprIsObject2; - null === undefined ? exprString1 : exprBoolean1; // union - - //Results shoud be same as Expr1 and Expr2 - var resultIsAny1 = condBoolean ? exprAny1 : exprAny2; - var resultIsBoolean1 = condBoolean ? exprBoolean1 : exprBoolean2; - var resultIsNumber1 = condBoolean ? exprNumber1 : exprNumber2; - var resultIsString1 = condBoolean ? exprString1 : exprString2; - var resultIsObject1 = condBoolean ? exprIsObject1 : exprIsObject2; - var resultIsStringOrBoolean1 = condBoolean ? exprString1 : exprBoolean1; // union - - var resultIsAny2 = true ? exprAny1 : exprAny2; - var resultIsBoolean2 = false ? exprBoolean1 : exprBoolean2; - var resultIsNumber2 = true ? exprNumber1 : exprNumber2; - var resultIsString2 = false ? exprString1 : exprString2; - var resultIsObject2 = true ? exprIsObject1 : exprIsObject2; - var resultIsStringOrBoolean2 = true ? exprString1 : exprBoolean1; // union - var resultIsStringOrBoolean3 = false ? exprString1 : exprBoolean1; // union - - var resultIsAny3 = !true ? exprAny1 : exprAny2; - var resultIsBoolean3 = typeof "123" == "string" ? exprBoolean1 : exprBoolean2; - var resultIsNumber3 = 2 > 1 ? exprNumber1 : exprNumber2; - ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types '2' and '1'. - var resultIsString3 = null === undefined ? exprString1 : exprString2; - var resultIsObject3 = true || false ? exprIsObject1 : exprIsObject2; - var resultIsStringOrBoolean4 = typeof "123" === "string" ? exprString1 : exprBoolean1; // union - \ No newline at end of file diff --git a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types index 7733b80f69b..f19769b1c58 100644 --- a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types +++ b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types @@ -75,37 +75,37 @@ condBoolean ? exprString1 : exprBoolean1; // union //Cond is a boolean type literal true ? exprAny1 : exprAny2; >true ? exprAny1 : exprAny2 : any ->true : boolean +>true : true >exprAny1 : any >exprAny2 : any false ? exprBoolean1 : exprBoolean2; >false ? exprBoolean1 : exprBoolean2 : boolean ->false : boolean +>false : false >exprBoolean1 : boolean >exprBoolean2 : boolean true ? exprNumber1 : exprNumber2; >true ? exprNumber1 : exprNumber2 : number ->true : boolean +>true : true >exprNumber1 : number >exprNumber2 : number false ? exprString1 : exprString2; >false ? exprString1 : exprString2 : string ->false : boolean +>false : false >exprString1 : string >exprString2 : string true ? exprIsObject1 : exprIsObject2; >true ? exprIsObject1 : exprIsObject2 : Object ->true : boolean +>true : true >exprIsObject1 : Object >exprIsObject2 : Object true ? exprString1 : exprBoolean1; // union >true ? exprString1 : exprBoolean1 : string | boolean ->true : boolean +>true : true >exprString1 : string >exprBoolean1 : boolean @@ -113,7 +113,7 @@ true ? exprString1 : exprBoolean1; // union !true ? exprAny1 : exprAny2; >!true ? exprAny1 : exprAny2 : any >!true : boolean ->true : boolean +>true : true >exprAny1 : any >exprAny2 : any @@ -121,7 +121,7 @@ typeof "123" == "string" ? exprBoolean1 : exprBoolean2; >typeof "123" == "string" ? exprBoolean1 : exprBoolean2 : boolean >typeof "123" == "string" : boolean >typeof "123" : string ->"123" : string +>"123" : "123" >"string" : "string" >exprBoolean1 : boolean >exprBoolean2 : boolean @@ -129,8 +129,8 @@ typeof "123" == "string" ? exprBoolean1 : exprBoolean2; 2 > 1 ? exprNumber1 : exprNumber2; >2 > 1 ? exprNumber1 : exprNumber2 : number >2 > 1 : boolean ->2 : number ->1 : number +>2 : 2 +>1 : 1 >exprNumber1 : number >exprNumber2 : number @@ -145,7 +145,7 @@ null === undefined ? exprString1 : exprString2; true || false ? exprIsObject1 : exprIsObject2; >true || false ? exprIsObject1 : exprIsObject2 : Object >true || false : boolean ->true : boolean +>true : true >false : false >exprIsObject1 : Object >exprIsObject2 : Object @@ -204,49 +204,49 @@ var resultIsStringOrBoolean1 = condBoolean ? exprString1 : exprBoolean1; // unio var resultIsAny2 = true ? exprAny1 : exprAny2; >resultIsAny2 : any >true ? exprAny1 : exprAny2 : any ->true : boolean +>true : true >exprAny1 : any >exprAny2 : any var resultIsBoolean2 = false ? exprBoolean1 : exprBoolean2; >resultIsBoolean2 : boolean >false ? exprBoolean1 : exprBoolean2 : boolean ->false : boolean +>false : false >exprBoolean1 : boolean >exprBoolean2 : boolean var resultIsNumber2 = true ? exprNumber1 : exprNumber2; >resultIsNumber2 : number >true ? exprNumber1 : exprNumber2 : number ->true : boolean +>true : true >exprNumber1 : number >exprNumber2 : number var resultIsString2 = false ? exprString1 : exprString2; >resultIsString2 : string >false ? exprString1 : exprString2 : string ->false : boolean +>false : false >exprString1 : string >exprString2 : string var resultIsObject2 = true ? exprIsObject1 : exprIsObject2; >resultIsObject2 : Object >true ? exprIsObject1 : exprIsObject2 : Object ->true : boolean +>true : true >exprIsObject1 : Object >exprIsObject2 : Object var resultIsStringOrBoolean2 = true ? exprString1 : exprBoolean1; // union >resultIsStringOrBoolean2 : string | boolean >true ? exprString1 : exprBoolean1 : string | boolean ->true : boolean +>true : true >exprString1 : string >exprBoolean1 : boolean var resultIsStringOrBoolean3 = false ? exprString1 : exprBoolean1; // union >resultIsStringOrBoolean3 : string | boolean >false ? exprString1 : exprBoolean1 : string | boolean ->false : boolean +>false : false >exprString1 : string >exprBoolean1 : boolean @@ -254,7 +254,7 @@ var resultIsAny3 = !true ? exprAny1 : exprAny2; >resultIsAny3 : any >!true ? exprAny1 : exprAny2 : any >!true : boolean ->true : boolean +>true : true >exprAny1 : any >exprAny2 : any @@ -263,7 +263,7 @@ var resultIsBoolean3 = typeof "123" == "string" ? exprBoolean1 : exprBoolean2; >typeof "123" == "string" ? exprBoolean1 : exprBoolean2 : boolean >typeof "123" == "string" : boolean >typeof "123" : string ->"123" : string +>"123" : "123" >"string" : "string" >exprBoolean1 : boolean >exprBoolean2 : boolean @@ -272,8 +272,8 @@ var resultIsNumber3 = 2 > 1 ? exprNumber1 : exprNumber2; >resultIsNumber3 : number >2 > 1 ? exprNumber1 : exprNumber2 : number >2 > 1 : boolean ->2 : number ->1 : number +>2 : 2 +>1 : 1 >exprNumber1 : number >exprNumber2 : number @@ -290,7 +290,7 @@ var resultIsObject3 = true || false ? exprIsObject1 : exprIsObject2; >resultIsObject3 : Object >true || false ? exprIsObject1 : exprIsObject2 : Object >true || false : boolean ->true : boolean +>true : true >false : false >exprIsObject1 : Object >exprIsObject2 : Object @@ -300,7 +300,7 @@ var resultIsStringOrBoolean4 = typeof "123" === "string" ? exprString1 : exprBoo >typeof "123" === "string" ? exprString1 : exprBoolean1 : string | boolean >typeof "123" === "string" : boolean >typeof "123" : string ->"123" : string +>"123" : "123" >"string" : "string" >exprString1 : string >exprBoolean1 : boolean diff --git a/tests/baselines/reference/constDeclarations-errors.errors.txt b/tests/baselines/reference/constDeclarations-errors.errors.txt index ace4cd7b25f..83031e0aa79 100644 --- a/tests/baselines/reference/constDeclarations-errors.errors.txt +++ b/tests/baselines/reference/constDeclarations-errors.errors.txt @@ -4,14 +4,12 @@ tests/cases/compiler/constDeclarations-errors.ts(5,7): error TS1155: 'const' dec tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized -tests/cases/compiler/constDeclarations-errors.ts(10,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/constDeclarations-errors.ts(10,27): error TS2540: Cannot assign to 'c8' because it is a constant or a read-only property. tests/cases/compiler/constDeclarations-errors.ts(13,11): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(16,20): error TS1155: 'const' declarations must be initialized -tests/cases/compiler/constDeclarations-errors.ts(16,25): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -==== tests/cases/compiler/constDeclarations-errors.ts (11 errors) ==== +==== tests/cases/compiler/constDeclarations-errors.ts (9 errors) ==== // error, missing intialicer const c1; @@ -34,8 +32,6 @@ tests/cases/compiler/constDeclarations-errors.ts(16,25): error TS2365: Operator // error, assigning to a const for(const c8 = 0; c8 < 1; c8++) { } - ~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. ~~ !!! error TS2540: Cannot assign to 'c8' because it is a constant or a read-only property. @@ -47,6 +43,4 @@ tests/cases/compiler/constDeclarations-errors.ts(16,25): error TS2365: Operator // error, can not be unintalized for(const c10 = 0, c11; c10 < 1;) { } ~~~ -!!! error TS1155: 'const' declarations must be initialized - ~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. \ No newline at end of file +!!! error TS1155: 'const' declarations must be initialized \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations-scopes2.errors.txt b/tests/baselines/reference/constDeclarations-scopes2.errors.txt deleted file mode 100644 index b998f3a9980..00000000000 --- a/tests/baselines/reference/constDeclarations-scopes2.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -tests/cases/compiler/constDeclarations-scopes2.ts(9,19): error TS2365: Operator '<' cannot be applied to types '0' and '10'. - - -==== tests/cases/compiler/constDeclarations-scopes2.ts (1 errors) ==== - - // global - const c = "string"; - - var n: number; - var b: boolean; - - // for scope - for (const c = 0; c < 10; n = c ) { - ~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '10'. - // for block - const c = false; - b = c; - } - - \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations-scopes2.types b/tests/baselines/reference/constDeclarations-scopes2.types index a6bbdee7612..9834c6bb16e 100644 --- a/tests/baselines/reference/constDeclarations-scopes2.types +++ b/tests/baselines/reference/constDeclarations-scopes2.types @@ -2,8 +2,8 @@ // global const c = "string"; ->c : string ->"string" : string +>c : "string" +>"string" : "string" var n: number; >n : number @@ -13,24 +13,24 @@ var b: boolean; // for scope for (const c = 0; c < 10; n = c ) { ->c : number ->0 : number +>c : 0 +>0 : 0 >c < 10 : boolean ->c : number ->10 : number ->n = c : number +>c : 0 +>10 : 10 +>n = c : 0 >n : number ->c : number +>c : 0 // for block const c = false; ->c : boolean ->false : boolean +>c : false +>false : false b = c; ->b = c : boolean +>b = c : false >b : boolean ->c : boolean +>c : false } diff --git a/tests/baselines/reference/constDeclarations.errors.txt b/tests/baselines/reference/constDeclarations.errors.txt deleted file mode 100644 index 1642610eec2..00000000000 --- a/tests/baselines/reference/constDeclarations.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/compiler/constDeclarations.ts(8,19): error TS2365: Operator '<' cannot be applied to types '0' and '9'. - - -==== tests/cases/compiler/constDeclarations.ts (1 errors) ==== - - // No error - const c1 = false; - const c2: number = 23; - const c3 = 0, c4 :string = "", c5 = null; - - - for(const c4 = 0; c4 < 9; ) { break; } - ~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '0' and '9'. - - - for(const c5 = 0, c6 = 0; c5 < c6; ) { break; } \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations.types b/tests/baselines/reference/constDeclarations.types index efdc534ef1c..0fa7893529f 100644 --- a/tests/baselines/reference/constDeclarations.types +++ b/tests/baselines/reference/constDeclarations.types @@ -2,36 +2,36 @@ // No error const c1 = false; ->c1 : boolean ->false : boolean +>c1 : false +>false : false const c2: number = 23; >c2 : number ->23 : number +>23 : 23 const c3 = 0, c4 :string = "", c5 = null; ->c3 : number ->0 : number +>c3 : 0 +>0 : 0 >c4 : string ->"" : string +>"" : "" >c5 : any >null : null for(const c4 = 0; c4 < 9; ) { break; } ->c4 : number ->0 : number +>c4 : 0 +>0 : 0 >c4 < 9 : boolean ->c4 : number ->9 : number +>c4 : 0 +>9 : 9 for(const c5 = 0, c6 = 0; c5 < c6; ) { break; } ->c5 : number ->0 : number ->c6 : number ->0 : number +>c5 : 0 +>0 : 0 +>c6 : 0 +>0 : 0 >c5 < c6 : boolean ->c5 : number ->c6 : number +>c5 : 0 +>c6 : 0 diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.js b/tests/baselines/reference/contextuallyTypedBindingInitializer.js index f2424ce55d7..6542e747edc 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializer.js +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.js @@ -37,7 +37,7 @@ function f2(_a) { var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v.toString(); } : _b; } function f3(_a) { - var _b = "show", _c = _a[_b], showRename = _c === void 0 ? function (v) { return v.toString(); } : _c; + var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v.toString(); } : _b; } function ff(_a) { var _b = _a.nested, nested = _b === void 0 ? { show: function (v) { return v.toString(); } } : _b; diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js index 3f1ed156fdb..bdc7ed68b3f 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js @@ -35,7 +35,7 @@ function f2(_a) { var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v; } : _b; } function f3(_a) { - var _b = "show", _c = _a[_b], showRename = _c === void 0 ? function (v) { return v; } : _c; + var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v; } : _b; } function ff(_a) { var _b = _a.nested, nestedRename = _b === void 0 ? { show: function (v) { return v; } } : _b; diff --git a/tests/baselines/reference/duplicateLocalVariable1.errors.txt b/tests/baselines/reference/duplicateLocalVariable1.errors.txt index 87bcc71cdfc..b264574ea09 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable1.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/duplicateLocalVariable1.ts(2,4): error TS1005: ';' expected tests/cases/compiler/duplicateLocalVariable1.ts(2,11): error TS1146: Declaration expected. tests/cases/compiler/duplicateLocalVariable1.ts(2,13): error TS2304: Cannot find name 'commonjs'. tests/cases/compiler/duplicateLocalVariable1.ts(187,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. -tests/cases/compiler/duplicateLocalVariable1.ts(187,29): error TS2365: Operator '<' cannot be applied to types 'string' and '14'. +tests/cases/compiler/duplicateLocalVariable1.ts(187,29): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. tests/cases/compiler/duplicateLocalVariable1.ts(187,37): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -203,7 +203,7 @@ tests/cases/compiler/duplicateLocalVariable1.ts(187,37): error TS2356: An arithm ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. ~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'string' and '14'. +!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. ~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. bytes.push(fb.readByte()); diff --git a/tests/baselines/reference/duplicateLocalVariable2.errors.txt b/tests/baselines/reference/duplicateLocalVariable2.errors.txt index 466e145d28d..5e89cc422cc 100644 --- a/tests/baselines/reference/duplicateLocalVariable2.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/duplicateLocalVariable2.ts(27,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. -tests/cases/compiler/duplicateLocalVariable2.ts(27,29): error TS2365: Operator '<' cannot be applied to types 'string' and '14'. +tests/cases/compiler/duplicateLocalVariable2.ts(27,29): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. tests/cases/compiler/duplicateLocalVariable2.ts(27,37): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -34,7 +34,7 @@ tests/cases/compiler/duplicateLocalVariable2.ts(27,37): error TS2356: An arithme ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. ~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'string' and '14'. +!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. ~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. bytes.push(fb.readByte()); diff --git a/tests/baselines/reference/es6modulekindWithES5Target11.js b/tests/baselines/reference/es6modulekindWithES5Target11.js index 1268c33697a..4ec0802a5f5 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target11.js +++ b/tests/baselines/reference/es6modulekindWithES5Target11.js @@ -16,16 +16,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -var C = (function () { +var C = C_1 = (function () { function C() { this.p = 1; } - C.x = function () { return C.y; }; + C.x = function () { return C_1.y; }; C.prototype.method = function () { }; return C; }()); C.y = 1; -C = __decorate([ +C = C_1 = __decorate([ foo ], C); export default C; +var C_1; diff --git a/tests/baselines/reference/grammarAmbiguities1.errors.txt b/tests/baselines/reference/grammarAmbiguities1.errors.txt index 8809c4aa334..12df5f3c1e0 100644 --- a/tests/baselines/reference/grammarAmbiguities1.errors.txt +++ b/tests/baselines/reference/grammarAmbiguities1.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/grammarAmbiguities1.ts(8,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/grammarAmbiguities1.ts(8,3): error TS2365: Operator '<' cannot be applied to types '(x: any) => any' and 'typeof A'. -tests/cases/compiler/grammarAmbiguities1.ts(8,10): error TS2365: Operator '>' cannot be applied to types 'typeof B' and '7'. +tests/cases/compiler/grammarAmbiguities1.ts(8,10): error TS2365: Operator '>' cannot be applied to types 'typeof B' and 'number'. tests/cases/compiler/grammarAmbiguities1.ts(9,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/grammarAmbiguities1.ts(9,3): error TS2365: Operator '<' cannot be applied to types '(x: any) => any' and 'typeof A'. tests/cases/compiler/grammarAmbiguities1.ts(9,10): error TS2365: Operator '>' cannot be applied to types 'typeof B' and 'number'. @@ -20,7 +20,7 @@ tests/cases/compiler/grammarAmbiguities1.ts(9,10): error TS2365: Operator '>' ca ~~~~~ !!! error TS2365: Operator '<' cannot be applied to types '(x: any) => any' and 'typeof A'. ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'typeof B' and '7'. +!!! error TS2365: Operator '>' cannot be applied to types 'typeof B' and 'number'. f(g < A, B > +(7)); ~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/importHelpersInTsx.js b/tests/baselines/reference/importHelpersInTsx.js index 29e43e191e8..d1fe0df2c51 100644 --- a/tests/baselines/reference/importHelpersInTsx.js +++ b/tests/baselines/reference/importHelpersInTsx.js @@ -29,6 +29,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/objectRest.js b/tests/baselines/reference/objectRest.js index 519283b32e5..85d8a6a573e 100644 --- a/tests/baselines/reference/objectRest.js +++ b/tests/baselines/reference/objectRest.js @@ -1,5 +1,5 @@ //// [objectRest.ts] -let o = { a: 1, b: 'no' } +var o = { a: 1, b: 'no' } var { ...clone } = o; var { a, ...justB } = o; var { a, b: renamed, ...empty } = o; @@ -31,21 +31,29 @@ class Removable { } var removable = new Removable(); var { removed, ...removableRest } = removable; + +let computed = 'b'; +let computed2 = 'a'; +var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; +({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); //// [objectRest.js] var __rest = (this && this.__rest) || function (s, e) { var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; return t; }; -let o = { a: 1, b: 'no' }; +var o = { a: 1, b: 'no' }; var clone = __rest(o, []); var { a } = o, justB = __rest(o, ["a"]); var { a, b: renamed } = o, empty = __rest(o, ["a", "b"]); -var { ['b']: renamed } = o, justA = __rest(o, ["b"]); -var { 'b': renamed } = o, justA = __rest(o, ["b"]); +var { ['b']: renamed } = o, justA = __rest(o, ['b']); +var { 'b': renamed } = o, justA = __rest(o, ['b']); var { b: { '0': n, '1': oooo } } = o, justA = __rest(o, ["b"]); let o2 = { c: 'terrible idea?', d: 'yes' }; var { d: renamed } = o2, d = __rest(o2, ["d"]); @@ -64,4 +72,8 @@ class Removable { } var removable = new Removable(); var { removed } = removable, removableRest = __rest(removable, ["removed"]); -var _d, _f; +let computed = 'b'; +let computed2 = 'a'; +var _g = computed, stillNotGreat = o[_g], _h = computed2, soSo = o[_h], o = __rest(o, [typeof _g === "symbol" ? _g : _g + "", typeof _h === "symbol" ? _h : _h + ""]); +(_j = computed, stillNotGreat = o[_j], _k = computed2, soSo = o[_k], o = __rest(o, [typeof _j === "symbol" ? _j : _j + "", typeof _k === "symbol" ? _k : _k + ""])); +var _d, _f, _j, _k; diff --git a/tests/baselines/reference/objectRest.symbols b/tests/baselines/reference/objectRest.symbols index 427656248ee..325258aa8cd 100644 --- a/tests/baselines/reference/objectRest.symbols +++ b/tests/baselines/reference/objectRest.symbols @@ -1,42 +1,42 @@ === tests/cases/conformance/types/rest/objectRest.ts === -let o = { a: 1, b: 'no' } ->o : Symbol(o, Decl(objectRest.ts, 0, 3)) +var o = { a: 1, b: 'no' } +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) >a : Symbol(a, Decl(objectRest.ts, 0, 9)) >b : Symbol(b, Decl(objectRest.ts, 0, 15)) var { ...clone } = o; >clone : Symbol(clone, Decl(objectRest.ts, 1, 5)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) var { a, ...justB } = o; >a : Symbol(a, Decl(objectRest.ts, 2, 5), Decl(objectRest.ts, 3, 5)) >justB : Symbol(justB, Decl(objectRest.ts, 2, 8)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) var { a, b: renamed, ...empty } = o; >a : Symbol(a, Decl(objectRest.ts, 2, 5), Decl(objectRest.ts, 3, 5)) >b : Symbol(b, Decl(objectRest.ts, 0, 15)) >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >empty : Symbol(empty, Decl(objectRest.ts, 3, 20)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) var { ['b']: renamed, ...justA } = o; >'b' : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) var { 'b': renamed, ...justA } = o; >renamed : Symbol(renamed, Decl(objectRest.ts, 3, 8), Decl(objectRest.ts, 4, 5), Decl(objectRest.ts, 5, 5), Decl(objectRest.ts, 9, 5)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) var { b: { '0': n, '1': oooo }, ...justA } = o; >b : Symbol(b, Decl(objectRest.ts, 0, 15)) >n : Symbol(n, Decl(objectRest.ts, 6, 10)) >oooo : Symbol(oooo, Decl(objectRest.ts, 6, 18)) >justA : Symbol(justA, Decl(objectRest.ts, 4, 21), Decl(objectRest.ts, 5, 19), Decl(objectRest.ts, 6, 31)) ->o : Symbol(o, Decl(objectRest.ts, 0, 3)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) let o2 = { c: 'terrible idea?', d: 'yes' }; >o2 : Symbol(o2, Decl(objectRest.ts, 8, 3)) @@ -91,8 +91,10 @@ var { x: { ka, ...nested }, y: other, ...rest } = complex; ({x: { ka, ...nested }, y: other, ...rest} = complex); >x : Symbol(x, Decl(objectRest.ts, 16, 2)) >ka : Symbol(ka, Decl(objectRest.ts, 16, 6)) +>nested : Symbol(nested, Decl(objectRest.ts, 15, 14)) >y : Symbol(y, Decl(objectRest.ts, 16, 23)) >other : Symbol(other, Decl(objectRest.ts, 15, 27)) +>rest : Symbol(rest, Decl(objectRest.ts, 15, 37)) >complex : Symbol(complex, Decl(objectRest.ts, 14, 3)) var { x, ...fresh } = { x: 1, y: 2 }; @@ -103,6 +105,7 @@ var { x, ...fresh } = { x: 1, y: 2 }; ({ x, ...fresh } = { x: 1, y: 2 }); >x : Symbol(x, Decl(objectRest.ts, 18, 2)) +>fresh : Symbol(fresh, Decl(objectRest.ts, 17, 8)) >x : Symbol(x, Decl(objectRest.ts, 18, 20)) >y : Symbol(y, Decl(objectRest.ts, 18, 26)) @@ -144,3 +147,25 @@ var { removed, ...removableRest } = removable; >removableRest : Symbol(removableRest, Decl(objectRest.ts, 31, 14)) >removable : Symbol(removable, Decl(objectRest.ts, 30, 3)) +let computed = 'b'; +>computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) + +let computed2 = 'a'; +>computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) + +var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; +>computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) +>stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 35, 5)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) +>soSo : Symbol(soSo, Decl(objectRest.ts, 35, 32)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) + +({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); +>computed : Symbol(computed, Decl(objectRest.ts, 33, 3)) +>stillNotGreat : Symbol(stillNotGreat, Decl(objectRest.ts, 35, 5)) +>computed2 : Symbol(computed2, Decl(objectRest.ts, 34, 3)) +>soSo : Symbol(soSo, Decl(objectRest.ts, 35, 32)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) +>o : Symbol(o, Decl(objectRest.ts, 0, 3), Decl(objectRest.ts, 35, 51)) + diff --git a/tests/baselines/reference/objectRest.types b/tests/baselines/reference/objectRest.types index 95e378359c8..7d833543747 100644 --- a/tests/baselines/reference/objectRest.types +++ b/tests/baselines/reference/objectRest.types @@ -1,5 +1,5 @@ === tests/cases/conformance/types/rest/objectRest.ts === -let o = { a: 1, b: 'no' } +var o = { a: 1, b: 'no' } >o : { a: number; b: string; } >{ a: 1, b: 'no' } : { a: number; b: string; } >a : number @@ -101,10 +101,10 @@ var { x: { ka, ...nested }, y: other, ...rest } = complex; >x : { ki: any; ka: any; } >{ ka, ...nested } : { ki: any; ka: any; } >ka : any ->nested : any +>nested : { ki: any; } >y : number >other : number ->rest : any +>rest : {} >complex : { x: { ka: any; ki: any; }; y: number; } var { x, ...fresh } = { x: 1, y: 2 }; @@ -121,7 +121,7 @@ var { x, ...fresh } = { x: 1, y: 2 }; >{ x, ...fresh } = { x: 1, y: 2 } : { x: number; y: number; } >{ x, ...fresh } : { y: number; x: number; } >x : number ->fresh : any +>fresh : { y: number; } >{ x: 1, y: 2 } : { x: number; y: number; } >x : number >1 : 1 @@ -168,3 +168,30 @@ var { removed, ...removableRest } = removable; >removableRest : { both: number; remainder: string; } >removable : Removable +let computed = 'b'; +>computed : string +>'b' : "b" + +let computed2 = 'a'; +>computed2 : string +>'a' : "a" + +var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; +>computed : string +>stillNotGreat : any +>computed2 : string +>soSo : any +>o : { a: number; b: string; } +>o : { a: number; b: string; } + +({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); +>({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o) : { a: number; b: string; } +>{ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o : { a: number; b: string; } +>{ [computed]: stillNotGreat, [computed2]: soSo, ...o } : { a: number; b: string; } +>computed : string +>stillNotGreat : any +>computed2 : string +>soSo : any +>o : { a: number; b: string; } +>o : { a: number; b: string; } + diff --git a/tests/baselines/reference/objectRest2.js b/tests/baselines/reference/objectRest2.js new file mode 100644 index 00000000000..5e3f17b857f --- /dev/null +++ b/tests/baselines/reference/objectRest2.js @@ -0,0 +1,45 @@ +//// [objectRest2.ts] +// test for #12203 +declare function connectionFromArray(objects: number, args: any): {}; +function rootConnection(name: string) { + return { + resolve: async (context, args) => { + const { objects } = await { objects: 12 }; + return { + ...connectionFromArray(objects, args) + }; + } + }; +} +rootConnection('test'); + + +//// [objectRest2.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; + } + return t; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function rootConnection(name) { + return { + resolve: (context, args) => __awaiter(this, void 0, void 0, function* () { + const { objects } = yield { objects: 12 }; + return __assign({}, connectionFromArray(objects, args)); + }) + }; +} +rootConnection('test'); diff --git a/tests/baselines/reference/objectRest2.symbols b/tests/baselines/reference/objectRest2.symbols new file mode 100644 index 00000000000..42532f5d183 --- /dev/null +++ b/tests/baselines/reference/objectRest2.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/types/rest/objectRest2.ts === +// test for #12203 +declare function connectionFromArray(objects: number, args: any): {}; +>connectionFromArray : Symbol(connectionFromArray, Decl(objectRest2.ts, 0, 0)) +>objects : Symbol(objects, Decl(objectRest2.ts, 1, 37)) +>args : Symbol(args, Decl(objectRest2.ts, 1, 53)) + +function rootConnection(name: string) { +>rootConnection : Symbol(rootConnection, Decl(objectRest2.ts, 1, 69)) +>name : Symbol(name, Decl(objectRest2.ts, 2, 24)) + + return { + resolve: async (context, args) => { +>resolve : Symbol(resolve, Decl(objectRest2.ts, 3, 10)) +>context : Symbol(context, Decl(objectRest2.ts, 4, 20)) +>args : Symbol(args, Decl(objectRest2.ts, 4, 28)) + + const { objects } = await { objects: 12 }; +>objects : Symbol(objects, Decl(objectRest2.ts, 5, 15)) +>objects : Symbol(objects, Decl(objectRest2.ts, 5, 35)) + + return { + ...connectionFromArray(objects, args) +>connectionFromArray : Symbol(connectionFromArray, Decl(objectRest2.ts, 0, 0)) +>objects : Symbol(objects, Decl(objectRest2.ts, 5, 15)) +>args : Symbol(args, Decl(objectRest2.ts, 4, 28)) + + }; + } + }; +} +rootConnection('test'); +>rootConnection : Symbol(rootConnection, Decl(objectRest2.ts, 1, 69)) + diff --git a/tests/baselines/reference/objectRest2.types b/tests/baselines/reference/objectRest2.types new file mode 100644 index 00000000000..8e89a3cb573 --- /dev/null +++ b/tests/baselines/reference/objectRest2.types @@ -0,0 +1,45 @@ +=== tests/cases/conformance/types/rest/objectRest2.ts === +// test for #12203 +declare function connectionFromArray(objects: number, args: any): {}; +>connectionFromArray : (objects: number, args: any) => {} +>objects : number +>args : any + +function rootConnection(name: string) { +>rootConnection : (name: string) => { resolve: (context: any, args: any) => Promise<{}>; } +>name : string + + return { +>{ resolve: async (context, args) => { const { objects } = await { objects: 12 }; return { ...connectionFromArray(objects, args) }; } } : { resolve: (context: any, args: any) => Promise<{}>; } + + resolve: async (context, args) => { +>resolve : (context: any, args: any) => Promise<{}> +>async (context, args) => { const { objects } = await { objects: 12 }; return { ...connectionFromArray(objects, args) }; } : (context: any, args: any) => Promise<{}> +>context : any +>args : any + + const { objects } = await { objects: 12 }; +>objects : number +>await { objects: 12 } : { objects: number; } +>{ objects: 12 } : { objects: number; } +>objects : number +>12 : 12 + + return { +>{ ...connectionFromArray(objects, args) } : {} + + ...connectionFromArray(objects, args) +>connectionFromArray(objects, args) : {} +>connectionFromArray : (objects: number, args: any) => {} +>objects : number +>args : any + + }; + } + }; +} +rootConnection('test'); +>rootConnection('test') : { resolve: (context: any, args: any) => Promise<{}>; } +>rootConnection : (name: string) => { resolve: (context: any, args: any) => Promise<{}>; } +>'test' : "test" + diff --git a/tests/baselines/reference/objectRestAssignment.js b/tests/baselines/reference/objectRestAssignment.js index 50d38c178a9..66ee00f6696 100644 --- a/tests/baselines/reference/objectRestAssignment.js +++ b/tests/baselines/reference/objectRestAssignment.js @@ -17,8 +17,11 @@ var { a: [{ ...nested2 }, ...y], b: { z, ...c }, ...rest2 } = overEmit; //// [objectRestAssignment.js] var __rest = (this && this.__rest) || function (s, e) { var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; return t; }; let ka; diff --git a/tests/baselines/reference/objectRestAssignment.symbols b/tests/baselines/reference/objectRestAssignment.symbols index 4cb27e6e7ec..82324873283 100644 --- a/tests/baselines/reference/objectRestAssignment.symbols +++ b/tests/baselines/reference/objectRestAssignment.symbols @@ -22,8 +22,10 @@ let complex: { x: { ka, ki }, y: number }; ({x: { ka, ...nested }, y: other, ...rest} = complex); >x : Symbol(x, Decl(objectRestAssignment.ts, 5, 2)) >ka : Symbol(ka, Decl(objectRestAssignment.ts, 5, 6)) +>nested : Symbol(nested, Decl(objectRestAssignment.ts, 1, 3)) >y : Symbol(y, Decl(objectRestAssignment.ts, 5, 23)) >other : Symbol(other, Decl(objectRestAssignment.ts, 2, 3)) +>rest : Symbol(rest, Decl(objectRestAssignment.ts, 3, 3)) >complex : Symbol(complex, Decl(objectRestAssignment.ts, 4, 3)) // should be: @@ -52,8 +54,11 @@ var { a: [{ ...nested2 }, ...y], b: { z, ...c }, ...rest2 } = overEmit; ({ a: [{ ...nested2 }, ...y], b: { z, ...c }, ...rest2 } = overEmit); >a : Symbol(a, Decl(objectRestAssignment.ts, 12, 2)) +>nested2 : Symbol(nested2, Decl(objectRestAssignment.ts, 11, 11)) >y : Symbol(y, Decl(objectRestAssignment.ts, 11, 25)) >b : Symbol(b, Decl(objectRestAssignment.ts, 12, 29)) >z : Symbol(z, Decl(objectRestAssignment.ts, 12, 34)) +>c : Symbol(c, Decl(objectRestAssignment.ts, 11, 40)) +>rest2 : Symbol(rest2, Decl(objectRestAssignment.ts, 11, 48)) >overEmit : Symbol(overEmit, Decl(objectRestAssignment.ts, 8, 3)) diff --git a/tests/baselines/reference/objectRestAssignment.types b/tests/baselines/reference/objectRestAssignment.types index 38aa00ce61d..b51260736ad 100644 --- a/tests/baselines/reference/objectRestAssignment.types +++ b/tests/baselines/reference/objectRestAssignment.types @@ -26,10 +26,10 @@ let complex: { x: { ka, ki }, y: number }; >x : { ki: any; ka: any; } >{ ka, ...nested } : { ki: any; ka: any; } >ka : any ->nested : any +>nested : { ki: any; } >y : number >other : number ->rest : any +>rest : {} >complex : { x: { ka: any; ki: any; }; y: number; } // should be: @@ -63,13 +63,13 @@ var { a: [{ ...nested2 }, ...y], b: { z, ...c }, ...rest2 } = overEmit; >a : { ka: string; x: string; }[] >[{ ...nested2 }, ...y] : { ka: string; x: string; }[] >{ ...nested2 } : { ka: string; x: string; } ->nested2 : any +>nested2 : { ka: string; x: string; } >...y : { ka: string; x: string; } >y : { ka: string; x: string; }[] >b : { ki: string; ku: string; z: string; } >{ z, ...c } : { ki: string; ku: string; z: string; } >z : string ->c : any ->rest2 : any +>c : { ki: string; ku: string; } +>rest2 : { ke: string; ko: string; } >overEmit : { a: { ka: string; x: string; }[]; b: { z: string; ki: string; ku: string; }; ke: string; ko: string; } diff --git a/tests/baselines/reference/objectRestForOf.js b/tests/baselines/reference/objectRestForOf.js index f8872ffbae4..f8343c86126 100644 --- a/tests/baselines/reference/objectRestForOf.js +++ b/tests/baselines/reference/objectRestForOf.js @@ -20,13 +20,19 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; return t; }; let array; diff --git a/tests/baselines/reference/objectRestForOf.symbols b/tests/baselines/reference/objectRestForOf.symbols index ec0ccde740d..f3786fed55f 100644 --- a/tests/baselines/reference/objectRestForOf.symbols +++ b/tests/baselines/reference/objectRestForOf.symbols @@ -23,6 +23,7 @@ let rrestOff: { y: string }; for ({ x: xx, ...rrestOff } of array ) { >x : Symbol(x, Decl(objectRestForOf.ts, 6, 6)) >xx : Symbol(xx, Decl(objectRestForOf.ts, 4, 3)) +>rrestOff : Symbol(rrestOff, Decl(objectRestForOf.ts, 5, 3)) >array : Symbol(array, Decl(objectRestForOf.ts, 0, 3)) [xx, rrestOff]; @@ -35,6 +36,7 @@ for (const norest of array.map(a => ({ ...a, x: 'a string' }))) { >array : Symbol(array, Decl(objectRestForOf.ts, 0, 3)) >map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >a : Symbol(a, Decl(objectRestForOf.ts, 9, 31)) +>a : Symbol(a, Decl(objectRestForOf.ts, 9, 31)) >x : Symbol(x, Decl(objectRestForOf.ts, 9, 44)) [norest.x, norest.y]; diff --git a/tests/baselines/reference/objectRestForOf.types b/tests/baselines/reference/objectRestForOf.types index e8c3b4a82ab..2fde7566c74 100644 --- a/tests/baselines/reference/objectRestForOf.types +++ b/tests/baselines/reference/objectRestForOf.types @@ -25,7 +25,7 @@ for ({ x: xx, ...rrestOff } of array ) { >{ x: xx, ...rrestOff } : { y: string; x: number; } >x : { x: number; y: string; } >xx : number ->rrestOff : any +>rrestOff : { y: string; } >array : { x: number; y: string; }[] [xx, rrestOff]; @@ -43,7 +43,7 @@ for (const norest of array.map(a => ({ ...a, x: 'a string' }))) { >a : { x: number; y: string; } >({ ...a, x: 'a string' }) : { x: string; y: string; } >{ ...a, x: 'a string' } : { x: string; y: string; } ->a : any +>a : { x: number; y: string; } >x : string >'a string' : "a string" diff --git a/tests/baselines/reference/objectRestNegative.js b/tests/baselines/reference/objectRestNegative.js index c9f0dba32c1..a2da998cf8a 100644 --- a/tests/baselines/reference/objectRestNegative.js +++ b/tests/baselines/reference/objectRestNegative.js @@ -15,8 +15,11 @@ let rest: { b: string } //// [objectRestNegative.js] var __rest = (this && this.__rest) || function (s, e) { var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; return t; }; var o = { a: 1, b: 'no' }; diff --git a/tests/baselines/reference/objectRestParameter.js b/tests/baselines/reference/objectRestParameter.js index 49434f24eec..f7241135486 100644 --- a/tests/baselines/reference/objectRestParameter.js +++ b/tests/baselines/reference/objectRestParameter.js @@ -11,8 +11,11 @@ suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' //// [objectRestParameter.js] var __rest = (this && this.__rest) || function (s, e) { var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p)) + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; return t; }; function cloneAgain(_a) { diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index d1de48c5cab..dc49d1f40ff 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -87,6 +87,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; @@ -105,7 +108,7 @@ var combinedMid = __assign({}, o, { b: 'ok' }, o2); var combinedAfter = __assign({}, o, o2, { b: 'ok' }); var combinedNested = __assign({}, __assign({ a: 4 }, { b: false, c: 'overriden' }), { d: 'actually new' }, { a: 5, d: 'maybe new' }); var combinedNestedChangeType = __assign({}, __assign({ a: 1 }, { b: false, c: 'overriden' }), { c: -1 }); -var propertyNested = __assign({ a: __assign({}, o) }); +var propertyNested = { a: __assign({}, o) }; // accessors don't copy the descriptor // (which means that readonly getters become read/write properties) var op = { get a() { return 6; } }; diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 9946b313f52..0b2fce46b0d 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -21,6 +21,7 @@ let addAfter: { a: number, b: string, c: boolean } = >c : Symbol(c, Decl(objectSpread.ts, 4, 37)) { ...o, c: false } +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >c : Symbol(c, Decl(objectSpread.ts, 5, 11)) let addBefore: { a: number, b: string, c: boolean } = @@ -31,6 +32,7 @@ let addBefore: { a: number, b: string, c: boolean } = { c: false, ...o } >c : Symbol(c, Decl(objectSpread.ts, 7, 5)) +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) // Note: ignore still changes the order that properties are printed let ignore: { a: number, b: string } = @@ -40,6 +42,7 @@ let ignore: { a: number, b: string } = { b: 'ignored', ...o } >b : Symbol(b, Decl(objectSpread.ts, 10, 5)) +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) let override: { a: number, b: string } = >override : Symbol(override, Decl(objectSpread.ts, 11, 3)) @@ -47,6 +50,7 @@ let override: { a: number, b: string } = >b : Symbol(b, Decl(objectSpread.ts, 11, 26)) { ...o, b: 'override' } +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >b : Symbol(b, Decl(objectSpread.ts, 12, 11)) let nested: { a: number, b: boolean, c: string } = @@ -68,6 +72,9 @@ let combined: { a: number, b: string, c: boolean } = >c : Symbol(c, Decl(objectSpread.ts, 15, 37)) { ...o, ...o2 } +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) +>o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) + let combinedBefore: { a: number, b: string, c: boolean } = >combinedBefore : Symbol(combinedBefore, Decl(objectSpread.ts, 17, 3)) >a : Symbol(a, Decl(objectSpread.ts, 17, 21)) @@ -76,6 +83,8 @@ let combinedBefore: { a: number, b: string, c: boolean } = { b: 'ok', ...o, ...o2 } >b : Symbol(b, Decl(objectSpread.ts, 18, 5)) +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) +>o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) let combinedMid: { a: number, b: string, c: boolean } = >combinedMid : Symbol(combinedMid, Decl(objectSpread.ts, 19, 3)) @@ -84,7 +93,9 @@ let combinedMid: { a: number, b: string, c: boolean } = >c : Symbol(c, Decl(objectSpread.ts, 19, 40)) { ...o, b: 'ok', ...o2 } +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >b : Symbol(b, Decl(objectSpread.ts, 20, 11)) +>o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) let combinedAfter: { a: number, b: string, c: boolean } = >combinedAfter : Symbol(combinedAfter, Decl(objectSpread.ts, 21, 3)) @@ -93,6 +104,8 @@ let combinedAfter: { a: number, b: string, c: boolean } = >c : Symbol(c, Decl(objectSpread.ts, 21, 42)) { ...o, ...o2, b: 'ok' } +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) +>o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) >b : Symbol(b, Decl(objectSpread.ts, 22, 18)) let combinedNested: { a: number, b: boolean, c: string, d: string } = @@ -130,6 +143,7 @@ let propertyNested: { a: { a: number, b: string } } = { a: { ... o } } >a : Symbol(a, Decl(objectSpread.ts, 28, 5)) +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) // accessors don't copy the descriptor // (which means that readonly getters become read/write properties) @@ -143,6 +157,7 @@ let getter: { a: number, c: number } = >c : Symbol(c, Decl(objectSpread.ts, 32, 24)) { ...op, c: 7 } +>op : Symbol(op, Decl(objectSpread.ts, 31, 3)) >c : Symbol(c, Decl(objectSpread.ts, 33, 12)) getter.a = 12; @@ -160,6 +175,7 @@ let anything: any; let spreadAny = { ...anything }; >spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 41, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 40, 3)) // methods are not enumerable class C { p = 1; m() { } } @@ -175,12 +191,14 @@ let c: C = new C() let spreadC: { p: number } = { ...c } >spreadC : Symbol(spreadC, Decl(objectSpread.ts, 46, 3)) >p : Symbol(p, Decl(objectSpread.ts, 46, 14)) +>c : Symbol(c, Decl(objectSpread.ts, 45, 3)) // own methods are enumerable let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }; >cplus : Symbol(cplus, Decl(objectSpread.ts, 49, 3)) >p : Symbol(p, Decl(objectSpread.ts, 49, 12)) >plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) +>c : Symbol(c, Decl(objectSpread.ts, 45, 3)) >plus : Symbol(plus, Decl(objectSpread.ts, 49, 48)) >this : Symbol(__object, Decl(objectSpread.ts, 41, 15)) @@ -196,6 +214,7 @@ let changeTypeAfter: { a: string, b: string } = >b : Symbol(b, Decl(objectSpread.ts, 53, 33)) { ...o, a: 'wrong type?' } +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >a : Symbol(a, Decl(objectSpread.ts, 54, 11)) let changeTypeBefore: { a: number, b: string } = @@ -205,6 +224,7 @@ let changeTypeBefore: { a: number, b: string } = { a: 'wrong type?', ...o }; >a : Symbol(a, Decl(objectSpread.ts, 56, 5)) +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) let changeTypeBoth: { a: string, b: number } = >changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 57, 3)) @@ -212,6 +232,8 @@ let changeTypeBoth: { a: string, b: number } = >b : Symbol(b, Decl(objectSpread.ts, 57, 32)) { ...o, ...swap }; +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) +>swap : Symbol(swap, Decl(objectSpread.ts, 2, 3)) // optional let definiteBoolean: { sn: boolean }; @@ -233,14 +255,23 @@ let optionalNumber: { sn?: number }; let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; >optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 65, 3)) >sn : Symbol(sn, Decl(objectSpread.ts, 65, 25)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 61, 3)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 62, 3)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; >optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 66, 3)) >sn : Symbol(sn, Decl(objectSpread.ts, 66, 30)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 61, 3)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 62, 3)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 63, 3)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; >allOptional : Symbol(allOptional, Decl(objectSpread.ts, 67, 3)) >sn : Symbol(sn, Decl(objectSpread.ts, 67, 18)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 63, 3)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) // computed property let computedFirst: { a: number, b: string, "before everything": number } = @@ -250,6 +281,7 @@ let computedFirst: { a: number, b: string, "before everything": number } = { ['before everything']: 12, ...o, b: 'yes' } >'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 71, 5)) +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >b : Symbol(b, Decl(objectSpread.ts, 71, 38)) let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = @@ -259,8 +291,10 @@ let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number >c : Symbol(c, Decl(objectSpread.ts, 72, 43)) { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 73, 11)) >b : Symbol(b, Decl(objectSpread.ts, 73, 34)) +>o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) let computedAfter: { a: number, b: string, "at the end": number } = >computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 74, 3)) @@ -268,6 +302,7 @@ let computedAfter: { a: number, b: string, "at the end": number } = >b : Symbol(b, Decl(objectSpread.ts, 74, 31)) { ...o, b: 'yeah', ['at the end']: 14 } +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >b : Symbol(b, Decl(objectSpread.ts, 75, 11)) >'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 75, 22)) @@ -279,6 +314,7 @@ let shortCutted: { a: number, b: string } = { ...o, a } >shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 78, 3)) >a : Symbol(a, Decl(objectSpread.ts, 78, 18)) >b : Symbol(b, Decl(objectSpread.ts, 78, 29)) +>o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >a : Symbol(a, Decl(objectSpread.ts, 78, 51)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index a1c70720d12..a571bd0bb63 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -32,7 +32,7 @@ let addAfter: { a: number, b: string, c: boolean } = { ...o, c: false } >{ ...o, c: false } : { c: false; a: number; b: string; } ->o : any +>o : { a: number; b: string; } >c : boolean >false : false @@ -46,7 +46,7 @@ let addBefore: { a: number, b: string, c: boolean } = >{ c: false, ...o } : { a: number; b: string; c: false; } >c : boolean >false : false ->o : any +>o : { a: number; b: string; } // Note: ignore still changes the order that properties are printed let ignore: { a: number, b: string } = @@ -58,7 +58,7 @@ let ignore: { a: number, b: string } = >{ b: 'ignored', ...o } : { a: number; b: string; } >b : string >'ignored' : "ignored" ->o : any +>o : { a: number; b: string; } let override: { a: number, b: string } = >override : { a: number; b: string; } @@ -67,7 +67,7 @@ let override: { a: number, b: string } = { ...o, b: 'override' } >{ ...o, b: 'override' } : { b: string; a: number; } ->o : any +>o : { a: number; b: string; } >b : string >'override' : "override" @@ -98,8 +98,8 @@ let combined: { a: number, b: string, c: boolean } = { ...o, ...o2 } >{ ...o, ...o2 } : { b: string; c: boolean; a: number; } ->o : any ->o2 : any +>o : { a: number; b: string; } +>o2 : { b: string; c: boolean; } let combinedBefore: { a: number, b: string, c: boolean } = >combinedBefore : { a: number; b: string; c: boolean; } @@ -111,8 +111,8 @@ let combinedBefore: { a: number, b: string, c: boolean } = >{ b: 'ok', ...o, ...o2 } : { b: string; c: boolean; a: number; } >b : string >'ok' : "ok" ->o : any ->o2 : any +>o : { a: number; b: string; } +>o2 : { b: string; c: boolean; } let combinedMid: { a: number, b: string, c: boolean } = >combinedMid : { a: number; b: string; c: boolean; } @@ -122,10 +122,10 @@ let combinedMid: { a: number, b: string, c: boolean } = { ...o, b: 'ok', ...o2 } >{ ...o, b: 'ok', ...o2 } : { b: string; c: boolean; a: number; } ->o : any +>o : { a: number; b: string; } >b : string >'ok' : "ok" ->o2 : any +>o2 : { b: string; c: boolean; } let combinedAfter: { a: number, b: string, c: boolean } = >combinedAfter : { a: number; b: string; c: boolean; } @@ -135,8 +135,8 @@ let combinedAfter: { a: number, b: string, c: boolean } = { ...o, ...o2, b: 'ok' } >{ ...o, ...o2, b: 'ok' } : { b: string; c: boolean; a: number; } ->o : any ->o2 : any +>o : { a: number; b: string; } +>o2 : { b: string; c: boolean; } >b : string >'ok' : "ok" @@ -195,7 +195,7 @@ let propertyNested: { a: { a: number, b: string } } = >{ a: { ... o } } : { a: { a: number; b: string; }; } >a : { a: number; b: string; } >{ ... o } : { a: number; b: string; } ->o : any +>o : { a: number; b: string; } // accessors don't copy the descriptor // (which means that readonly getters become read/write properties) @@ -212,7 +212,7 @@ let getter: { a: number, c: number } = { ...op, c: 7 } >{ ...op, c: 7 } : { c: number; readonly a: number; } ->op : any +>op : { readonly a: number; } >c : number >7 : 7 @@ -256,7 +256,7 @@ let spreadC: { p: number } = { ...c } >spreadC : { p: number; } >p : number >{ ...c } : { p: number; } ->c : any +>c : C // own methods are enumerable let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }; @@ -264,7 +264,7 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } } >p : number >plus : () => void >{ ...c, plus() { return this.p + 1; } } : { plus(): any; p: number; } ->c : any +>c : C >plus : () => any >this.p + 1 : any >this.p : any @@ -286,7 +286,7 @@ let changeTypeAfter: { a: string, b: string } = { ...o, a: 'wrong type?' } >{ ...o, a: 'wrong type?' } : { a: string; b: string; } ->o : any +>o : { a: number; b: string; } >a : string >'wrong type?' : "wrong type?" @@ -299,7 +299,7 @@ let changeTypeBefore: { a: number, b: string } = >{ a: 'wrong type?', ...o } : { a: number; b: string; } >a : string >'wrong type?' : "wrong type?" ->o : any +>o : { a: number; b: string; } let changeTypeBoth: { a: string, b: number } = >changeTypeBoth : { a: string; b: number; } @@ -308,8 +308,8 @@ let changeTypeBoth: { a: string, b: number } = { ...o, ...swap }; >{ ...o, ...swap } : { a: string; b: number; } ->o : any ->swap : any +>o : { a: number; b: string; } +>swap : { a: string; b: number; } // optional let definiteBoolean: { sn: boolean }; @@ -332,25 +332,25 @@ let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean >optionalUnionStops : { sn: string | number | boolean; } >sn : string | number | boolean >{ ...definiteBoolean, ...definiteString, ...optionalNumber } : { sn: string | number; } ->definiteBoolean : any ->definiteString : any ->optionalNumber : any +>definiteBoolean : { sn: boolean; } +>definiteString : { sn: string; } +>optionalNumber : { sn?: number; } let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; >optionalUnionDuplicates : { sn: string | number; } >sn : string | number >{ ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber } : { sn: string | number; } ->definiteBoolean : any ->definiteString : any ->optionalString : any ->optionalNumber : any +>definiteBoolean : { sn: boolean; } +>definiteString : { sn: string; } +>optionalString : { sn?: string; } +>optionalNumber : { sn?: number; } let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; >allOptional : { sn?: string | number; } >sn : string | number >{ ...optionalString, ...optionalNumber } : { sn?: string | number; } ->optionalString : any ->optionalNumber : any +>optionalString : { sn?: string; } +>optionalNumber : { sn?: number; } // computed property let computedFirst: { a: number, b: string, "before everything": number } = @@ -362,7 +362,7 @@ let computedFirst: { a: number, b: string, "before everything": number } = >{ ['before everything']: 12, ...o, b: 'yes' } : { b: string; a: number; ['before everything']: number; } >'before everything' : "before everything" >12 : 12 ->o : any +>o : { a: number; b: string; } >b : string >'yes' : "yes" @@ -374,12 +374,12 @@ let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } >{ ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } : { b: string; c: boolean; ['in the middle']: number; a: number; } ->o : any +>o : { a: number; b: string; } >'in the middle' : "in the middle" >13 : 13 >b : string >'maybe?' : "maybe?" ->o2 : any +>o2 : { b: string; c: boolean; } let computedAfter: { a: number, b: string, "at the end": number } = >computedAfter : { a: number; b: string; "at the end": number; } @@ -388,7 +388,7 @@ let computedAfter: { a: number, b: string, "at the end": number } = { ...o, b: 'yeah', ['at the end']: 14 } >{ ...o, b: 'yeah', ['at the end']: 14 } : { b: string; ['at the end']: number; a: number; } ->o : any +>o : { a: number; b: string; } >b : string >'yeah' : "yeah" >'at the end' : "at the end" @@ -404,7 +404,7 @@ let shortCutted: { a: number, b: string } = { ...o, a } >a : number >b : string >{ ...o, a } : { a: number; b: string; } ->o : any +>o : { a: number; b: string; } >a : number diff --git a/tests/baselines/reference/objectSpreadComputedProperty.js b/tests/baselines/reference/objectSpreadComputedProperty.js new file mode 100644 index 00000000000..6f27e696ae7 --- /dev/null +++ b/tests/baselines/reference/objectSpreadComputedProperty.js @@ -0,0 +1,34 @@ +//// [objectSpreadComputedProperty.ts] +// fixes #12200 +function f() { + let n: number = 12; + let m: number = 13; + let a: any = null; + const o1 = { ...{}, [n]: n }; + const o2 = { ...{}, [a]: n }; + const o3 = { [a]: n, ...{}, [n]: n, ...{}, [m]: m }; +} + + +//// [objectSpreadComputedProperty.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; + } + return t; +}; +// fixes #12200 +function f() { + var n = 12; + var m = 13; + var a = null; + var o1 = __assign({}, (_a = {}, _a[n] = n, _a)); + var o2 = __assign({}, (_b = {}, _b[a] = n, _b)); + var o3 = __assign((_c = {}, _c[a] = n, _c), {}, (_d = {}, _d[n] = n, _d), {}, (_e = {}, _e[m] = m, _e)); + var _a, _b, _c, _d, _e; +} diff --git a/tests/baselines/reference/objectSpreadComputedProperty.symbols b/tests/baselines/reference/objectSpreadComputedProperty.symbols new file mode 100644 index 00000000000..57a0db0962b --- /dev/null +++ b/tests/baselines/reference/objectSpreadComputedProperty.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/types/spread/objectSpreadComputedProperty.ts === +// fixes #12200 +function f() { +>f : Symbol(f, Decl(objectSpreadComputedProperty.ts, 0, 0)) + + let n: number = 12; +>n : Symbol(n, Decl(objectSpreadComputedProperty.ts, 2, 7)) + + let m: number = 13; +>m : Symbol(m, Decl(objectSpreadComputedProperty.ts, 3, 7)) + + let a: any = null; +>a : Symbol(a, Decl(objectSpreadComputedProperty.ts, 4, 7)) + + const o1 = { ...{}, [n]: n }; +>o1 : Symbol(o1, Decl(objectSpreadComputedProperty.ts, 5, 9)) +>n : Symbol(n, Decl(objectSpreadComputedProperty.ts, 2, 7)) +>n : Symbol(n, Decl(objectSpreadComputedProperty.ts, 2, 7)) + + const o2 = { ...{}, [a]: n }; +>o2 : Symbol(o2, Decl(objectSpreadComputedProperty.ts, 6, 9)) +>a : Symbol(a, Decl(objectSpreadComputedProperty.ts, 4, 7)) +>n : Symbol(n, Decl(objectSpreadComputedProperty.ts, 2, 7)) + + const o3 = { [a]: n, ...{}, [n]: n, ...{}, [m]: m }; +>o3 : Symbol(o3, Decl(objectSpreadComputedProperty.ts, 7, 9)) +>a : Symbol(a, Decl(objectSpreadComputedProperty.ts, 4, 7)) +>n : Symbol(n, Decl(objectSpreadComputedProperty.ts, 2, 7)) +>n : Symbol(n, Decl(objectSpreadComputedProperty.ts, 2, 7)) +>n : Symbol(n, Decl(objectSpreadComputedProperty.ts, 2, 7)) +>m : Symbol(m, Decl(objectSpreadComputedProperty.ts, 3, 7)) +>m : Symbol(m, Decl(objectSpreadComputedProperty.ts, 3, 7)) +} + diff --git a/tests/baselines/reference/objectSpreadComputedProperty.types b/tests/baselines/reference/objectSpreadComputedProperty.types new file mode 100644 index 00000000000..287936d4354 --- /dev/null +++ b/tests/baselines/reference/objectSpreadComputedProperty.types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/types/spread/objectSpreadComputedProperty.ts === +// fixes #12200 +function f() { +>f : () => void + + let n: number = 12; +>n : number +>12 : 12 + + let m: number = 13; +>m : number +>13 : 13 + + let a: any = null; +>a : any +>null : null + + const o1 = { ...{}, [n]: n }; +>o1 : {} +>{ ...{}, [n]: n } : {} +>{} : {} +>n : number +>n : number + + const o2 = { ...{}, [a]: n }; +>o2 : {} +>{ ...{}, [a]: n } : {} +>{} : {} +>a : any +>n : number + + const o3 = { [a]: n, ...{}, [n]: n, ...{}, [m]: m }; +>o3 : {} +>{ [a]: n, ...{}, [n]: n, ...{}, [m]: m } : {} +>a : any +>n : number +>{} : {} +>n : number +>n : number +>{} : {} +>m : number +>m : number +} + diff --git a/tests/baselines/reference/objectSpreadIndexSignature.js b/tests/baselines/reference/objectSpreadIndexSignature.js index 22e92e6a844..ffe88a89c9a 100644 --- a/tests/baselines/reference/objectSpreadIndexSignature.js +++ b/tests/baselines/reference/objectSpreadIndexSignature.js @@ -23,6 +23,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/objectSpreadIndexSignature.symbols b/tests/baselines/reference/objectSpreadIndexSignature.symbols index c51e7f4532f..cd64b157196 100644 --- a/tests/baselines/reference/objectSpreadIndexSignature.symbols +++ b/tests/baselines/reference/objectSpreadIndexSignature.symbols @@ -27,6 +27,7 @@ let indexed2: Indexed2; let i = { ...indexed, b: 11 }; >i : Symbol(i, Decl(objectSpreadIndexSignature.ts, 10, 3)) +>indexed : Symbol(indexed, Decl(objectSpreadIndexSignature.ts, 8, 3)) >b : Symbol(b, Decl(objectSpreadIndexSignature.ts, 10, 21)) // only indexed has indexer, so i[101]: any @@ -35,6 +36,8 @@ i[101]; let ii = { ...indexed, ...indexed2 }; >ii : Symbol(ii, Decl(objectSpreadIndexSignature.ts, 13, 3)) +>indexed : Symbol(indexed, Decl(objectSpreadIndexSignature.ts, 8, 3)) +>indexed2 : Symbol(indexed2, Decl(objectSpreadIndexSignature.ts, 9, 3)) // both have indexer, so i[1001]: number | boolean ii[1001]; diff --git a/tests/baselines/reference/objectSpreadIndexSignature.types b/tests/baselines/reference/objectSpreadIndexSignature.types index 79a515e7374..5eebc2ffa02 100644 --- a/tests/baselines/reference/objectSpreadIndexSignature.types +++ b/tests/baselines/reference/objectSpreadIndexSignature.types @@ -28,7 +28,7 @@ let indexed2: Indexed2; let i = { ...indexed, b: 11 }; >i : { b: number; a: number; } >{ ...indexed, b: 11 } : { b: number; a: number; } ->indexed : any +>indexed : Indexed >b : number >11 : 11 @@ -41,8 +41,8 @@ i[101]; let ii = { ...indexed, ...indexed2 }; >ii : { [x: string]: number | boolean; c: boolean; a: number; } >{ ...indexed, ...indexed2 } : { [x: string]: number | boolean; c: boolean; a: number; } ->indexed : any ->indexed2 : any +>indexed : Indexed +>indexed2 : Indexed2 // both have indexer, so i[1001]: number | boolean ii[1001]; diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index 6287f4559a7..472a0857169 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -77,6 +77,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/objectSpreadNegativeParse.js b/tests/baselines/reference/objectSpreadNegativeParse.js index 297c56c3e62..4076ab1c3a0 100644 --- a/tests/baselines/reference/objectSpreadNegativeParse.js +++ b/tests/baselines/reference/objectSpreadNegativeParse.js @@ -11,6 +11,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/objectSpreadNoTransform.symbols b/tests/baselines/reference/objectSpreadNoTransform.symbols index d7dac11a530..78423330dbb 100644 --- a/tests/baselines/reference/objectSpreadNoTransform.symbols +++ b/tests/baselines/reference/objectSpreadNoTransform.symbols @@ -7,6 +7,7 @@ const y = { a: 'yes', b: 'no' }; const o = { x: 1, ...y }; >o : Symbol(o, Decl(objectSpreadNoTransform.ts, 1, 5)) >x : Symbol(x, Decl(objectSpreadNoTransform.ts, 1, 11)) +>y : Symbol(y, Decl(objectSpreadNoTransform.ts, 0, 5)) var b; >b : Symbol(b, Decl(objectSpreadNoTransform.ts, 2, 3)) @@ -16,5 +17,6 @@ var rest; ({ b, ...rest } = o); >b : Symbol(b, Decl(objectSpreadNoTransform.ts, 4, 2)) +>rest : Symbol(rest, Decl(objectSpreadNoTransform.ts, 3, 3)) >o : Symbol(o, Decl(objectSpreadNoTransform.ts, 1, 5)) diff --git a/tests/baselines/reference/objectSpreadNoTransform.types b/tests/baselines/reference/objectSpreadNoTransform.types index 0a6c867e8fe..ae89a3a7993 100644 --- a/tests/baselines/reference/objectSpreadNoTransform.types +++ b/tests/baselines/reference/objectSpreadNoTransform.types @@ -12,7 +12,7 @@ const o = { x: 1, ...y }; >{ x: 1, ...y } : { a: string; b: string; x: number; } >x : number >1 : 1 ->y : any +>y : { a: string; b: string; } var b; >b : any @@ -25,6 +25,6 @@ var rest; >{ b, ...rest } = o : { a: string; b: string; x: number; } >{ b, ...rest } : any >b : any ->rest : any +>rest : undefined >o : { a: string; b: string; x: number; } diff --git a/tests/baselines/reference/objectSpreadStrictNull.js b/tests/baselines/reference/objectSpreadStrictNull.js index 84604d728cd..fc0d4a80564 100644 --- a/tests/baselines/reference/objectSpreadStrictNull.js +++ b/tests/baselines/reference/objectSpreadStrictNull.js @@ -27,6 +27,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/objectSpreadStrictNull.symbols b/tests/baselines/reference/objectSpreadStrictNull.symbols index 85def473ce4..2586d4ddbd3 100644 --- a/tests/baselines/reference/objectSpreadStrictNull.symbols +++ b/tests/baselines/reference/objectSpreadStrictNull.symbols @@ -31,30 +31,51 @@ function f( let optionalUnionStops: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; >optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpreadStrictNull.ts, 9, 7)) >sn : Symbol(sn, Decl(objectSpreadStrictNull.ts, 9, 29)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpreadStrictNull.ts, 1, 11)) +>definiteString : Symbol(definiteString, Decl(objectSpreadStrictNull.ts, 2, 37)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpreadStrictNull.ts, 4, 36)) let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; >optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpreadStrictNull.ts, 10, 7)) >sn : Symbol(sn, Decl(objectSpreadStrictNull.ts, 10, 34)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpreadStrictNull.ts, 1, 11)) +>definiteString : Symbol(definiteString, Decl(objectSpreadStrictNull.ts, 2, 37)) +>optionalString : Symbol(optionalString, Decl(objectSpreadStrictNull.ts, 3, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpreadStrictNull.ts, 4, 36)) let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; >allOptional : Symbol(allOptional, Decl(objectSpreadStrictNull.ts, 11, 7)) >sn : Symbol(sn, Decl(objectSpreadStrictNull.ts, 11, 22)) +>optionalString : Symbol(optionalString, Decl(objectSpreadStrictNull.ts, 3, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpreadStrictNull.ts, 4, 36)) // undefined let undefinedUnionStops: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...undefinedNumber }; >undefinedUnionStops : Symbol(undefinedUnionStops, Decl(objectSpreadStrictNull.ts, 14, 7)) >sn : Symbol(sn, Decl(objectSpreadStrictNull.ts, 14, 30)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpreadStrictNull.ts, 1, 11)) +>definiteString : Symbol(definiteString, Decl(objectSpreadStrictNull.ts, 2, 37)) +>undefinedNumber : Symbol(undefinedNumber, Decl(objectSpreadStrictNull.ts, 6, 48)) let undefinedUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...undefinedString, ...undefinedNumber }; >undefinedUnionDuplicates : Symbol(undefinedUnionDuplicates, Decl(objectSpreadStrictNull.ts, 15, 7)) >sn : Symbol(sn, Decl(objectSpreadStrictNull.ts, 15, 35)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpreadStrictNull.ts, 1, 11)) +>definiteString : Symbol(definiteString, Decl(objectSpreadStrictNull.ts, 2, 37)) +>undefinedString : Symbol(undefinedString, Decl(objectSpreadStrictNull.ts, 5, 36)) +>undefinedNumber : Symbol(undefinedNumber, Decl(objectSpreadStrictNull.ts, 6, 48)) let allUndefined: { sn: string | number | undefined } = { ...undefinedString, ...undefinedNumber }; >allUndefined : Symbol(allUndefined, Decl(objectSpreadStrictNull.ts, 16, 7)) >sn : Symbol(sn, Decl(objectSpreadStrictNull.ts, 16, 23)) +>undefinedString : Symbol(undefinedString, Decl(objectSpreadStrictNull.ts, 5, 36)) +>undefinedNumber : Symbol(undefinedNumber, Decl(objectSpreadStrictNull.ts, 6, 48)) let undefinedWithOptionalContinues: { sn: string | number | boolean } = { ...definiteBoolean, ...undefinedString, ...optionalNumber }; >undefinedWithOptionalContinues : Symbol(undefinedWithOptionalContinues, Decl(objectSpreadStrictNull.ts, 18, 7)) >sn : Symbol(sn, Decl(objectSpreadStrictNull.ts, 18, 41)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpreadStrictNull.ts, 1, 11)) +>undefinedString : Symbol(undefinedString, Decl(objectSpreadStrictNull.ts, 5, 36)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpreadStrictNull.ts, 4, 36)) } diff --git a/tests/baselines/reference/objectSpreadStrictNull.types b/tests/baselines/reference/objectSpreadStrictNull.types index a91295b2bca..c9ed742c6b6 100644 --- a/tests/baselines/reference/objectSpreadStrictNull.types +++ b/tests/baselines/reference/objectSpreadStrictNull.types @@ -32,57 +32,57 @@ function f( >optionalUnionStops : { sn: string | number; } >sn : string | number >{ ...definiteBoolean, ...definiteString, ...optionalNumber } : { sn: string | number; } ->definiteBoolean : any ->definiteString : any ->optionalNumber : any +>definiteBoolean : { sn: boolean; } +>definiteString : { sn: string; } +>optionalNumber : { sn?: number | undefined; } let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; >optionalUnionDuplicates : { sn: string | number; } >sn : string | number >{ ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber } : { sn: string | number; } ->definiteBoolean : any ->definiteString : any ->optionalString : any ->optionalNumber : any +>definiteBoolean : { sn: boolean; } +>definiteString : { sn: string; } +>optionalString : { sn?: string | undefined; } +>optionalNumber : { sn?: number | undefined; } let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; >allOptional : { sn?: string | number | undefined; } >sn : string | number | undefined >{ ...optionalString, ...optionalNumber } : { sn?: string | number | undefined; } ->optionalString : any ->optionalNumber : any +>optionalString : { sn?: string | undefined; } +>optionalNumber : { sn?: number | undefined; } // undefined let undefinedUnionStops: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...undefinedNumber }; >undefinedUnionStops : { sn: string | number; } >sn : string | number >{ ...definiteBoolean, ...definiteString, ...undefinedNumber } : { sn: string | number; } ->definiteBoolean : any ->definiteString : any ->undefinedNumber : any +>definiteBoolean : { sn: boolean; } +>definiteString : { sn: string; } +>undefinedNumber : { sn: number | undefined; } let undefinedUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...undefinedString, ...undefinedNumber }; >undefinedUnionDuplicates : { sn: string | number; } >sn : string | number >{ ...definiteBoolean, ...definiteString, ...undefinedString, ...undefinedNumber } : { sn: string | number; } ->definiteBoolean : any ->definiteString : any ->undefinedString : any ->undefinedNumber : any +>definiteBoolean : { sn: boolean; } +>definiteString : { sn: string; } +>undefinedString : { sn: string | undefined; } +>undefinedNumber : { sn: number | undefined; } let allUndefined: { sn: string | number | undefined } = { ...undefinedString, ...undefinedNumber }; >allUndefined : { sn: string | number | undefined; } >sn : string | number | undefined >{ ...undefinedString, ...undefinedNumber } : { sn: string | number | undefined; } ->undefinedString : any ->undefinedNumber : any +>undefinedString : { sn: string | undefined; } +>undefinedNumber : { sn: number | undefined; } let undefinedWithOptionalContinues: { sn: string | number | boolean } = { ...definiteBoolean, ...undefinedString, ...optionalNumber }; >undefinedWithOptionalContinues : { sn: string | number | boolean; } >sn : string | number | boolean >{ ...definiteBoolean, ...undefinedString, ...optionalNumber } : { sn: string | number | boolean; } ->definiteBoolean : any ->undefinedString : any ->optionalNumber : any +>definiteBoolean : { sn: boolean; } +>undefinedString : { sn: string | undefined; } +>optionalNumber : { sn?: number | undefined; } } diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity2.errors.txt b/tests/baselines/reference/parserGreaterThanTokenAmbiguity2.errors.txt index ee2d3666682..30ede342a85 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity2.errors.txt +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity2.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity2.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity2.ts(1,5): error TS1109: Expression expected. ==== tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity2.ts (2 errors) ==== 1 > > 2; ~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.errors.txt b/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.errors.txt index 1651009bf0d..baebfd81304 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.errors.txt +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity3.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity3.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity3.ts(1,8): error TS1109: Expression expected. ==== tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity3.ts (2 errors) ==== 1 >/**/> 2; ~~~~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity4.errors.txt b/tests/baselines/reference/parserGreaterThanTokenAmbiguity4.errors.txt index dff69b37612..924c9440d16 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity4.errors.txt +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity4.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity4.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity4.ts(2,1): error TS1109: Expression expected. @@ -7,6 +7,6 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbigu ~~~ > 2; ~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.js b/tests/baselines/reference/reactNamespaceJSXEmit.js index 3a21504bb80..48e514c2538 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.js +++ b/tests/baselines/reference/reactNamespaceJSXEmit.js @@ -18,6 +18,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/relationalOperatorComparable.errors.txt b/tests/baselines/reference/relationalOperatorComparable.errors.txt new file mode 100644 index 00000000000..bc48eaf92c0 --- /dev/null +++ b/tests/baselines/reference/relationalOperatorComparable.errors.txt @@ -0,0 +1,40 @@ +tests/cases/compiler/relationalOperatorComparable.ts(5,14): error TS2365: Operator '<' cannot be applied to types 'number' and 'boolean'. +tests/cases/compiler/relationalOperatorComparable.ts(6,14): error TS2365: Operator '<=' cannot be applied to types 'number' and 'boolean'. +tests/cases/compiler/relationalOperatorComparable.ts(7,14): error TS2365: Operator '>=' cannot be applied to types 'number' and 'boolean'. +tests/cases/compiler/relationalOperatorComparable.ts(8,14): error TS2365: Operator '>' cannot be applied to types 'number' and 'boolean'. +tests/cases/compiler/relationalOperatorComparable.ts(9,14): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'number'. +tests/cases/compiler/relationalOperatorComparable.ts(10,14): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'number'. +tests/cases/compiler/relationalOperatorComparable.ts(11,14): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. + + +==== tests/cases/compiler/relationalOperatorComparable.ts (7 errors) ==== + function f(onethree: 1 | 3, two: 2) { + const t = true; + const f = false; + let a1 = onethree < two; // ok + let a2 = onethree < true; // error, number and boolean + ~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'boolean'. + let a3 = onethree <= false; // error, number and boolean + ~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '<=' cannot be applied to types 'number' and 'boolean'. + let a4 = onethree >= t; // error, number and boolean + ~~~~~~~~~~~~~ +!!! error TS2365: Operator '>=' cannot be applied to types 'number' and 'boolean'. + let a5 = onethree > f; // error, number and boolean + ~~~~~~~~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'boolean'. + let a6 = true < onethree; // error, boolean and number + ~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'number'. + let a7 = false < two; // error, boolean and number + ~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'number'. + let a8 = 'foo' < onethree; // error, string and number + ~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. + let a9 = onethree < 1; // ok + let a10 = 1 < two; // ok + let a11 = 2 < 1; // ok + } + \ No newline at end of file diff --git a/tests/baselines/reference/relationalOperatorComparable.js b/tests/baselines/reference/relationalOperatorComparable.js new file mode 100644 index 00000000000..019c257fe7d --- /dev/null +++ b/tests/baselines/reference/relationalOperatorComparable.js @@ -0,0 +1,34 @@ +//// [relationalOperatorComparable.ts] +function f(onethree: 1 | 3, two: 2) { + const t = true; + const f = false; + let a1 = onethree < two; // ok + let a2 = onethree < true; // error, number and boolean + let a3 = onethree <= false; // error, number and boolean + let a4 = onethree >= t; // error, number and boolean + let a5 = onethree > f; // error, number and boolean + let a6 = true < onethree; // error, boolean and number + let a7 = false < two; // error, boolean and number + let a8 = 'foo' < onethree; // error, string and number + let a9 = onethree < 1; // ok + let a10 = 1 < two; // ok + let a11 = 2 < 1; // ok +} + + +//// [relationalOperatorComparable.js] +function f(onethree, two) { + var t = true; + var f = false; + var a1 = onethree < two; // ok + var a2 = onethree < true; // error, number and boolean + var a3 = onethree <= false; // error, number and boolean + var a4 = onethree >= t; // error, number and boolean + var a5 = onethree > f; // error, number and boolean + var a6 = true < onethree; // error, boolean and number + var a7 = false < two; // error, boolean and number + var a8 = 'foo' < onethree; // error, string and number + var a9 = onethree < 1; // ok + var a10 = 1 < two; // ok + var a11 = 2 < 1; // ok +} diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt index a51469baa93..a4944f7f163 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt @@ -7,12 +7,11 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperato tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(13,11): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(14,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(15,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(16,9): error TS2365: Operator '<' cannot be applied to types '"ABC"' and '"XYZ"'. tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(17,9): error TS2365: Operator '===' cannot be applied to types '"ABC"' and '"XYZ"'. tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(18,9): error TS2365: Operator '!=' cannot be applied to types '"ABC"' and '"XYZ"'. -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts (12 errors) ==== +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts (11 errors) ==== let abc: "ABC" = "ABC"; let xyz: "XYZ" = "XYZ"; @@ -47,8 +46,6 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperato ~~~~~~~~~~~~~~~~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. let j = abc < xyz; - ~~~~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types '"ABC"' and '"XYZ"'. let k = abc === xyz; ~~~~~~~~~~~ !!! error TS2365: Operator '===' cannot be applied to types '"ABC"' and '"XYZ"'. diff --git a/tests/baselines/reference/superCallWithCommentEmit01.js b/tests/baselines/reference/superCallWithCommentEmit01.js new file mode 100644 index 00000000000..c7ea3cc8b85 --- /dev/null +++ b/tests/baselines/reference/superCallWithCommentEmit01.js @@ -0,0 +1,32 @@ +//// [superCallWithCommentEmit01.ts] +class A { + constructor(public text: string) { } +} + +class B extends A { + constructor(text: string) { + // this is subclass constructor + super(text) + } +} + +//// [superCallWithCommentEmit01.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A(text) { + this.text = text; + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B(text) { + // this is subclass constructor + return _super.call(this, text) || this; + } + return B; +}(A)); diff --git a/tests/baselines/reference/superCallWithCommentEmit01.symbols b/tests/baselines/reference/superCallWithCommentEmit01.symbols new file mode 100644 index 00000000000..9476ee1c4e5 --- /dev/null +++ b/tests/baselines/reference/superCallWithCommentEmit01.symbols @@ -0,0 +1,21 @@ +=== tests/cases/compiler/superCallWithCommentEmit01.ts === +class A { +>A : Symbol(A, Decl(superCallWithCommentEmit01.ts, 0, 0)) + + constructor(public text: string) { } +>text : Symbol(A.text, Decl(superCallWithCommentEmit01.ts, 1, 16)) +} + +class B extends A { +>B : Symbol(B, Decl(superCallWithCommentEmit01.ts, 2, 1)) +>A : Symbol(A, Decl(superCallWithCommentEmit01.ts, 0, 0)) + + constructor(text: string) { +>text : Symbol(text, Decl(superCallWithCommentEmit01.ts, 5, 16)) + + // this is subclass constructor + super(text) +>super : Symbol(A, Decl(superCallWithCommentEmit01.ts, 0, 0)) +>text : Symbol(text, Decl(superCallWithCommentEmit01.ts, 5, 16)) + } +} diff --git a/tests/baselines/reference/superCallWithCommentEmit01.types b/tests/baselines/reference/superCallWithCommentEmit01.types new file mode 100644 index 00000000000..dfa0b1ce333 --- /dev/null +++ b/tests/baselines/reference/superCallWithCommentEmit01.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/superCallWithCommentEmit01.ts === +class A { +>A : A + + constructor(public text: string) { } +>text : string +} + +class B extends A { +>B : B +>A : A + + constructor(text: string) { +>text : string + + // this is subclass constructor + super(text) +>super(text) : void +>super : typeof A +>text : string + } +} diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.js b/tests/baselines/reference/tsxExternalModuleEmit2.js index 6c01a48af78..d3a6591cdaa 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.js +++ b/tests/baselines/reference/tsxExternalModuleEmit2.js @@ -24,6 +24,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/tsxReactEmit2.js b/tests/baselines/reference/tsxReactEmit2.js index 80e3215e2b6..4ddf442b53f 100644 --- a/tests/baselines/reference/tsxReactEmit2.js +++ b/tests/baselines/reference/tsxReactEmit2.js @@ -21,6 +21,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/tsxReactEmit4.js b/tests/baselines/reference/tsxReactEmit4.js index 33c835d1ab2..8ccc940880f 100644 --- a/tests/baselines/reference/tsxReactEmit4.js +++ b/tests/baselines/reference/tsxReactEmit4.js @@ -23,6 +23,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/tsxReactEmit5.js b/tests/baselines/reference/tsxReactEmit5.js index c3e58d0a0da..6e4d43dd676 100644 --- a/tests/baselines/reference/tsxReactEmit5.js +++ b/tests/baselines/reference/tsxReactEmit5.js @@ -28,6 +28,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/baselines/reference/tsxReactEmit6.js b/tests/baselines/reference/tsxReactEmit6.js index 85aa8c123c9..4c951354aa8 100644 --- a/tests/baselines/reference/tsxReactEmit6.js +++ b/tests/baselines/reference/tsxReactEmit6.js @@ -33,6 +33,9 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + if (typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) + t[p[i]] = s[p[i]]; } return t; }; diff --git a/tests/cases/compiler/relationalOperatorComparable.ts b/tests/cases/compiler/relationalOperatorComparable.ts new file mode 100644 index 00000000000..e95bb6e71cc --- /dev/null +++ b/tests/cases/compiler/relationalOperatorComparable.ts @@ -0,0 +1,15 @@ +function f(onethree: 1 | 3, two: 2) { + const t = true; + const f = false; + let a1 = onethree < two; // ok + let a2 = onethree < true; // error, number and boolean + let a3 = onethree <= false; // error, number and boolean + let a4 = onethree >= t; // error, number and boolean + let a5 = onethree > f; // error, number and boolean + let a6 = true < onethree; // error, boolean and number + let a7 = false < two; // error, boolean and number + let a8 = 'foo' < onethree; // error, string and number + let a9 = onethree < 1; // ok + let a10 = 1 < two; // ok + let a11 = 2 < 1; // ok +} diff --git a/tests/cases/compiler/superCallWithCommentEmit01.ts b/tests/cases/compiler/superCallWithCommentEmit01.ts new file mode 100644 index 00000000000..800fad29bfb --- /dev/null +++ b/tests/cases/compiler/superCallWithCommentEmit01.ts @@ -0,0 +1,10 @@ +class A { + constructor(public text: string) { } +} + +class B extends A { + constructor(text: string) { + // this is subclass constructor + super(text) + } +} \ No newline at end of file diff --git a/tests/cases/conformance/types/rest/objectRest.ts b/tests/cases/conformance/types/rest/objectRest.ts index f1a77b1c129..3f7be177c7b 100644 --- a/tests/cases/conformance/types/rest/objectRest.ts +++ b/tests/cases/conformance/types/rest/objectRest.ts @@ -1,5 +1,5 @@ // @target: es2015 -let o = { a: 1, b: 'no' } +var o = { a: 1, b: 'no' } var { ...clone } = o; var { a, ...justB } = o; var { a, b: renamed, ...empty } = o; @@ -31,3 +31,8 @@ class Removable { } var removable = new Removable(); var { removed, ...removableRest } = removable; + +let computed = 'b'; +let computed2 = 'a'; +var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o; +({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o); diff --git a/tests/cases/conformance/types/rest/objectRest2.ts b/tests/cases/conformance/types/rest/objectRest2.ts new file mode 100644 index 00000000000..4a38123f1ac --- /dev/null +++ b/tests/cases/conformance/types/rest/objectRest2.ts @@ -0,0 +1,15 @@ +// @lib: es2015 +// @target: es2015 +// test for #12203 +declare function connectionFromArray(objects: number, args: any): {}; +function rootConnection(name: string) { + return { + resolve: async (context, args) => { + const { objects } = await { objects: 12 }; + return { + ...connectionFromArray(objects, args) + }; + } + }; +} +rootConnection('test'); diff --git a/tests/cases/conformance/types/spread/objectSpreadComputedProperty.ts b/tests/cases/conformance/types/spread/objectSpreadComputedProperty.ts new file mode 100644 index 00000000000..7e2182a2f1d --- /dev/null +++ b/tests/cases/conformance/types/spread/objectSpreadComputedProperty.ts @@ -0,0 +1,9 @@ +// fixes #12200 +function f() { + let n: number = 12; + let m: number = 13; + let a: any = null; + const o1 = { ...{}, [n]: n }; + const o2 = { ...{}, [a]: n }; + const o3 = { [a]: n, ...{}, [n]: n, ...{}, [m]: m }; +} diff --git a/tests/cases/fourslash/renameObjectSpreadAssignment.ts b/tests/cases/fourslash/renameObjectSpreadAssignment.ts new file mode 100644 index 00000000000..9cf0b6ebf81 --- /dev/null +++ b/tests/cases/fourslash/renameObjectSpreadAssignment.ts @@ -0,0 +1,20 @@ +/// + +////interface A1 { a: number }; +////interface A2 { a?: number }; +////let [|a1|]: A1; +////let [|a2|]: A2; +////let a12 = { ...[|a1|], ...[|a2|] }; +const ranges = test.ranges(); +verify.assertHasRanges(ranges); + +// rename a1 +goTo.position(ranges[0].start); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[0], ranges[2]]); +goTo.position(ranges[2].start); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[0], ranges[2]]); +// rename a2 +goTo.position(ranges[1].start); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[1], ranges[3]]); +goTo.position(ranges[3].start); +verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [ranges[1], ranges[3]]); diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts new file mode 100644 index 00000000000..586202ab0c7 --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace1.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// class class1 { +//// } +//// } |] + +verify.codeFixAtPosition(`namespace greeter { +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace2.ts b/tests/cases/fourslash/unusedClassInNamespace2.ts new file mode 100644 index 00000000000..c182f4e3655 --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace2.ts @@ -0,0 +1,15 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// export class class2 { +//// } +//// class class1 { +//// } +//// } |] + +verify.codeFixAtPosition(`namespace greeter { + export class class2 { + } +}`); + diff --git a/tests/cases/fourslash/unusedClassInNamespace3.ts b/tests/cases/fourslash/unusedClassInNamespace3.ts new file mode 100644 index 00000000000..391c5e833ef --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace3.ts @@ -0,0 +1,25 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +//// [| namespace Validation { +//// class c1 { +//// +//// } +//// +//// export class c2 { +//// +//// } +//// +//// class c3 extends c1 { +//// +//// } +////} |] + +verify.codeFixAtPosition(`namespace Validation { + class c1 { + } + + export class c2 { + } +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts new file mode 100644 index 00000000000..5db5b1aefa6 --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace4.ts @@ -0,0 +1,27 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +//// [| namespace Validation { +//// class c1 { +//// +//// } +//// +//// export class c2 { +//// +//// } +//// +//// class c3 { +//// public x: c1; +//// } +////} |] + +verify.codeFixAtPosition(`namespace Validation { + class c1 { + + } + + export class c2 { + + } +}`); diff --git a/tests/cases/fourslash/unusedConstantInFunction1.ts b/tests/cases/fourslash/unusedConstantInFunction1.ts new file mode 100644 index 00000000000..df373257809 --- /dev/null +++ b/tests/cases/fourslash/unusedConstantInFunction1.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +//// [| function f1 () { +//// const x: string = "x"; +//// } |] + +verify.codeFixAtPosition(`function f1 () { +}`); + diff --git a/tests/cases/fourslash/unusedEnumInFunction1.ts b/tests/cases/fourslash/unusedEnumInFunction1.ts new file mode 100644 index 00000000000..1d88f07ebf7 --- /dev/null +++ b/tests/cases/fourslash/unusedEnumInFunction1.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// [| function f1 () { +//// enum Directions { Up, Down} +//// } |] + +verify.codeFixAtPosition(`function f1 () { +} +`); + diff --git a/tests/cases/fourslash/unusedEnumInNamespace1.ts b/tests/cases/fourslash/unusedEnumInNamespace1.ts new file mode 100644 index 00000000000..88e8e32d5f8 --- /dev/null +++ b/tests/cases/fourslash/unusedEnumInNamespace1.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// enum enum1 { +//// Monday +//// } +//// } |] + +verify.codeFixAtPosition(`namespace greeter { +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts new file mode 100644 index 00000000000..e0f6b2e18ac --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// function function1() { +//// }/*1*/ +//// } |] + +verify.codeFixAtPosition(`namespace greeter { +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace2.ts b/tests/cases/fourslash/unusedFunctionInNamespace2.ts new file mode 100644 index 00000000000..c823777048e --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace2.ts @@ -0,0 +1,14 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// export function function2() { +//// } +//// function function1() { +//// } +////} |] + +verify.codeFixAtPosition(`namespace greeter { + export function function2() { + } +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace3.ts b/tests/cases/fourslash/unusedFunctionInNamespace3.ts new file mode 100644 index 00000000000..144e9f325b4 --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace3.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true + +//// [| namespace Validation { +//// function function1() { +//// } +////} |] + +verify.codeFixAtPosition(`namespace Validation { +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace4.ts b/tests/cases/fourslash/unusedFunctionInNamespace4.ts new file mode 100644 index 00000000000..5b5995da9c7 --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace4.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +//// [| namespace Validation { +//// var function1 = function() { +//// } +////} |] + +verify.codeFixAtPosition(`namespace Validation { +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace5.ts b/tests/cases/fourslash/unusedFunctionInNamespace5.ts new file mode 100644 index 00000000000..b839d9dcd97 --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace5.ts @@ -0,0 +1,28 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +////namespace Validation { +//// var function1 = function() { +//// } +//// +//// export function function2() { +//// +//// } +//// +//// [| function function3() { +//// function1(); +//// } +//// +//// function function4() { +//// +//// } +//// +//// export let a = function3; |] +////} + +verify.codeFixAtPosition(`function function3() { + function1(); + } + + export let a = function3;`); diff --git a/tests/cases/fourslash/unusedImports10FS.ts b/tests/cases/fourslash/unusedImports10FS.ts new file mode 100644 index 00000000000..f9d38e4cfb0 --- /dev/null +++ b/tests/cases/fourslash/unusedImports10FS.ts @@ -0,0 +1,16 @@ +/// + +// @noUnusedLocals: true +//// module A { +//// export class Calculator { +//// public handelChar() { +//// } +//// } +//// } + +//// module B { +//// [|import a = A;|] +//// } + +verify.codeFixAtPosition(""); + diff --git a/tests/cases/fourslash/unusedImports11FS.ts b/tests/cases/fourslash/unusedImports11FS.ts new file mode 100644 index 00000000000..a18a4634d71 --- /dev/null +++ b/tests/cases/fourslash/unusedImports11FS.ts @@ -0,0 +1,14 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [| import f1, * as s from "./file1"; |] +//// s.f2('hello'); + +// @Filename: file1.ts +//// export var v1; +//// export function f1(n: number){} +//// export function f2(s: string){}; +//// export default f1; + +verify.codeFixAtPosition('import * as s from "./file1";'); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports12FS.ts b/tests/cases/fourslash/unusedImports12FS.ts new file mode 100644 index 00000000000..4d8243eb4ab --- /dev/null +++ b/tests/cases/fourslash/unusedImports12FS.ts @@ -0,0 +1,13 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [| import f1, * as s from "./file1"; |] +//// f1(42); + +// @Filename: file1.ts +//// export function f1(n: number){} +//// export function f2(s: string){}; +//// export default f1; + +verify.codeFixAtPosition('import f1 from "./file1";'); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports1FS.ts b/tests/cases/fourslash/unusedImports1FS.ts new file mode 100644 index 00000000000..d9fc17a2448 --- /dev/null +++ b/tests/cases/fourslash/unusedImports1FS.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [|import { Calculator } from "./file1" |] + +// @Filename: file1.ts +//// export class Calculator { +//// +//// } + +verify.codeFixAtPosition(''); diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts new file mode 100644 index 00000000000..6e3d9527c52 --- /dev/null +++ b/tests/cases/fourslash/unusedImports2FS.ts @@ -0,0 +1,19 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [|import {Calculator} from "./file1" +//// import {test} from "./file1"|] + +//// var x = new Calculator(); +//// x.handleChar(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() {} +//// } +//// export function test() { +//// +//// } + +verify.codeFixAtPosition(`import {Calculator} from "./file1"`); diff --git a/tests/cases/fourslash/unusedImports3FS.ts b/tests/cases/fourslash/unusedImports3FS.ts new file mode 100644 index 00000000000..205666e971d --- /dev/null +++ b/tests/cases/fourslash/unusedImports3FS.ts @@ -0,0 +1,24 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +////[| import {Calculator, test, test2} from "./file1" |] + +//// test(); +//// test2(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() {} +//// } + +//// export function test() { +//// +//// } + +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(`import {test, test2} from "./file1"`); + diff --git a/tests/cases/fourslash/unusedImports4FS.ts b/tests/cases/fourslash/unusedImports4FS.ts new file mode 100644 index 00000000000..302007748f4 --- /dev/null +++ b/tests/cases/fourslash/unusedImports4FS.ts @@ -0,0 +1,24 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [| import {Calculator, test, test2} from "./file1" |] +//// +//// var x = new Calculator(); +//// x.handleChar(); +//// test2(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() {} +//// } +//// +//// export function test() { +//// +//// } +//// +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(`import {Calculator, test2} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports5FS.ts b/tests/cases/fourslash/unusedImports5FS.ts new file mode 100644 index 00000000000..1d68f6ae643 --- /dev/null +++ b/tests/cases/fourslash/unusedImports5FS.ts @@ -0,0 +1,24 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [| import {Calculator, test, test2} from "./file1" |] +//// +//// var x = new Calculator(); +//// x.handleChar(); +//// test(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() {} +//// } +//// +//// export function test() { +//// +//// } +//// +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(`import {Calculator, test} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports6FS.ts b/tests/cases/fourslash/unusedImports6FS.ts new file mode 100644 index 00000000000..a5c6744855a --- /dev/null +++ b/tests/cases/fourslash/unusedImports6FS.ts @@ -0,0 +1,20 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [| import d from "./file1" |] + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() { } +//// } + +//// export function test() { +//// +//// } + +//// export default function test2() { +//// +//// } + +verify.codeFixAtPosition(''); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports7FS.ts b/tests/cases/fourslash/unusedImports7FS.ts new file mode 100644 index 00000000000..23066ef538d --- /dev/null +++ b/tests/cases/fourslash/unusedImports7FS.ts @@ -0,0 +1,16 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [| import * as n from "./file1" |] + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() { } +//// } +//// export function test() { +//// } +//// export default function test2() { +//// } + +verify.codeFixAtPosition(''); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports8FS.ts b/tests/cases/fourslash/unusedImports8FS.ts new file mode 100644 index 00000000000..02564e35989 --- /dev/null +++ b/tests/cases/fourslash/unusedImports8FS.ts @@ -0,0 +1,24 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [|import {Calculator as calc, test as t1, test2 as t2} from "./file1"|] +//// +//// var x = new calc(); +//// x.handleChar(); +//// t1(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() { } +//// } + +//// export function test() { +//// +//// } + +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(`import {Calculator as calc, test as t1} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports9FS.ts b/tests/cases/fourslash/unusedImports9FS.ts new file mode 100644 index 00000000000..324d57a1928 --- /dev/null +++ b/tests/cases/fourslash/unusedImports9FS.ts @@ -0,0 +1,20 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// [|import c = require('./file1')|] + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() { } +//// } +//// +//// export function test() { +//// +//// } +//// +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(""); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts new file mode 100644 index 00000000000..8d07a8c7912 --- /dev/null +++ b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// interface interface1 { +//// } +////} |] + +verify.codeFixAtPosition(` +namespace greeter { +}`); diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts new file mode 100644 index 00000000000..baa46c65a0c --- /dev/null +++ b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +////namespace greeter { +//// [| export interface interface2 { +//// } +//// interface interface1 { +//// } |] +////} + +verify.codeFixAtPosition(`export interface interface2 { +}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction1.ts b/tests/cases/fourslash/unusedLocalsInFunction1.ts new file mode 100644 index 00000000000..2edd7c176e7 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInFunction1.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +//// [| function greeter() { +//// var x = 0; +////} |] + +verify.codeFixAtPosition(` +function greeter() { +}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction2.ts b/tests/cases/fourslash/unusedLocalsInFunction2.ts new file mode 100644 index 00000000000..b7094328041 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInFunction2.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////function greeter() { +//// [| var x, y = 0; |] +//// x+1; +////} + +verify.codeFixAtPosition("var x;"); diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts new file mode 100644 index 00000000000..906517ee0a7 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInFunction3.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +////function greeter() { +//// [| var x, y = 0,z = 1; |] +//// x+1; +//// z+1; +////} + +verify.codeFixAtPosition("var x,z = 1;", 6133); diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts new file mode 100644 index 00000000000..54d3223f236 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +////function greeter() { +//// [| var x,y = 0,z = 1; |] +//// y++; +//// z++; +////} + +verify.codeFixAtPosition("var y = 0,z = 1;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts new file mode 100644 index 00000000000..43b782ce266 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +////class greeter { +//// public function1() { +//// [| var /*0*/x,/*1*/ y = 10; |] +//// y++; +//// } +////} + +verify.codeFixAtPosition("var y = 10;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts new file mode 100644 index 00000000000..322cfad3940 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +////class greeter { +//// public function1() { +//// [| var x, y; |] +//// y = 1; +//// } +////} + +verify.codeFixAtPosition("var y;"); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts new file mode 100644 index 00000000000..412b599b780 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +////class greeter { +//// [| constructor() { +//// var unused = 20; +//// } |] +////} + +verify.codeFixAtPosition(`constructor() { +}`); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts new file mode 100644 index 00000000000..eff9b7c8d54 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts @@ -0,0 +1,18 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +////class greeter { +//// [|constructor() { +//// var unused = 20; +//// var used = "dummy"; +//// used = used + "second part"; +//// }|] +////} + +verify.codeFixAtPosition(` + constructor() { + var used = "dummy"; + used = used + "second part"; + } +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass1.ts b/tests/cases/fourslash/unusedMethodInClass1.ts new file mode 100644 index 00000000000..7795a4d1530 --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass1.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +////[| class greeter { +//// private function1() { +//// } +////} |] + +verify.codeFixAtPosition(` +class greeter { +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass2.ts b/tests/cases/fourslash/unusedMethodInClass2.ts new file mode 100644 index 00000000000..24b6fe155ef --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass2.ts @@ -0,0 +1,15 @@ +/// + +// @noUnusedLocals: true +//// [| class greeter { +//// public function2() { +//// } +//// private function1() { +//// } +////} |] + +verify.codeFixAtPosition(` +class greeter { + public function2() { + } +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass3.ts b/tests/cases/fourslash/unusedMethodInClass3.ts new file mode 100644 index 00000000000..eab535fb5af --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass3.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +////[|class greeter { +//// private function1 = function() { +//// } +////} |] + +verify.codeFixAtPosition(` +class greeter { +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass4.ts b/tests/cases/fourslash/unusedMethodInClass4.ts new file mode 100644 index 00000000000..ee27ec331eb --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass4.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +////class greeter { +//// [|public function2(){ +//// } +//// private function1 = function() { +//// } |] +////} + +verify.codeFixAtPosition(`public function2(){ +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass5.ts b/tests/cases/fourslash/unusedMethodInClass5.ts new file mode 100644 index 00000000000..36ef3670cac --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass5.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// [|class C { +//// private ["string"] (){} +//// }|] + +verify.codeFixAtPosition("class C { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass6.ts b/tests/cases/fourslash/unusedMethodInClass6.ts new file mode 100644 index 00000000000..71fcb92d037 --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass6.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// [|class C { +//// private "string" (){} +//// }|] + +verify.codeFixAtPosition("class C { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedNamespaceInNamespace.ts b/tests/cases/fourslash/unusedNamespaceInNamespace.ts new file mode 100644 index 00000000000..41fe162ef15 --- /dev/null +++ b/tests/cases/fourslash/unusedNamespaceInNamespace.ts @@ -0,0 +1,13 @@ +/// + +// @noUnusedLocals: true +//// [|namespace A { +//// namespace B { +//// } +//// }|] + +verify.codeFixAtPosition(` +namespace A { +} +`); + diff --git a/tests/cases/fourslash/unusedParameterInConstructor1.ts b/tests/cases/fourslash/unusedParameterInConstructor1.ts new file mode 100644 index 00000000000..f53c6d3e8bd --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInConstructor1.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// [|constructor(private p1: string, public p2: boolean, public p3: any, p5)|] { p5; } +//// } + +verify.codeFixAtPosition("constructor(public p2: boolean, public p3: any, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor2.ts b/tests/cases/fourslash/unusedParameterInConstructor2.ts new file mode 100644 index 00000000000..bd5f66ff966 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInConstructor2.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// [|constructor(public p1: string, private p2: boolean, public p3: any, p5)|] { p5; } +//// } + +verify.codeFixAtPosition("constructor(public p1: string, public p3: any, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor3.ts b/tests/cases/fourslash/unusedParameterInConstructor3.ts new file mode 100644 index 00000000000..173e00113d8 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInConstructor3.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// [|constructor(public p1: string, public p2: boolean, private p3: any, p5)|] { p5; } +//// } + +verify.codeFixAtPosition("constructor(public p1: string, public p2: boolean, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor4.ts b/tests/cases/fourslash/unusedParameterInConstructor4.ts new file mode 100644 index 00000000000..6d0223dc5f4 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInConstructor4.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// [|constructor(private readonly p2: boolean, p5)|] { p5; } +//// } + +verify.codeFixAtPosition("constructor(p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction1.ts b/tests/cases/fourslash/unusedParameterInFunction1.ts new file mode 100644 index 00000000000..2243af9f5f5 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInFunction1.ts @@ -0,0 +1,7 @@ +/// + +// @noUnusedParameters: true +////function [|greeter( x)|] { +////} + +verify.codeFixAtPosition("greeter()"); diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts new file mode 100644 index 00000000000..493eafc5722 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInFunction2.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedParameters: true +////function [|greeter(x,y)|] { +//// x++; +////} + +verify.codeFixAtPosition("greeter(x)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction3.ts b/tests/cases/fourslash/unusedParameterInFunction3.ts new file mode 100644 index 00000000000..6d79ba071b4 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInFunction3.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedParameters: true +////function [|greeter(x,y)|] { +//// y++; +////} + +verify.codeFixAtPosition("greeter(y)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts new file mode 100644 index 00000000000..b536543fb6d --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInFunction4.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedParameters: true +////[|function greeter(x,y,z) |] { +//// x++; +//// z++; +////} + +verify.codeFixAtPosition("function greeter(x,z)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInLambda1.ts b/tests/cases/fourslash/unusedParameterInLambda1.ts new file mode 100644 index 00000000000..c462b742569 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInLambda1.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// function f1() { +//// [|return (x:number) => {}|] +//// } + +verify.codeFixAtPosition("return () => {}"); diff --git a/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts new file mode 100644 index 00000000000..593c0fe8cf4 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// type hw = "Hello" |"world"; +//// export type nw = "No" | "Way"; +//// } |] + +verify.codeFixAtPosition(`namespace greeter { + export type nw = "No" | "Way"; +}`); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts new file mode 100644 index 00000000000..ab654a5150e --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInClass1.ts @@ -0,0 +1,7 @@ +/// + +// @noUnusedLocals: true +////[|class greeter |] { +////} + +verify.codeFixAtPosition("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass2.ts b/tests/cases/fourslash/unusedTypeParametersInClass2.ts new file mode 100644 index 00000000000..8e860c10e04 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInClass2.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +////[|class greeter |] { +//// public a: X; +////} + +verify.codeFixAtPosition("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3.ts b/tests/cases/fourslash/unusedTypeParametersInClass3.ts new file mode 100644 index 00000000000..75ae98f53e0 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInClass3.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////[|class greeter |] { +//// public a: X; +//// public b: Z; +////} + +verify.codeFixAtPosition("class greeter"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts new file mode 100644 index 00000000000..7177ed41c84 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts @@ -0,0 +1,6 @@ +/// + +// @noUnusedLocals: true +//// [|function f1() {}|] + +verify.codeFixAtPosition("function f1() {}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts new file mode 100644 index 00000000000..344ae303c75 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts @@ -0,0 +1,6 @@ +/// + +// @noUnusedLocals: true +//// [|function f1(a: X) {a}|] + +verify.codeFixAtPosition("function f1(a: X) {a}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts new file mode 100644 index 00000000000..746b174db18 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts @@ -0,0 +1,6 @@ +/// + +// @noUnusedLocals: true +//// [|function f1(a: X) {a;var b:Z;b}|] + +verify.codeFixAtPosition("function f1(a: X) {a;var b:Z;b}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts new file mode 100644 index 00000000000..70d8bc7800c --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts @@ -0,0 +1,7 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// [|interface I {}|] + +verify.codeFixAtPosition("interface I {}"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts new file mode 100644 index 00000000000..73d70672368 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// function f1() { +//// [|return (x:number) => {x}|] +//// } + +verify.codeFixAtPosition("return (x:number) => {x}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts new file mode 100644 index 00000000000..77c802f5c44 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// var x : { +//// [|new (a: T): void;|] +//// } + +verify.codeFixAtPosition("new (a: T): void;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts new file mode 100644 index 00000000000..0ecb0338be2 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// class A { public x: Dummy } +//// var x : { +//// [|new (a: T): A;|] +//// } + +verify.codeFixAtPosition("new (a: T): A;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts new file mode 100644 index 00000000000..5a226fc9005 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +//// class A { +//// public x: T; +//// } +//// [|var y: new (a:T)=>void;|] + +verify.codeFixAtPosition("var y: new (a:T)=>void;"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts new file mode 100644 index 00000000000..7a9f04147d6 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// [|f1()|] {} +//// } + +verify.codeFixAtPosition("f1()"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts new file mode 100644 index 00000000000..3650cfbad98 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// [|f1(a: U)|] {a;} +//// } + +verify.codeFixAtPosition("f1(a: U)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts new file mode 100644 index 00000000000..cb9b965ca4d --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// class A { +//// [|public f1(a: X)|] { a; var b: Z; b } +//// } + +verify.codeFixAtPosition("public f1(a: X)"); diff --git a/tests/cases/fourslash/unusedVariableInBlocks.ts b/tests/cases/fourslash/unusedVariableInBlocks.ts new file mode 100644 index 00000000000..e9dedaef31e --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInBlocks.ts @@ -0,0 +1,15 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// [|let x = 10; +//// { +//// let x = 11; +//// } +//// x;|] +//// } + +verify.codeFixAtPosition(`let x = 10; + { + } + x;`); diff --git a/tests/cases/fourslash/unusedVariableInClass1.ts b/tests/cases/fourslash/unusedVariableInClass1.ts new file mode 100644 index 00000000000..82bb99016ef --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInClass1.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +////class greeter { +//// [|private greeting: string;|] +////} + +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInClass2.ts b/tests/cases/fourslash/unusedVariableInClass2.ts new file mode 100644 index 00000000000..c971092584a --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInClass2.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////class greeter { +//// [|public greeting1; +//// private greeting: string;|] +////} + +verify.codeFixAtPosition("public greeting1;"); diff --git a/tests/cases/fourslash/unusedVariableInClass3.ts b/tests/cases/fourslash/unusedVariableInClass3.ts new file mode 100644 index 00000000000..8d2a62e7175 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInClass3.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +////class greeter {[| +//// private X = function() {}; +////|]} + +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts new file mode 100644 index 00000000000..0ee02ab4363 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// [|for(var i = 0; ;) |]{ +//// +//// } +//// } + +verify.codeFixAtPosition("for(; ;)"); + diff --git a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts new file mode 100644 index 00000000000..1b1a0798c04 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// [|for(var i = 0, j= 0; ;i++)|] { +//// +//// } +//// } + +verify.codeFixAtPosition("for(var i = 0; ;i++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts new file mode 100644 index 00000000000..4eed9599b15 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// [|for(var i = 0, j= 0, k=0; ;i++, k++)|] { +//// +//// } +//// } + +verify.codeFixAtPosition("for(var i = 0, k=0; ;i++,k++)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts new file mode 100644 index 00000000000..76e551612ba --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// [|for(var i = 0, j= 0, k=0; ;j++, k++) |]{ +//// +//// } +//// } + +verify.codeFixAtPosition("for(var j = 0, k=0; ;j++,k++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts new file mode 100644 index 00000000000..23df03480e3 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for (const elem in ["a", "b", "c"]) { +//// +//// } +//// } + +verify.not.codeFixAvailable(); + diff --git a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts new file mode 100644 index 00000000000..4187c3141b5 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for ([|const elem of|] ["a", "b", "c"]) { +//// +//// } +//// } + +verify.codeFixAtPosition("const {} of "); + diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts new file mode 100644 index 00000000000..8fd0fee735e --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for (const elem of ["a", "b", "c"]) { +//// elem; +//// [|var x = 20;|] +//// } +////} +//// + +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInModule1.ts b/tests/cases/fourslash/unusedVariableInModule1.ts new file mode 100644 index 00000000000..011434ce098 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInModule1.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// export {} +//// [|var x: string;|] +//// export var y: string; + +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInModule2.ts b/tests/cases/fourslash/unusedVariableInModule2.ts new file mode 100644 index 00000000000..db4519c8faa --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInModule2.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// export {} +//// [|var x: string, z: number;|] +//// z; +//// export var y: string; + +verify.codeFixAtPosition("var z: number;"); diff --git a/tests/cases/fourslash/unusedVariableInModule3.ts b/tests/cases/fourslash/unusedVariableInModule3.ts new file mode 100644 index 00000000000..bffffc768d3 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInModule3.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// export {} +//// [|var x = function f1() {}|] +//// export var y: string; + +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInModule4.ts b/tests/cases/fourslash/unusedVariableInModule4.ts new file mode 100644 index 00000000000..6a1be9fe5b8 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInModule4.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// export {} +//// [|var x = function f1(m: number) {}|] +//// x; +//// export var y: string; + +verify.codeFixAtPosition(`var x = function f1() {}`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace1.ts b/tests/cases/fourslash/unusedVariableInNamespace1.ts new file mode 100644 index 00000000000..caf778bc0da --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInNamespace1.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +////namespace greeter { +//// [|let a = "dummy entry";|] +////} + +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts new file mode 100644 index 00000000000..fbb9e2d6a0c --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +////namespace greeter { +//// [|let a = "dummy entry", b, c = 0;|] +//// export function function1() { +//// a = "dummy"; +//// c++; +//// } +////} + +verify.codeFixAtPosition(`let a = "dummy entry", c = 0;`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts new file mode 100644 index 00000000000..33e501d0c0d --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +////namespace greeter { +//// [|let a = "dummy entry", b, c = 0;|] +//// export function function1() { +//// a = "dummy"; +//// b = 0; +//// } +////} + +verify.codeFixAtPosition(`let a = "dummy entry", b;`);