diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 3f52f4e9ee9e5..eec9e16cbbe4c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -361,6 +361,7 @@ namespace ts { const printerOptions: PrinterOptions = { removeComments: compilerOptions.removeComments, newLine: compilerOptions.newLine, + preserveSourceNewlines: true, noEmitHelpers: compilerOptions.noEmitHelpers, module: compilerOptions.module, target: compilerOptions.target, @@ -2365,16 +2366,10 @@ namespace ts { function emitParenthesizedExpression(node: ParenthesizedExpression) { const openParenPos = emitTokenWithComment(SyntaxKind.OpenParenToken, node.pos, writePunctuation, node); - const leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(node, [node.expression], ListFormat.None); - if (leadingNewlines) { - writeLinesAndIndent(leadingNewlines, /*writeLinesIfNotIndenting*/ false); - } + const indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression); - const trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(node, [node.expression], ListFormat.None); - if (trailingNewlines) { - writeLine(trailingNewlines); - } - decreaseIndentIf(leadingNewlines); + writeLineSeparatorsAfter(node.expression, node); + decreaseIndentIf(indented); emitTokenWithComment(SyntaxKind.CloseParenToken, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } @@ -3292,12 +3287,15 @@ namespace ts { writePunctuation("<"); if (isJsxOpeningElement(node)) { + const indented = writeLineSeparatorsAndIndentBefore(node.tagName, node); emitJsxTagName(node.tagName); emitTypeArguments(node, node.typeArguments); if (node.attributes.properties && node.attributes.properties.length > 0) { writeSpace(); } emit(node.attributes); + writeLineSeparatorsAfter(node.attributes, node); + decreaseIndentIf(indented); } writePunctuation(">"); @@ -3686,7 +3684,9 @@ namespace ts { const statements = node.statements; pushNameGenerationScope(node); forEach(node.statements, generateNames); - emitHelpers(node); + if (emitHelpers(node)) { + writeLine(); + } const index = findIndex(statements, statement => !isPrologueDirective(statement)); emitTripleSlashDirectivesIfNeeded(node); emitList(node, statements, ListFormat.MultiLine, index === -1 ? statements.length : index); @@ -4301,6 +4301,7 @@ namespace ts { return getEffectiveLines( includeComments => getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter( firstChild.pos, + parentNode.pos, currentSourceFile!, includeComments)); } @@ -4322,12 +4323,12 @@ namespace ts { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!nodeIsSynthesized(previousNode) && !nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) { + else if (siblingNodePositionsAreComparable(previousNode, nextNode)) { if (preserveSourceNewlines) { return getEffectiveLines( includeComments => getLinesBetweenRangeEndAndRangeStart( - previousNode, - nextNode, + getOriginalNode(previousNode), + getOriginalNode(nextNode), currentSourceFile!, includeComments)); } @@ -4343,6 +4344,22 @@ namespace ts { return format & ListFormat.MultiLine ? 1 : 0; } + function siblingNodePositionsAreComparable(previousNode: Node, nextNode: Node) { + if (previousNode.kind === SyntaxKind.NotEmittedStatement && nextNode.kind === SyntaxKind.NotEmittedStatement) { + return false; + } + if (nodeIsSynthesized(previousNode) || nodeIsSynthesized(nextNode)) { + return false; + } + + if (!previousNode.parent || !nextNode.parent) { + const previousParent = getOriginalNode(previousNode).parent; + return previousParent && previousParent === getOriginalNode(nextNode).parent; + } + + return nextNode.pos >= previousNode.end; + } + function getClosingLineTerminatorCount(parentNode: TextRange, children: readonly Node[], format: ListFormat): number { if (format & ListFormat.PreserveLines || preserveSourceNewlines) { if (format & ListFormat.PreferNewLine) { @@ -4358,6 +4375,7 @@ namespace ts { return getEffectiveLines( includeComments => getLinesBetweenPositionAndNextNonWhitespaceCharacter( lastChild.end, + parentNode.end, currentSourceFile!, includeComments)); } @@ -4397,6 +4415,21 @@ namespace ts { return lines; } + function writeLineSeparatorsAndIndentBefore(node: Node, parent: Node): boolean { + const leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], ListFormat.None); + if (leadingNewlines) { + writeLinesAndIndent(leadingNewlines, /*writeLinesIfNotIndenting*/ false); + } + return !!leadingNewlines; + } + + function writeLineSeparatorsAfter(node: Node, parent: Node) { + const trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], ListFormat.None); + if (trailingNewlines) { + writeLine(trailingNewlines); + } + } + function synthesizedNodeStartsOnNewLine(node: Node, format: ListFormat) { if (nodeIsSynthesized(node)) { const startsOnNewLine = getStartsOnNewLine(node); diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 6bffbe3b299b1..955a10ee9316a 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -870,7 +870,7 @@ namespace ts { transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) ); - setTextRange(constructorFunction, constructor || node); + setTextRange(setOriginalNode(constructorFunction, constructor), constructor || node); if (extendsClauseElement) { setEmitFlags(constructorFunction, EmitFlags.CapturesThis); } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 0ef7db0627219..e67663d9e9cfc 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2178,13 +2178,16 @@ namespace ts { return undefined; } - return setTextRange( - createExpressionStatement( - inlineExpressions( - map(variables, transformInitializedVariable) - ) + return setOriginalNode( + setTextRange( + createExpressionStatement( + inlineExpressions( + map(variables, transformInitializedVariable) + ) + ), + node ), - node + node, ); } else { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a5235eeae2308..493accb8d619c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4776,19 +4776,19 @@ namespace ts { return positionIsSynthesized(range.pos) ? -1 : skipTrivia(sourceFile.text, range.pos, /*stopAfterLineBreak*/ false, includeComments); } - export function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos: number, sourceFile: SourceFile, includeComments?: boolean) { + export function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos: number, stopPos: number, sourceFile: SourceFile, includeComments?: boolean) { const startPos = skipTrivia(sourceFile.text, pos, /*stopAfterLineBreak*/ false, includeComments); - const prevPos = getPreviousNonWhitespacePosition(startPos, sourceFile); - return getLinesBetweenPositions(sourceFile, prevPos || 0, startPos); + const prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile); + return getLinesBetweenPositions(sourceFile, prevPos ?? stopPos, startPos); } - export function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos: number, sourceFile: SourceFile, includeComments?: boolean) { + export function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos: number, stopPos: number, sourceFile: SourceFile, includeComments?: boolean) { const nextPos = skipTrivia(sourceFile.text, pos, /*stopAfterLineBreak*/ false, includeComments); - return getLinesBetweenPositions(sourceFile, pos, nextPos); + return getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos)); } - function getPreviousNonWhitespacePosition(pos: number, sourceFile: SourceFile) { - while (pos-- > 0) { + function getPreviousNonWhitespacePosition(pos: number, stopPos = 0, sourceFile: SourceFile) { + while (pos-- > stopPos) { if (!isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) { return pos; } diff --git a/tests/baselines/reference/1.0lib-noErrors.js b/tests/baselines/reference/1.0lib-noErrors.js index 3dac98d9e5647..1f311bef1da26 100644 --- a/tests/baselines/reference/1.0lib-noErrors.js +++ b/tests/baselines/reference/1.0lib-noErrors.js @@ -1158,4 +1158,5 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + /// diff --git a/tests/baselines/reference/APISample_Watch.js b/tests/baselines/reference/APISample_Watch.js index e675f2ec4eb47..88551e865f286 100644 --- a/tests/baselines/reference/APISample_Watch.js +++ b/tests/baselines/reference/APISample_Watch.js @@ -90,17 +90,21 @@ watchMain(); * Please log a "breaking change" issue for any API breaking change affecting this issue */ exports.__esModule = true; + var ts = require("typescript"); + var formatHost = { getCanonicalFileName: function (path) { return path; }, getCurrentDirectory: ts.sys.getCurrentDirectory, getNewLine: function () { return ts.sys.newLine; } }; + function watchMain() { var configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json"); if (!configPath) { throw new Error("Could not find a valid 'tsconfig.json'."); } + // TypeScript can use several different program creation "strategies": // * ts.createEmitAndSemanticDiagnosticsBuilderProgram, // * ts.createSemanticDiagnosticsBuilderProgram @@ -111,7 +115,11 @@ function watchMain() { // Between `createEmitAndSemanticDiagnosticsBuilderProgram` and `createSemanticDiagnosticsBuilderProgram`, the only difference is emit. // For pure type-checking scenarios, or when another tool/process handles emit, using `createSemanticDiagnosticsBuilderProgram` may be more desirable. // Note that there is another overload for `createWatchCompilerHost` that takes a set of root files. - var host = ts.createWatchCompilerHost(configPath, {}, ts.sys, ts.createSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportWatchStatusChanged); + var host = ts.createWatchCompilerHost(configPath, {}, ts.sys, + ts.createSemanticDiagnosticsBuilderProgram, + reportDiagnostic, + reportWatchStatusChanged); + // You can technically override any given hook on the host, though you probably don't need to. // Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all. var origCreateProgram = host.createProgram; @@ -120,16 +128,22 @@ function watchMain() { return origCreateProgram(rootNames, options, host, oldProgram); }; var origPostProgramCreate = host.afterProgramCreate; + host.afterProgramCreate = function (program) { console.log("** We finished making the program! **"); origPostProgramCreate(program); }; + // `createWatchProgram` creates an initial program, watches files, and updates the program over time. ts.createWatchProgram(host); } + function reportDiagnostic(diagnostic) { - console.error("Error", diagnostic.code, ":", ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine())); + console.error("Error", diagnostic.code, ":", + ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()) + ); } + /** * Prints a diagnostic every time the watch status changes. * This is mainly for messages like "Starting compilation" or "Compilation completed". @@ -137,4 +151,5 @@ function reportDiagnostic(diagnostic) { function reportWatchStatusChanged(diagnostic) { console.info(ts.formatDiagnostic(diagnostic, formatHost)); } + watchMain(); diff --git a/tests/baselines/reference/APISample_WatchWithDefaults.js b/tests/baselines/reference/APISample_WatchWithDefaults.js index 63bfa4965e51e..3d53005055e5d 100644 --- a/tests/baselines/reference/APISample_WatchWithDefaults.js +++ b/tests/baselines/reference/APISample_WatchWithDefaults.js @@ -62,12 +62,15 @@ watchMain(); * Please log a "breaking change" issue for any API breaking change affecting this issue */ exports.__esModule = true; + var ts = require("typescript"); + function watchMain() { var configPath = ts.findConfigFile(/*searchPath*/ "./", ts.sys.fileExists, "tsconfig.json"); if (!configPath) { throw new Error("Could not find a valid 'tsconfig.json'."); } + // TypeScript can use several different program creation "strategies": // * ts.createEmitAndSemanticDiagnosticsBuilderProgram, // * ts.createSemanticDiagnosticsBuilderProgram @@ -79,6 +82,7 @@ function watchMain() { // For pure type-checking scenarios, or when another tool/process handles emit, using `createSemanticDiagnosticsBuilderProgram` may be more desirable. // Note that there is another overload for `createWatchCompilerHost` that takes a set of root files. var host = ts.createWatchCompilerHost(configPath, {}, ts.sys); + // You can technically override any given hook on the host, though you probably don't need to. // Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all. var origCreateProgram = host.createProgram; @@ -87,11 +91,14 @@ function watchMain() { return origCreateProgram(rootNames, options, host, oldProgram); }; var origPostProgramCreate = host.afterProgramCreate; + host.afterProgramCreate = function (program) { console.log("** We finished making the program! **"); origPostProgramCreate(program); }; + // `createWatchProgram` creates an initial program, watches files, and updates the program over time. ts.createWatchProgram(host); } + watchMain(); diff --git a/tests/baselines/reference/APISample_WatchWithOwnWatchHost.js b/tests/baselines/reference/APISample_WatchWithOwnWatchHost.js index 75444a614f952..67f6ea32b646d 100644 --- a/tests/baselines/reference/APISample_WatchWithOwnWatchHost.js +++ b/tests/baselines/reference/APISample_WatchWithOwnWatchHost.js @@ -69,11 +69,14 @@ watchMain(); * Please log a "breaking change" issue for any API breaking change affecting this issue */ exports.__esModule = true; + var ts = require("typescript"); + function watchMain() { // get list of files and compiler options somehow var files = []; var options = {}; + var host = { rootFiles: files, options: options, @@ -81,16 +84,19 @@ function watchMain() { getNewLine: function () { return ts.sys.newLine; }, getCurrentDirectory: ts.sys.getCurrentDirectory, getDefaultLibFileName: function (options) { return ts.getDefaultLibFilePath(options); }, + fileExists: ts.sys.fileExists, readFile: ts.sys.readFile, directoryExists: ts.sys.directoryExists, getDirectories: ts.sys.getDirectories, readDirectory: ts.sys.readDirectory, realpath: ts.sys.realpath, + watchFile: ts.sys.watchFile, watchDirectory: ts.sys.watchDirectory, createProgram: ts.createAbstractBuilder }; + // You can technically override any given hook on the host, though you probably don't need to. // Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all. var origCreateProgram = host.createProgram; @@ -99,11 +105,14 @@ function watchMain() { return origCreateProgram(rootNames, options, host, oldProgram); }; var origPostProgramCreate = host.afterProgramCreate; + host.afterProgramCreate = function (program) { console.log("** We finished making the program! **"); origPostProgramCreate(program); }; + // `createWatchProgram` creates an initial program, watches files, and updates the program over time. ts.createWatchProgram(host); } + watchMain(); diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index 673dc047fa163..d5b9386801c39 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -54,11 +54,15 @@ compile(process.argv.slice(2), { */ exports.__esModule = true; exports.compile = void 0; + var ts = require("typescript"); + function compile(fileNames, options) { var program = ts.createProgram(fileNames, options); var emitResult = program.emit(); + var allDiagnostics = ts.getPreEmitDiagnostics(program); + allDiagnostics.forEach(function (diagnostic) { var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); if (!diagnostic.file) { @@ -68,6 +72,7 @@ function compile(fileNames, options) { var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character; console.log(diagnostic.file.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message); }); + var exitCode = emitResult.emitSkipped ? 1 : 0; console.log("Process exiting with code '" + exitCode + "'."); process.exit(exitCode); diff --git a/tests/baselines/reference/APISample_jsdoc.js b/tests/baselines/reference/APISample_jsdoc.js index 9c1dd5f824fdb..5ebd6956168dd 100644 --- a/tests/baselines/reference/APISample_jsdoc.js +++ b/tests/baselines/reference/APISample_jsdoc.js @@ -129,19 +129,27 @@ function getSomeOtherTags(node: ts.Node) { * Please log a "breaking change" issue for any API breaking change affecting this issue */ exports.__esModule = true; + var ts = require("typescript"); + // excerpted from https://github.com/YousefED/typescript-json-schema // (converted from a method and modified; for example, `this: any` to compensate, among other changes) -function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) { +function parseCommentsIntoDefinition( +symbol, + definition, + otherAnnotations) { var _this = this; if (!symbol) { return; } + // the comments for a symbol var comments = symbol.getDocumentationComment(undefined); + if (comments.length) { definition.description = comments.map(function (comment) { return comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n"); }).join(""); } + // jsdocs are separate from comments var jsdocs = symbol.getJsDocTags(); jsdocs.forEach(function (doc) { @@ -156,25 +164,31 @@ function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) { } }); } + + function getAnnotations(node) { var _this = this; var symbol = node.symbol; if (!symbol) { return undefined; } + var jsDocTags = symbol.getJsDocTags(); if (!jsDocTags || !jsDocTags.length) { return undefined; } + var annotations = jsDocTags.reduce(function (result, jsDocTag) { var value = _this.parseJsDocTag(jsDocTag); if (value !== undefined) { result[jsDocTag.name] = value; } + return result; }, {}); return Object.keys(annotations).length ? annotations : undefined; } + // these examples are artificial and mostly nonsensical function parseSpecificTags(node) { if (node.kind === ts.SyntaxKind.Parameter) { @@ -193,6 +207,7 @@ function parseSpecificTags(node) { } } } + function getReturnTypeFromJSDoc(node) { if (node.kind === ts.SyntaxKind.FunctionDeclaration) { return ts.getJSDocReturnType(node); @@ -202,9 +217,11 @@ function getReturnTypeFromJSDoc(node) { return type.type; } } + function getAllTags(node) { ts.getJSDocTags(node); } + function getSomeOtherTags(node) { var tags = []; tags.push(ts.getJSDocAugmentsTag(node)); diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index a51c9cde268b7..07e17dde77778 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -79,9 +79,12 @@ fileNames.forEach(fileName => { */ exports.__esModule = true; exports.delint = void 0; + var ts = require("typescript"); + function delint(sourceFile) { delintNode(sourceFile); + function delintNode(node) { switch (node.kind) { case ts.SyntaxKind.ForStatement: @@ -92,6 +95,7 @@ function delint(sourceFile) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; + case ts.SyntaxKind.IfStatement: var ifStatement = node; if (ifStatement.thenStatement.kind !== ts.SyntaxKind.Block) { @@ -103,6 +107,7 @@ function delint(sourceFile) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; + case ts.SyntaxKind.BinaryExpression: var op = node.operatorToken.kind; if (op === ts.SyntaxKind.EqualsEqualsToken || op == ts.SyntaxKind.ExclamationEqualsToken) { @@ -110,8 +115,10 @@ function delint(sourceFile) { } break; } + ts.forEachChild(node, delintNode); } + function report(node, message) { var _a = sourceFile.getLineAndCharacterOfPosition(node.getStart()), line = _a.line, character = _a.character; console.log(sourceFile.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message); @@ -122,6 +129,7 @@ var fileNames = process.argv.slice(2); fileNames.forEach(function (fileName) { // Parse a file var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true); + // delint it delint(sourceFile); }); diff --git a/tests/baselines/reference/APISample_parseConfig.js b/tests/baselines/reference/APISample_parseConfig.js index ffd27fdbabbcf..931569c991426 100644 --- a/tests/baselines/reference/APISample_parseConfig.js +++ b/tests/baselines/reference/APISample_parseConfig.js @@ -51,13 +51,16 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string): */ exports.__esModule = true; exports.createProgram = void 0; + var ts = require("typescript"); + function printError(error) { if (!error) { return; } console.log((error.file && error.file.fileName) + ": " + error.messageText); } + function createProgram(rootFiles, compilerOptionsJson) { var _a = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson), config = _a.config, error = _a.error; if (error) { diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index db25c1bd1dd06..ffaf2c3eea86a 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -30,7 +30,11 @@ console.log(JSON.stringify(result)); * Please log a "breaking change" issue for any API breaking change affecting this issue */ exports.__esModule = true; + var ts = require("typescript"); + var source = "let x: string = 'string'"; + var result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); + console.log(JSON.stringify(result)); diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index e93856a31656b..c274f07846f7b 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -124,13 +124,17 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); * Please log a "breaking change" issue for any API breaking change affecting this issue */ exports.__esModule = true; + var ts = require("typescript"); + function watch(rootFileNames, options) { var files = {}; + // initialize the list of files rootFileNames.forEach(function (fileName) { files[fileName] = { version: 0 }; }); + // Create the language service host to allow the LS to communicate with the host var servicesHost = { getScriptFileNames: function () { return rootFileNames; }, @@ -139,32 +143,42 @@ function watch(rootFileNames, options) { if (!fs.existsSync(fileName)) { return undefined; } + return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); }, getCurrentDirectory: function () { return process.cwd(); }, getCompilationSettings: function () { return options; }, getDefaultLibFileName: function (options) { return ts.getDefaultLibFilePath(options); } }; + // Create the language service files var services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry()); + // Now let's watch the files rootFileNames.forEach(function (fileName) { // First time around, emit all files emitFile(fileName); + // Add a watch on the file to handle next change - fs.watchFile(fileName, { persistent: true, interval: 250 }, function (curr, prev) { - // Check timestamp - if (+curr.mtime <= +prev.mtime) { - return; - } - // Update the version to signal a change in the file - files[fileName].version++; - // write the changes to disk - emitFile(fileName); - }); + fs.watchFile(fileName, + { persistent: true, interval: 250 }, + function (curr, prev) { + // Check timestamp + if (+curr.mtime <= +prev.mtime) { + return; + } + + // Update the version to signal a change in the file + files[fileName].version++; + + // write the changes to disk + emitFile(fileName); + }); }); + function emitFile(fileName) { var output = services.getEmitOutput(fileName); + if (!output.emitSkipped) { console.log("Emitting " + fileName); } @@ -172,14 +186,17 @@ function watch(rootFileNames, options) { console.log("Emitting " + fileName + " failed"); logErrors(fileName); } + output.outputFiles.forEach(function (o) { fs.writeFileSync(o.name, o.text, "utf8"); }); } + function logErrors(fileName) { var allDiagnostics = services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat(services.getSemanticDiagnostics(fileName)); + allDiagnostics.forEach(function (diagnostic) { var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); if (diagnostic.file) { @@ -192,8 +209,10 @@ function watch(rootFileNames, options) { }); } } + // Initialize files constituting the program as all .ts files in the current directory var currentDirectoryFiles = fs.readdirSync(process.cwd()). filter(function (fileName) { return fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts"; }); + // Start the watcher watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); diff --git a/tests/baselines/reference/ArrowFunction3.js b/tests/baselines/reference/ArrowFunction3.js index 41182da2eeddb..0189786bd6eb0 100644 --- a/tests/baselines/reference/ArrowFunction3.js +++ b/tests/baselines/reference/ArrowFunction3.js @@ -4,7 +4,5 @@ var v = (a): => { }; //// [ArrowFunction3.js] -var v = (a); -{ -} -; +var v = (a);{ +}; diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.js b/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.js index f266c117dff68..28ffb1b9b59bd 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.js +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.js @@ -51,6 +51,7 @@ module clodule4 { //// [ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.js] // all expected to be errors + var clodule1 = /** @class */ (function () { function clodule1() { } @@ -66,6 +67,7 @@ var clodule2 = /** @class */ (function () { }()); (function (clodule2) { var x; + var D = /** @class */ (function () { function D() { } diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.js b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.js index de0bb3cd400a6..3292c1561068d 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.js +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.js @@ -28,6 +28,7 @@ var Point = /** @class */ (function () { this.x = x; this.y = y; } + Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246 return Point; }()); @@ -42,6 +43,7 @@ var A; this.x = x; this.y = y; } + Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246 return Point; }()); diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.js b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.js index 50acdf1b9dadc..4360e2b8b73fa 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.js +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.js @@ -28,6 +28,7 @@ var Point = /** @class */ (function () { this.x = x; this.y = y; } + Point.Origin = function () { return { x: 0, y: 0 }; }; return Point; }()); @@ -41,6 +42,7 @@ var A; this.x = x; this.y = y; } + Point.Origin = function () { return { x: 0, y: 0 }; }; return Point; }()); diff --git a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.js b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.js index a6ca39648ae61..d6d0f634a7266 100644 --- a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.js +++ b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.js @@ -70,6 +70,7 @@ var X; //var cl: { x: number; y: number; } var cl = new X.Y.Point(1, 1); var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ? + //// [simple.js] var A = /** @class */ (function () { function A() { diff --git a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.js b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.js index 9187c99c84038..935f216a5fee5 100644 --- a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.js +++ b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.js @@ -69,6 +69,7 @@ var X; //var cl: { x: number; y: number; } var cl = new X.Y.Point(1, 1); var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ? + //// [simple.js] class A { } diff --git a/tests/baselines/reference/ClassDeclaration15.js b/tests/baselines/reference/ClassDeclaration15.js index f5040f9c63b93..728be72d0fc2b 100644 --- a/tests/baselines/reference/ClassDeclaration15.js +++ b/tests/baselines/reference/ClassDeclaration15.js @@ -6,7 +6,6 @@ class C { //// [ClassDeclaration15.js] var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); diff --git a/tests/baselines/reference/ClassDeclaration26.js b/tests/baselines/reference/ClassDeclaration26.js index 8a240f696a451..9ebfdca1a9ce6 100644 --- a/tests/baselines/reference/ClassDeclaration26.js +++ b/tests/baselines/reference/ClassDeclaration26.js @@ -12,5 +12,4 @@ var C = /** @class */ (function () { } return C; }()); -var constructor; -(function () { }); +var constructor;(function () { }); diff --git a/tests/baselines/reference/ES5SymbolProperty1.js b/tests/baselines/reference/ES5SymbolProperty1.js index 4300218c62668..d727a2fb6bd71 100644 --- a/tests/baselines/reference/ES5SymbolProperty1.js +++ b/tests/baselines/reference/ES5SymbolProperty1.js @@ -13,7 +13,9 @@ obj[Symbol.foo]; //// [ES5SymbolProperty1.js] var _a; var Symbol; + var obj = (_a = {}, _a[Symbol.foo] = 0, _a); + obj[Symbol.foo]; diff --git a/tests/baselines/reference/ES5SymbolProperty2.js b/tests/baselines/reference/ES5SymbolProperty2.js index 3de8541a6c94d..11341266a0bb9 100644 --- a/tests/baselines/reference/ES5SymbolProperty2.js +++ b/tests/baselines/reference/ES5SymbolProperty2.js @@ -14,6 +14,7 @@ module M { var M; (function (M) { var Symbol; + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/ES5SymbolProperty3.js b/tests/baselines/reference/ES5SymbolProperty3.js index 362fcfc7375ed..e5470ad414c6d 100644 --- a/tests/baselines/reference/ES5SymbolProperty3.js +++ b/tests/baselines/reference/ES5SymbolProperty3.js @@ -9,6 +9,7 @@ class C { //// [ES5SymbolProperty3.js] var Symbol; + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/ES5SymbolProperty4.js b/tests/baselines/reference/ES5SymbolProperty4.js index f756a730d52d8..4d4f1c6989b69 100644 --- a/tests/baselines/reference/ES5SymbolProperty4.js +++ b/tests/baselines/reference/ES5SymbolProperty4.js @@ -9,6 +9,7 @@ class C { //// [ES5SymbolProperty4.js] var Symbol; + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/ES5SymbolProperty5.js b/tests/baselines/reference/ES5SymbolProperty5.js index c146b8dd5f1e5..9ac3ee0941ae5 100644 --- a/tests/baselines/reference/ES5SymbolProperty5.js +++ b/tests/baselines/reference/ES5SymbolProperty5.js @@ -9,6 +9,7 @@ class C { //// [ES5SymbolProperty5.js] var Symbol; + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/ES5SymbolProperty7.js b/tests/baselines/reference/ES5SymbolProperty7.js index f874c4c77cd39..08bd994b7298c 100644 --- a/tests/baselines/reference/ES5SymbolProperty7.js +++ b/tests/baselines/reference/ES5SymbolProperty7.js @@ -9,6 +9,7 @@ class C { //// [ES5SymbolProperty7.js] var Symbol; + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/ES5for-of32.js b/tests/baselines/reference/ES5for-of32.js index 747f9524062f6..302e7557deac8 100644 --- a/tests/baselines/reference/ES5for-of32.js +++ b/tests/baselines/reference/ES5for-of32.js @@ -18,5 +18,6 @@ for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { if (sum === 0) { array = [4, 5, 6]; } + sum += num; } diff --git a/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.js b/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.js index 40075310eb1f5..2ebd18f25e6e4 100644 --- a/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.js +++ b/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.js @@ -23,6 +23,7 @@ var enumdule; enumdule[enumdule["Blue"] = 1] = "Blue"; })(enumdule || (enumdule = {})); (function (enumdule) { + var Point = /** @class */ (function () { function Point(x, y) { this.x = x; @@ -34,5 +35,6 @@ var enumdule; })(enumdule || (enumdule = {})); var x; var x = enumdule.Red; + var y; var y = new enumdule.Point(0, 0); diff --git a/tests/baselines/reference/ExportAssignment8.js b/tests/baselines/reference/ExportAssignment8.js index 5ef706afbd5aa..14fe09440998f 100644 --- a/tests/baselines/reference/ExportAssignment8.js +++ b/tests/baselines/reference/ExportAssignment8.js @@ -13,3 +13,4 @@ var C = /** @class */ (function () { return C; }()); module.exports = B; + diff --git a/tests/baselines/reference/ExportClassWhichExtendsInterfaceWithInaccessibleType.js b/tests/baselines/reference/ExportClassWhichExtendsInterfaceWithInaccessibleType.js index 94faa0dd4b34c..1a6856f0eefda 100644 --- a/tests/baselines/reference/ExportClassWhichExtendsInterfaceWithInaccessibleType.js +++ b/tests/baselines/reference/ExportClassWhichExtendsInterfaceWithInaccessibleType.js @@ -22,11 +22,14 @@ module A { //// [ExportClassWhichExtendsInterfaceWithInaccessibleType.js] var A; (function (A) { + + var Point2d = /** @class */ (function () { function Point2d(x, y) { this.x = x; this.y = y; } + Point2d.prototype.fromOrigin = function (p) { return 1; }; diff --git a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js index 9074e2ad4c806..9243b5cb03e4c 100644 --- a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js +++ b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js @@ -36,6 +36,7 @@ var __extends = (this && this.__extends) || (function () { })(); var A; (function (A) { + var Point = /** @class */ (function () { function Point() { } @@ -43,6 +44,7 @@ var A; }()); A.Point = Point; A.Origin = { x: 0, y: 0 }; + var Point3d = /** @class */ (function (_super) { __extends(Point3d, _super); function Point3d() { @@ -52,6 +54,7 @@ var A; }(Point)); A.Point3d = Point3d; A.Origin3d = { x: 0, y: 0, z: 0 }; + var Line = /** @class */ (function () { function Line(start, end) { this.start = start; diff --git a/tests/baselines/reference/ExportClassWithInaccessibleTypeInIndexerTypeAnnotations.js b/tests/baselines/reference/ExportClassWithInaccessibleTypeInIndexerTypeAnnotations.js index 7642a6cbe871a..db7d84739d538 100644 --- a/tests/baselines/reference/ExportClassWithInaccessibleTypeInIndexerTypeAnnotations.js +++ b/tests/baselines/reference/ExportClassWithInaccessibleTypeInIndexerTypeAnnotations.js @@ -18,6 +18,7 @@ module A { //// [ExportClassWithInaccessibleTypeInIndexerTypeAnnotations.js] var A; (function (A) { + var Point = /** @class */ (function () { function Point() { } diff --git a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js index 7ffab7697940b..f72e9db20684c 100644 --- a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js +++ b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.js @@ -40,12 +40,14 @@ var __extends = (this && this.__extends) || (function () { })(); var A; (function (A) { + var Point = /** @class */ (function () { function Point() { } return Point; }()); A.Origin = { x: 0, y: 0 }; + var Point3d = /** @class */ (function (_super) { __extends(Point3d, _super); function Point3d() { @@ -55,11 +57,13 @@ var A; }(Point)); A.Point3d = Point3d; A.Origin3d = { x: 0, y: 0, z: 0 }; + var Line = /** @class */ (function () { function Line(start, end) { this.start = start; this.end = end; } + Line.fromorigin2d = function (p) { return null; }; diff --git a/tests/baselines/reference/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.js b/tests/baselines/reference/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.js index 2d7e408d81ba6..351730b7a9a08 100644 --- a/tests/baselines/reference/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.js +++ b/tests/baselines/reference/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.js @@ -18,6 +18,7 @@ module A { //// [ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.js] var A; (function (A) { + var Point = /** @class */ (function () { function Point() { } diff --git a/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.js b/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.js index ac8e36d42224a..1779aee97723a 100644 --- a/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.js +++ b/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.js @@ -18,6 +18,7 @@ module A { //// [ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.js] var A; (function (A) { + var Point = /** @class */ (function () { function Point() { } diff --git a/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.js b/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.js index b2abc1a4d31fc..192f39d0610d7 100644 --- a/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.js +++ b/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.js @@ -18,6 +18,7 @@ module A { //// [ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.js] var A; (function (A) { + var Point = /** @class */ (function () { function Point() { } diff --git a/tests/baselines/reference/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js b/tests/baselines/reference/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js index e2b32a3bca409..ab01ff69b35ea 100644 --- a/tests/baselines/reference/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js +++ b/tests/baselines/reference/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js @@ -25,6 +25,11 @@ module A { //// [ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js] var A; (function (A) { + + A.Origin = { x: 0, y: 0 }; + + A.Origin3d = { x: 0, y: 0, z: 0 }; + })(A || (A = {})); diff --git a/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInIndexerTypeAnnotations.js b/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInIndexerTypeAnnotations.js index 8f5df1d3fceba..2b8fd1d2cd7f1 100644 --- a/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInIndexerTypeAnnotations.js +++ b/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInIndexerTypeAnnotations.js @@ -16,3 +16,4 @@ module A { //// [ExportInterfaceWithInaccessibleTypeInIndexerTypeAnnotations.js] + diff --git a/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.js b/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.js index 7625500a1d0a4..30faef49e20f1 100644 --- a/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.js +++ b/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.js @@ -26,6 +26,11 @@ module A { //// [ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.js] var A; (function (A) { + + A.Origin = { x: 0, y: 0 }; + + A.Origin3d = { x: 0, y: 0, z: 0 }; + })(A || (A = {})); diff --git a/tests/baselines/reference/ExportModuleWithAccessibleTypesOnItsExportedMembers.js b/tests/baselines/reference/ExportModuleWithAccessibleTypesOnItsExportedMembers.js index 401962dd2616f..8adea78468cfe 100644 --- a/tests/baselines/reference/ExportModuleWithAccessibleTypesOnItsExportedMembers.js +++ b/tests/baselines/reference/ExportModuleWithAccessibleTypesOnItsExportedMembers.js @@ -23,6 +23,7 @@ module A { //// [ExportModuleWithAccessibleTypesOnItsExportedMembers.js] var A; (function (A) { + var Point = /** @class */ (function () { function Point(x, y) { this.x = x; @@ -34,9 +35,11 @@ var A; var B; (function (B) { B.Origin = new Point(0, 0); + var Line = /** @class */ (function () { function Line(start, end) { } + Line.fromOrigin = function (p) { return new Line({ x: 0, y: 0 }, p); }; diff --git a/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.js b/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.js index 0990c9bf2bd2d..b72c9dbc41c56 100644 --- a/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.js +++ b/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.js @@ -14,6 +14,7 @@ module A { //// [ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.js] var A; (function (A) { + var Point = /** @class */ (function () { function Point(x, y) { this.x = x; @@ -22,5 +23,6 @@ var A; return Point; }()); A.Origin = { x: 0, y: 0 }; + A.Unity = { start: new Point(0, 0), end: new Point(1, 0) }; })(A || (A = {})); diff --git a/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.js b/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.js index b454d785e9c7a..f546142945e1c 100644 --- a/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.js +++ b/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.js @@ -14,6 +14,7 @@ module A { //// [ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.js] var A; (function (A) { + var Point = /** @class */ (function () { function Point(x, y) { this.x = x; diff --git a/tests/baselines/reference/ExportVariableWithAccessibleTypeInTypeAnnotation.js b/tests/baselines/reference/ExportVariableWithAccessibleTypeInTypeAnnotation.js index 591845b627e2b..06c336b3b69b4 100644 --- a/tests/baselines/reference/ExportVariableWithAccessibleTypeInTypeAnnotation.js +++ b/tests/baselines/reference/ExportVariableWithAccessibleTypeInTypeAnnotation.js @@ -14,6 +14,8 @@ module A { //// [ExportVariableWithAccessibleTypeInTypeAnnotation.js] var A; (function (A) { + + // valid since Point is exported A.Origin = { x: 0, y: 0 }; })(A || (A = {})); diff --git a/tests/baselines/reference/ExportVariableWithInaccessibleTypeInTypeAnnotation.js b/tests/baselines/reference/ExportVariableWithInaccessibleTypeInTypeAnnotation.js index d63edb655691a..45c70ff4d6c90 100644 --- a/tests/baselines/reference/ExportVariableWithInaccessibleTypeInTypeAnnotation.js +++ b/tests/baselines/reference/ExportVariableWithInaccessibleTypeInTypeAnnotation.js @@ -21,8 +21,12 @@ module A { //// [ExportVariableWithInaccessibleTypeInTypeAnnotation.js] var A; (function (A) { + + // valid since Point is exported A.Origin = { x: 0, y: 0 }; + + // invalid Point3d is not exported A.Origin3d = { x: 0, y: 0, z: 0 }; })(A || (A = {})); diff --git a/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.js b/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.js index daa56620014bd..20abb5a06c776 100644 --- a/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.js +++ b/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.js @@ -62,12 +62,15 @@ var A; //// [test.js] var fn; var fn = A.Point; + var cl; var cl = A.Point(); var cl = A.Point.Origin; // not expected to be an error. + //// [simple.js] var B; (function (B) { + function Point() { return { x: 0, y: 0 }; } @@ -78,6 +81,7 @@ var B; })(B || (B = {})); var fn; var fn = B.Point; // not expected to be an error. bug 840000: [corelang] Function of fundule not assignalbe as expected + var cl; var cl = B.Point(); var cl = B.Point.Origin; diff --git a/tests/baselines/reference/FunctionAndModuleWithSameNameAndDifferentCommonRoot.js b/tests/baselines/reference/FunctionAndModuleWithSameNameAndDifferentCommonRoot.js index 13302ea391a09..26a2e3d90769e 100644 --- a/tests/baselines/reference/FunctionAndModuleWithSameNameAndDifferentCommonRoot.js +++ b/tests/baselines/reference/FunctionAndModuleWithSameNameAndDifferentCommonRoot.js @@ -41,5 +41,6 @@ var B; //// [test.js] var fn; var fn = A.Point; + var cl; var cl = B.Point.Origin; diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.js b/tests/baselines/reference/FunctionDeclaration10_es6.js index aca7c00e58c0a..e9b8beff45b9a 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.js +++ b/tests/baselines/reference/FunctionDeclaration10_es6.js @@ -3,7 +3,5 @@ function * foo(a = yield => yield) { } //// [FunctionDeclaration10_es6.js] -function* foo(a = yield) { } -yield; -{ +function* foo(a = yield) { }yield;{ } diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.js b/tests/baselines/reference/FunctionDeclaration12_es6.js index d2f490ef5e8d5..d9047af7f6631 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.js +++ b/tests/baselines/reference/FunctionDeclaration12_es6.js @@ -2,5 +2,4 @@ var v = function * yield() { } //// [FunctionDeclaration12_es6.js] -var v = function* () { }, yield; -() => { }; +var v = function* () { }, yield;() => { }; diff --git a/tests/baselines/reference/FunctionDeclaration5_es6.js b/tests/baselines/reference/FunctionDeclaration5_es6.js index 645ee976ecd96..e5f853552bc5c 100644 --- a/tests/baselines/reference/FunctionDeclaration5_es6.js +++ b/tests/baselines/reference/FunctionDeclaration5_es6.js @@ -3,7 +3,5 @@ function*foo(yield) { } //// [FunctionDeclaration5_es6.js] -function* foo() { } -yield; -{ +function* foo() { }yield;{ } diff --git a/tests/baselines/reference/InvalidNonInstantiatedModule.js b/tests/baselines/reference/InvalidNonInstantiatedModule.js index 54c0f7a42ab1f..6d642d63b6589 100644 --- a/tests/baselines/reference/InvalidNonInstantiatedModule.js +++ b/tests/baselines/reference/InvalidNonInstantiatedModule.js @@ -9,5 +9,7 @@ var x: typeof M; // Error only a namespace //// [InvalidNonInstantiatedModule.js] + var m = M; // Error, not instantiated can not be used as var + var x; // Error only a namespace diff --git a/tests/baselines/reference/MemberFunctionDeclaration8_es6.js b/tests/baselines/reference/MemberFunctionDeclaration8_es6.js index a44ff273fa000..39d702b5cd497 100644 --- a/tests/baselines/reference/MemberFunctionDeclaration8_es6.js +++ b/tests/baselines/reference/MemberFunctionDeclaration8_es6.js @@ -12,8 +12,7 @@ class C { foo() { // Make sure we don't think of *bar as the start of a generator method. if (a) - ; - * bar; + ; * bar; return bar; } } diff --git a/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.js b/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.js index 740d02edd17ff..2410707d0ca7e 100644 --- a/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.js +++ b/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.js @@ -19,6 +19,7 @@ var y = new enumdule.Point(0, 0); //// [ModuleAndEnumWithSameNameAndCommonRoot.js] var enumdule; (function (enumdule) { + var Point = /** @class */ (function () { function Point(x, y) { this.x = x; @@ -34,5 +35,6 @@ var enumdule; })(enumdule || (enumdule = {})); var x; var x = enumdule.Red; + var y; var y = new enumdule.Point(0, 0); diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.js b/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.js index 26d014f16c2f3..c896f6198a953 100644 --- a/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.js +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.js @@ -62,7 +62,10 @@ var A; // no errors expected, these are all exported var a; var a = new A.A(); + var AG = new A.AG(); + // errors expected, these are not exported var a2 = new A.A2(); var ag2 = new A.A2(); + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.js b/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.js index 713d2ac7f1870..88f119df21d88 100644 --- a/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.js +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.js @@ -27,5 +27,6 @@ var A; })(A || (A = {})); // not an error since exported var a = A.Color.Red; + // error not exported var b = A.Day.Monday; diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.js b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.js index ed0e1f90bf33f..c73e5342b2c0f 100644 --- a/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.js +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.js @@ -32,6 +32,7 @@ var fng2 = A.fng2; //// [ModuleWithExportedAndNonExportedFunctions.js] var A; (function (A) { + function fn(s) { return true; } @@ -43,6 +44,7 @@ var A; function fn2(s) { return false; } + function fng2(s) { return null; } @@ -50,8 +52,11 @@ var A; // these should not be errors since the functions are exported var fn; var fn = A.fn; + var fng; var fng = A.fng; // bug 838015 + + // these should be errors since the functions are not exported var fn2 = A.fn2; var fng2 = A.fng2; diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.js b/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.js index e1c36200005c5..5be0aa0d441c2 100644 --- a/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.js +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.js @@ -54,7 +54,9 @@ var B; var Geometry; (function (Geometry) { var Lines = B; + Geometry.Origin = { x: 0, y: 0 }; + // this is valid since B.Line _is_ visible outside Geometry Geometry.Unit = new Lines.Line(Geometry.Origin, { x: 1, y: 0 }); })(Geometry || (Geometry = {})); @@ -62,7 +64,10 @@ var Geometry; var p; var p; var p = Geometry.Origin; + var line; var line = Geometry.Unit; + // not expected to work since non are exported var line = Geometry.Lines.Line; + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.js b/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.js index 0a2c63342c6f4..be6459b95d02c 100644 --- a/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.js +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.js @@ -20,5 +20,6 @@ var A; })(A || (A = {})); var x; var x = A.x; + // Error, since y is not exported var y = A.y; diff --git a/tests/baselines/reference/NonInitializedExportInInternalModule.js b/tests/baselines/reference/NonInitializedExportInInternalModule.js index e1df1d41f5483..0dbb970754c8e 100644 --- a/tests/baselines/reference/NonInitializedExportInInternalModule.js +++ b/tests/baselines/reference/NonInitializedExportInInternalModule.js @@ -40,9 +40,13 @@ var Inner; var ; let; var ; + + + + + var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); var B; @@ -59,8 +63,7 @@ var Inner; Inner.c1 = 'a'; Inner.d1 = 1; var D = /** @class */ (function () { - function D() { - } + function D() {} return D; }()); Inner.e1 = new D; diff --git a/tests/baselines/reference/Protected3.js b/tests/baselines/reference/Protected3.js index 29b1f96effe8e..bfb44dc226c2f 100644 --- a/tests/baselines/reference/Protected3.js +++ b/tests/baselines/reference/Protected3.js @@ -5,7 +5,6 @@ class C { //// [Protected3.js] var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); diff --git a/tests/baselines/reference/SystemModuleForStatementNoInitializer.js b/tests/baselines/reference/SystemModuleForStatementNoInitializer.js index ff31b3c73e284..0f6e49c6c7919 100644 --- a/tests/baselines/reference/SystemModuleForStatementNoInitializer.js +++ b/tests/baselines/reference/SystemModuleForStatementNoInitializer.js @@ -30,9 +30,11 @@ System.register([], function (exports_1, context_1) { for (; i < limit; ++i) { break; } + for (;; ++i) { break; } + for (;;) { break; } diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.js b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.js index 134c14e3a8ecb..b63a9c0117f19 100644 --- a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.js +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.js @@ -94,3 +94,4 @@ var X; // ensure merges as expected var l; var l; + diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedInterfacesOfTheSameName.js b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedInterfacesOfTheSameName.js index b9218ea1a555a..b60e8e17a81f4 100644 --- a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedInterfacesOfTheSameName.js +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedInterfacesOfTheSameName.js @@ -38,9 +38,12 @@ var l: X.Y.Z.Line; //// [TwoInternalModulesThatMergeEachWithExportedAndNonExportedInterfacesOfTheSameName.js] + // ensure merges as expected var p; var p; + + // ensure merges as expected var l; var l; diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.js b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.js index 16c37108d3f0a..c0c037ec4830a 100644 --- a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.js +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.js @@ -72,10 +72,13 @@ var A; })(A || (A = {})); //// [part3.js] // test the merging actually worked + var o; var o; var o = A.Origin; var o = A.Utils.mirror(o); + var p; var p; var p = new A.Utils.Plane(o, { x: 1, y: 1 }); + diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedInterfacesOfTheSameName.js b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedInterfacesOfTheSameName.js index b54a0938a32ba..21bb31f6683fd 100644 --- a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedInterfacesOfTheSameName.js +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedInterfacesOfTheSameName.js @@ -38,9 +38,12 @@ var l: X.Y.Z.Line; //// [TwoInternalModulesThatMergeEachWithExportedInterfacesOfTheSameName.js] + // ensure merges as expected var p; var p; + + // ensure merges as expected var l; var l; diff --git a/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndSameCommonRoot.js b/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndSameCommonRoot.js index d221274edd87b..0da77f47681d0 100644 --- a/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndSameCommonRoot.js +++ b/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndSameCommonRoot.js @@ -68,10 +68,13 @@ var A; })(A || (A = {})); //// [part3.js] // test the merging actually worked + var o; var o; var o = A.Origin; var o = A.Utils.mirror(o); + var p; var p; var p = new A.Utils.Plane(o, { x: 1, y: 1 }); + diff --git a/tests/baselines/reference/TypeArgumentList1.js b/tests/baselines/reference/TypeArgumentList1.js index f6f5412ce1624..b76ec2b036b3d 100644 --- a/tests/baselines/reference/TypeArgumentList1.js +++ b/tests/baselines/reference/TypeArgumentList1.js @@ -2,5 +2,4 @@ Foo(4, 5, 6); //// [TypeArgumentList1.js] -Foo < A, B, ; -C > (4, 5, 6); +Foo < A, B, ;C > (4, 5, 6); diff --git a/tests/baselines/reference/TypeGuardWithEnumUnion.js b/tests/baselines/reference/TypeGuardWithEnumUnion.js index f582c70857af7..8f5ca6c42587c 100644 --- a/tests/baselines/reference/TypeGuardWithEnumUnion.js +++ b/tests/baselines/reference/TypeGuardWithEnumUnion.js @@ -53,6 +53,7 @@ function f1(x) { var z; } } + function f2(x) { if (typeof x === "object") { var y = x; diff --git a/tests/baselines/reference/VariableDeclaration12_es6.js b/tests/baselines/reference/VariableDeclaration12_es6.js index da0748d2191a1..e0567d1345eed 100644 --- a/tests/baselines/reference/VariableDeclaration12_es6.js +++ b/tests/baselines/reference/VariableDeclaration12_es6.js @@ -3,4 +3,5 @@ let x //// [VariableDeclaration12_es6.js] -let x; +let +x; diff --git a/tests/baselines/reference/VariableDeclaration13_es6.js b/tests/baselines/reference/VariableDeclaration13_es6.js index 152ca6a26d6c8..66ffa72d16b62 100644 --- a/tests/baselines/reference/VariableDeclaration13_es6.js +++ b/tests/baselines/reference/VariableDeclaration13_es6.js @@ -8,6 +8,4 @@ let[0] = 100; // An ExpressionStatement cannot start with the two token sequence `let [` because // that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern. var let; -let []; -0; -100; +let [];0;100; diff --git a/tests/baselines/reference/abstractClassInLocalScope.js b/tests/baselines/reference/abstractClassInLocalScope.js index 4e7b9f8709563..2f8cfbb72c2c5 100644 --- a/tests/baselines/reference/abstractClassInLocalScope.js +++ b/tests/baselines/reference/abstractClassInLocalScope.js @@ -23,8 +23,7 @@ var __extends = (this && this.__extends) || (function () { })(); (function () { var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); var B = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js index 60af14e625b0e..5a6aaa3fb4c37 100644 --- a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js +++ b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.js @@ -23,8 +23,7 @@ var __extends = (this && this.__extends) || (function () { })(); (function () { var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); var B = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.js b/tests/baselines/reference/abstractIdentifierNameStrict.js index 92d159766d7e8..949159cb8b1e4 100644 --- a/tests/baselines/reference/abstractIdentifierNameStrict.js +++ b/tests/baselines/reference/abstractIdentifierNameStrict.js @@ -8,6 +8,7 @@ function foo() { //// [abstractIdentifierNameStrict.js] var abstract = true; + function foo() { "use strict"; var abstract = true; diff --git a/tests/baselines/reference/abstractPropertyInConstructor.js b/tests/baselines/reference/abstractPropertyInConstructor.js index ab830664d51f3..1700f843f5fec 100644 --- a/tests/baselines/reference/abstractPropertyInConstructor.js +++ b/tests/baselines/reference/abstractPropertyInConstructor.js @@ -92,17 +92,29 @@ var AbstractClass = /** @class */ (function () { this.fn = function () { return _this.prop; }; this.method(parseInt(str)); var val = this.prop.toLowerCase(); + if (!str) { this.prop = "Hello World"; } this.cb(str); + // OK, reference is inside function var innerFunction = function () { return _this.prop; }; + // OK, references are to another instance other.cb(other.prop); } + + + + + + + + + AbstractClass.prototype.method2 = function () { this.prop = this.prop + "!"; }; @@ -115,7 +127,9 @@ var DerivedAbstractClass = /** @class */ (function (_super) { _this.cb = function (s) { }; // there is no implementation of 'prop' in any base class _this.cb(_this.prop.toLowerCase()); + _this.method(1); + // OK, references are to another instance other.cb(other.prop); yetAnother.cb(yetAnother.prop); @@ -132,6 +146,7 @@ var Implementation = /** @class */ (function (_super) { _this.cb(_this.prop); return _this; } + Implementation.prototype.method = function (n) { this.cb(this.prop + n); }; diff --git a/tests/baselines/reference/abstractPropertyNegative.js b/tests/baselines/reference/abstractPropertyNegative.js index a26369108ab0b..8eb88dcf63968 100644 --- a/tests/baselines/reference/abstractPropertyNegative.js +++ b/tests/baselines/reference/abstractPropertyNegative.js @@ -78,6 +78,7 @@ var C = /** @class */ (function (_super) { }(B)); var c = new C(); c.ro = "error: lhs of assignment can't be readonly"; + var WrongTypeProperty = /** @class */ (function () { function WrongTypeProperty() { } diff --git a/tests/baselines/reference/accessorWithES3.js b/tests/baselines/reference/accessorWithES3.js index 5137754c845d1..e9a264b775a10 100644 --- a/tests/baselines/reference/accessorWithES3.js +++ b/tests/baselines/reference/accessorWithES3.js @@ -22,6 +22,7 @@ var y = { //// [accessorWithES3.js] // error to use accessors in ES3 mode + var C = /** @class */ (function () { function C() { } @@ -48,6 +49,7 @@ var D = /** @class */ (function () { var x = { get a() { return 1; } }; + var y = { set b(v) { } }; diff --git a/tests/baselines/reference/accessorWithES5.js b/tests/baselines/reference/accessorWithES5.js index 0f75d614de3e0..cdb4d597ab818 100644 --- a/tests/baselines/reference/accessorWithES5.js +++ b/tests/baselines/reference/accessorWithES5.js @@ -45,6 +45,7 @@ var D = /** @class */ (function () { var x = { get a() { return 1; } }; + var y = { set b(v) { } }; diff --git a/tests/baselines/reference/accessorWithInitializer.js b/tests/baselines/reference/accessorWithInitializer.js index 9fa2908855c36..823c7b7bc352c 100644 --- a/tests/baselines/reference/accessorWithInitializer.js +++ b/tests/baselines/reference/accessorWithInitializer.js @@ -9,16 +9,12 @@ var C = /** @class */ (function () { function C() { } Object.defineProperty(C.prototype, "X", { - set: function (v) { - if (v === void 0) { v = 0; } - }, + set: function (v) {if (v === void 0) { v = 0; }}, enumerable: false, configurable: true }); Object.defineProperty(C, "X", { - set: function (v2) { - if (v2 === void 0) { v2 = 0; } - }, + set: function (v2) {if (v2 === void 0) { v2 = 0; }}, enumerable: false, configurable: true }); diff --git a/tests/baselines/reference/accessorWithRestParam.js b/tests/baselines/reference/accessorWithRestParam.js index c9afc192f5064..f9457fa6e7417 100644 --- a/tests/baselines/reference/accessorWithRestParam.js +++ b/tests/baselines/reference/accessorWithRestParam.js @@ -9,8 +9,7 @@ var C = /** @class */ (function () { function C() { } Object.defineProperty(C.prototype, "X", { - set: function () { - var v = []; + set: function () {var v = []; for (var _i = 0; _i < arguments.length; _i++) { v[_i] = arguments[_i]; } @@ -19,8 +18,7 @@ var C = /** @class */ (function () { configurable: true }); Object.defineProperty(C, "X", { - set: function () { - var v2 = []; + set: function () {var v2 = []; for (var _i = 0; _i < arguments.length; _i++) { v2[_i] = arguments[_i]; } diff --git a/tests/baselines/reference/accessorsAreNotContextuallyTyped.js b/tests/baselines/reference/accessorsAreNotContextuallyTyped.js index 171fce799b9dd..097628aee7f5d 100644 --- a/tests/baselines/reference/accessorsAreNotContextuallyTyped.js +++ b/tests/baselines/reference/accessorsAreNotContextuallyTyped.js @@ -15,6 +15,7 @@ var r = c.x(''); // string //// [accessorsAreNotContextuallyTyped.js] // accessors are not contextually typed + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/accessorsEmit.js b/tests/baselines/reference/accessorsEmit.js index 46c35a643d5f2..6947390ac73d6 100644 --- a/tests/baselines/reference/accessorsEmit.js +++ b/tests/baselines/reference/accessorsEmit.js @@ -17,8 +17,7 @@ class Test2 { //// [accessorsEmit.js] var Result = /** @class */ (function () { - function Result() { - } + function Result() {} return Result; }()); var Test = /** @class */ (function () { diff --git a/tests/baselines/reference/accessorsOverrideProperty2.js b/tests/baselines/reference/accessorsOverrideProperty2.js index e16ae60363e36..3a15aef291a8a 100644 --- a/tests/baselines/reference/accessorsOverrideProperty2.js +++ b/tests/baselines/reference/accessorsOverrideProperty2.js @@ -16,9 +16,11 @@ console.log(obj.x); // 1 class Base { x = 1; } + class Derived extends Base { get x() { return 2; } // should be an error set x(value) { console.log(`x was set to ${value}`); } } + const obj = new Derived(); // nothing printed console.log(obj.x); // 1 diff --git a/tests/baselines/reference/accessorsOverrideProperty5.js b/tests/baselines/reference/accessorsOverrideProperty5.js index fb7cee0630b67..c909c993789ce 100644 --- a/tests/baselines/reference/accessorsOverrideProperty5.js +++ b/tests/baselines/reference/accessorsOverrideProperty5.js @@ -11,8 +11,7 @@ class C extends B { //// [accessorsOverrideProperty5.js] -class B { -} +class B {} class C extends B { get p() { return 1; } set p(value) { } diff --git a/tests/baselines/reference/accessorsOverrideProperty6.js b/tests/baselines/reference/accessorsOverrideProperty6.js index 3cd61062c8626..fef52d372fea5 100644 --- a/tests/baselines/reference/accessorsOverrideProperty6.js +++ b/tests/baselines/reference/accessorsOverrideProperty6.js @@ -16,19 +16,16 @@ class D extends C { //// [accessorsOverrideProperty6.js] -class A { - constructor() { +class A {constructor() { this.p = 'yep'; - } -} + }} class B extends A { get p() { return 'oh no'; } // error } class C { constructor() { this.p = 101; - } -} + }} class D extends C { constructor() { super(...arguments); diff --git a/tests/baselines/reference/accessors_spec_section-4.5_inference.js b/tests/baselines/reference/accessors_spec_section-4.5_inference.js index 9d0a9689e05e2..9acb75b34b274 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_inference.js +++ b/tests/baselines/reference/accessors_spec_section-4.5_inference.js @@ -39,8 +39,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); var B = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/addMoreCallSignaturesToBaseSignature.js b/tests/baselines/reference/addMoreCallSignaturesToBaseSignature.js index a08a0f4ba7594..88ab0f04ba73b 100644 --- a/tests/baselines/reference/addMoreCallSignaturesToBaseSignature.js +++ b/tests/baselines/reference/addMoreCallSignaturesToBaseSignature.js @@ -12,5 +12,6 @@ var kitty = a(); //// [addMoreCallSignaturesToBaseSignature.js] + var a; var kitty = a(); diff --git a/tests/baselines/reference/addMoreCallSignaturesToBaseSignature2.js b/tests/baselines/reference/addMoreCallSignaturesToBaseSignature2.js index 73f7316dedc3c..aa62e1df896cf 100644 --- a/tests/baselines/reference/addMoreCallSignaturesToBaseSignature2.js +++ b/tests/baselines/reference/addMoreCallSignaturesToBaseSignature2.js @@ -11,5 +11,6 @@ var a: Bar; var kitty = a(1); //// [addMoreCallSignaturesToBaseSignature2.js] + var a; var kitty = a(1); diff --git a/tests/baselines/reference/additionOperatorWithAnyAndEveryType.js b/tests/baselines/reference/additionOperatorWithAnyAndEveryType.js index 82559b521dd85..137eb00e57e58 100644 --- a/tests/baselines/reference/additionOperatorWithAnyAndEveryType.js +++ b/tests/baselines/reference/additionOperatorWithAnyAndEveryType.js @@ -54,24 +54,26 @@ var E; E[E["c"] = 2] = "c"; })(E || (E = {})); var M; -(function (M) { -})(M || (M = {})); +(function (M) {})(M || (M = {})); var a; var b; var c; var d; var e; + // any as left operand, result is type Any except plusing string var r1 = a + a; var r2 = a + b; var r3 = a + c; var r4 = a + d; var r5 = a + e; + // any as right operand, result is type Any except plusing string var r6 = b + a; var r7 = c + a; var r8 = d + a; var r9 = e + a; + // other cases var r10 = a + foo; var r11 = a + foo(); diff --git a/tests/baselines/reference/additionOperatorWithInvalidOperands.js b/tests/baselines/reference/additionOperatorWithInvalidOperands.js index fe7a332b5eef1..da8b57c72a6f5 100644 --- a/tests/baselines/reference/additionOperatorWithInvalidOperands.js +++ b/tests/baselines/reference/additionOperatorWithInvalidOperands.js @@ -55,24 +55,27 @@ var E; E[E["c"] = 2] = "c"; })(E || (E = {})); var M; -(function (M) { -})(M || (M = {})); +(function (M) {})(M || (M = {})); var a; var b; var c; var d; + // boolean + every type except any and string var r1 = a + a; var r2 = a + b; var r3 = a + c; + // number + every type except any and string var r4 = b + a; var r5 = b + b; // number + number is valid var r6 = b + c; + // object + every type except any and string var r7 = c + a; var r8 = c + b; var r9 = c + c; + // other cases var r10 = a + true; var r11 = true + false; diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.js b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.js index 79d3c0b9b8da0..c0962ce1f75e3 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.js +++ b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.js @@ -25,11 +25,14 @@ var r11 = null + (() => { }); //// [additionOperatorWithNullValueAndInvalidOperator.js] // If one operand is the null or undefined value, it is treated as having the type of the other operand. + function foo() { return undefined; } + var a; var b; var c; var d; + // null + boolean/Object var r1 = null + a; var r2 = null + b; @@ -37,6 +40,7 @@ var r3 = null + c; var r4 = a + null; var r5 = b + null; var r6 = null + c; + // other cases var r7 = null + d; var r8 = null + true; diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js index 1b5cb877d21bc..6a526f6b7183b 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js +++ b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js @@ -42,9 +42,11 @@ var a; var b; var c; var d; + // null + any var r1 = null + a; var r2 = a + null; + // null + number/enum var r3 = null + b; var r4 = null + 1; @@ -56,6 +58,7 @@ var r9 = 1 + null; var r10 = c + null; var r11 = E.a + null; var r12 = E['a'] + null; + // null + string var r13 = null + d; var r14 = null + ''; diff --git a/tests/baselines/reference/additionOperatorWithNumberAndEnum.js b/tests/baselines/reference/additionOperatorWithNumberAndEnum.js index d559e98dc3eff..4466701949c65 100644 --- a/tests/baselines/reference/additionOperatorWithNumberAndEnum.js +++ b/tests/baselines/reference/additionOperatorWithNumberAndEnum.js @@ -38,15 +38,18 @@ var F; var a; var b; var c; + var r1 = a + a; var r2 = a + b; var r3 = b + a; var r4 = b + b; + var r5 = 0 + a; var r6 = E.a + 0; var r7 = E.a + E.b; var r8 = E['a'] + E['b']; var r9 = E['a'] + F['c']; + var r10 = a + c; var r11 = c + a; var r12 = b + c; diff --git a/tests/baselines/reference/additionOperatorWithStringAndEveryType.js b/tests/baselines/reference/additionOperatorWithStringAndEveryType.js index 03456020c802f..c985c5f49f4fc 100644 --- a/tests/baselines/reference/additionOperatorWithStringAndEveryType.js +++ b/tests/baselines/reference/additionOperatorWithStringAndEveryType.js @@ -52,7 +52,9 @@ var d; var e; var f; var g; + var x; + // string could plus every type, and the result is always string // string as left operand var r1 = x + a; @@ -62,6 +64,7 @@ var r4 = x + d; var r5 = x + e; var r6 = x + f; var r7 = x + g; + // string as right operand var r8 = a + x; var r9 = b + x; @@ -70,6 +73,7 @@ var r11 = d + x; var r12 = e + x; var r13 = f + x; var r14 = g + x; + // other cases var r15 = x + E; var r16 = x + E.a; diff --git a/tests/baselines/reference/additionOperatorWithTypeParameter.js b/tests/baselines/reference/additionOperatorWithTypeParameter.js index a568f420a32a4..c040fa6d32281 100644 --- a/tests/baselines/reference/additionOperatorWithTypeParameter.js +++ b/tests/baselines/reference/additionOperatorWithTypeParameter.js @@ -53,6 +53,7 @@ function foo(t, u) { var e; var g; var f; + // type parameter as left operand var r1 = t + a; // ok, one operand is any var r2 = t + b; @@ -61,6 +62,7 @@ function foo(t, u) { var r5 = t + e; var r6 = t + g; var r7 = t + f; + // type parameter as right operand var r8 = a + t; // ok, one operand is any var r9 = b + t; @@ -69,6 +71,7 @@ function foo(t, u) { var r12 = e + t; var r13 = g + t; var r14 = f + t; + // other cases var r15 = t + null; var r16 = t + undefined; diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.js b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.js index 98935db2b86e6..d8c8329c5c2b3 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.js +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.js @@ -25,11 +25,14 @@ var r11 = undefined + (() => { }); //// [additionOperatorWithUndefinedValueAndInvalidOperands.js] // If one operand is the null or undefined value, it is treated as having the type of the other operand. + function foo() { return undefined; } + var a; var b; var c; var d; + // undefined + boolean/Object var r1 = undefined + a; var r2 = undefined + b; @@ -37,6 +40,7 @@ var r3 = undefined + c; var r4 = a + undefined; var r5 = b + undefined; var r6 = undefined + c; + // other cases var r7 = undefined + d; var r8 = undefined + true; diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js index 68804694449e1..350592d00d9db 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js @@ -42,9 +42,11 @@ var a; var b; var c; var d; + // undefined + any var r1 = undefined + a; var r2 = a + undefined; + // undefined + number/enum var r3 = undefined + b; var r4 = undefined + 1; @@ -56,6 +58,7 @@ var r9 = 1 + undefined; var r10 = c + undefined; var r11 = E.a + undefined; var r12 = E['a'] + undefined; + // undefined + string var r13 = undefined + d; var r14 = undefined + ''; diff --git a/tests/baselines/reference/aliasBug.js b/tests/baselines/reference/aliasBug.js index 502bc9e11a715..17584b555226f 100644 --- a/tests/baselines/reference/aliasBug.js +++ b/tests/baselines/reference/aliasBug.js @@ -31,10 +31,8 @@ var foo; var bar; (function (bar) { var baz; - (function (baz) { - var boo = /** @class */ (function () { - function boo() { - } + (function (baz) {var boo = /** @class */ (function () { + function boo() {} return boo; }()); baz.boo = boo; @@ -43,7 +41,9 @@ var foo; })(foo || (foo = {})); var provide = foo; var booz = foo.bar.baz; + var p = new provide.Provide(); + function use() { var p1; // error here, but should be okay var p2; diff --git a/tests/baselines/reference/aliasErrors.js b/tests/baselines/reference/aliasErrors.js index 54edb24fff32d..2565cc07eb6c4 100644 --- a/tests/baselines/reference/aliasErrors.js +++ b/tests/baselines/reference/aliasErrors.js @@ -42,10 +42,8 @@ var foo; var bar; (function (bar) { var baz; - (function (baz) { - var boo = /** @class */ (function () { - function boo() { - } + (function (baz) {var boo = /** @class */ (function () { + function boo() {} return boo; }()); baz.boo = boo; @@ -55,13 +53,17 @@ var foo; var provide = foo; var booz = foo.bar.baz; var beez = foo.bar; + var m = no; var m2 = no.mod; 5; "s"; null; var r = undefined; + + var p = new provide.Provide(); + function use() { beez.baz.boo; var p1; @@ -69,3 +71,4 @@ function use() { var p3; var p22 = new provide.Provide(); } + diff --git a/tests/baselines/reference/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js b/tests/baselines/reference/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js index 567b75e850241..9fbad672a51f6 100644 --- a/tests/baselines/reference/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js +++ b/tests/baselines/reference/aliasOfGenericFunctionWithRestBehavedSameAsUnaliased.js @@ -37,6 +37,28 @@ let check3: test3 = "y"; "use strict"; // the type printback for every `test` below should be "y" var check = "y"; + + + + + + + + + var check1 = "y"; + + + + + + + + var check2 = "y"; + + + + + var check3 = "y"; diff --git a/tests/baselines/reference/aliasUsageInArray.js b/tests/baselines/reference/aliasUsageInArray.js index 5c695af51010a..21e6b3fe7f4c1 100644 --- a/tests/baselines/reference/aliasUsageInArray.js +++ b/tests/baselines/reference/aliasUsageInArray.js @@ -61,5 +61,6 @@ exports.VisualizationModel = VisualizationModel; "use strict"; exports.__esModule = true; var moduleA = require("./aliasUsageInArray_moduleA"); + var xs = [moduleA]; var xs2 = [moduleA]; diff --git a/tests/baselines/reference/aliasUsedAsNameValue.js b/tests/baselines/reference/aliasUsedAsNameValue.js index 84489f6eff307..6d9904c5b1471 100644 --- a/tests/baselines/reference/aliasUsedAsNameValue.js +++ b/tests/baselines/reference/aliasUsedAsNameValue.js @@ -36,6 +36,7 @@ exports.a = void 0; /// var mod = require("./aliasUsedAsNameValue_0"); var b = require("./aliasUsedAsNameValue_1"); + exports.a = function () { //var x = mod.id; // TODO needed hack that mod is loaded b.b(mod); diff --git a/tests/baselines/reference/allowImportClausesToMergeWithTypes.js b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js index 9c50acdfb1a90..0aa5bf07b8724 100644 --- a/tests/baselines/reference/allowImportClausesToMergeWithTypes.js +++ b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js @@ -37,6 +37,7 @@ exports["default"] = exports.zzz; "use strict"; exports.__esModule = true; exports["default"] = void 0; + var b_1 = require("./b"); exports["default"] = b_1["default"]; var x = { x: "" }; @@ -46,6 +47,8 @@ b_1["default"]; exports.__esModule = true; var x = { x: "" }; zzz; + var b_1 = require("./b"); b_1["default"]; + var y = x; diff --git a/tests/baselines/reference/ambient.js b/tests/baselines/reference/ambient.js index 6d4190bf34cdb..6f8a06ffecbb0 100644 --- a/tests/baselines/reference/ambient.js +++ b/tests/baselines/reference/ambient.js @@ -16,8 +16,7 @@ declare namespace ns { exports.__esModule = true; exports.A = void 0; var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); exports.A = A; diff --git a/tests/baselines/reference/ambientClassDeclarationWithExtends.js b/tests/baselines/reference/ambientClassDeclarationWithExtends.js index 1b7bcf88b2084..0f5a00dc84826 100644 --- a/tests/baselines/reference/ambientClassDeclarationWithExtends.js +++ b/tests/baselines/reference/ambientClassDeclarationWithExtends.js @@ -25,14 +25,11 @@ var f: E = new F(); //// [ambientClassDeclarationExtends_singleFile.js] var D; -(function (D) { - var x; -})(D || (D = {})); +(function (D) {var x;})(D || (D = {})); + var d = new D(); //// [ambientClassDeclarationExtends_file1.js] var F; -(function (F) { - var y; -})(F || (F = {})); +(function (F) {var y;})(F || (F = {})); //// [ambientClassDeclarationExtends_file2.js] var f = new F(); diff --git a/tests/baselines/reference/ambientDeclarations.js b/tests/baselines/reference/ambientDeclarations.js index 729ecf7d45e21..3a69cc126230f 100644 --- a/tests/baselines/reference/ambientDeclarations.js +++ b/tests/baselines/reference/ambientDeclarations.js @@ -78,6 +78,10 @@ declare module 'external1' { //// [ambientDeclarations.js] var x = E3.B; + + // Ambient module members are always exported with or without export keyword var p = M1.x; var q = M1.fn(); + + diff --git a/tests/baselines/reference/ambientDeclarationsExternal.js b/tests/baselines/reference/ambientDeclarationsExternal.js index ed413fb0d8e2f..ac75a4a009b39 100644 --- a/tests/baselines/reference/ambientDeclarationsExternal.js +++ b/tests/baselines/reference/ambientDeclarationsExternal.js @@ -24,6 +24,7 @@ var n: number; //// [decls.js] + // Ambient external import declaration referencing ambient external module using top level module name //// [consumer.js] "use strict"; diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.js b/tests/baselines/reference/ambientDeclarationsPatterns.js index 84088d11d4eb4..4d16983d80d44 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns.js +++ b/tests/baselines/reference/ambientDeclarationsPatterns.js @@ -38,8 +38,10 @@ exports.__esModule = true; /// var foobarbaz_1 = require("foobarbaz"); foobarbaz_1.foo(foobarbaz_1.baz); + var foosball_1 = require("foosball"); foobarbaz_1.foo(foosball_1.foos); + // Works with relative file name var file_text_1 = require("./file!text"); foobarbaz_1.foo(file_text_1["default"]); diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js index 56abd8298cdf2..b947d0f6b7ade 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging1.js @@ -17,6 +17,7 @@ import { everywhere, onlyInA } from "b.foo"; // Error //// [types.js] + //// [testA.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js index 65726bba7225e..8f1ee0800c4b6 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js +++ b/tests/baselines/reference/ambientDeclarationsPatterns_merging2.js @@ -19,6 +19,7 @@ declare module "a.foo" { } //// [types.js] + //// [testA.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/ambientEnumDeclaration1.js b/tests/baselines/reference/ambientEnumDeclaration1.js index dcdb100e90696..d6d4e5aa3e340 100644 --- a/tests/baselines/reference/ambientEnumDeclaration1.js +++ b/tests/baselines/reference/ambientEnumDeclaration1.js @@ -11,3 +11,4 @@ declare enum E { //// [ambientEnumDeclaration1.js] // In ambient enum declarations, all values specified in enum member declarations must be classified as constant enum expressions. + diff --git a/tests/baselines/reference/ambientEnumDeclaration2.js b/tests/baselines/reference/ambientEnumDeclaration2.js index 8ef6facfe6d0d..35f12d46edb42 100644 --- a/tests/baselines/reference/ambientEnumDeclaration2.js +++ b/tests/baselines/reference/ambientEnumDeclaration2.js @@ -15,3 +15,4 @@ declare const enum E1 { //// [ambientEnumDeclaration2.js] // In ambient enum declarations that specify no const modifier, enum member declarations // that omit a value are considered computed members (as opposed to having auto- incremented values assigned). + diff --git a/tests/baselines/reference/ambientErrors.js b/tests/baselines/reference/ambientErrors.js index c524a6cfe72fc..b687e9f54db1d 100644 --- a/tests/baselines/reference/ambientErrors.js +++ b/tests/baselines/reference/ambientErrors.js @@ -61,3 +61,4 @@ declare module 'bar' { //// [ambientErrors.js] ; + diff --git a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.js b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.js index d6db77b6050ef..7ea2ad6ea2501 100644 --- a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.js +++ b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.js @@ -14,10 +14,12 @@ var x = ext; define(["require", "exports", "ext"], function (require, exports, ext) { "use strict"; var D = /** @class */ (function () { - function D() { - } + function D() {} return D; }()); + + + var x = ext; return D; }); diff --git a/tests/baselines/reference/ambientModuleExports.js b/tests/baselines/reference/ambientModuleExports.js index 59c608a717469..847ffffc840b2 100644 --- a/tests/baselines/reference/ambientModuleExports.js +++ b/tests/baselines/reference/ambientModuleExports.js @@ -20,9 +20,12 @@ Foo2.b; var c2 = new Foo2.C(); //// [ambientModuleExports.js] + Foo.a(); Foo.b; var c = new Foo.C(); + + Foo2.a(); Foo2.b; var c2 = new Foo2.C(); diff --git a/tests/baselines/reference/ambientModuleWithTemplateLiterals.js b/tests/baselines/reference/ambientModuleWithTemplateLiterals.js index e9c55fe7ca055..2dd79dbd062aa 100644 --- a/tests/baselines/reference/ambientModuleWithTemplateLiterals.js +++ b/tests/baselines/reference/ambientModuleWithTemplateLiterals.js @@ -21,6 +21,7 @@ Foo.d; Foo.e; //// [ambientModuleWithTemplateLiterals.js] + Foo.a; Foo.b; Foo.c; diff --git a/tests/baselines/reference/ambientRequireFunction.js b/tests/baselines/reference/ambientRequireFunction.js index 348ee0a144389..81a28cebc4785 100644 --- a/tests/baselines/reference/ambientRequireFunction.js +++ b/tests/baselines/reference/ambientRequireFunction.js @@ -15,5 +15,6 @@ const text = fs.readFileSync("/a/b/c"); //// [app.js] /// + var fs = require("fs"); var text = fs.readFileSync("/a/b/c"); diff --git a/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.js b/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.js index 6937384136dda..56c04b53471e2 100644 --- a/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.js +++ b/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.js @@ -34,6 +34,9 @@ var TestClass = /** @class */ (function () { } TestClass.prototype.bar = function (x) { }; + + + TestClass.prototype.foo = function (x) { this.bar(x); // should not error }; @@ -45,6 +48,9 @@ var TestClass2 = /** @class */ (function () { TestClass2.prototype.bar = function (x) { return 0; }; + + + TestClass2.prototype.foo = function (x) { return this.bar(x); // should not error }; diff --git a/tests/baselines/reference/ambiguousGenericAssertion1.js b/tests/baselines/reference/ambiguousGenericAssertion1.js index 8d40873036caa..24508ea2bbd04 100644 --- a/tests/baselines/reference/ambiguousGenericAssertion1.js +++ b/tests/baselines/reference/ambiguousGenericAssertion1.js @@ -9,5 +9,4 @@ var r3 = <(x: T) => T>f; // ambiguous, appears to the parser as a << operatio function f(x) { return null; } var r = function (x) { return x; }; var r2 = f; // valid -var r3 = << T > (x), T; -T > f; // ambiguous, appears to the parser as a << operation +var r3 = << T > (x), T;T > f; // ambiguous, appears to the parser as a << operation diff --git a/tests/baselines/reference/ambiguousOverload.js b/tests/baselines/reference/ambiguousOverload.js index 642f09dca1683..6b31563e61f52 100644 --- a/tests/baselines/reference/ambiguousOverload.js +++ b/tests/baselines/reference/ambiguousOverload.js @@ -12,11 +12,10 @@ var x2: string = foof2("s", null); var y2: number = foof2("s", null); //// [ambiguousOverload.js] -function foof(bar) { return bar; } -; +function foof(bar) { return bar; }; var x = foof("s", null); var y = foof("s", null); -function foof2(bar) { return bar; } -; + +function foof2(bar) { return bar; }; var x2 = foof2("s", null); var y2 = foof2("s", null); diff --git a/tests/baselines/reference/ambiguousOverloadResolution.js b/tests/baselines/reference/ambiguousOverloadResolution.js index 56bef268fb4a9..76848fb268d91 100644 --- a/tests/baselines/reference/ambiguousOverloadResolution.js +++ b/tests/baselines/reference/ambiguousOverloadResolution.js @@ -23,8 +23,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); var B = /** @class */ (function (_super) { @@ -34,5 +33,6 @@ var B = /** @class */ (function (_super) { } return B; }(A)); + var x; var t = f(x, x); // Not an error diff --git a/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.js b/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.js index f8f25a4e1aa86..5cb0cf4f703c0 100644 --- a/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.js +++ b/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.js @@ -42,8 +42,7 @@ define("Configurable", ["require", "exports"], function (require, exports) { function Configurable(base) { return /** @class */ (function (_super) { __extends(class_1, _super); - function class_1() { - var args = []; + function class_1() {var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } @@ -59,8 +58,7 @@ define("Class", ["require", "exports", "Configurable"], function (require, expor exports.__esModule = true; exports.ActualClass = exports.HiddenClass = void 0; var HiddenClass = /** @class */ (function () { - function HiddenClass() { - } + function HiddenClass() {} return HiddenClass; }()); exports.HiddenClass = HiddenClass; diff --git a/tests/baselines/reference/amdDependencyCommentName4.js b/tests/baselines/reference/amdDependencyCommentName4.js index 6542aa14fa299..741d006c191b0 100644 --- a/tests/baselines/reference/amdDependencyCommentName4.js +++ b/tests/baselines/reference/amdDependencyCommentName4.js @@ -29,7 +29,13 @@ define(["require", "exports", "aliasedModule5", "aliasedModule6", "aliasedModule "use strict"; exports.__esModule = true; r1; + + aliasedModule2_1.p1; + + aliasedModule3_1["default"]; + + ns; }); diff --git a/tests/baselines/reference/amdModuleBundleNoDuplicateDeclarationEmitComments.js b/tests/baselines/reference/amdModuleBundleNoDuplicateDeclarationEmitComments.js index ab9cd9794077d..1b7a8a6b53141 100644 --- a/tests/baselines/reference/amdModuleBundleNoDuplicateDeclarationEmitComments.js +++ b/tests/baselines/reference/amdModuleBundleNoDuplicateDeclarationEmitComments.js @@ -14,8 +14,7 @@ define("mynamespace::SomeModuleA", ["require", "exports"], function (require, ex exports.Foo = void 0; /// var Foo = /** @class */ (function () { - function Foo() { - } + function Foo() {} return Foo; }()); exports.Foo = Foo; @@ -26,8 +25,7 @@ define("mynamespace::SomeModuleB", ["require", "exports"], function (require, ex exports.Bar = void 0; /// var Bar = /** @class */ (function () { - function Bar() { - } + function Bar() {} return Bar; }()); exports.Bar = Bar; diff --git a/tests/baselines/reference/anonymousClassExpression1.js b/tests/baselines/reference/anonymousClassExpression1.js index 7223b816b9031..9ef4aa5bfa46e 100644 --- a/tests/baselines/reference/anonymousClassExpression1.js +++ b/tests/baselines/reference/anonymousClassExpression1.js @@ -6,8 +6,7 @@ function f() { //// [anonymousClassExpression1.js] function f() { return typeof /** @class */ (function () { - function class_1() { - } + function class_1() {} return class_1; }()) === "function"; } diff --git a/tests/baselines/reference/anonymousDefaultExportsAmd.js b/tests/baselines/reference/anonymousDefaultExportsAmd.js index 24e833b7542ee..29a041fddcf93 100644 --- a/tests/baselines/reference/anonymousDefaultExportsAmd.js +++ b/tests/baselines/reference/anonymousDefaultExportsAmd.js @@ -10,8 +10,7 @@ export default function() {} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - class default_1 { - } + class default_1 {} exports.default = default_1; }); //// [b.js] diff --git a/tests/baselines/reference/anonymousDefaultExportsCommonjs.js b/tests/baselines/reference/anonymousDefaultExportsCommonjs.js index e22000856d686..9e4bc52ab1cb9 100644 --- a/tests/baselines/reference/anonymousDefaultExportsCommonjs.js +++ b/tests/baselines/reference/anonymousDefaultExportsCommonjs.js @@ -9,8 +9,7 @@ export default function() {} //// [a.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -class default_1 { -} +class default_1 {} exports.default = default_1; //// [b.js] "use strict"; diff --git a/tests/baselines/reference/anonymousDefaultExportsSystem.js b/tests/baselines/reference/anonymousDefaultExportsSystem.js index 48071da9e9b47..d7ba682a0abd3 100644 --- a/tests/baselines/reference/anonymousDefaultExportsSystem.js +++ b/tests/baselines/reference/anonymousDefaultExportsSystem.js @@ -14,8 +14,7 @@ System.register([], function (exports_1, context_1) { return { setters: [], execute: function () { - default_1 = class { - }; + default_1 = class {}; exports_1("default", default_1); } }; @@ -28,7 +27,6 @@ System.register([], function (exports_1, context_1) { exports_1("default", default_1); return { setters: [], - execute: function () { - } + execute: function () {} }; }); diff --git a/tests/baselines/reference/anonymousDefaultExportsUmd.js b/tests/baselines/reference/anonymousDefaultExportsUmd.js index 484238b8722cf..0c97fcfaf59ad 100644 --- a/tests/baselines/reference/anonymousDefaultExportsUmd.js +++ b/tests/baselines/reference/anonymousDefaultExportsUmd.js @@ -18,8 +18,7 @@ export default function() {} })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - class default_1 { - } + class default_1 {} exports.default = default_1; }); //// [b.js] diff --git a/tests/baselines/reference/anonymousModules.js b/tests/baselines/reference/anonymousModules.js index 5270594e8ee99..8684854c021ba 100644 --- a/tests/baselines/reference/anonymousModules.js +++ b/tests/baselines/reference/anonymousModules.js @@ -14,16 +14,16 @@ module { } //// [anonymousModules.js] -module; -{ +module;{ export var foo = 1; - module; - { + + module;{ export var bar = 1; } + var bar = 2; - module; - { + + module;{ var x = bar; } } diff --git a/tests/baselines/reference/anyAsConstructor.js b/tests/baselines/reference/anyAsConstructor.js index 2dfa9a5398b95..d706d1d6a6a91 100644 --- a/tests/baselines/reference/anyAsConstructor.js +++ b/tests/baselines/reference/anyAsConstructor.js @@ -13,9 +13,11 @@ var d = new x(x); // no error //// [anyAsConstructor.js] // any is considered an untyped function call // can be called except with type arguments which is an error + var x; var a = new x(); var b = new x('hello'); var c = new x(x); + // grammar allows this for constructors var d = new x(x); // no error diff --git a/tests/baselines/reference/anyAsFunctionCall.js b/tests/baselines/reference/anyAsFunctionCall.js index 9b1e0852de991..340d7444f567a 100644 --- a/tests/baselines/reference/anyAsFunctionCall.js +++ b/tests/baselines/reference/anyAsFunctionCall.js @@ -10,6 +10,7 @@ var c = x(x); //// [anyAsFunctionCall.js] // any is considered an untyped function call // can be called except with type arguments which is an error + var x; var a = x(); var b = x('hello'); diff --git a/tests/baselines/reference/anyAsGenericFunctionCall.js b/tests/baselines/reference/anyAsGenericFunctionCall.js index 085e1065a07c2..a6f497a862d14 100644 --- a/tests/baselines/reference/anyAsGenericFunctionCall.js +++ b/tests/baselines/reference/anyAsGenericFunctionCall.js @@ -13,12 +13,13 @@ var d = x(x); //// [anyAsGenericFunctionCall.js] // any is considered an untyped function call // can be called except with type arguments which is an error + var x; var a = x(); var b = x('hello'); + var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); var c = x(x); diff --git a/tests/baselines/reference/anyAsReturnTypeForNewOnCall.js b/tests/baselines/reference/anyAsReturnTypeForNewOnCall.js index a6b26d3890e40..79605c5c13e15 100644 --- a/tests/baselines/reference/anyAsReturnTypeForNewOnCall.js +++ b/tests/baselines/reference/anyAsReturnTypeForNewOnCall.js @@ -16,8 +16,15 @@ var xx = o.x; //// [anyAsReturnTypeForNewOnCall.js] function Point(x, y) { + this.x = x; + this.y = y; + } + var o = new Point(3, 4); + var xx = o.x; + + diff --git a/tests/baselines/reference/anyAssignabilityInInheritance.js b/tests/baselines/reference/anyAssignabilityInInheritance.js index 6871d6738aca7..4bd8e797bfa72 100644 --- a/tests/baselines/reference/anyAssignabilityInInheritance.js +++ b/tests/baselines/reference/anyAssignabilityInInheritance.js @@ -90,47 +90,62 @@ var r3 = foo3(a); // any //// [anyAssignabilityInInheritance.js] // any is not a subtype of any other types, errors expected on all the below derived classes unless otherwise noted + + var a; + var r3 = foo2(a); // any, not a subtype of number so it skips that overload, is a subtype of itself so it picks second (if truly ambiguous it would pick first overload) + var r3 = foo3(a); // any + var r3 = foo3(a); // any + var r3 = foo3(a); // any + var r3 = foo3(a); // any + var r3 = foo3(a); // any + var r3 = foo3(a); // any + var r3 = foo3(a); // any + var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); var r3 = foo3(a); // any + var A2 = /** @class */ (function () { - function A2() { - } + function A2() {} return A2; }()); var r3 = foo3(a); // any + var r3 = foo3(a); // any + var r3 = foo3(a); // any var E; (function (E) { E[E["A"] = 0] = "A"; })(E || (E = {})); var r3 = foo3(a); // any + function f() { } (function (f) { f.bar = 1; })(f || (f = {})); var r3 = foo3(a); // any + var CC = /** @class */ (function () { - function CC() { - } + function CC() {} return CC; }()); (function (CC) { CC.bar = 1; })(CC || (CC = {})); var r3 = foo3(a); // any + var r3 = foo3(a); // any + var r3 = foo3(a); // any diff --git a/tests/baselines/reference/anyAssignableToEveryType.js b/tests/baselines/reference/anyAssignableToEveryType.js index eff97905e4f4a..b5ad284ed69bb 100644 --- a/tests/baselines/reference/anyAssignableToEveryType.js +++ b/tests/baselines/reference/anyAssignableToEveryType.js @@ -47,6 +47,7 @@ function foo(x: T, y: U, z: V) { //// [anyAssignableToEveryType.js] var a; + var C = /** @class */ (function () { function C() { } @@ -59,6 +60,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); var ae; + var b = a; var c = a; var d = a; @@ -78,11 +80,13 @@ var n = a; var o = a; var p = a; var q = a; + function foo(x, y, z) { x = a; y = a; z = a; } + //function foo(x: T, y: U, z: V) { // x = a; // y = a; diff --git a/tests/baselines/reference/anyAssignableToEveryType2.js b/tests/baselines/reference/anyAssignableToEveryType2.js index 28b4ab7148d90..f8cbc276fefcf 100644 --- a/tests/baselines/reference/anyAssignableToEveryType2.js +++ b/tests/baselines/reference/anyAssignableToEveryType2.js @@ -132,27 +132,31 @@ interface I20 { //// [anyAssignableToEveryType2.js] // any is not a subtype of any other types, but is assignable, all the below should work + + var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); + var A2 = /** @class */ (function () { - function A2() { - } + function A2() {} return A2; }()); var E; (function (E) { E[E["A"] = 0] = "A"; })(E || (E = {})); + + function f() { } (function (f) { f.bar = 1; })(f || (f = {})); + + var c = /** @class */ (function () { - function c() { - } + function c() {} return c; }()); (function (c) { diff --git a/tests/baselines/reference/anyIdenticalToItself.js b/tests/baselines/reference/anyIdenticalToItself.js index 6ec3d0d43e619..f162234934dbe 100644 --- a/tests/baselines/reference/anyIdenticalToItself.js +++ b/tests/baselines/reference/anyIdenticalToItself.js @@ -14,6 +14,7 @@ class C { //// [anyIdenticalToItself.js] function foo(x, y) { } + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/anyInferenceAnonymousFunctions.js b/tests/baselines/reference/anyInferenceAnonymousFunctions.js index df921965994d7..f4fb94e00f238 100644 --- a/tests/baselines/reference/anyInferenceAnonymousFunctions.js +++ b/tests/baselines/reference/anyInferenceAnonymousFunctions.js @@ -19,12 +19,19 @@ paired.map(function (c2) { return c2.count; }); //// [anyInferenceAnonymousFunctions.js] var paired; + paired.reduce(function (a1, a2) { + return a1.concat({}); + }, []); + paired.reduce(function (b1, b2) { + return b1.concat({}); }, []); + paired.reduce(function (b3, b4) { return b3.concat({}); }, []); + paired.map(function (c1) { return c1.count; }); paired.map(function (c2) { return c2.count; }); diff --git a/tests/baselines/reference/apparentTypeSubtyping.js b/tests/baselines/reference/apparentTypeSubtyping.js index 2e9987f1e0d8d..9e76e73cc6fbf 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.js +++ b/tests/baselines/reference/apparentTypeSubtyping.js @@ -37,6 +37,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { function Base() { } diff --git a/tests/baselines/reference/apparentTypeSupertype.js b/tests/baselines/reference/apparentTypeSupertype.js index 82443d221978a..d7f4158702517 100644 --- a/tests/baselines/reference/apparentTypeSupertype.js +++ b/tests/baselines/reference/apparentTypeSupertype.js @@ -27,6 +27,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { function Base() { } diff --git a/tests/baselines/reference/argumentExpressionContextualTyping.js b/tests/baselines/reference/argumentExpressionContextualTyping.js index 14efadcab7585..caea5b6e7899f 100644 --- a/tests/baselines/reference/argumentExpressionContextualTyping.js +++ b/tests/baselines/reference/argumentExpressionContextualTyping.js @@ -34,14 +34,17 @@ function bar(_a) { var _b = _a.x, a = _b[0], _c = _b[1], b = _c === void 0 ? 10 : _c, _d = _a.y, c = _d.c, d = _d.d, _e = _d.e, e = _e === void 0 ? { f: 1 } : _e; } function baz(x) { } + var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; var o1 = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; foo(o1); // Not error since x has contextual type of tuple namely [string, number] foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error + var array = ["string", 1, true]; var tuple = ["string", 1, true]; baz(tuple); baz(["string", 1, true]); + baz(array); // Error baz(__spreadArrays(["string", 1, true], array)); // Error foo(o); // Error because x has an array type namely (string|number)[] diff --git a/tests/baselines/reference/arguments.js b/tests/baselines/reference/arguments.js index 3dd362506c6cb..2dc55dffed952 100644 --- a/tests/baselines/reference/arguments.js +++ b/tests/baselines/reference/arguments.js @@ -19,4 +19,6 @@ function f() { var x = arguments[12]; (() => arguments)(); } + (() => arguments)(); + diff --git a/tests/baselines/reference/argumentsAsPropertyName.js b/tests/baselines/reference/argumentsAsPropertyName.js index a4197c0a1d249..c619e51ac3463 100644 --- a/tests/baselines/reference/argumentsAsPropertyName.js +++ b/tests/baselines/reference/argumentsAsPropertyName.js @@ -16,6 +16,8 @@ function myFunction(myType: MyType) { } //// [argumentsAsPropertyName.js] + + function myFunction(myType) { var _loop_1 = function (i) { use(myType.arguments[i]); diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES5.js b/tests/baselines/reference/argumentsObjectIterator02_ES5.js index ae8675d97453b..4f07608380968 100644 --- a/tests/baselines/reference/argumentsObjectIterator02_ES5.js +++ b/tests/baselines/reference/argumentsObjectIterator02_ES5.js @@ -14,6 +14,7 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe //// [argumentsObjectIterator02_ES5.js] function doubleAndReturnAsArray(x, y, z) { var blah = arguments[Symbol.iterator]; + var result = []; for (var _i = 0, _a = blah(); _i < _a.length; _i++) { var arg = _a[_i]; @@ -21,3 +22,4 @@ function doubleAndReturnAsArray(x, y, z) { } return result; } + diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES6.js b/tests/baselines/reference/argumentsObjectIterator02_ES6.js index 1155ab929eab5..63d3e0d282949 100644 --- a/tests/baselines/reference/argumentsObjectIterator02_ES6.js +++ b/tests/baselines/reference/argumentsObjectIterator02_ES6.js @@ -14,9 +14,11 @@ function doubleAndReturnAsArray(x: number, y: number, z: number): [number, numbe //// [argumentsObjectIterator02_ES6.js] function doubleAndReturnAsArray(x, y, z) { let blah = arguments[Symbol.iterator]; + let result = []; for (let arg of blah()) { result.push(arg + arg); } return result; } + diff --git a/tests/baselines/reference/argumentsObjectIterator03_ES5.js b/tests/baselines/reference/argumentsObjectIterator03_ES5.js index 837808a6d926d..f963914d98689 100644 --- a/tests/baselines/reference/argumentsObjectIterator03_ES5.js +++ b/tests/baselines/reference/argumentsObjectIterator03_ES5.js @@ -10,5 +10,7 @@ function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, nu //// [argumentsObjectIterator03_ES5.js] function asReversedTuple(a, b, c) { var x = arguments[0], y = arguments[1], z = arguments[2]; + return [z, y, x]; } + diff --git a/tests/baselines/reference/argumentsObjectIterator03_ES6.js b/tests/baselines/reference/argumentsObjectIterator03_ES6.js index 789bcc9390d51..53af8d4ea978f 100644 --- a/tests/baselines/reference/argumentsObjectIterator03_ES6.js +++ b/tests/baselines/reference/argumentsObjectIterator03_ES6.js @@ -10,5 +10,7 @@ function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, nu //// [argumentsObjectIterator03_ES6.js] function asReversedTuple(a, b, c) { let [x, y, z] = arguments; + return [z, y, x]; } + diff --git a/tests/baselines/reference/arithAssignTyping.js b/tests/baselines/reference/arithAssignTyping.js index 7bb31b2804533..4d59d53d3023f 100644 --- a/tests/baselines/reference/arithAssignTyping.js +++ b/tests/baselines/reference/arithAssignTyping.js @@ -16,8 +16,7 @@ f ^= 1; // error //// [arithAssignTyping.js] var f = /** @class */ (function () { - function f() { - } + function f() {} return f; }()); f += ''; // error diff --git a/tests/baselines/reference/arithmeticOperatorWithAnyAndNumber.js b/tests/baselines/reference/arithmeticOperatorWithAnyAndNumber.js index 7cb45f63230dd..dde8b9c45224b 100644 --- a/tests/baselines/reference/arithmeticOperatorWithAnyAndNumber.js +++ b/tests/baselines/reference/arithmeticOperatorWithAnyAndNumber.js @@ -105,6 +105,7 @@ var rj8 = b | b; //// [arithmeticOperatorWithAnyAndNumber.js] var a; var b; + // operator * var ra1 = a * a; var ra2 = a * b; @@ -114,6 +115,7 @@ var ra5 = 0 * 0; var ra6 = b * 0; var ra7 = 0 * b; var ra8 = b * b; + // operator / var rb1 = a / a; var rb2 = a / b; @@ -123,6 +125,7 @@ var rb5 = 0 / 0; var rb6 = b / 0; var rb7 = 0 / b; var rb8 = b / b; + // operator % var rc1 = a % a; var rc2 = a % b; @@ -132,6 +135,7 @@ var rc5 = 0 % 0; var rc6 = b % 0; var rc7 = 0 % b; var rc8 = b % b; + // operator - var rd1 = a - a; var rd2 = a - b; @@ -141,6 +145,7 @@ var rd5 = 0 - 0; var rd6 = b - 0; var rd7 = 0 - b; var rd8 = b - b; + // operator << var re1 = a << a; var re2 = a << b; @@ -150,6 +155,7 @@ var re5 = 0 << 0; var re6 = b << 0; var re7 = 0 << b; var re8 = b << b; + // operator >> var rf1 = a >> a; var rf2 = a >> b; @@ -159,6 +165,7 @@ var rf5 = 0 >> 0; var rf6 = b >> 0; var rf7 = 0 >> b; var rf8 = b >> b; + // operator >>> var rg1 = a >>> a; var rg2 = a >>> b; @@ -168,6 +175,7 @@ var rg5 = 0 >>> 0; var rg6 = b >>> 0; var rg7 = 0 >>> b; var rg8 = b >>> b; + // operator & var rh1 = a & a; var rh2 = a & b; @@ -177,6 +185,7 @@ var rh5 = 0 & 0; var rh6 = b & 0; var rh7 = 0 & b; var rh8 = b & b; + // operator ^ var ri1 = a ^ a; var ri2 = a ^ b; @@ -186,6 +195,7 @@ var ri5 = 0 ^ 0; var ri6 = b ^ 0; var ri7 = 0 ^ b; var ri8 = b ^ b; + // operator | var rj1 = a | a; var rj2 = a | b; diff --git a/tests/baselines/reference/arithmeticOperatorWithEnum.js b/tests/baselines/reference/arithmeticOperatorWithEnum.js index 3572f3ecc41e4..a5fc9c7e8d91a 100644 --- a/tests/baselines/reference/arithmeticOperatorWithEnum.js +++ b/tests/baselines/reference/arithmeticOperatorWithEnum.js @@ -160,6 +160,7 @@ var E; var a; var b; var c; + // operator * var ra1 = c * a; var ra2 = c * b; @@ -173,6 +174,7 @@ var ra9 = E.a * 1; var ra10 = a * E.b; var ra11 = b * E.b; var ra12 = 1 * E.b; + // operator / var rb1 = c / a; var rb2 = c / b; @@ -186,6 +188,7 @@ var rb9 = E.a / 1; var rb10 = a / E.b; var rb11 = b / E.b; var rb12 = 1 / E.b; + // operator % var rc1 = c % a; var rc2 = c % b; @@ -199,6 +202,7 @@ var rc9 = E.a % 1; var rc10 = a % E.b; var rc11 = b % E.b; var rc12 = 1 % E.b; + // operator - var rd1 = c - a; var rd2 = c - b; @@ -212,6 +216,7 @@ var rd9 = E.a - 1; var rd10 = a - E.b; var rd11 = b - E.b; var rd12 = 1 - E.b; + // operator << var re1 = c << a; var re2 = c << b; @@ -225,6 +230,7 @@ var re9 = E.a << 1; var re10 = a << E.b; var re11 = b << E.b; var re12 = 1 << E.b; + // operator >> var rf1 = c >> a; var rf2 = c >> b; @@ -238,6 +244,7 @@ var rf9 = E.a >> 1; var rf10 = a >> E.b; var rf11 = b >> E.b; var rf12 = 1 >> E.b; + // operator >>> var rg1 = c >>> a; var rg2 = c >>> b; @@ -251,6 +258,7 @@ var rg9 = E.a >>> 1; var rg10 = a >>> E.b; var rg11 = b >>> E.b; var rg12 = 1 >>> E.b; + // operator & var rh1 = c & a; var rh2 = c & b; @@ -264,6 +272,7 @@ var rh9 = E.a & 1; var rh10 = a & E.b; var rh11 = b & E.b; var rh12 = 1 & E.b; + // operator ^ var ri1 = c ^ a; var ri2 = c ^ b; @@ -277,6 +286,7 @@ var ri9 = E.a ^ 1; var ri10 = a ^ E.b; var ri11 = b ^ E.b; var ri12 = 1 ^ E.b; + // operator | var rj1 = c | a; var rj2 = c | b; diff --git a/tests/baselines/reference/arithmeticOperatorWithEnumUnion.js b/tests/baselines/reference/arithmeticOperatorWithEnumUnion.js index 95bc0b866c91c..a995396250169 100644 --- a/tests/baselines/reference/arithmeticOperatorWithEnumUnion.js +++ b/tests/baselines/reference/arithmeticOperatorWithEnumUnion.js @@ -169,6 +169,7 @@ var F; var a; var b; var c; + // operator * var ra1 = c * a; var ra2 = c * b; @@ -182,6 +183,7 @@ var ra9 = E.a * 1; var ra10 = a * E.b; var ra11 = b * E.b; var ra12 = 1 * E.b; + // operator / var rb1 = c / a; var rb2 = c / b; @@ -195,6 +197,7 @@ var rb9 = E.a / 1; var rb10 = a / E.b; var rb11 = b / E.b; var rb12 = 1 / E.b; + // operator % var rc1 = c % a; var rc2 = c % b; @@ -208,6 +211,7 @@ var rc9 = E.a % 1; var rc10 = a % E.b; var rc11 = b % E.b; var rc12 = 1 % E.b; + // operator - var rd1 = c - a; var rd2 = c - b; @@ -221,6 +225,7 @@ var rd9 = E.a - 1; var rd10 = a - E.b; var rd11 = b - E.b; var rd12 = 1 - E.b; + // operator << var re1 = c << a; var re2 = c << b; @@ -234,6 +239,7 @@ var re9 = E.a << 1; var re10 = a << E.b; var re11 = b << E.b; var re12 = 1 << E.b; + // operator >> var rf1 = c >> a; var rf2 = c >> b; @@ -247,6 +253,7 @@ var rf9 = E.a >> 1; var rf10 = a >> E.b; var rf11 = b >> E.b; var rf12 = 1 >> E.b; + // operator >>> var rg1 = c >>> a; var rg2 = c >>> b; @@ -260,6 +267,7 @@ var rg9 = E.a >>> 1; var rg10 = a >>> E.b; var rg11 = b >>> E.b; var rg12 = 1 >>> E.b; + // operator & var rh1 = c & a; var rh2 = c & b; @@ -273,6 +281,7 @@ var rh9 = E.a & 1; var rh10 = a & E.b; var rh11 = b & E.b; var rh12 = 1 & E.b; + // operator ^ var ri1 = c ^ a; var ri2 = c ^ b; @@ -286,6 +295,7 @@ var ri9 = E.a ^ 1; var ri10 = a ^ E.b; var ri11 = b ^ E.b; var ri12 = 1 ^ E.b; + // operator | var rj1 = c | a; var rj2 = c | b; diff --git a/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.js b/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.js index 974e9930103d7..f69276a39d1ce 100644 --- a/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.js +++ b/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.js @@ -596,6 +596,7 @@ var c; var d; var e; var f; + // All of the below should be an error unless otherwise noted // operator * var r1a1 = a * a; //ok @@ -604,48 +605,56 @@ var r1a3 = a * c; //ok var r1a4 = a * d; var r1a5 = a * e; var r1a6 = a * f; + var r1b1 = b * a; var r1b2 = b * b; var r1b3 = b * c; var r1b4 = b * d; var r1b5 = b * e; var r1b6 = b * f; + var r1c1 = c * a; //ok var r1c2 = c * b; var r1c3 = c * c; //ok var r1c4 = c * d; var r1c5 = c * e; var r1c6 = c * f; + var r1d1 = d * a; var r1d2 = d * b; var r1d3 = d * c; var r1d4 = d * d; var r1d5 = d * e; var r1d6 = d * f; + var r1e1 = e * a; var r1e2 = e * b; var r1e3 = e * c; var r1e4 = e * d; var r1e5 = e * e; var r1e6 = e * f; + var r1f1 = f * a; var r1f2 = f * b; var r1f3 = f * c; var r1f4 = f * d; var r1f5 = f * e; var r1f6 = f * f; + var r1g1 = E.a * a; //ok var r1g2 = E.a * b; var r1g3 = E.a * c; //ok var r1g4 = E.a * d; var r1g5 = E.a * e; var r1g6 = E.a * f; + var r1h1 = a * E.b; //ok var r1h2 = b * E.b; var r1h3 = c * E.b; //ok var r1h4 = d * E.b; var r1h5 = e * E.b; var r1h6 = f * E.b; + // operator / var r2a1 = a / a; //ok var r2a2 = a / b; @@ -653,48 +662,56 @@ var r2a3 = a / c; //ok var r2a4 = a / d; var r2a5 = a / e; var r2a6 = a / f; + var r2b1 = b / a; var r2b2 = b / b; var r2b3 = b / c; var r2b4 = b / d; var r2b5 = b / e; var r2b6 = b / f; + var r2c1 = c / a; //ok var r2c2 = c / b; var r2c3 = c / c; //ok var r2c4 = c / d; var r2c5 = c / e; var r2c6 = c / f; + var r2d1 = d / a; var r2d2 = d / b; var r2d3 = d / c; var r2d4 = d / d; var r2d5 = d / e; var r2d6 = d / f; + var r2e1 = e / a; var r2e2 = e / b; var r2e3 = e / c; var r2e4 = e / d; var r2e5 = e / e; var r2e6 = e / f; + var r2f1 = f / a; var r2f2 = f / b; var r2f3 = f / c; var r2f4 = f / d; var r2f5 = f / e; var r2f6 = f / f; + var r2g1 = E.a / a; //ok var r2g2 = E.a / b; var r2g3 = E.a / c; //ok var r2g4 = E.a / d; var r2g5 = E.a / e; var r2g6 = E.a / f; + var r2h1 = a / E.b; //ok var r2h2 = b / E.b; var r2h3 = c / E.b; //ok var r2h4 = d / E.b; var r2h5 = e / E.b; var r2h6 = f / E.b; + // operator % var r3a1 = a % a; //ok var r3a2 = a % b; @@ -702,48 +719,56 @@ var r3a3 = a % c; //ok var r3a4 = a % d; var r3a5 = a % e; var r3a6 = a % f; + var r3b1 = b % a; var r3b2 = b % b; var r3b3 = b % c; var r3b4 = b % d; var r3b5 = b % e; var r3b6 = b % f; + var r3c1 = c % a; //ok var r3c2 = c % b; var r3c3 = c % c; //ok var r3c4 = c % d; var r3c5 = c % e; var r3c6 = c % f; + var r3d1 = d % a; var r3d2 = d % b; var r3d3 = d % c; var r3d4 = d % d; var r3d5 = d % e; var r3d6 = d % f; + var r3e1 = e % a; var r3e2 = e % b; var r3e3 = e % c; var r3e4 = e % d; var r3e5 = e % e; var r3e6 = e % f; + var r3f1 = f % a; var r3f2 = f % b; var r3f3 = f % c; var r3f4 = f % d; var r3f5 = f % e; var r3f6 = f % f; + var r3g1 = E.a % a; //ok var r3g2 = E.a % b; var r3g3 = E.a % c; //ok var r3g4 = E.a % d; var r3g5 = E.a % e; var r3g6 = E.a % f; + var r3h1 = a % E.b; //ok var r3h2 = b % E.b; var r3h3 = c % E.b; //ok var r3h4 = d % E.b; var r3h5 = e % E.b; var r3h6 = f % E.b; + // operator - var r4a1 = a - a; //ok var r4a2 = a - b; @@ -751,48 +776,56 @@ var r4a3 = a - c; //ok var r4a4 = a - d; var r4a5 = a - e; var r4a6 = a - f; + var r4b1 = b - a; var r4b2 = b - b; var r4b3 = b - c; var r4b4 = b - d; var r4b5 = b - e; var r4b6 = b - f; + var r4c1 = c - a; //ok var r4c2 = c - b; var r4c3 = c - c; //ok var r4c4 = c - d; var r4c5 = c - e; var r4c6 = c - f; + var r4d1 = d - a; var r4d2 = d - b; var r4d3 = d - c; var r4d4 = d - d; var r4d5 = d - e; var r4d6 = d - f; + var r4e1 = e - a; var r4e2 = e - b; var r4e3 = e - c; var r4e4 = e - d; var r4e5 = e - e; var r4e6 = e - f; + var r4f1 = f - a; var r4f2 = f - b; var r4f3 = f - c; var r4f4 = f - d; var r4f5 = f - e; var r4f6 = f - f; + var r4g1 = E.a - a; //ok var r4g2 = E.a - b; var r4g3 = E.a - c; //ok var r4g4 = E.a - d; var r4g5 = E.a - e; var r4g6 = E.a - f; + var r4h1 = a - E.b; //ok var r4h2 = b - E.b; var r4h3 = c - E.b; //ok var r4h4 = d - E.b; var r4h5 = e - E.b; var r4h6 = f - E.b; + // operator << var r5a1 = a << a; //ok var r5a2 = a << b; @@ -800,48 +833,56 @@ var r5a3 = a << c; //ok var r5a4 = a << d; var r5a5 = a << e; var r5a6 = a << f; + var r5b1 = b << a; var r5b2 = b << b; var r5b3 = b << c; var r5b4 = b << d; var r5b5 = b << e; var r5b6 = b << f; + var r5c1 = c << a; //ok var r5c2 = c << b; var r5c3 = c << c; //ok var r5c4 = c << d; var r5c5 = c << e; var r5c6 = c << f; + var r5d1 = d << a; var r5d2 = d << b; var r5d3 = d << c; var r5d4 = d << d; var r5d5 = d << e; var r5d6 = d << f; + var r5e1 = e << a; var r5e2 = e << b; var r5e3 = e << c; var r5e4 = e << d; var r5e5 = e << e; var r5e6 = e << f; + var r5f1 = f << a; var r5f2 = f << b; var r5f3 = f << c; var r5f4 = f << d; var r5f5 = f << e; var r5f6 = f << f; + var r5g1 = E.a << a; //ok var r5g2 = E.a << b; var r5g3 = E.a << c; //ok var r5g4 = E.a << d; var r5g5 = E.a << e; var r5g6 = E.a << f; + var r5h1 = a << E.b; //ok var r5h2 = b << E.b; var r5h3 = c << E.b; //ok var r5h4 = d << E.b; var r5h5 = e << E.b; var r5h6 = f << E.b; + // operator >> var r6a1 = a >> a; //ok var r6a2 = a >> b; @@ -849,48 +890,56 @@ var r6a3 = a >> c; //ok var r6a4 = a >> d; var r6a5 = a >> e; var r6a6 = a >> f; + var r6b1 = b >> a; var r6b2 = b >> b; var r6b3 = b >> c; var r6b4 = b >> d; var r6b5 = b >> e; var r6b6 = b >> f; + var r6c1 = c >> a; //ok var r6c2 = c >> b; var r6c3 = c >> c; //ok var r6c4 = c >> d; var r6c5 = c >> e; var r6c6 = c >> f; + var r6d1 = d >> a; var r6d2 = d >> b; var r6d3 = d >> c; var r6d4 = d >> d; var r6d5 = d >> e; var r6d6 = d >> f; + var r6e1 = e >> a; var r6e2 = e >> b; var r6e3 = e >> c; var r6e4 = e >> d; var r6e5 = e >> e; var r6e6 = e >> f; + var r6f1 = f >> a; var r6f2 = f >> b; var r6f3 = f >> c; var r6f4 = f >> d; var r6f5 = f >> e; var r6f6 = f >> f; + var r6g1 = E.a >> a; //ok var r6g2 = E.a >> b; var r6g3 = E.a >> c; //ok var r6g4 = E.a >> d; var r6g5 = E.a >> e; var r6g6 = E.a >> f; + var r6h1 = a >> E.b; //ok var r6h2 = b >> E.b; var r6h3 = c >> E.b; //ok var r6h4 = d >> E.b; var r6h5 = e >> E.b; var r6h6 = f >> E.b; + // operator >>> var r7a1 = a >>> a; //ok var r7a2 = a >>> b; @@ -898,48 +947,56 @@ var r7a3 = a >>> c; //ok var r7a4 = a >>> d; var r7a5 = a >>> e; var r7a6 = a >>> f; + var r7b1 = b >>> a; var r7b2 = b >>> b; var r7b3 = b >>> c; var r7b4 = b >>> d; var r7b5 = b >>> e; var r7b6 = b >>> f; + var r7c1 = c >>> a; //ok var r7c2 = c >>> b; var r7c3 = c >>> c; //ok var r7c4 = c >>> d; var r7c5 = c >>> e; var r7c6 = c >>> f; + var r7d1 = d >>> a; var r7d2 = d >>> b; var r7d3 = d >>> c; var r7d4 = d >>> d; var r7d5 = d >>> e; var r7d6 = d >>> f; + var r7e1 = e >>> a; var r7e2 = e >>> b; var r7e3 = e >>> c; var r7e4 = e >>> d; var r7e5 = e >>> e; var r7e6 = e >>> f; + var r7f1 = f >>> a; var r7f2 = f >>> b; var r7f3 = f >>> c; var r7f4 = f >>> d; var r7f5 = f >>> e; var r7f6 = f >>> f; + var r7g1 = E.a >>> a; //ok var r7g2 = E.a >>> b; var r7g3 = E.a >>> c; //ok var r7g4 = E.a >>> d; var r7g5 = E.a >>> e; var r7g6 = E.a >>> f; + var r7h1 = a >>> E.b; //ok var r7h2 = b >>> E.b; var r7h3 = c >>> E.b; //ok var r7h4 = d >>> E.b; var r7h5 = e >>> E.b; var r7h6 = f >>> E.b; + // operator & var r8a1 = a & a; //ok var r8a2 = a & b; @@ -947,48 +1004,56 @@ var r8a3 = a & c; //ok var r8a4 = a & d; var r8a5 = a & e; var r8a6 = a & f; + var r8b1 = b & a; var r8b2 = b & b; var r8b3 = b & c; var r8b4 = b & d; var r8b5 = b & e; var r8b6 = b & f; + var r8c1 = c & a; //ok var r8c2 = c & b; var r8c3 = c & c; //ok var r8c4 = c & d; var r8c5 = c & e; var r8c6 = c & f; + var r8d1 = d & a; var r8d2 = d & b; var r8d3 = d & c; var r8d4 = d & d; var r8d5 = d & e; var r8d6 = d & f; + var r8e1 = e & a; var r8e2 = e & b; var r8e3 = e & c; var r8e4 = e & d; var r8e5 = e & e; var r8e6 = e & f; + var r8f1 = f & a; var r8f2 = f & b; var r8f3 = f & c; var r8f4 = f & d; var r8f5 = f & e; var r8f6 = f & f; + var r8g1 = E.a & a; //ok var r8g2 = E.a & b; var r8g3 = E.a & c; //ok var r8g4 = E.a & d; var r8g5 = E.a & e; var r8g6 = E.a & f; + var r8h1 = a & E.b; //ok var r8h2 = b & E.b; var r8h3 = c & E.b; //ok var r8h4 = d & E.b; var r8h5 = e & E.b; var r8h6 = f & E.b; + // operator ^ var r9a1 = a ^ a; //ok var r9a2 = a ^ b; @@ -996,48 +1061,56 @@ var r9a3 = a ^ c; //ok var r9a4 = a ^ d; var r9a5 = a ^ e; var r9a6 = a ^ f; + var r9b1 = b ^ a; var r9b2 = b ^ b; var r9b3 = b ^ c; var r9b4 = b ^ d; var r9b5 = b ^ e; var r9b6 = b ^ f; + var r9c1 = c ^ a; //ok var r9c2 = c ^ b; var r9c3 = c ^ c; //ok var r9c4 = c ^ d; var r9c5 = c ^ e; var r9c6 = c ^ f; + var r9d1 = d ^ a; var r9d2 = d ^ b; var r9d3 = d ^ c; var r9d4 = d ^ d; var r9d5 = d ^ e; var r9d6 = d ^ f; + var r9e1 = e ^ a; var r9e2 = e ^ b; var r9e3 = e ^ c; var r9e4 = e ^ d; var r9e5 = e ^ e; var r9e6 = e ^ f; + var r9f1 = f ^ a; var r9f2 = f ^ b; var r9f3 = f ^ c; var r9f4 = f ^ d; var r9f5 = f ^ e; var r9f6 = f ^ f; + var r9g1 = E.a ^ a; //ok var r9g2 = E.a ^ b; var r9g3 = E.a ^ c; //ok var r9g4 = E.a ^ d; var r9g5 = E.a ^ e; var r9g6 = E.a ^ f; + var r9h1 = a ^ E.b; //ok var r9h2 = b ^ E.b; var r9h3 = c ^ E.b; //ok var r9h4 = d ^ E.b; var r9h5 = e ^ E.b; var r9h6 = f ^ E.b; + // operator | var r10a1 = a | a; //ok var r10a2 = a | b; @@ -1045,42 +1118,49 @@ var r10a3 = a | c; //ok var r10a4 = a | d; var r10a5 = a | e; var r10a6 = a | f; + var r10b1 = b | a; var r10b2 = b | b; var r10b3 = b | c; var r10b4 = b | d; var r10b5 = b | e; var r10b6 = b | f; + var r10c1 = c | a; //ok var r10c2 = c | b; var r10c3 = c | c; //ok var r10c4 = c | d; var r10c5 = c | e; var r10c6 = c | f; + var r10d1 = d | a; var r10d2 = d | b; var r10d3 = d | c; var r10d4 = d | d; var r10d5 = d | e; var r10d6 = d | f; + var r10e1 = e | a; var r10e2 = e | b; var r10e3 = e | c; var r10e4 = e | d; var r10e5 = e | e; var r10e6 = e | f; + var r10f1 = f | a; var r10f2 = f | b; var r10f3 = f | c; var r10f4 = f | d; var r10f5 = f | e; var r10f6 = f | f; + var r10g1 = E.a | a; //ok var r10g2 = E.a | b; var r10g3 = E.a | c; //ok var r10g4 = E.a | d; var r10g5 = E.a | e; var r10g6 = E.a | f; + var r10h1 = a | E.b; //ok var r10h2 = b | E.b; var r10h3 = c | E.b; //ok diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.js b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.js index b277abb668d86..a46b8f3af3cd3 100644 --- a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.js +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.js @@ -179,136 +179,177 @@ var r10d3 = {} | null; //// [arithmeticOperatorWithNullValueAndInvalidOperands.js] // If one operand is the null or undefined value, it is treated as having the type of the // other operand. + var a; var b; var c; + // operator * var r1a1 = null * a; var r1a2 = null * b; var r1a3 = null * c; + var r1b1 = a * null; var r1b2 = b * null; var r1b3 = c * null; + var r1c1 = null * true; var r1c2 = null * ''; var r1c3 = null * {}; + var r1d1 = true * null; var r1d2 = '' * null; var r1d3 = {} * null; + // operator / var r2a1 = null / a; var r2a2 = null / b; var r2a3 = null / c; + var r2b1 = a / null; var r2b2 = b / null; var r2b3 = c / null; + var r2c1 = null / true; var r2c2 = null / ''; var r2c3 = null / {}; + var r2d1 = true / null; var r2d2 = '' / null; var r2d3 = {} / null; + // operator % var r3a1 = null % a; var r3a2 = null % b; var r3a3 = null % c; + var r3b1 = a % null; var r3b2 = b % null; var r3b3 = c % null; + var r3c1 = null % true; var r3c2 = null % ''; var r3c3 = null % {}; + var r3d1 = true % null; var r3d2 = '' % null; var r3d3 = {} % null; + // operator - var r4a1 = null - a; var r4a2 = null - b; var r4a3 = null - c; + var r4b1 = a - null; var r4b2 = b - null; var r4b3 = c - null; + var r4c1 = null - true; var r4c2 = null - ''; var r4c3 = null - {}; + var r4d1 = true - null; var r4d2 = '' - null; var r4d3 = {} - null; + // operator << var r5a1 = null << a; var r5a2 = null << b; var r5a3 = null << c; + var r5b1 = a << null; var r5b2 = b << null; var r5b3 = c << null; + var r5c1 = null << true; var r5c2 = null << ''; var r5c3 = null << {}; + var r5d1 = true << null; var r5d2 = '' << null; var r5d3 = {} << null; + // operator >> var r6a1 = null >> a; var r6a2 = null >> b; var r6a3 = null >> c; + var r6b1 = a >> null; var r6b2 = b >> null; var r6b3 = c >> null; + var r6c1 = null >> true; var r6c2 = null >> ''; var r6c3 = null >> {}; + var r6d1 = true >> null; var r6d2 = '' >> null; var r6d3 = {} >> null; + // operator >>> var r7a1 = null >>> a; var r7a2 = null >>> b; var r7a3 = null >>> c; + var r7b1 = a >>> null; var r7b2 = b >>> null; var r7b3 = c >>> null; + var r7c1 = null >>> true; var r7c2 = null >>> ''; var r7c3 = null >>> {}; + var r7d1 = true >>> null; var r7d2 = '' >>> null; var r7d3 = {} >>> null; + // operator & var r8a1 = null & a; var r8a2 = null & b; var r8a3 = null & c; + var r8b1 = a & null; var r8b2 = b & null; var r8b3 = c & null; + var r8c1 = null & true; var r8c2 = null & ''; var r8c3 = null & {}; + var r8d1 = true & null; var r8d2 = '' & null; var r8d3 = {} & null; + // operator ^ var r9a1 = null ^ a; var r9a2 = null ^ b; var r9a3 = null ^ c; + var r9b1 = a ^ null; var r9b2 = b ^ null; var r9b3 = c ^ null; + var r9c1 = null ^ true; var r9c2 = null ^ ''; var r9c3 = null ^ {}; + var r9d1 = true ^ null; var r9d2 = '' ^ null; var r9d3 = {} ^ null; + // operator | var r10a1 = null | a; var r10a2 = null | b; var r10a3 = null | c; + var r10b1 = a | null; var r10b2 = b | null; var r10b3 = c | null; + var r10c1 = null | true; var r10c2 = null | ''; var r10c3 = null | {}; + var r10d1 = true | null; var r10d2 = '' | null; var r10d3 = {} | null; diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.js b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.js index 0c30e8d048492..189ea74239c38 100644 --- a/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.js +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.js @@ -120,6 +120,7 @@ var E; })(E || (E = {})); var a; var b; + // operator * var ra1 = null * a; var ra2 = null * b; @@ -129,6 +130,7 @@ var ra5 = a * null; var ra6 = b * null; var ra7 = 0 * null; var ra8 = E.b * null; + // operator / var rb1 = null / a; var rb2 = null / b; @@ -138,6 +140,7 @@ var rb5 = a / null; var rb6 = b / null; var rb7 = 0 / null; var rb8 = E.b / null; + // operator % var rc1 = null % a; var rc2 = null % b; @@ -147,6 +150,7 @@ var rc5 = a % null; var rc6 = b % null; var rc7 = 0 % null; var rc8 = E.b % null; + // operator - var rd1 = null - a; var rd2 = null - b; @@ -156,6 +160,7 @@ var rd5 = a - null; var rd6 = b - null; var rd7 = 0 - null; var rd8 = E.b - null; + // operator << var re1 = null << a; var re2 = null << b; @@ -165,6 +170,7 @@ var re5 = a << null; var re6 = b << null; var re7 = 0 << null; var re8 = E.b << null; + // operator >> var rf1 = null >> a; var rf2 = null >> b; @@ -174,6 +180,7 @@ var rf5 = a >> null; var rf6 = b >> null; var rf7 = 0 >> null; var rf8 = E.b >> null; + // operator >>> var rg1 = null >>> a; var rg2 = null >>> b; @@ -183,6 +190,7 @@ var rg5 = a >>> null; var rg6 = b >>> null; var rg7 = 0 >>> null; var rg8 = E.b >>> null; + // operator & var rh1 = null & a; var rh2 = null & b; @@ -192,6 +200,7 @@ var rh5 = a & null; var rh6 = b & null; var rh7 = 0 & null; var rh8 = E.b & null; + // operator ^ var ri1 = null ^ a; var ri2 = null ^ b; @@ -201,6 +210,7 @@ var ri5 = a ^ null; var ri6 = b ^ null; var ri7 = 0 ^ null; var ri8 = E.b ^ null; + // operator | var rj1 = null | a; var rj2 = null | b; diff --git a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.js b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.js index f1421a6b5c974..82e1428b5c3d6 100644 --- a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.js +++ b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.js @@ -65,46 +65,55 @@ var ra1 = null * null; var ra2 = null * undefined; var ra3 = undefined * null; var ra4 = undefined * undefined; + // operator / var rb1 = null / null; var rb2 = null / undefined; var rb3 = undefined / null; var rb4 = undefined / undefined; + // operator % var rc1 = null % null; var rc2 = null % undefined; var rc3 = undefined % null; var rc4 = undefined % undefined; + // operator - var rd1 = null - null; var rd2 = null - undefined; var rd3 = undefined - null; var rd4 = undefined - undefined; + // operator << var re1 = null << null; var re2 = null << undefined; var re3 = undefined << null; var re4 = undefined << undefined; + // operator >> var rf1 = null >> null; var rf2 = null >> undefined; var rf3 = undefined >> null; var rf4 = undefined >> undefined; + // operator >>> var rg1 = null >>> null; var rg2 = null >>> undefined; var rg3 = undefined >>> null; var rg4 = undefined >>> undefined; + // operator & var rh1 = null & null; var rh2 = null & undefined; var rh3 = undefined & null; var rh4 = undefined & undefined; + // operator ^ var ri1 = null ^ null; var ri2 = null ^ undefined; var ri3 = undefined ^ null; var ri4 = undefined ^ undefined; + // operator | var rj1 = null | null; var rj2 = null | undefined; diff --git a/tests/baselines/reference/arithmeticOperatorWithTypeParameter.js b/tests/baselines/reference/arithmeticOperatorWithTypeParameter.js index 94475b88fd807..2eab1642247cd 100644 --- a/tests/baselines/reference/arithmeticOperatorWithTypeParameter.js +++ b/tests/baselines/reference/arithmeticOperatorWithTypeParameter.js @@ -137,6 +137,7 @@ function foo(t) { var c; var d; var e; + var r1a1 = a * t; var r1a2 = a / t; var r1a3 = a % t; @@ -147,6 +148,7 @@ function foo(t) { var r1a8 = a & t; var r1a9 = a ^ t; var r1a10 = a | t; + var r2a1 = t * a; var r2a2 = t / a; var r2a3 = t % a; @@ -157,6 +159,7 @@ function foo(t) { var r2a8 = t & a; var r2a9 = t ^ a; var r2a10 = t | a; + var r1b1 = b * t; var r1b2 = b / t; var r1b3 = b % t; @@ -167,6 +170,7 @@ function foo(t) { var r1b8 = b & t; var r1b9 = b ^ t; var r1b10 = b | t; + var r2b1 = t * b; var r2b2 = t / b; var r2b3 = t % b; @@ -177,6 +181,7 @@ function foo(t) { var r2b8 = t & b; var r2b9 = t ^ b; var r2b10 = t | b; + var r1c1 = c * t; var r1c2 = c / t; var r1c3 = c % t; @@ -187,6 +192,7 @@ function foo(t) { var r1c8 = c & t; var r1c9 = c ^ t; var r1c10 = c | t; + var r2c1 = t * c; var r2c2 = t / c; var r2c3 = t % c; @@ -197,6 +203,7 @@ function foo(t) { var r2c8 = t & c; var r2c9 = t ^ c; var r2c10 = t | c; + var r1d1 = d * t; var r1d2 = d / t; var r1d3 = d % t; @@ -207,6 +214,7 @@ function foo(t) { var r1d8 = d & t; var r1d9 = d ^ t; var r1d10 = d | t; + var r2d1 = t * d; var r2d2 = t / d; var r2d3 = t % d; @@ -217,6 +225,7 @@ function foo(t) { var r2d8 = t & d; var r2d9 = t ^ d; var r2d10 = t | d; + var r1e1 = e * t; var r1e2 = e / t; var r1e3 = e % t; @@ -227,6 +236,7 @@ function foo(t) { var r1e8 = e & t; var r1e9 = e ^ t; var r1e10 = e | t; + var r2e1 = t * e; var r2e2 = t / e; var r2e3 = t % e; @@ -237,6 +247,7 @@ function foo(t) { var r2e8 = t & e; var r2e9 = t ^ e; var r2e10 = t | e; + var r1f1 = t * t; var r1f2 = t / t; var r1f3 = t % t; diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.js b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.js index b64c2d9dc0945..079fa71013eaf 100644 --- a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.js +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.js @@ -179,136 +179,177 @@ var r10d3 = {} | undefined; //// [arithmeticOperatorWithUndefinedValueAndInvalidOperands.js] // If one operand is the undefined or undefined value, it is treated as having the type of the // other operand. + var a; var b; var c; + // operator * var r1a1 = undefined * a; var r1a2 = undefined * b; var r1a3 = undefined * c; + var r1b1 = a * undefined; var r1b2 = b * undefined; var r1b3 = c * undefined; + var r1c1 = undefined * true; var r1c2 = undefined * ''; var r1c3 = undefined * {}; + var r1d1 = true * undefined; var r1d2 = '' * undefined; var r1d3 = {} * undefined; + // operator / var r2a1 = undefined / a; var r2a2 = undefined / b; var r2a3 = undefined / c; + var r2b1 = a / undefined; var r2b2 = b / undefined; var r2b3 = c / undefined; + var r2c1 = undefined / true; var r2c2 = undefined / ''; var r2c3 = undefined / {}; + var r2d1 = true / undefined; var r2d2 = '' / undefined; var r2d3 = {} / undefined; + // operator % var r3a1 = undefined % a; var r3a2 = undefined % b; var r3a3 = undefined % c; + var r3b1 = a % undefined; var r3b2 = b % undefined; var r3b3 = c % undefined; + var r3c1 = undefined % true; var r3c2 = undefined % ''; var r3c3 = undefined % {}; + var r3d1 = true % undefined; var r3d2 = '' % undefined; var r3d3 = {} % undefined; + // operator - var r4a1 = undefined - a; var r4a2 = undefined - b; var r4a3 = undefined - c; + var r4b1 = a - undefined; var r4b2 = b - undefined; var r4b3 = c - undefined; + var r4c1 = undefined - true; var r4c2 = undefined - ''; var r4c3 = undefined - {}; + var r4d1 = true - undefined; var r4d2 = '' - undefined; var r4d3 = {} - undefined; + // operator << var r5a1 = undefined << a; var r5a2 = undefined << b; var r5a3 = undefined << c; + var r5b1 = a << undefined; var r5b2 = b << undefined; var r5b3 = c << undefined; + var r5c1 = undefined << true; var r5c2 = undefined << ''; var r5c3 = undefined << {}; + var r5d1 = true << undefined; var r5d2 = '' << undefined; var r5d3 = {} << undefined; + // operator >> var r6a1 = undefined >> a; var r6a2 = undefined >> b; var r6a3 = undefined >> c; + var r6b1 = a >> undefined; var r6b2 = b >> undefined; var r6b3 = c >> undefined; + var r6c1 = undefined >> true; var r6c2 = undefined >> ''; var r6c3 = undefined >> {}; + var r6d1 = true >> undefined; var r6d2 = '' >> undefined; var r6d3 = {} >> undefined; + // operator >>> var r7a1 = undefined >>> a; var r7a2 = undefined >>> b; var r7a3 = undefined >>> c; + var r7b1 = a >>> undefined; var r7b2 = b >>> undefined; var r7b3 = c >>> undefined; + var r7c1 = undefined >>> true; var r7c2 = undefined >>> ''; var r7c3 = undefined >>> {}; + var r7d1 = true >>> undefined; var r7d2 = '' >>> undefined; var r7d3 = {} >>> undefined; + // operator & var r8a1 = undefined & a; var r8a2 = undefined & b; var r8a3 = undefined & c; + var r8b1 = a & undefined; var r8b2 = b & undefined; var r8b3 = c & undefined; + var r8c1 = undefined & true; var r8c2 = undefined & ''; var r8c3 = undefined & {}; + var r8d1 = true & undefined; var r8d2 = '' & undefined; var r8d3 = {} & undefined; + // operator ^ var r9a1 = undefined ^ a; var r9a2 = undefined ^ b; var r9a3 = undefined ^ c; + var r9b1 = a ^ undefined; var r9b2 = b ^ undefined; var r9b3 = c ^ undefined; + var r9c1 = undefined ^ true; var r9c2 = undefined ^ ''; var r9c3 = undefined ^ {}; + var r9d1 = true ^ undefined; var r9d2 = '' ^ undefined; var r9d3 = {} ^ undefined; + // operator | var r10a1 = undefined | a; var r10a2 = undefined | b; var r10a3 = undefined | c; + var r10b1 = a | undefined; var r10b2 = b | undefined; var r10b3 = c | undefined; + var r10c1 = undefined | true; var r10c2 = undefined | ''; var r10c3 = undefined | {}; + var r10d1 = true | undefined; var r10d2 = '' | undefined; var r10d3 = {} | undefined; diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.js b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.js index 60ea9af32c2b5..bf297e7bddd58 100644 --- a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.js +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.js @@ -120,6 +120,7 @@ var E; })(E || (E = {})); var a; var b; + // operator * var ra1 = undefined * a; var ra2 = undefined * b; @@ -129,6 +130,7 @@ var ra5 = a * undefined; var ra6 = b * undefined; var ra7 = 0 * undefined; var ra8 = E.b * undefined; + // operator / var rb1 = undefined / a; var rb2 = undefined / b; @@ -138,6 +140,7 @@ var rb5 = a / undefined; var rb6 = b / undefined; var rb7 = 0 / undefined; var rb8 = E.b / undefined; + // operator % var rc1 = undefined % a; var rc2 = undefined % b; @@ -147,6 +150,7 @@ var rc5 = a % undefined; var rc6 = b % undefined; var rc7 = 0 % undefined; var rc8 = E.b % undefined; + // operator - var rd1 = undefined - a; var rd2 = undefined - b; @@ -156,6 +160,7 @@ var rd5 = a - undefined; var rd6 = b - undefined; var rd7 = 0 - undefined; var rd8 = E.b - undefined; + // operator << var re1 = undefined << a; var re2 = undefined << b; @@ -165,6 +170,7 @@ var re5 = a << undefined; var re6 = b << undefined; var re7 = 0 << undefined; var re8 = E.b << undefined; + // operator >> var rf1 = undefined >> a; var rf2 = undefined >> b; @@ -174,6 +180,7 @@ var rf5 = a >> undefined; var rf6 = b >> undefined; var rf7 = 0 >> undefined; var rf8 = E.b >> undefined; + // operator >>> var rg1 = undefined >>> a; var rg2 = undefined >>> b; @@ -183,6 +190,7 @@ var rg5 = a >>> undefined; var rg6 = b >>> undefined; var rg7 = 0 >>> undefined; var rg8 = E.b >>> undefined; + // operator & var rh1 = undefined & a; var rh2 = undefined & b; @@ -192,6 +200,7 @@ var rh5 = a & undefined; var rh6 = b & undefined; var rh7 = 0 & undefined; var rh8 = E.b & undefined; + // operator ^ var ri1 = undefined ^ a; var ri2 = undefined ^ b; @@ -201,6 +210,7 @@ var ri5 = a ^ undefined; var ri6 = b ^ undefined; var ri7 = 0 ^ undefined; var ri8 = E.b ^ undefined; + // operator | var rj1 = undefined | a; var rj2 = undefined | b; diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.js b/tests/baselines/reference/arityAndOrderCompatibility01.js index bf7736a80c997..2e3079e659fce 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.js +++ b/tests/baselines/reference/arityAndOrderCompatibility01.js @@ -37,9 +37,11 @@ var o3: [string, number] = y; //// [arityAndOrderCompatibility01.js] + var x; var y; var z; + var a = x[0], b = x[1], c = x[2]; var d = y[0], e = y[1], f = y[2]; var g = z[0], h = z[1], i = z[2]; diff --git a/tests/baselines/reference/arityErrorRelatedSpanBindingPattern.js b/tests/baselines/reference/arityErrorRelatedSpanBindingPattern.js index 66f9316457d12..c8c2c51f7176c 100644 --- a/tests/baselines/reference/arityErrorRelatedSpanBindingPattern.js +++ b/tests/baselines/reference/arityErrorRelatedSpanBindingPattern.js @@ -12,8 +12,11 @@ bar("", 0); function foo(a, b, _a) { var c = _a.c; } + function bar(a, b, _a) { var c = _a[0]; } + foo("", 0); + bar("", 0); diff --git a/tests/baselines/reference/arrayAssignmentTest1.js b/tests/baselines/reference/arrayAssignmentTest1.js index baf1e8bfa3a40..129994d8120af 100644 --- a/tests/baselines/reference/arrayAssignmentTest1.js +++ b/tests/baselines/reference/arrayAssignmentTest1.js @@ -99,6 +99,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var C1 = /** @class */ (function () { function C1() { } @@ -138,6 +139,7 @@ var c2 = new C2(); var c3 = new C3(); var o1 = { one: 1 }; var f1 = function () { return new C1(); }; + var arr_any = []; var arr_i1 = []; var arr_c1 = []; @@ -146,32 +148,43 @@ var arr_i1_2 = []; var arr_c1_2 = []; var arr_c2_2 = []; var arr_c3 = []; + var i1_error = []; // should be an error - is var c1_error = []; // should be an error - is var c2_error = []; // should be an error - is var c3_error = []; // should be an error - is + + arr_any = arr_i1; // should be ok - is arr_any = arr_c1; // should be ok - is arr_any = arr_c2; // should be ok - is arr_any = arr_c3; // should be ok - is + arr_i1 = arr_i1; // should be ok - subtype relationship - is arr_i1 = arr_c1; // should be ok - subtype relationship - is arr_i1 = arr_c2; // should be ok - subtype relationship - is arr_i1 = arr_c3; // should be an error - is + arr_c1 = arr_c1; // should be ok - subtype relationship - is arr_c1 = arr_c2; // should be ok - subtype relationship - is arr_c1 = arr_i1; // should be an error - is arr_c1 = arr_c3; // should be an error - is + arr_c2 = arr_c2; // should be ok - subtype relationship - is arr_c2 = arr_c1; // should be an error - subtype relationship - is arr_c2 = arr_i1; // should be an error - subtype relationship - is arr_c2 = arr_c3; // should be an error - is + + + + // "clean up bug" occurs at this point // if you move these three expressions to another file, they raise an error // something to do with state from the above propagating forward? arr_c3 = arr_c2_2; // should be an error - is arr_c3 = arr_c1_2; // should be an error - is arr_c3 = arr_i1_2; // should be an error - is + arr_any = f1; // should be an error - is arr_any = o1; // should be an error - is arr_any = a1; // should be ok - is diff --git a/tests/baselines/reference/arrayAssignmentTest2.js b/tests/baselines/reference/arrayAssignmentTest2.js index 5b1a655d781f2..06bb238aa6334 100644 --- a/tests/baselines/reference/arrayAssignmentTest2.js +++ b/tests/baselines/reference/arrayAssignmentTest2.js @@ -73,6 +73,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var C1 = /** @class */ (function () { function C1() { } @@ -112,6 +113,7 @@ var c2 = new C2(); var c3 = new C3(); var o1 = { one: 1 }; var f1 = function () { return new C1(); }; + var arr_any = []; var arr_i1 = []; var arr_c1 = []; @@ -120,10 +122,12 @@ var arr_i1_2 = []; var arr_c1_2 = []; var arr_c2_2 = []; var arr_c3 = []; + // "clean up error" occurs at this point arr_c3 = arr_c2_2; // should be an error - is arr_c3 = arr_c1_2; // should be an error - is arr_c3 = arr_i1_2; // should be an error - is + arr_any = f1; // should be an error - is arr_any = function () { return null; }; // should be an error - is arr_any = o1; // should be an error - is diff --git a/tests/baselines/reference/arrayAssignmentTest3.js b/tests/baselines/reference/arrayAssignmentTest3.js index 965da445a2ba8..8565f37fa117f 100644 --- a/tests/baselines/reference/arrayAssignmentTest3.js +++ b/tests/baselines/reference/arrayAssignmentTest3.js @@ -19,8 +19,7 @@ var xx = new a(null, 7, new B()); // Michal saw no error if he used number instead of B, // but I do... var B = /** @class */ (function () { - function B() { - } + function B() {} return B; }()); var a = /** @class */ (function () { @@ -31,3 +30,4 @@ var a = /** @class */ (function () { return a; }()); var xx = new a(null, 7, new B()); + diff --git a/tests/baselines/reference/arrayAssignmentTest4.js b/tests/baselines/reference/arrayAssignmentTest4.js index da900089c9d1a..6fffd71cbef02 100644 --- a/tests/baselines/reference/arrayAssignmentTest4.js +++ b/tests/baselines/reference/arrayAssignmentTest4.js @@ -44,6 +44,8 @@ Type 1 of any[]: */ var c3 = new C3(); var o1 = { one: 1 }; + var arr_any = []; + arr_any = function () { return null; }; // should be an error - is arr_any = c3; // should be an error - is diff --git a/tests/baselines/reference/arrayAugment.js b/tests/baselines/reference/arrayAugment.js index 20cf510712a92..67834d8a426e0 100644 --- a/tests/baselines/reference/arrayAugment.js +++ b/tests/baselines/reference/arrayAugment.js @@ -9,6 +9,7 @@ var y: string[][]; // Expect no error here //// [arrayAugment.js] + var x = ['']; var y = x.split(4); var y; // Expect no error here diff --git a/tests/baselines/reference/arrayBestCommonTypes.js b/tests/baselines/reference/arrayBestCommonTypes.js index 7b8da4f797073..eb9131cd81edd 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.js +++ b/tests/baselines/reference/arrayBestCommonTypes.js @@ -124,13 +124,11 @@ var __extends = (this && this.__extends) || (function () { var EmptyTypes; (function (EmptyTypes) { var base = /** @class */ (function () { - function base() { - } + function base() {} return base; }()); var base2 = /** @class */ (function () { - function base2() { - } + function base2() {} return base2; }()); var derived = /** @class */ (function (_super) { @@ -143,10 +141,10 @@ var EmptyTypes; var f = /** @class */ (function () { function f() { } - f.prototype.voidIfAny = function (x, y) { - if (y === void 0) { y = false; } + f.prototype.voidIfAny = function (x, y) {if (y === void 0) { y = false; } return null; }; + f.prototype.x = function () { (this.voidIfAny([4, 2][0])); (this.voidIfAny([4, 2, undefined][0])); @@ -154,24 +152,31 @@ var EmptyTypes; (this.voidIfAny([null, 2, 4][0])); (this.voidIfAny([2, 4, null][0])); (this.voidIfAny([undefined, 4, null][0])); + (this.voidIfAny(['', "q"][0])); (this.voidIfAny(['', "q", undefined][0])); (this.voidIfAny([undefined, "q", ''][0])); (this.voidIfAny([null, "q", ''][0])); (this.voidIfAny(["q", '', null][0])); (this.voidIfAny([undefined, '', null][0])); + (this.voidIfAny([[3, 4], [null]][0][0])); + + var t1 = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; var t2 = [{ x: true, y: new derived() }, { x: false, y: new base() }]; var t3 = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; + var anyObj = null; // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; + var ifaceObj = null; var baseObj = new base(); var base2Obj = new base2(); + var b1 = [baseObj, base2Obj, ifaceObj]; var b2 = [base2Obj, baseObj, ifaceObj]; var b3 = [baseObj, ifaceObj, base2Obj]; @@ -183,13 +188,11 @@ var EmptyTypes; var NonEmptyTypes; (function (NonEmptyTypes) { var base = /** @class */ (function () { - function base() { - } + function base() {} return base; }()); var base2 = /** @class */ (function () { - function base2() { - } + function base2() {} return base2; }()); var derived = /** @class */ (function (_super) { @@ -202,10 +205,10 @@ var NonEmptyTypes; var f = /** @class */ (function () { function f() { } - f.prototype.voidIfAny = function (x, y) { - if (y === void 0) { y = false; } + f.prototype.voidIfAny = function (x, y) {if (y === void 0) { y = false; } return null; }; + f.prototype.x = function () { (this.voidIfAny([4, 2][0])); (this.voidIfAny([4, 2, undefined][0])); @@ -213,24 +216,31 @@ var NonEmptyTypes; (this.voidIfAny([null, 2, 4][0])); (this.voidIfAny([2, 4, null][0])); (this.voidIfAny([undefined, 4, null][0])); + (this.voidIfAny(['', "q"][0])); (this.voidIfAny(['', "q", undefined][0])); (this.voidIfAny([undefined, "q", ''][0])); (this.voidIfAny([null, "q", ''][0])); (this.voidIfAny(["q", '', null][0])); (this.voidIfAny([undefined, '', null][0])); + (this.voidIfAny([[3, 4], [null]][0][0])); + + var t1 = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; var t2 = [{ x: true, y: new derived() }, { x: false, y: new base() }]; var t3 = [{ x: undefined, y: new base() }, { x: '', y: new derived() }]; + var anyObj = null; // Order matters here so test all the variants var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }]; var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; + var ifaceObj = null; var baseObj = new base(); var base2Obj = new base2(); + var b1 = [baseObj, base2Obj, ifaceObj]; var b2 = [base2Obj, baseObj, ifaceObj]; var b3 = [baseObj, ifaceObj, base2Obj]; diff --git a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.js b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.js index 916eee6218392..52e8255c7e6cf 100644 --- a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.js +++ b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.js @@ -17,6 +17,7 @@ function f([, a, , b, , , , s, , , ] = results) { //// [arrayBindingPatternOmittedExpressions.js] var results; + { let [, b, , a] = results; let x = { @@ -24,6 +25,8 @@ var results; b }; } + + function f([, a, , b, , , , s, , ,] = results) { a = s[1]; b = s[2]; diff --git a/tests/baselines/reference/arrayCast.js b/tests/baselines/reference/arrayCast.js index 214bf642250b9..784eaeede25ea 100644 --- a/tests/baselines/reference/arrayCast.js +++ b/tests/baselines/reference/arrayCast.js @@ -10,5 +10,6 @@ // Should fail. Even though the array is contextually typed with { id: number }[], it still // has type { foo: string }[], which is not assignable to { id: number }[]. [{ foo: "s" }]; + // Should succeed, as the {} element causes the type of the array to be {}[] [{ foo: "s" }, {}]; diff --git a/tests/baselines/reference/arrayConcat2.js b/tests/baselines/reference/arrayConcat2.js index 8db2d62e1d357..d7cea9b56f016 100644 --- a/tests/baselines/reference/arrayConcat2.js +++ b/tests/baselines/reference/arrayConcat2.js @@ -11,6 +11,8 @@ b.concat('hello'); //// [arrayConcat2.js] var a = []; a.concat("hello", 'world'); + a.concat('Hello'); + var b = new Array(); b.concat('hello'); diff --git a/tests/baselines/reference/arrayConstructors1.js b/tests/baselines/reference/arrayConstructors1.js index 488cf49a3160b..ae92444f33f13 100644 --- a/tests/baselines/reference/arrayConstructors1.js +++ b/tests/baselines/reference/arrayConstructors1.js @@ -14,6 +14,7 @@ var x; x = new Array(1); x = new Array('hi', 'bye'); x = new Array('hi', 'bye'); + var y; y = new Array(1); y = new Array(1, 2); diff --git a/tests/baselines/reference/arrayFilter.js b/tests/baselines/reference/arrayFilter.js index dd3b321b19ced..ca00fcd7aae80 100644 --- a/tests/baselines/reference/arrayFilter.js +++ b/tests/baselines/reference/arrayFilter.js @@ -13,4 +13,5 @@ var foo = [ { name: null }, { name: 'baz' } ]; + foo.filter(function (x) { return x.name; }); //should accepted all possible types not only boolean! diff --git a/tests/baselines/reference/arrayFind.js b/tests/baselines/reference/arrayFind.js index 1926c3a8dcc15..d62e8ed6270f4 100644 --- a/tests/baselines/reference/arrayFind.js +++ b/tests/baselines/reference/arrayFind.js @@ -16,7 +16,9 @@ const readonlyFoundNumber: number | undefined = readonlyArrayOfStringsNumbersAnd function isNumber(x) { return typeof x === "number"; } + var arrayOfStringsNumbersAndBooleans = ["string", false, 0, "strung", 1, true]; var foundNumber = arrayOfStringsNumbersAndBooleans.find(isNumber); + var readonlyArrayOfStringsNumbersAndBooleans = arrayOfStringsNumbersAndBooleans; var readonlyFoundNumber = readonlyArrayOfStringsNumbersAndBooleans.find(isNumber); diff --git a/tests/baselines/reference/arrayFrom.js b/tests/baselines/reference/arrayFrom.js index ea6fcf8fcf03f..abd19c4d8d780 100644 --- a/tests/baselines/reference/arrayFrom.js +++ b/tests/baselines/reference/arrayFrom.js @@ -39,34 +39,34 @@ function getEither (in1: Iterable, in2: ArrayLike) { //// [arrayFrom.js] // Tests fix for #20432, ensures Array.from accepts all valid inputs // Also tests for #19682 + + var inputA = []; var inputB = []; var inputALike = { length: 0 }; var inputARand = getEither(inputA, inputALike); var inputASet = new Set(); + var result1 = Array.from(inputA); var result2 = Array.from(inputA.values()); var result3 = Array.from(inputA.values()); // expect error var result4 = Array.from(inputB, function (_a) { var b = _a.b; - return ({ a: b }); -}); + return ({ a: b });}); var result5 = Array.from(inputALike); var result6 = Array.from(inputALike); // expect error var result7 = Array.from(inputALike, function (_a) { var a = _a.a; - return ({ b: a }); -}); + return ({ b: a });}); var result8 = Array.from(inputARand); var result9 = Array.from(inputARand, function (_a) { var a = _a.a; - return ({ b: a }); -}); + return ({ b: a });}); var result10 = Array.from(new Set()); var result11 = Array.from(inputASet, function (_a) { var a = _a.a; - return ({ b: a }); -}); + return ({ b: a });}); + // if this is written inline, the compiler seems to infer // the ?: as always taking the false branch, narrowing to ArrayLike, // even when the type is written as : Iterable|ArrayLike diff --git a/tests/baselines/reference/arrayLiteral.js b/tests/baselines/reference/arrayLiteral.js index ae210aabd42c2..a1e96dbdc9f65 100644 --- a/tests/baselines/reference/arrayLiteral.js +++ b/tests/baselines/reference/arrayLiteral.js @@ -17,13 +17,17 @@ var y2: number[] = new Array(); //// [arrayLiteral.js] // valid uses of array literals + var x = []; var x = new Array(1); + var y = [1]; var y = [1, 2]; var y = new Array(); + var x2 = []; var x2 = new Array(1); + var y2 = [1]; var y2 = [1, 2]; var y2 = new Array(); diff --git a/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.js b/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.js index 0b9f543e38242..19db942445c83 100644 --- a/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.js +++ b/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.js @@ -18,9 +18,11 @@ var myCars = new Array(); var myCars3 = new Array({}); var myCars4; // error var myCars5; + myCars = myCars3; myCars = myCars4; myCars = myCars5; + myCars3 = myCars; myCars3 = myCars4; myCars3 = myCars5; diff --git a/tests/baselines/reference/arrayLiteralContextualType.js b/tests/baselines/reference/arrayLiteralContextualType.js index 2d48085c80ff3..aeb2a749516b5 100644 --- a/tests/baselines/reference/arrayLiteralContextualType.js +++ b/tests/baselines/reference/arrayLiteralContextualType.js @@ -30,6 +30,7 @@ foo(arr); // ok because arr is Array not {}[] bar(arr); // ok because arr is Array not {}[] //// [arrayLiteralContextualType.js] + var Giraffe = /** @class */ (function () { function Giraffe() { this.name = "Giraffe"; @@ -46,6 +47,7 @@ var Elephant = /** @class */ (function () { }()); function foo(animals) { } function bar(animals) { } + foo([ new Giraffe(), new Elephant() @@ -54,6 +56,7 @@ bar([ new Giraffe(), new Elephant() ]); // Legal because of the contextual type IAnimal provided by the parameter + var arr = [new Giraffe(), new Elephant()]; foo(arr); // ok because arr is Array not {}[] bar(arr); // ok because arr is Array not {}[] diff --git a/tests/baselines/reference/arrayLiteralExpressionContextualTyping.js b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.js index 9061b1a9d4e84..dd0337c655dbd 100644 --- a/tests/baselines/reference/arrayLiteralExpressionContextualTyping.js +++ b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.js @@ -31,6 +31,9 @@ var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the c var tup = [1, 2, 3, 4]; var tup1 = [1, 2, 3, "string"]; var tup2 = [1, 2, 3, "string"]; // Error + + + // In a contextually typed array literal expression containing one or more spread elements, // an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. var spr = __spreadArrays([1, 2, 3], array); diff --git a/tests/baselines/reference/arrayLiteralInNonVarArgParameter.js b/tests/baselines/reference/arrayLiteralInNonVarArgParameter.js index 57cba07d6bf16..fbdc9e899ac81 100644 --- a/tests/baselines/reference/arrayLiteralInNonVarArgParameter.js +++ b/tests/baselines/reference/arrayLiteralInNonVarArgParameter.js @@ -5,10 +5,10 @@ panic([], 'one', 'two'); //// [arrayLiteralInNonVarArgParameter.js] -function panic(val) { - var opt = []; +function panic(val) {var opt = []; for (var _i = 1; _i < arguments.length; _i++) { opt[_i - 1] = arguments[_i]; } } + panic([], 'one', 'two'); diff --git a/tests/baselines/reference/arrayLiteralInference.js b/tests/baselines/reference/arrayLiteralInference.js index 6b98b22394ac2..90a40cdc03ff3 100644 --- a/tests/baselines/reference/arrayLiteralInference.js +++ b/tests/baselines/reference/arrayLiteralInference.js @@ -61,5 +61,6 @@ const appTypeStylesWithError = new Map([ [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]] ]); + let b1 = foo({ x: true }, { x: false }); let b2 = foo([true], [false]); diff --git a/tests/baselines/reference/arrayLiteralSpread.js b/tests/baselines/reference/arrayLiteralSpread.js index bf86204156a16..e036b27d4cff9 100644 --- a/tests/baselines/reference/arrayLiteralSpread.js +++ b/tests/baselines/reference/arrayLiteralSpread.js @@ -42,11 +42,13 @@ function f0() { var a7 = __spreadArrays([1], a, [2], a); var a8 = __spreadArrays(a, a, a); } + function f1() { var a = [1, 2, 3]; var b = __spreadArrays(["hello"], a, [true]); var b; } + function f2() { var a = []; var b = [5]; diff --git a/tests/baselines/reference/arrayLiteralSpreadES5iterable.js b/tests/baselines/reference/arrayLiteralSpreadES5iterable.js index d71f49242dd58..e7836e30fb6bd 100644 --- a/tests/baselines/reference/arrayLiteralSpreadES5iterable.js +++ b/tests/baselines/reference/arrayLiteralSpreadES5iterable.js @@ -55,11 +55,13 @@ function f0() { var a7 = __spread([1], a, [2], a); var a8 = __spread(a, a, a); } + function f1() { var a = [1, 2, 3]; var b = __spread(["hello"], a, [true]); var b; } + function f2() { var a = __spread([]); var b = __spread([5]); diff --git a/tests/baselines/reference/arrayLiteralTypeInference.js b/tests/baselines/reference/arrayLiteralTypeInference.js index fcd8a62ce0bbe..8f02d19fc597d 100644 --- a/tests/baselines/reference/arrayLiteralTypeInference.js +++ b/tests/baselines/reference/arrayLiteralTypeInference.js @@ -88,25 +88,34 @@ var x1 = [ { id: 2, trueness: false }, { id: 3, name: "three" } ]; + var x2 = [ new ActionA(), new ActionB() ]; + var x3 = [ new Action(), new ActionA(), new ActionB() ]; + var z1 = [ { id: 2, trueness: false }, { id: 3, name: "three" } ]; + var z2 = [ new ActionA(), new ActionB() ]; + var z3 = [ new Action(), new ActionA(), new ActionB() ]; + + + + diff --git a/tests/baselines/reference/arrayLiteralWidened.js b/tests/baselines/reference/arrayLiteralWidened.js index 5b7346b87381b..52214565537b3 100644 --- a/tests/baselines/reference/arrayLiteralWidened.js +++ b/tests/baselines/reference/arrayLiteralWidened.js @@ -25,17 +25,23 @@ var d = [undefined, x]; //// [arrayLiteralWidened.js] // array literals are widened upon assignment according to their element type + var a = []; // any[] var a = [, ,]; + var a = [null, null]; var a = [undefined, undefined]; + var b = [[], [null, null]]; // any[][] var b = [[], []]; var b = [[undefined, undefined]]; + var c = [[[]]]; // any[][][] var c = [[[null]], [undefined]]; + // no widening when one or more elements are non-widening var x = undefined; + var d = [x]; var d = [, x]; var d = [undefined, x]; diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.js b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.js index b4f869d499eae..0743b19e61301 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.js +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.js @@ -17,12 +17,15 @@ var gs = [(b: { x: number; z?: number }) => 2, (a: { x: number; y?: number }) => //// [arrayLiteralWithMultipleBestCommonTypes.js] // when multiple best common types exist we will choose the first candidate + var a; var b; var c; + var as = [a, b]; // { x: number; y?: number };[] var bs = [b, a]; // { x: number; z?: number };[] var cs = [a, b, c]; // { x: number; y?: number };[] + var ds = [function (x) { return 1; }, function (x) { return 2; }]; // { (x:Object) => number }[] var es = [function (x) { return 2; }, function (x) { return 1; }]; // { (x:string) => number }[] var fs = [function (a) { return 1; }, function (b) { return 2; }]; // (a: { x: number; y?: number }) => number[] diff --git a/tests/baselines/reference/arrayLiterals.js b/tests/baselines/reference/arrayLiterals.js index c4d257dd546ba..17941dd6843bf 100644 --- a/tests/baselines/reference/arrayLiterals.js +++ b/tests/baselines/reference/arrayLiterals.js @@ -51,28 +51,38 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var arr1 = [[], [1], ['']]; + var arr2 = [[null], [1], ['']]; + + // Array literal with elements of only EveryType E has type E[] var stringArrArr = [[''], [""]]; + var stringArr = ['', ""]; + var numberArr = [0, 0.0, 0x00, 1e1]; + var boolArr = [false, true, false, true]; + var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); var classArr = [new C(), new C()]; + var classTypeArray = [C, C, C]; var classTypeArray; // Should OK, not be a parse error + + // Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] var context1 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; + // Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived1 = /** @class */ (function (_super) { @@ -92,5 +102,7 @@ var Derived2 = /** @class */ (function (_super) { }(Base)); ; var context3 = [new Derived1(), new Derived2()]; + // Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[] var context4 = [new Derived1(), new Derived1()]; + diff --git a/tests/baselines/reference/arrayLiterals2ES5.js b/tests/baselines/reference/arrayLiterals2ES5.js index 2626be0834381..a744e944b1798 100644 --- a/tests/baselines/reference/arrayLiterals2ES5.js +++ b/tests/baselines/reference/arrayLiterals2ES5.js @@ -69,6 +69,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { r[k] = a[j]; return r; }; + // SpreadElement: // ... AssignmentExpression var a0 = [, , 2, 3, 4]; @@ -77,6 +78,7 @@ var a2 = __spreadArrays([, , ], a0, ["hello"]); var a3 = __spreadArrays([, ], a0); var a4 = [function () { return 1; },]; var a5 = __spreadArrays(a0, [,]); + // Each element expression in a non-empty array literal is processed as follows: // - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) // by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, @@ -86,11 +88,16 @@ var a5 = __spreadArrays(a0, [,]); // the resulting type is a tuple type constructed from the types of the element expressions. var b0 = [undefined, null, undefined]; var b1 = [[1, 2, 3], ["hello", "string"]]; + // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), // the resulting type is a tuple type constructed from the types of the element expressions. var _a = [1, 2], c0 = _a[0], c1 = _a[1]; // tuple type [number, number] var _b = [1, 2, true], c2 = _b[0], c3 = _b[1]; // tuple type [number, number, boolean] + + + + // The resulting type an array literal expression is determined as follows: // - the resulting type is an array type with an element type that is the union of the types of the // non - spread element expressions and the numeric index signature types of the spread element expressions @@ -99,6 +106,7 @@ var temp1 = [1, 2, 3]; var temp2 = [[1, 2, 3], ["hello", "string"]]; var temp3 = [undefined, null, undefined]; var temp4 = []; + var d0 = __spreadArrays([1, true], temp); // has type (string|number|boolean)[] var d1 = __spreadArrays(temp); // has type string[] var d2 = __spreadArrays(temp1); diff --git a/tests/baselines/reference/arrayLiterals2ES6.js b/tests/baselines/reference/arrayLiterals2ES6.js index cb6bf2684e858..30783ea5852c4 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.js +++ b/tests/baselines/reference/arrayLiterals2ES6.js @@ -68,6 +68,7 @@ var a2 = [, , , ...a0, "hello"]; var a3 = [, , ...a0]; var a4 = [() => 1,]; var a5 = [...a0, ,]; + // Each element expression in a non-empty array literal is processed as follows: // - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) // by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, @@ -77,17 +78,23 @@ var a5 = [...a0, ,]; // the resulting type is a tuple type constructed from the types of the element expressions. var b0 = [undefined, null, undefined]; var b1 = [[1, 2, 3], ["hello", "string"]]; + // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), // the resulting type is a tuple type constructed from the types of the element expressions. var [c0, c1] = [1, 2]; // tuple type [number, number] var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] + + + + // The resulting type an array literal expression is determined as follows: // - the resulting type is an array type with an element type that is the union of the types of the // non - spread element expressions and the numeric index signature types of the spread element expressions var temp = ["s", "t", "r"]; var temp1 = [1, 2, 3]; var temp2 = [[1, 2, 3], ["hello", "string"]]; + var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[] var d1 = [...temp]; // has type string[] var d2 = [...temp1]; diff --git a/tests/baselines/reference/arrayLiterals3.js b/tests/baselines/reference/arrayLiterals3.js index 754bd1fba1e71..ff8beb5e97aba 100644 --- a/tests/baselines/reference/arrayLiterals3.js +++ b/tests/baselines/reference/arrayLiterals3.js @@ -47,21 +47,29 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { r[k] = a[j]; return r; }; + // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is contextually typed by a tuple-like type, // the resulting type is a tuple type constructed from the types of the element expressions. var a0 = []; // Error var a1 = ["string", 1, true]; // Error + + + + + // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), // the resulting type is a tuple type constructed from the types of the element expressions. var _a = [1, 2, "string", true], b1 = _a[0], b2 = _a[1]; + // The resulting type an array literal expression is determined as follows: // - the resulting type is an array type with an element type that is the union of the types of the // non - spread element expressions and the numeric index signature types of the spread element expressions var temp = ["s", "t", "r"]; var temp1 = [1, 2, 3]; var temp2 = [[1, 2, 3], ["hello", "string"]]; + var c0 = __spreadArrays(temp2); // Error var c1 = __spreadArrays(temp1); // Error cannot assign number[] to [number, number, number] var c2 = __spreadArrays(temp1, temp); // Error cannot assign (number|string)[] to number[] diff --git a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js index 25a76bec5c758..6a9e78426ee9c 100644 --- a/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js +++ b/tests/baselines/reference/arrayLiteralsWithRecursiveGenerics.js @@ -59,8 +59,10 @@ var MyList = /** @class */ (function () { var list; var list2; var myList; + var xs = [list, myList]; // {}[] var ys = [list, list2]; // {}[] var zs = [list, null]; // List[] + var myDerivedList; var as = [list, myDerivedList]; // List[] diff --git a/tests/baselines/reference/arrayOfExportedClass.js b/tests/baselines/reference/arrayOfExportedClass.js index 2a41475c1cd33..e614aeb6904dc 100644 --- a/tests/baselines/reference/arrayOfExportedClass.js +++ b/tests/baselines/reference/arrayOfExportedClass.js @@ -38,6 +38,7 @@ var Road = /** @class */ (function () { function Road() { } Road.prototype.AddCars = function (cars) { + this.cars = cars; }; return Road; diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.js b/tests/baselines/reference/arrayOfFunctionTypes3.js index 758e11f6f1fc5..826ff1d468427 100644 --- a/tests/baselines/reference/arrayOfFunctionTypes3.js +++ b/tests/baselines/reference/arrayOfFunctionTypes3.js @@ -28,8 +28,10 @@ var r7 = r6(''); // any not string //// [arrayOfFunctionTypes3.js] // valid uses of arrays of function types + var x = [function () { return 1; }, function () { }]; var r2 = x[0](); + var C = /** @class */ (function () { function C() { } @@ -37,6 +39,7 @@ var C = /** @class */ (function () { }()); var y = [C, C]; var r3 = new y[0](); + var a; var b; var c; @@ -44,9 +47,11 @@ var z = [a, b, c]; var r4 = z[0]; var r5 = r4(''); // any not string var r5b = r4(1); + var a2; var b2; var c2; + var z2 = [a2, b2, c2]; var r6 = z2[0]; var r7 = r6(''); // any not string diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js index 45b587c0e62ff..6dbff412c7e27 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js @@ -34,8 +34,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); var B = /** @class */ (function (_super) { @@ -56,6 +55,7 @@ rra = ara; rrb = arb; // OK, Array is assignable to ReadonlyArray rra = arb; rrb = ara; // error: 'A' is not assignable to 'B' + rra = cra; rra = crb; // OK, C is assignable to ReadonlyArray rrb = crb; diff --git a/tests/baselines/reference/arraySigChecking.js b/tests/baselines/reference/arraySigChecking.js index 16189305eaddb..5028458b14350 100644 --- a/tests/baselines/reference/arraySigChecking.js +++ b/tests/baselines/reference/arraySigChecking.js @@ -35,11 +35,15 @@ isEmpty(['a']); //// [arraySigChecking.js] var myVar; var strArray = [myVar.voidFn()]; + + var myArray; myArray = [[1, 2]]; + function isEmpty(l) { return l.length === 0; } + isEmpty([]); isEmpty(new Array(3)); isEmpty(new Array(3)); diff --git a/tests/baselines/reference/arrayTypeOfFunctionTypes.js b/tests/baselines/reference/arrayTypeOfFunctionTypes.js index 9a7a4516cb585..a4e75475db9e0 100644 --- a/tests/baselines/reference/arrayTypeOfFunctionTypes.js +++ b/tests/baselines/reference/arrayTypeOfFunctionTypes.js @@ -18,14 +18,17 @@ var r6b = new r5(); // error //// [arrayTypeOfFunctionTypes.js] // valid uses of arrays of function types + var x; var r = x[1]; var r2 = r(); var r2b = new r(); + var x2; var r3 = x2[1]; var r4 = r3(); var r4b = new r3(); // error + var x3; var r5 = x2[1]; var r6 = r5(); diff --git a/tests/baselines/reference/arrayTypeOfFunctionTypes2.js b/tests/baselines/reference/arrayTypeOfFunctionTypes2.js index f9baa9871e183..a196ddab1ac2d 100644 --- a/tests/baselines/reference/arrayTypeOfFunctionTypes2.js +++ b/tests/baselines/reference/arrayTypeOfFunctionTypes2.js @@ -18,14 +18,17 @@ var r6b = r5(); //// [arrayTypeOfFunctionTypes2.js] // valid uses of arrays of function types + var x; var r = x[1]; var r2 = new r(); var r2b = r(); + var x2; var r3 = x[1]; var r4 = new r3(); var r4b = new r3(); + var x3; var r5 = x2[1]; var r6 = new r5(); diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.js b/tests/baselines/reference/arrayTypeOfTypeOf.js index ced62a73a0772..503627dcd5be7 100644 --- a/tests/baselines/reference/arrayTypeOfTypeOf.js +++ b/tests/baselines/reference/arrayTypeOfTypeOf.js @@ -9,10 +9,9 @@ var xs4: typeof Array; //// [arrayTypeOfTypeOf.js] // array type cannot use typeof. + var x = 1; var xs; // Not an error. This is equivalent to Array var xs2; -var xs3; -; -var xs4; -; +var xs3;; +var xs4;; diff --git a/tests/baselines/reference/arrayconcat.js b/tests/baselines/reference/arrayconcat.js index 8730fff8c41ee..b4c2e7b43cec8 100644 --- a/tests/baselines/reference/arrayconcat.js +++ b/tests/baselines/reference/arrayconcat.js @@ -29,6 +29,7 @@ class parser { } //// [arrayconcat.js] + var parser = /** @class */ (function () { function parser() { } @@ -36,6 +37,7 @@ var parser = /** @class */ (function () { this.options = this.options.sort(function (a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); + if (aName > bName) { return 1; } diff --git a/tests/baselines/reference/arrowFunctionContexts.js b/tests/baselines/reference/arrowFunctionContexts.js index 466131ea20606..a314ef1b67130 100644 --- a/tests/baselines/reference/arrowFunctionContexts.js +++ b/tests/baselines/reference/arrowFunctionContexts.js @@ -114,10 +114,10 @@ var _this = this; with (window) { var p = function () { return _this; }; } + // Arrow function as argument to super call var Base = /** @class */ (function () { - function Base(n) { - } + function Base(n) {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -130,9 +130,11 @@ var Derived = /** @class */ (function (_super) { }(Base)); // Arrow function as function argument window.setTimeout(function () { return null; }, 100); + // Arrow function as value in array literal var obj = function (n) { return ''; }; var obj; // OK + var arr = [function (n) { return ''; }]; var arr; // Incorrect error here (bug 829597) // Arrow function as enum value @@ -156,10 +158,10 @@ var M2; with (window) { var p = function () { return _this; }; } + // Arrow function as argument to super call var Base = /** @class */ (function () { - function Base(n) { - } + function Base(n) {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -172,9 +174,11 @@ var M2; }(Base)); // Arrow function as function argument window.setTimeout(function () { return null; }, 100); + // Arrow function as value in array literal var obj = function (n) { return ''; }; var obj; // OK + var arr = [function (n) { return ''; }]; var arr; // Incorrect error here (bug 829597) // Arrow function as enum value @@ -196,8 +200,10 @@ var generic1 = function (n) { return [n]; }; var generic1; // Incorrect error, Bug 829597 var generic2 = function (n) { return [n]; }; var generic2; + // ((ParamList) => { ... } ) is a type assertion to an arrow function var asserted1 = (function (n) { return [n]; }); var asserted1; var asserted2 = (function (n) { return n; }); var asserted2; + diff --git a/tests/baselines/reference/arrowFunctionErrorSpan.js b/tests/baselines/reference/arrowFunctionErrorSpan.js index ca1f966f5178b..c641497b82c60 100644 --- a/tests/baselines/reference/arrowFunctionErrorSpan.js +++ b/tests/baselines/reference/arrowFunctionErrorSpan.js @@ -56,36 +56,49 @@ f(_ => 1 + //// [arrowFunctionErrorSpan.js] function f(a) { } + // oneliner f(function () { }); + // multiline, body f(function () { }); + // multiline 2, body f(function () { }); + // multiline 3, arrow on a new line f(function () { }); + // multiline 4, arguments -f(function (a, b, c, d) { }); +f(function (a, + b, + c, + d) { }); + // single line with a comment f(/* */ function () { }); + // multi line with a comment f(/* */ function () { }); + // multi line with a comment 2 f(/* */ function () { }); + // multi line with a comment 3 -f(// comment 1 +f( // comment 2 function () { // comment 4 } // comment 5 ); + // body is not a block f(function (_) { return 1 + 2; }); diff --git a/tests/baselines/reference/arrowFunctionExpressions.js b/tests/baselines/reference/arrowFunctionExpressions.js index 19b7651b1e778..2f74402c984b2 100644 --- a/tests/baselines/reference/arrowFunctionExpressions.js +++ b/tests/baselines/reference/arrowFunctionExpressions.js @@ -103,14 +103,17 @@ function tryCatchFn() { // ArrowFormalParameters => AssignmentExpression is equivalent to ArrowFormalParameters => { return AssignmentExpression; } var a = function (p) { return p.length; }; var a = function (p) { return p.length; }; + // Identifier => Block is equivalent to(Identifier) => Block var b = function (j) { return 0; }; var b = function (j) { return 0; }; + // Identifier => AssignmentExpression is equivalent to(Identifier) => AssignmentExpression var c; var d = function (n) { return c = n; }; var d = function (n) { return c = n; }; var d; + // Binding patterns in arrow functions var p1 = function (_a) { var a = _a[0]; @@ -142,6 +145,7 @@ var p9 = function (_a) { var p10 = function (_a) { var _b = _a[0], value = _b.value, done = _b.done; }; + // Arrow function used in class member initializer // Arrow function used in class member function var MyClass = /** @class */ (function () { @@ -161,16 +165,19 @@ var MyClass = /** @class */ (function () { var arrrr = function () { return function (m) { return function () { return function (n) { return m + n; }; }; }; }; var e = arrrr()(3)()(4); var e; + // Arrow function used in arrow function used in function function someFn() { var arr = function (n) { return function (p) { return p * n; }; }; arr(3)(4).toExponential(); } + // Arrow function used in function function someOtherFn() { var arr = function (n) { return '' + n; }; arr(4).charAt(0); } + // Arrow function used in nested function in function function outerFn() { function innerFn() { @@ -179,6 +186,7 @@ function outerFn() { var p; } } + // Arrow function used in nested function in arrow function var f = function (n) { function fn(x) { @@ -188,6 +196,8 @@ var f = function (n) { }; var g = f('')(); var g; + + // Arrow function used in nested function in arrow function in nested function function someOuterFn() { var arr = function (n) { @@ -200,6 +210,7 @@ function someOuterFn() { } var h = someOuterFn()('')()(); h.toExponential(); + // Arrow function used in try/catch/finally in function function tryCatchFn() { var _this = this; diff --git a/tests/baselines/reference/arrowFunctionInConstructorArgument1.js b/tests/baselines/reference/arrowFunctionInConstructorArgument1.js index f80b870692958..5ea8a5312db72 100644 --- a/tests/baselines/reference/arrowFunctionInConstructorArgument1.js +++ b/tests/baselines/reference/arrowFunctionInConstructorArgument1.js @@ -7,8 +7,7 @@ var c = new C(() => { return asdf; } ) // should error //// [arrowFunctionInConstructorArgument1.js] var C = /** @class */ (function () { - function C(x) { - } + function C(x) {} return C; }()); var c = new C(function () { return asdf; }); // should error diff --git a/tests/baselines/reference/arrowFunctionInExpressionStatement2.js b/tests/baselines/reference/arrowFunctionInExpressionStatement2.js index 2cc6aca998ea5..5b3a1b4602cf3 100644 --- a/tests/baselines/reference/arrowFunctionInExpressionStatement2.js +++ b/tests/baselines/reference/arrowFunctionInExpressionStatement2.js @@ -6,5 +6,6 @@ module M { //// [arrowFunctionInExpressionStatement2.js] var M; (function (M) { - (function () { return 0; }); + ( + function () { return 0; }); })(M || (M = {})); diff --git a/tests/baselines/reference/arrowFunctionWithObjectLiteralBody5.js b/tests/baselines/reference/arrowFunctionWithObjectLiteralBody5.js index c097ccf0d50e7..cfc5ebf165bd1 100644 --- a/tests/baselines/reference/arrowFunctionWithObjectLiteralBody5.js +++ b/tests/baselines/reference/arrowFunctionWithObjectLiteralBody5.js @@ -9,6 +9,9 @@ var d = () => ((({ name: "foo", message: "bar" }))); //// [arrowFunctionWithObjectLiteralBody5.js] var a = function () { return ({ name: "foo", message: "bar" }); }; + var b = function () { return ({ name: "foo", message: "bar" }); }; + var c = function () { return ({ name: "foo", message: "bar" }); }; + var d = function () { return ({ name: "foo", message: "bar" }); }; diff --git a/tests/baselines/reference/arrowFunctionWithObjectLiteralBody6.js b/tests/baselines/reference/arrowFunctionWithObjectLiteralBody6.js index 270a9927835a9..6f2c5cad5d3f0 100644 --- a/tests/baselines/reference/arrowFunctionWithObjectLiteralBody6.js +++ b/tests/baselines/reference/arrowFunctionWithObjectLiteralBody6.js @@ -9,6 +9,9 @@ var d = () => ((({ name: "foo", message: "bar" }))); //// [arrowFunctionWithObjectLiteralBody6.js] var a = () => ({ name: "foo", message: "bar" }); + var b = () => ({ name: "foo", message: "bar" }); + var c = () => ({ name: "foo", message: "bar" }); + var d = () => ({ name: "foo", message: "bar" }); diff --git a/tests/baselines/reference/arrowFunctionsMissingTokens.js b/tests/baselines/reference/arrowFunctionsMissingTokens.js index d0a8bde2a5365..c753d367c38c6 100644 --- a/tests/baselines/reference/arrowFunctionsMissingTokens.js +++ b/tests/baselines/reference/arrowFunctionsMissingTokens.js @@ -69,9 +69,13 @@ module okay { var missingArrowsWithCurly; (function (missingArrowsWithCurly) { var a = function () { }; + var b = function () { }; + var c = function (x) { }; + var d = function (x, y) { }; + var e = function (x, y) { }; })(missingArrowsWithCurly || (missingArrowsWithCurly = {})); var missingCurliesWithArrow; @@ -79,39 +83,51 @@ var missingCurliesWithArrow; var withStatement; (function (withStatement) { var a = function () { var k = 10; }; + var b = function () { var k = 10; }; + var c = function (x) { var k = 10; }; + var d = function (x, y) { var k = 10; }; + var e = function (x, y) { var k = 10; }; + var f = function () { var k = 10; }; })(withStatement || (withStatement = {})); var withoutStatement; (function (withoutStatement) { - var a = function () { return ; }; - })(withoutStatement || (withoutStatement = {})); + var a = function () { return ; };})(withoutStatement || (withoutStatement = {})); ; - var b = function () { return ; }; -})(missingCurliesWithArrow || (missingCurliesWithArrow = {})); -var c = function (x) { return ; }; -; -var d = function (x, y) { return ; }; -; -var e = function (x, y) { return ; }; -; + + var b = function () { return ; };})(missingCurliesWithArrow || (missingCurliesWithArrow = {})); +var c = function (x) { return ; };; + +var d = function (x, y) { return ; };; + +var e = function (x, y) { return ; };; + var f = function () { return ; }; var ce_nEst_pas_une_arrow_function; (function (ce_nEst_pas_une_arrow_function) { var a = (); + var b = function () { return ; }; + var c = (x); + var d = function (x, y) { return ; }; + var e = function (x, y) { return ; }; })(ce_nEst_pas_une_arrow_function || (ce_nEst_pas_une_arrow_function = {})); var okay; (function (okay) { var a = function () { }; + var b = function () { }; + var c = function (x) { }; + var d = function (x, y) { }; + var e = function (x, y) { }; })(okay || (okay = {})); diff --git a/tests/baselines/reference/asOpEmitParens.js b/tests/baselines/reference/asOpEmitParens.js index dee8d263eaef2..3b33a0a45689d 100644 --- a/tests/baselines/reference/asOpEmitParens.js +++ b/tests/baselines/reference/asOpEmitParens.js @@ -13,7 +13,9 @@ new (x() as any); //// [asOpEmitParens.js] // Must emit as (x + 1) * 3 (x + 1) * 3; + // Should still emit as x.y x.y; + // Emit as new (x()) new (x()); diff --git a/tests/baselines/reference/asOperator1.js b/tests/baselines/reference/asOperator1.js index 1b23d0a86f7c9..04a4645808c87 100644 --- a/tests/baselines/reference/asOperator1.js +++ b/tests/baselines/reference/asOperator1.js @@ -14,6 +14,7 @@ var as = 43; var x = undefined; var y = null.length; var z = Date; + // Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string' var j = 32; j = ''; diff --git a/tests/baselines/reference/asOperator3.js b/tests/baselines/reference/asOperator3.js index 7cbb277bb0339..4f3d20a7f1efc 100644 --- a/tests/baselines/reference/asOperator3.js +++ b/tests/baselines/reference/asOperator3.js @@ -15,6 +15,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; + var a = "" + (123 + 456); var b = "leading " + (123 + 456); var c = 123 + 456 + " trailing"; diff --git a/tests/baselines/reference/asOperator4.js b/tests/baselines/reference/asOperator4.js index 15f15d0f02717..3301809bafb35 100644 --- a/tests/baselines/reference/asOperator4.js +++ b/tests/baselines/reference/asOperator4.js @@ -21,6 +21,7 @@ exports.foo = foo; "use strict"; exports.__esModule = true; var foo_1 = require("./foo"); + // These should emit identically foo_1.foo; foo_1.foo; diff --git a/tests/baselines/reference/asOperatorASI.js b/tests/baselines/reference/asOperatorASI.js index 4a78b022c4fe7..30eec3121eb17 100644 --- a/tests/baselines/reference/asOperatorASI.js +++ b/tests/baselines/reference/asOperatorASI.js @@ -17,13 +17,15 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook return cooked; }; var Foo = /** @class */ (function () { - function Foo() { - } + function Foo() {} return Foo; }()); + // Example 1 var x = 10; as(__makeTemplateObject(["Hello world"], ["Hello world"])); // should not error + + // Example 2 var y = 20; as(Foo); // should emit diff --git a/tests/baselines/reference/asOperatorAmbiguity.js b/tests/baselines/reference/asOperatorAmbiguity.js index 6c336970b65fe..c4dad80a761ca 100644 --- a/tests/baselines/reference/asOperatorAmbiguity.js +++ b/tests/baselines/reference/asOperatorAmbiguity.js @@ -10,7 +10,9 @@ var z = y[0].m; // z should be string //// [asOperatorAmbiguity.js] + // Make sure this is a type assertion to an array type, and not nested comparison operators. var x; var y = x; var z = y[0].m; // z should be string + diff --git a/tests/baselines/reference/asiArith.js b/tests/baselines/reference/asiArith.js index d552fd5ee77c4..d999339b265cf 100644 --- a/tests/baselines/reference/asiArith.js +++ b/tests/baselines/reference/asiArith.js @@ -36,12 +36,23 @@ y //// [asiArith.js] var x = 1; + var y = 1; + var z = x + + + + +y; + + var a = 1; + var b = 1; + var c = x + - + - -y; + diff --git a/tests/baselines/reference/asiInES6Classes.js b/tests/baselines/reference/asiInES6Classes.js index 375f0e4bc65da..cc453d4f273f1 100644 --- a/tests/baselines/reference/asiInES6Classes.js +++ b/tests/baselines/reference/asiInES6Classes.js @@ -30,7 +30,9 @@ var Foo = /** @class */ (function () { }; } Foo.prototype.bar = function () { + return 3; + }; return Foo; }()); diff --git a/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule01.js b/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule01.js index 40ec54d0ac51c..3c5692856f261 100644 --- a/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule01.js +++ b/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule01.js @@ -10,6 +10,7 @@ module // this is the identifier 'module' //// [asiPreventsParsingAsAmbientExternalModule01.js] var declare; var module; + declare; // this is the identifier 'declare' module; // this is the identifier 'module' "my external module"; // this is just a string diff --git a/tests/baselines/reference/asiPreventsParsingAsInterface01.js b/tests/baselines/reference/asiPreventsParsingAsInterface01.js index 4d0215454b6c4..d45115600217e 100644 --- a/tests/baselines/reference/asiPreventsParsingAsInterface01.js +++ b/tests/baselines/reference/asiPreventsParsingAsInterface01.js @@ -7,6 +7,7 @@ I // This should be the identifier 'I' //// [asiPreventsParsingAsInterface01.js] var interface, I; + interface; // This should be the identifier 'interface' I; // This should be the identifier 'I' { } // This should be a block body diff --git a/tests/baselines/reference/asiPreventsParsingAsInterface04.js b/tests/baselines/reference/asiPreventsParsingAsInterface04.js index 1c39f09d59694..7cffbc7a2fd7b 100644 --- a/tests/baselines/reference/asiPreventsParsingAsInterface04.js +++ b/tests/baselines/reference/asiPreventsParsingAsInterface04.js @@ -8,6 +8,7 @@ I // This should be the identifier 'I' //// [asiPreventsParsingAsInterface04.js] var declare, interface, I; + declare; // This should be the identifier 'declare' interface; // This should be the identifier 'interface' I; // This should be the identifier 'I' diff --git a/tests/baselines/reference/asiPreventsParsingAsInterface05.js b/tests/baselines/reference/asiPreventsParsingAsInterface05.js index 85c19be4473f6..bca98e39807e0 100644 --- a/tests/baselines/reference/asiPreventsParsingAsInterface05.js +++ b/tests/baselines/reference/asiPreventsParsingAsInterface05.js @@ -15,6 +15,7 @@ I // This should be the identifier 'I' //// [asiPreventsParsingAsInterface05.js] "use strict"; var interface; + // 'interface' is a strict mode reserved word, and so it would be permissible // to allow 'interface' and the name of the interface to be on separate lines; // however, this complicates things, and so it is preferable to restrict interface diff --git a/tests/baselines/reference/asiPreventsParsingAsNamespace01.js b/tests/baselines/reference/asiPreventsParsingAsNamespace01.js index f471b93e3c9a8..157bb1dc05179 100644 --- a/tests/baselines/reference/asiPreventsParsingAsNamespace01.js +++ b/tests/baselines/reference/asiPreventsParsingAsNamespace01.js @@ -9,6 +9,7 @@ n // this is the identifier 'n' //// [asiPreventsParsingAsNamespace01.js] var namespace; var n; + namespace; // this is the identifier 'namespace' n; // this is the identifier 'n' { } // this is a block body diff --git a/tests/baselines/reference/asiPreventsParsingAsNamespace02.js b/tests/baselines/reference/asiPreventsParsingAsNamespace02.js index c3a09147a9b56..c47bfe7f71721 100644 --- a/tests/baselines/reference/asiPreventsParsingAsNamespace02.js +++ b/tests/baselines/reference/asiPreventsParsingAsNamespace02.js @@ -9,6 +9,7 @@ m // this is the identifier 'm' //// [asiPreventsParsingAsNamespace02.js] var module; var m; + module; // this is the identifier 'namespace' m; // this is the identifier 'm' { } // this is a block body diff --git a/tests/baselines/reference/asiPreventsParsingAsTypeAlias01.js b/tests/baselines/reference/asiPreventsParsingAsTypeAlias01.js index 7a7ec322eead8..4bd48526b1e7c 100644 --- a/tests/baselines/reference/asiPreventsParsingAsTypeAlias01.js +++ b/tests/baselines/reference/asiPreventsParsingAsTypeAlias01.js @@ -10,5 +10,6 @@ Foo = string; var type; var string; var Foo; + type; Foo = string; diff --git a/tests/baselines/reference/assertionFunctionsCanNarrowByDiscriminant.js b/tests/baselines/reference/assertionFunctionsCanNarrowByDiscriminant.js index 8857b7dd16013..f6c4bb89b9a7e 100644 --- a/tests/baselines/reference/assertionFunctionsCanNarrowByDiscriminant.js +++ b/tests/baselines/reference/assertionFunctionsCanNarrowByDiscriminant.js @@ -26,9 +26,13 @@ animalOrUndef.canMeow; // since is cat, should not be an error //// [assertionFunctionsCanNarrowByDiscriminant.js] "use strict"; + var animal = { type: 'cat', canMeow: true }; assertEqual(animal.type, 'cat'); + animal.canMeow; // since is cat, should not be an error + var animalOrUndef = { type: 'cat', canMeow: true }; assertEqual(animalOrUndef === null || animalOrUndef === void 0 ? void 0 : animalOrUndef.type, 'cat'); + animalOrUndef.canMeow; // since is cat, should not be an error diff --git a/tests/baselines/reference/assertionTypePredicates1.js b/tests/baselines/reference/assertionTypePredicates1.js index a9128475c528d..f052518017d58 100644 --- a/tests/baselines/reference/assertionTypePredicates1.js +++ b/tests/baselines/reference/assertionTypePredicates1.js @@ -207,7 +207,10 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var assert = function (value) { }; + + function f01(x) { if (!!true) { assert(typeof x === "string"); @@ -244,6 +247,7 @@ function f01(x) { x; // Unreachable } } + function f02(x) { if (!!true) { assert(x); @@ -258,6 +262,7 @@ function f02(x) { x.length; } } + function f03(x, assert) { assert(x); x.length; @@ -283,6 +288,7 @@ function f10(x) { x; // Unreachable } } + var Test = /** @class */ (function () { function Test() { } @@ -357,6 +363,8 @@ function f11(items) { item.z; } } + + function f20(x) { var assert = function (value) { }; assert(typeof x === "string"); // Error @@ -367,6 +375,8 @@ function f20(x) { var t2 = new Test(); t2.assert(typeof x === "string"); } + + function example1(things) { for (var _i = 0, things_1 = things; _i < things_1.length; _i++) { var thing = things_1[_i]; diff --git a/tests/baselines/reference/assign1.js b/tests/baselines/reference/assign1.js index fa18c8f287bb7..8a2f2e87fef31 100644 --- a/tests/baselines/reference/assign1.js +++ b/tests/baselines/reference/assign1.js @@ -12,5 +12,6 @@ module M { //// [assign1.js] var M; (function (M) { + var x = { salt: 2, pepper: 0 }; })(M || (M = {})); diff --git a/tests/baselines/reference/assignAnyToEveryType.js b/tests/baselines/reference/assignAnyToEveryType.js index 351c041523fc9..5e70be4f3ca6c 100644 --- a/tests/baselines/reference/assignAnyToEveryType.js +++ b/tests/baselines/reference/assignAnyToEveryType.js @@ -47,7 +47,9 @@ function k(a: T) { //// [assignAnyToEveryType.js] // all of these are valid + var x; + var a = x; var b = x; var c = x; @@ -63,13 +65,17 @@ var E; var g = x; var g2 = E.A; g2 = x; + var C = /** @class */ (function () { function C() { } return C; }()); var h = x; + + var i = x; + var j = x; var j2 = x; var M; @@ -77,6 +83,7 @@ var M; M.foo = 1; })(M || (M = {})); M = x; + function k(a) { a = x; } diff --git a/tests/baselines/reference/assignEveryTypeToAny.js b/tests/baselines/reference/assignEveryTypeToAny.js index 07bfbaddebc11..993a8a51cf759 100644 --- a/tests/baselines/reference/assignEveryTypeToAny.js +++ b/tests/baselines/reference/assignEveryTypeToAny.js @@ -57,20 +57,27 @@ function j(a: T) { //// [assignEveryTypeToAny.js] // all of these are valid + var x; + x = 1; var a = 2; x = a; + x = true; var b = true; x = b; + x = ""; var c = ""; x = c; + var d; x = d; + var e = undefined; x = e; + var e2; x = e2; var E; @@ -80,8 +87,11 @@ var E; x = E.A; var f = E.A; x = f; + + var g; x = g; + var C = /** @class */ (function () { function C() { } @@ -89,10 +99,12 @@ var C = /** @class */ (function () { }()); var h; x = h; + var i; x = i; x = { f: function () { return 1; } }; x = { f: function (x) { return x; } }; + function j(a) { x = a; } diff --git a/tests/baselines/reference/assignFromBooleanInterface2.js b/tests/baselines/reference/assignFromBooleanInterface2.js index be376b293c0f5..0e9dc3fad7e45 100644 --- a/tests/baselines/reference/assignFromBooleanInterface2.js +++ b/tests/baselines/reference/assignFromBooleanInterface2.js @@ -23,12 +23,16 @@ x = b; // expected error //// [assignFromBooleanInterface2.js] + var x = true; var a; var b; + a = x; a = b; + b = a; b = x; + x = a; // expected error x = b; // expected error diff --git a/tests/baselines/reference/assignFromNumberInterface2.js b/tests/baselines/reference/assignFromNumberInterface2.js index 25262bf27f074..14bcd18b8733f 100644 --- a/tests/baselines/reference/assignFromNumberInterface2.js +++ b/tests/baselines/reference/assignFromNumberInterface2.js @@ -28,12 +28,16 @@ x = b; // expected error //// [assignFromNumberInterface2.js] + var x = 1; var a; var b; + a = x; a = b; + b = a; b = x; + x = a; // expected error x = b; // expected error diff --git a/tests/baselines/reference/assignFromStringInterface2.js b/tests/baselines/reference/assignFromStringInterface2.js index 5636a4806cc9e..d70ecf36211b9 100644 --- a/tests/baselines/reference/assignFromStringInterface2.js +++ b/tests/baselines/reference/assignFromStringInterface2.js @@ -51,12 +51,16 @@ x = b; // expected error //// [assignFromStringInterface2.js] + var x = ''; var a; var b; + a = x; a = b; + b = a; b = x; + x = a; // expected error x = b; // expected error diff --git a/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.js b/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.js index fe6142cafe088..5099569c1b8cd 100644 --- a/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.js +++ b/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.js @@ -10,6 +10,8 @@ fn(function (a, b) { return true; }) //// [assignLambdaToNominalSubtypeOfFunction.js] + function fn(cb) { } + fn(function (a, b) { return true; }); fn(function (a, b) { return true; }); diff --git a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.js b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.js index f71361eb570f5..1c4d0cb0ee167 100644 --- a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.js +++ b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.js @@ -58,9 +58,11 @@ class C { this.foo; // ok } } + class D extends C { quill = this.foo; // ok } + class E { foo2; bar = () => this.foo1 + this.foo2; // both ok @@ -69,6 +71,7 @@ class E { this.foo2 = foo2; } } + class F { Inner = class extends F { p2 = this.p1; diff --git a/tests/baselines/reference/assignToFn.js b/tests/baselines/reference/assignToFn.js index 2ff8ceedfa67c..40e9d57f2756c 100644 --- a/tests/baselines/reference/assignToFn.js +++ b/tests/baselines/reference/assignToFn.js @@ -13,6 +13,8 @@ module M { //// [assignToFn.js] var M; (function (M) { + var x = { f: function (n) { return true; } }; + x.f = "hello"; })(M || (M = {})); diff --git a/tests/baselines/reference/assignToInvalidLHS.js b/tests/baselines/reference/assignToInvalidLHS.js index 13906d28fdf26..c162aa9e3a2cf 100644 --- a/tests/baselines/reference/assignToInvalidLHS.js +++ b/tests/baselines/reference/assignToInvalidLHS.js @@ -5,5 +5,6 @@ declare var y:any; var x = new y = 5; //// [assignToInvalidLHS.js] + // Below is actually valid JavaScript (see http://es5.github.com/#x8.7 ), even though will always fail at runtime with 'invalid left-hand side' var x = new y = 5; diff --git a/tests/baselines/reference/assignToObjectTypeWithPrototypeProperty.js b/tests/baselines/reference/assignToObjectTypeWithPrototypeProperty.js index ac2b7368361f8..84be67d5158b2 100644 --- a/tests/baselines/reference/assignToObjectTypeWithPrototypeProperty.js +++ b/tests/baselines/reference/assignToObjectTypeWithPrototypeProperty.js @@ -5,8 +5,7 @@ var x: {prototype: XEvent} = XEvent; //// [assignToObjectTypeWithPrototypeProperty.js] var XEvent = /** @class */ (function () { - function XEvent() { - } + function XEvent() {} return XEvent; }()); var p = XEvent.prototype; diff --git a/tests/baselines/reference/assignToPrototype1.js b/tests/baselines/reference/assignToPrototype1.js index b2d2af37e5296..15df8a3a9e7e4 100644 --- a/tests/baselines/reference/assignToPrototype1.js +++ b/tests/baselines/reference/assignToPrototype1.js @@ -7,5 +7,6 @@ Point.prototype.add = function(dx, dy) { }; //// [assignToPrototype1.js] + Point.prototype.add = function (dx, dy) { }; diff --git a/tests/baselines/reference/assigningFromObjectToAnythingElse.js b/tests/baselines/reference/assigningFromObjectToAnythingElse.js index 61c4a6ede22f8..e45a5e7a0bf0d 100644 --- a/tests/baselines/reference/assigningFromObjectToAnythingElse.js +++ b/tests/baselines/reference/assigningFromObjectToAnythingElse.js @@ -13,6 +13,8 @@ var w: Error = new Object(); var x; var y; y = x; + var a = Object.create(""); var c = Object.create(1); + var w = new Object(); diff --git a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.js b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.js index fd3ac1d46f144..b69124f63bfb7 100644 --- a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.js +++ b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.js @@ -24,14 +24,17 @@ var numStrTuple; var numNumTuple; var numEmptyObjTuple; var emptyObjTuple; + var numArray; var emptyObjArray; + // no error numArray = numNumTuple; emptyObjArray = emptyObjTuple; emptyObjArray = numStrTuple; emptyObjArray = numNumTuple; emptyObjArray = numEmptyObjTuple; + // error numArray = numStrTuple; emptyObjTuple = emptyObjArray; diff --git a/tests/baselines/reference/assignmentCompatBug2.js b/tests/baselines/reference/assignmentCompatBug2.js index 5545cc7d19c65..768faa0df0e5e 100644 --- a/tests/baselines/reference/assignmentCompatBug2.js +++ b/tests/baselines/reference/assignmentCompatBug2.js @@ -40,22 +40,29 @@ b3 = { //// [assignmentCompatBug2.js] var b2 = { a: 0 }; // error + b2 = { a: 0 }; // error + b2 = { b: 0, a: 0 }; + var b3; + b3 = { f: function (n) { return 0; }, g: function (s) { return 0; }, m: 0 }; // ok + b3 = { f: function (n) { return 0; }, g: function (s) { return 0; } }; // error + b3 = { f: function (n) { return 0; }, m: 0 }; // error + b3 = { f: function (n) { return 0; }, g: function (s) { return 0; }, @@ -63,6 +70,7 @@ b3 = { n: 0, k: function (a) { return null; } }; // ok + b3 = { f: function (n) { return 0; }, g: function (s) { return 0; }, diff --git a/tests/baselines/reference/assignmentCompatBug3.js b/tests/baselines/reference/assignmentCompatBug3.js index ac79938f9364a..f3fd8755228aa 100644 --- a/tests/baselines/reference/assignmentCompatBug3.js +++ b/tests/baselines/reference/assignmentCompatBug3.js @@ -30,6 +30,8 @@ function makePoint(x, y) { return { get x() { return x; }, get y() { return y; }, + + //x: "yo", //y: "boo", dist: function () { @@ -37,6 +39,7 @@ function makePoint(x, y) { } }; } + var C = /** @class */ (function () { function C() { } @@ -50,7 +53,9 @@ var C = /** @class */ (function () { return C; }()); function foo(test) { } + var x; var y; + foo(x); foo(x + y); diff --git a/tests/baselines/reference/assignmentCompatBug5.js b/tests/baselines/reference/assignmentCompatBug5.js index ae444c3dad6eb..769d2fc5f7959 100644 --- a/tests/baselines/reference/assignmentCompatBug5.js +++ b/tests/baselines/reference/assignmentCompatBug5.js @@ -14,9 +14,11 @@ foo3((n) => { return; }); //// [assignmentCompatBug5.js] function foo1(x) { } foo1({ b: 5 }); + function foo2(x) { } foo2(["s", "t"]); -function foo3(x) { } -; + +function foo3(x) { }; foo3(function (s) { }); foo3(function (n) { return; }); + diff --git a/tests/baselines/reference/assignmentCompatForEnums.js b/tests/baselines/reference/assignmentCompatForEnums.js index 8db85399fa830..0c52be96c21c9 100644 --- a/tests/baselines/reference/assignmentCompatForEnums.js +++ b/tests/baselines/reference/assignmentCompatForEnums.js @@ -21,9 +21,15 @@ var TokenType; TokenType[TokenType["Two"] = 1] = "Two"; })(TokenType || (TokenType = {})); ; + var list = {}; + + function returnType() { return null; } + function foo() { var x = returnType(); + var x = list['one']; } + diff --git a/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.js b/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.js index 13448bc57a460..1a39f04fe9fda 100644 --- a/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.js +++ b/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.js @@ -17,6 +17,7 @@ Biz(new Foo()); //// [assignmentCompatInterfaceWithStringIndexSignature.js] + var Foo = /** @class */ (function () { function Foo() { } @@ -24,4 +25,5 @@ var Foo = /** @class */ (function () { return Foo; }()); function Biz(map) { } + Biz(new Foo()); diff --git a/tests/baselines/reference/assignmentCompatOnNew.js b/tests/baselines/reference/assignmentCompatOnNew.js index 14d9fb5071ee2..ea48b3dbde7c4 100644 --- a/tests/baselines/reference/assignmentCompatOnNew.js +++ b/tests/baselines/reference/assignmentCompatOnNew.js @@ -8,10 +8,11 @@ bar(Foo); // Error, but should be allowed //// [assignmentCompatOnNew.js] var Foo = /** @class */ (function () { - function Foo() { - } + function Foo() {} return Foo; }()); ; + function bar(x) { } + bar(Foo); // Error, but should be allowed diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures.js b/tests/baselines/reference/assignmentCompatWithCallSignatures.js index 12fc6159fac13..dee234361e2f5 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures.js @@ -45,22 +45,27 @@ a = function (x: string) { return ''; } //// [assignmentCompatWithCallSignatures.js] // void returning call signatures can be assigned a non-void returning call signature that otherwise matches + var t; var a; + t = a; a = t; + var s; var a2; t = s; t = a2; a = s; a = a2; + t = function (x) { return 1; }; t = function () { return 1; }; t = function (x) { return ''; }; a = function (x) { return 1; }; a = function () { return 1; }; a = function (x) { return ''; }; + var s2; var a3; // these are errors diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures2.js b/tests/baselines/reference/assignmentCompatWithCallSignatures2.js index 6bfc1b6c0d64d..edd886596efd9 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures2.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures2.js @@ -52,16 +52,20 @@ a = function (x: string) { return ''; } //// [assignmentCompatWithCallSignatures2.js] // void returning call signatures can be assigned a non-void returning call signature that otherwise matches + var t; var a; + t = a; a = t; + var s; var a2; t = s; t = a2; a = s; a = a2; + t = { f: function () { return 1; } }; t = { f: function (x) { return 1; } }; t = { f: function f() { return 1; } }; @@ -69,11 +73,13 @@ t = { f: function (x) { return ''; } }; a = { f: function () { return 1; } }; a = { f: function (x) { return 1; } }; a = { f: function (x) { return ''; } }; + // errors t = function () { return 1; }; t = function (x) { return ''; }; a = function () { return 1; }; a = function (x) { return ''; }; + var s2; var a3; // these are errors diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js index a051b4e5194fa..a3a660793f05b 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.js @@ -114,9 +114,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -158,6 +158,7 @@ var a15; var a16; var a17; var a18; + var b; a = b; // ok b = a; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js index fc83877023b23..4ee8f13a411f7 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.js @@ -116,8 +116,7 @@ var __extends = (this && this.__extends) || (function () { var Errors; (function (Errors) { var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -154,33 +153,44 @@ var Errors; var a15; var a16; var a17; + var b2; a2 = b2; b2 = a2; + var b7; a7 = b7; b7 = a7; + var b8; a8 = b8; // error, { foo: number } and Base are incompatible b8 = a8; // error, { foo: number } and Base are incompatible + + var b10; a10 = b10; b10 = a10; + var b11; a11 = b11; b11 = a11; + var b12; a12 = b12; b12 = a12; + var b15; a15 = b15; b15 = a15; + var b15a; a15 = b15a; b15a = a15; + var b16; a16 = b16; b16 = a16; + var b17; a17 = b17; b17 = a17; @@ -192,6 +202,7 @@ var Errors; var b2; a2 = b2; b2 = a2; + // target type has generic call signature var a3; var b3; diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js index fb6d0be1be198..37a065b35e859 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.js @@ -80,9 +80,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -117,6 +117,7 @@ var a15; var a16; var a17; var a18; + var b; a = b; // ok b = a; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js index 9e752a43a17d2..d07cff0f8da2c 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.js @@ -57,9 +57,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -83,7 +83,9 @@ var OtherDerived = /** @class */ (function (_super) { } return OtherDerived; }(Base)); + var x; + var b; x.a = b; b = x.a; diff --git a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.js b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.js index e12a741cd0f13..0f84596a8567b 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.js @@ -71,7 +71,9 @@ var a5: (x?: number, y?: number) => number; //// [assignmentCompatWithCallSignaturesWithOptionalParameters.js] // call signatures in derived types must have the same or fewer optional parameters as the base type + var b; + var a; a = function () { return 1; }; // ok, same number of required params a = function (x) { return 1; }; // ok, same number of required params @@ -82,6 +84,7 @@ a = b.a3; // error a = b.a4; // error a = b.a5; // ok a = b.a6; // error + var a2; a2 = function () { return 1; }; // ok, same number of required params a2 = function (x) { return 1; }; // ok, same number of required params @@ -92,6 +95,7 @@ a2 = b.a3; // ok, same number of params a2 = b.a4; // ok, excess params are optional in b.a3 a2 = b.a5; // ok a2 = b.a6; // error + var a3; a3 = function () { return 1; }; // ok, fewer required params a3 = function (x) { return 1; }; // ok, fewer required params @@ -103,6 +107,7 @@ a3 = b.a3; // ok a3 = b.a4; // ok a3 = b.a5; // ok a3 = b.a6; // error + var a4; a4 = function () { return 1; }; // ok, fewer required params a4 = function (x, y) { return 1; }; // ok, fewer required params @@ -114,6 +119,7 @@ a4 = b.a3; // ok a4 = b.a4; // ok a4 = b.a5; // ok a4 = b.a6; // ok, same number of params + var a5; a5 = function () { return 1; }; // ok, fewer required params a5 = function (x, y) { return 1; }; // ok, fewer required params diff --git a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.js b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.js index ec86f218ac0f9..08c9ff4f0336b 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.js +++ b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.js @@ -47,77 +47,69 @@ var a4: (x?: number, y?: string, ...z: number[]) => number; //// [assignmentCompatWithCallSignaturesWithRestParameters.js] // call signatures in derived types must have the same or fewer optional parameters as the target for assignment + + var a; // ok, same number of required params a = function () { return 1; }; // ok, same number of required params -a = function () { - var args = []; +a = function () {var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return 1; -}; // ok, same number of required params -a = function () { - var args = []; + return 1;}; // ok, same number of required params +a = function () {var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return 1; -}; // error, type mismatch + return 1;}; // error, type mismatch a = function (x) { return 1; }; // ok, same number of required params a = function (x, y, z) { return 1; }; // ok, same number of required params a = function (x) { return 1; }; // ok, rest param corresponds to infinite number of params a = function (x) { return 1; }; // error, incompatible type + + var a2; a2 = function () { return 1; }; // ok, fewer required params -a2 = function () { - var args = []; +a2 = function () {var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return 1; -}; // ok, fewer required params + return 1;}; // ok, fewer required params a2 = function (x) { return 1; }; // ok, fewer required params a2 = function (x) { return 1; }; // ok, same number of required params -a2 = function (x) { - var args = []; +a2 = function (x) {var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return 1; -}; // ok, same number of required params -a2 = function (x) { - var args = []; + return 1;}; // ok, same number of required params +a2 = function (x) {var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return 1; -}; // should be type mismatch error + return 1;}; // should be type mismatch error a2 = function (x, y) { return 1; }; // ok, rest param corresponds to infinite number of params a2 = function (x, y) { return 1; }; // ok, same number of required params + var a3; a3 = function () { return 1; }; // ok, fewer required params a3 = function (x) { return 1; }; // ok, fewer required params a3 = function (x) { return 1; }; // ok, same number of required params a3 = function (x, y) { return 1; }; // ok, all present params match a3 = function (x, y, z) { return 1; }; // error -a3 = function (x) { - var z = []; +a3 = function (x) {var z = []; for (var _i = 1; _i < arguments.length; _i++) { z[_i - 1] = arguments[_i]; } - return 1; -}; // error + return 1;}; // error a3 = function (x, y, z) { return 1; }; // error + var a4; a4 = function () { return 1; }; // ok, fewer required params a4 = function (x, y) { return 1; }; // error, type mismatch a4 = function (x) { return 1; }; // ok, all present params match a4 = function (x, y) { return 1; }; // error, second param has type mismatch a4 = function (x, y) { return 1; }; // ok, same number of required params with matching types -a4 = function (x) { - var args = []; +a4 = function (x) {var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return 1; -}; // error, rest params have type mismatch + return 1;}; // error, rest params have type mismatch diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures.js index c00aa121712ef..877094d2a46d2 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures.js @@ -38,16 +38,20 @@ a = function (x: string) { return ''; } //// [assignmentCompatWithConstructSignatures.js] // void returning call signatures can be assigned a non-void returning call signature that otherwise matches + var t; var a; + t = a; a = t; + var s; var a2; t = s; t = a2; a = s; a = a2; + var s2; var a3; // these are errors diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures2.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.js index d00762aa1c5b7..f2cd372cabb14 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures2.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.js @@ -44,21 +44,26 @@ a = function (x: string) { return ''; } //// [assignmentCompatWithConstructSignatures2.js] // void returning call signatures can be assigned a non-void returning call signature that otherwise matches + var t; var a; + t = a; a = t; + var s; var a2; t = s; t = a2; a = s; a = a2; + // errors t = function () { return 1; }; t = function (x) { return ''; }; a = function () { return 1; }; a = function (x) { return ''; }; + var s2; var a3; // these are errors diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js index 932f9bb5d66d8..452146b5bca64 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.js @@ -114,9 +114,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -158,6 +158,7 @@ var a15; var a16; var a17; var a18; + var b; a = b; // ok b = a; // ok diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js index 4dad18cea8f7a..a0104fb70bb0b 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.js @@ -116,8 +116,7 @@ var __extends = (this && this.__extends) || (function () { var Errors; (function (Errors) { var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -154,33 +153,44 @@ var Errors; var a15; var a16; var a17; + var b2; a2 = b2; // ok b2 = a2; // ok + var b7; a7 = b7; // ok b7 = a7; // ok + var b8; a8 = b8; // error, type mismatch b8 = a8; // error + + var b10; a10 = b10; // ok b10 = a10; // ok + var b11; a11 = b11; // ok b11 = a11; // ok + var b12; a12 = b12; // ok b12 = a12; // ok + var b15; a15 = b15; // ok b15 = a15; // ok + var b15a; a15 = b15a; // ok b15a = a15; // ok + var b16; a16 = b16; // error b16 = a16; // error + var b17; a17 = b17; // error b17 = a17; // error @@ -192,6 +202,8 @@ var Errors; var b2; a2 = b2; // ok b2 = a2; // ok + + // target type has generic call signature var a3; var b3; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js index 5f16895caf235..ca065594296af 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.js @@ -80,9 +80,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -117,6 +117,7 @@ var a15; var a16; var a17; var a18; + var b; a = b; // ok b = a; // ok diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js index dfce487fff156..130f00b68d93e 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.js @@ -57,9 +57,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -83,7 +83,9 @@ var OtherDerived = /** @class */ (function (_super) { } return OtherDerived; }(Base)); + var x; + var b; x.a = b; b = x.a; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.js b/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.js index e41011021d216..f3c82432d9a79 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.js +++ b/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.js @@ -54,7 +54,9 @@ var a5: new (x?: number, y?: number) => number; //// [assignmentCompatWithConstructSignaturesWithOptionalParameters.js] // call signatures in derived types must have the same or fewer optional parameters as the base type + var b; + var a; a = b.a; // ok a = b.a2; // ok @@ -62,6 +64,7 @@ a = b.a3; // error a = b.a4; // error a = b.a5; // ok a = b.a6; // error + var a2; a2 = b.a; // ok a2 = b.a2; // ok @@ -69,6 +72,7 @@ a2 = b.a3; // ok a2 = b.a4; // ok a2 = b.a5; // ok a2 = b.a6; // error + var a3; a3 = b.a; // ok a3 = b.a2; // ok @@ -76,6 +80,7 @@ a3 = b.a3; // ok a3 = b.a4; // ok a3 = b.a5; // ok a3 = b.a6; // error + var a4; a4 = b.a; // ok a4 = b.a2; // ok @@ -83,6 +88,7 @@ a4 = b.a3; // ok a4 = b.a4; // ok a4 = b.a5; // ok a4 = b.a6; // ok + var a5; a5 = b.a; // ok a5 = b.a2; // ok diff --git a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js index 2719a525ba7a5..6fb463716e1aa 100644 --- a/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js +++ b/tests/baselines/reference/assignmentCompatWithDiscriminatedUnion.js @@ -198,6 +198,8 @@ namespace GH20889 { // IteratorResult var Example1; (function (Example1) { + + // S is assignable to T0 when S["done"] is true // S is assignable to T1 when S["done"] is false t = s; @@ -205,6 +207,7 @@ var Example1; // Dropping constituents of T var Example2; (function (Example2) { + // S is assignable to T0 when S["a"] is 0 // S is assignable to T2 when S["a"] is 2 t = s; @@ -212,6 +215,7 @@ var Example2; // Unmatched discriminants var Example3; (function (Example3) { + // S is assignable to T0 when S["a"] is 0 // S is *not* assignable to T1 when S["b"] is 4 // S is *not* assignable to T2 when S["a"] is 2 @@ -220,6 +224,7 @@ var Example3; // Unmatched non-discriminants var Example4; (function (Example4) { + // S is assignable to T0 when S["a"] is 0 // S is *not* assignable to T2 when S["a"] is 2 as S is missing "c" t = s; @@ -227,6 +232,7 @@ var Example4; // Maximum discriminant combinations var Example5; (function (Example5) { + // S *should* be assignable but the number of // combinations is too complex. t = s; @@ -234,6 +240,7 @@ var Example5; // https://github.com/Microsoft/TypeScript/issues/14865 var GH14865; (function (GH14865) { + var a = { type: "A", data: "whatevs" }; var b; a.type; // "A" | "B" @@ -244,6 +251,7 @@ var GH14865; var GH30170; (function (GH30170) { function draw(val) { } + function drawWithColor(currentColor) { return draw({ color: currentColor }); } @@ -251,6 +259,10 @@ var GH30170; // https://github.com/Microsoft/TypeScript/issues/12052 var GH12052; (function (GH12052) { + + + + function getAxisType() { if (1 == 1) { return "categorical"; @@ -259,6 +271,7 @@ var GH12052; return "linear"; } } + var bad = { type: getAxisType() }; var good = { type: undefined }; good.type = getAxisType(); @@ -266,6 +279,11 @@ var GH12052; // https://github.com/Microsoft/TypeScript/issues/18421 var GH18421; (function (GH18421) { + + + + + function makeNewThing(thingType) { return { type: thingType @@ -275,14 +293,19 @@ var GH18421; // https://github.com/Microsoft/TypeScript/issues/15907 var GH15907; (function (GH15907) { + function dispatchAction(action) { } + var active = true; + dispatchAction({ type: (active ? 'disactivate' : 'activate') }); })(GH15907 || (GH15907 = {})); // https://github.com/Microsoft/TypeScript/issues/20889 var GH20889; (function (GH20889) { + + function foo(obj1) { var obj2 = { type: obj1.type diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures.js b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures.js index ba4093f523df8..c01d66cf39c6d 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures.js +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures.js @@ -9,7 +9,9 @@ g = f; // ok //// [assignmentCompatWithGenericCallSignatures.js] // some complex cases of assignment compat of generic signatures that stress contextual signature instantiation + var f; var g; + f = g; // ok g = f; // ok diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js index 057cbebb3828c..95103090d99c3 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js @@ -19,8 +19,11 @@ b = a; //// [assignmentCompatWithGenericCallSignatures2.js] // some complex cases of assignment compat of generic signatures. No contextual signature instantiation + + var a; var b; + // Both errors a = b; b = a; diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures3.js b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures3.js index ae83c39f2a02a..bec5557206d6e 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures3.js +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures3.js @@ -12,6 +12,9 @@ g = h // ok //// [assignmentCompatWithGenericCallSignatures3.js] // some complex cases of assignment compat of generic signatures that stress contextual signature instantiation + + var g; var h; + g = h; // ok diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures4.js b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures4.js index 6114e6fdb5419..9827222e31442 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures4.js +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures4.js @@ -15,8 +15,11 @@ y = x //// [assignmentCompatWithGenericCallSignatures4.js] // some complex cases of assignment compat of generic signatures. + + var x; var y; + // These both do not make sense as we would eventually be comparing I2 to I2>, and they are self referencing anyway x = y; y = x; diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.js b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.js index 78e657f5cb003..d8882847d9c00 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.js +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.js @@ -141,17 +141,22 @@ var ClassTypeParam; _this.a = function () { return null; }; // ok, same T of required params _this.a = function (x) { return null; }; // ok, same T of required params _this.a = function (x) { return null; }; // error, too many required params + _this.a2 = function () { return null; }; // ok, same T of required params _this.a2 = function (x) { return null; }; // ok, same T of required params _this.a2 = function (x) { return null; }; // ok, same number of params + _this.a3 = function () { return null; }; // ok, fewer required params _this.a3 = function (x) { return null; }; // ok, fewer required params _this.a3 = function (x) { return null; }; // ok, same T of required params _this.a3 = function (x, y) { return null; }; // error, too many required params + _this.a4 = function () { return null; }; // ok, fewer required params _this.a4 = function (x, y) { return null; }; // ok, fewer required params _this.a4 = function (x) { return null; }; // ok, same T of required params _this.a4 = function (x, y) { return null; }; // ok, same number of params + + _this.a5 = function () { return null; }; // ok, fewer required params _this.a5 = function (x, y) { return null; }; // ok, fewer required params _this.a5 = function (x) { return null; }; // ok, all present params match @@ -163,6 +168,7 @@ var ClassTypeParam; })(ClassTypeParam || (ClassTypeParam = {})); var GenericSignaturesInvalid; (function (GenericSignaturesInvalid) { + var Base2 = /** @class */ (function () { function Base2() { } @@ -176,27 +182,32 @@ var GenericSignaturesInvalid; function foo() { var b; var t; + // all errors b.a = t.a; b.a = t.a2; b.a = t.a3; b.a = t.a4; b.a = t.a5; + b.a2 = t.a; b.a2 = t.a2; b.a2 = t.a3; b.a2 = t.a4; b.a2 = t.a5; + b.a3 = t.a; b.a3 = t.a2; b.a3 = t.a3; b.a3 = t.a4; b.a3 = t.a5; + b.a4 = t.a; b.a4 = t.a2; b.a4 = t.a3; b.a4 = t.a4; b.a4 = t.a5; + b.a5 = t.a; b.a5 = t.a2; b.a5 = t.a3; @@ -206,6 +217,7 @@ var GenericSignaturesInvalid; })(GenericSignaturesInvalid || (GenericSignaturesInvalid = {})); var GenericSignaturesValid; (function (GenericSignaturesValid) { + var Base2 = /** @class */ (function () { function Base2() { var _this = this; @@ -213,17 +225,22 @@ var GenericSignaturesValid; _this.a = function () { return null; }; // ok, same T of required params _this.a = function (x) { return null; }; // ok, same T of required params _this.a = function (x) { return null; }; // error, too many required params + _this.a2 = function () { return null; }; // ok, same T of required params _this.a2 = function (x) { return null; }; // ok, same T of required params _this.a2 = function (x) { return null; }; // ok, same number of params + _this.a3 = function () { return null; }; // ok, fewer required params _this.a3 = function (x) { return null; }; // ok, fewer required params _this.a3 = function (x) { return null; }; // ok, same T of required params _this.a3 = function (x, y) { return null; }; // error, too many required params + _this.a4 = function () { return null; }; // ok, fewer required params _this.a4 = function (x, y) { return null; }; // ok, fewer required params _this.a4 = function (x) { return null; }; // ok, same T of required params _this.a4 = function (x, y) { return null; }; // ok, same number of params + + _this.a5 = function () { return null; }; // ok, fewer required params _this.a5 = function (x, y) { return null; }; // ok, fewer required params _this.a5 = function (x) { return null; }; // ok, all present params match diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js index 6cdab6f3bed55..3eb2f09dce7d8 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.js @@ -58,6 +58,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + + var A = /** @class */ (function () { function A() { } @@ -67,6 +69,7 @@ var a; var b; a = b; b = a; // error + var b2; a = b2; b2 = a; // error @@ -89,9 +92,11 @@ var Generics; var b; a = b; // error b = a; // error + var b2; a = b2; // error b2 = a; // error + var b3; a = b3; // ok b3 = a; // ok diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.js index 8af454eaf8d2e..d9149735494be 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.js @@ -45,23 +45,29 @@ module Generics { //// [assignmentCompatWithNumericIndexer2.js] // Derived type indexer must be subtype of base type indexer + + var a; var b; a = b; b = a; // error + var b2; a = b2; b2 = a; // error var Generics; (function (Generics) { + function foo() { var a; var b; a = b; // error b = a; // error + var b2; a = b2; // error b2 = a; // error + var b3; a = b3; // ok b3 = a; // ok diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js index 54eb5e3ac9bc7..c5e8aa312f98e 100644 --- a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.js @@ -55,6 +55,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + + var A = /** @class */ (function () { function A() { } @@ -62,8 +64,10 @@ var A = /** @class */ (function () { }()); var a; var b; + a = b; // error b = a; // ok + var B2 = /** @class */ (function (_super) { __extends(B2, _super); function B2() { @@ -86,6 +90,7 @@ var Generics; var b; a = b; // error b = a; // ok + var b2; a = b2; // ok b2 = a; // ok diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers.js b/tests/baselines/reference/assignmentCompatWithObjectMembers.js index 2589f464c5315..592d6a4512f8c 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers.js @@ -91,37 +91,42 @@ module ObjectTypes { var SimpleTypes; (function (SimpleTypes) { var S = /** @class */ (function () { - function S() { - } + function S() {} return S; }()); var T = /** @class */ (function () { - function T() { - } + function T() {} return T; }()); var s; var t; + var s2; var t2; + var a; var b; + var a2 = { foo: '' }; var b2 = { foo: '' }; + s = t; t = s; s = s2; s = a2; + s2 = t2; t2 = s2; s2 = t; s2 = b; s2 = a2; + a = b; b = a; a = s; a = s2; a = a2; + a2 = b2; b2 = a2; a2 = b; @@ -131,37 +136,42 @@ var SimpleTypes; var ObjectTypes; (function (ObjectTypes) { var S = /** @class */ (function () { - function S() { - } + function S() {} return S; }()); var T = /** @class */ (function () { - function T() { - } + function T() {} return T; }()); var s; var t; + var s2; var t2; + var a; var b; + var a2 = { foo: a2 }; var b2 = { foo: b2 }; + s = t; t = s; s = s2; s = a2; + s2 = t2; t2 = s2; s2 = t; s2 = b; s2 = a2; + a = b; b = a; a = s; a = s2; a = a2; + a2 = b2; b2 = a2; a2 = b; diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers2.js b/tests/baselines/reference/assignmentCompatWithObjectMembers2.js index 08452e3d210c9..9f85b8711a89d 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers2.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers2.js @@ -45,38 +45,44 @@ a2 = t; //// [assignmentCompatWithObjectMembers2.js] // members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M // additional optional properties do not cause errors + var S = /** @class */ (function () { - function S() { - } + function S() {} return S; }()); var T = /** @class */ (function () { - function T() { - } + function T() {} return T; }()); var s; var t; + var s2; var t2; + var a; var b; + var a2 = { foo: '' }; var b2 = { foo: '' }; + s = t; t = s; s = s2; s = a2; + s2 = t2; t2 = s2; s2 = t; s2 = b; s2 = a2; + a = b; b = a; a = s; a = s2; a = a2; + a2 = b2; b2 = a2; a2 = b; diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers3.js b/tests/baselines/reference/assignmentCompatWithObjectMembers3.js index 58c6321faa620..6ed4fd6266cc7 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers3.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers3.js @@ -45,38 +45,44 @@ a2 = t; //// [assignmentCompatWithObjectMembers3.js] // members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M // additional optional properties do not cause errors + var S = /** @class */ (function () { - function S() { - } + function S() {} return S; }()); var T = /** @class */ (function () { - function T() { - } + function T() {} return T; }()); var s; var t; + var s2; var t2; + var a; var b; + var a2 = { foo: '' }; var b2 = { foo: '' }; + s = t; t = s; s = s2; s = a2; + s2 = t2; t2 = s2; s2 = t; s2 = b; s2 = a2; + a = b; b = a; a = s; a = s2; a = a2; + a2 = b2; b2 = a2; a2 = b; diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js index dd8d9d1bf4637..ddb1ccb0b183c 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers4.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers4.js @@ -109,8 +109,7 @@ var __extends = (this && this.__extends) || (function () { var OnlyDerived; (function (OnlyDerived) { var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -128,37 +127,42 @@ var OnlyDerived; return Derived2; }(Base)); var S = /** @class */ (function () { - function S() { - } + function S() {} return S; }()); var T = /** @class */ (function () { - function T() { - } + function T() {} return T; }()); var s; var t; + var s2; var t2; + var a; var b; + var a2 = { foo: new Derived() }; var b2 = { foo: new Derived2() }; + s = t; // error t = s; // error s = s2; // ok s = a2; // ok + s2 = t2; // error t2 = s2; // error s2 = t; // error s2 = b; // error s2 = a2; // ok + a = b; // error b = a; // error a = s; // ok a = s2; // ok a = a2; // ok + a2 = b2; // error b2 = a2; // error a2 = b; // error @@ -168,8 +172,7 @@ var OnlyDerived; var WithBase; (function (WithBase) { var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -187,37 +190,42 @@ var WithBase; return Derived2; }(Base)); var S = /** @class */ (function () { - function S() { - } + function S() {} return S; }()); var T = /** @class */ (function () { - function T() { - } + function T() {} return T; }()); var s; var t; + var s2; var t2; + var a; var b; + var a2 = { foo: new Base() }; var b2 = { foo: new Derived2() }; + s = t; // ok t = s; // error s = s2; // ok s = a2; // ok + s2 = t2; // ok t2 = s2; // error s2 = t; // ok s2 = b; // ok s2 = a2; // ok + a = b; // ok b = a; // error a = s; // ok a = s2; // ok a = a2; // ok + a2 = b2; // ok b2 = a2; // error a2 = b; // ok diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers5.js b/tests/baselines/reference/assignmentCompatWithObjectMembers5.js index 86302977ecbab..6835a36c6452a 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers5.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers5.js @@ -21,6 +21,9 @@ var C = /** @class */ (function () { return C; }()); var c; + + var i; + c = i; // error i = c; // error diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.js b/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.js index efe6857f933a7..0f8b178e9e603 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.js @@ -119,9 +119,11 @@ var TargetIsPublic; } return Base; }()); + var a; var b; var i; + // sources var D = /** @class */ (function () { function D() { @@ -135,22 +137,27 @@ var TargetIsPublic; }()); var d; var e; + a = b; a = i; a = d; a = e; // error + b = a; b = i; b = d; b = e; // error + i = a; i = b; i = d; i = e; // error + d = a; d = b; d = i; d = e; // error + e = a; // errror e = b; // errror e = i; // errror @@ -164,9 +171,11 @@ var TargetIsPublic; } return Base; }()); + var a; var b; var i; + // sources var D = /** @class */ (function () { function D() { @@ -180,24 +189,29 @@ var TargetIsPublic; }()); var d; var e; + a = b; // error a = i; // error a = d; a = e; // error + b = a; // error b = i; b = d; // error b = e; // error b = b; + i = a; // error i = b; i = d; // error i = e; // error i = i; + d = a; d = b; // error d = i; // error d = e; // error + e = a; // errror e = b; // errror e = i; // errror diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.js b/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.js index e021f3e22e62e..d362550473455 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.js @@ -45,38 +45,44 @@ a2 = t; //// [assignmentCompatWithObjectMembersNumericNames.js] // members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M // numeric named properties work correctly, no errors expected + var S = /** @class */ (function () { - function S() { - } + function S() {} return S; }()); var T = /** @class */ (function () { - function T() { - } + function T() {} return T; }()); var s; var t; + var s2; var t2; + var a; var b; + var a2 = { 1.0: '' }; var b2 = { 1: '' }; + s = t; t = s; s = s2; s = a2; + s2 = t2; t2 = s2; s2 = t; s2 = b; s2 = a2; + a = b; b = a; a = s; a = s2; a = a2; + a2 = b2; b2 = a2; a2 = b; diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js index fa8ca3f7ad880..1222846d8e141 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.js @@ -103,9 +103,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -125,20 +125,25 @@ var Derived2 = /** @class */ (function (_super) { var TargetHasOptional; (function (TargetHasOptional) { var c; + var a; var b = { opt: new Base() }; + var d; var e; var f; + // all ok c = d; c = e; c = f; c = a; + a = d; a = e; a = f; a = c; + b = d; b = e; b = f; @@ -148,19 +153,24 @@ var TargetHasOptional; var SourceHasOptional; (function (SourceHasOptional) { var c; + var a; var b = { opt: new Base() }; + var d; var e; var f; + c = d; // error c = e; // error c = f; // ok c = a; // ok + a = d; // error a = e; // error a = f; // ok a = c; // ok + b = d; // error b = e; // error b = f; // ok diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js index 918c2739ace6c..0328a22c1ed47 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js @@ -106,9 +106,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -128,11 +128,14 @@ var Derived2 = /** @class */ (function (_super) { var TargetHasOptional; (function (TargetHasOptional) { var c; + var a; var b = { opt: new Base() }; + var d; var e; var f; + // disallowed by weak type checking c = d; c = e; @@ -143,6 +146,7 @@ var TargetHasOptional; b = d; b = e; b = f; + // ok c = a; a = c; @@ -152,19 +156,24 @@ var TargetHasOptional; var SourceHasOptional; (function (SourceHasOptional) { var c; + var a; var b = { opt: new Base() }; + var d; var e; var f; + c = d; // error c = e; // error c = f; // error c = a; // ok + a = d; // error a = e; // error a = f; // error a = c; // ok + b = d; // error b = e; // error b = f; // error diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.js b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.js index 30e81f3f19f08..8bc536c844b6e 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.js +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.js @@ -91,37 +91,42 @@ module NumbersAndStrings { var JustStrings; (function (JustStrings) { var S = /** @class */ (function () { - function S() { - } + function S() {} return S; }()); var T = /** @class */ (function () { - function T() { - } + function T() {} return T; }()); var s; var t; + var s2; var t2; + var a; var b; + var a2 = { '1.0': '' }; var b2 = { '1': '' }; + s = t; t = s; s = s2; // ok s = a2; + s2 = t2; t2 = s2; s2 = t; s2 = b; s2 = a2; + a = b; b = a; a = s; a = s2; a = a2; + a2 = b2; b2 = a2; a2 = b; // ok @@ -131,38 +136,43 @@ var JustStrings; var NumbersAndStrings; (function (NumbersAndStrings) { var S = /** @class */ (function () { - function S() { - } + function S() {} return S; }()); var T = /** @class */ (function () { - function T() { - } + function T() {} return T; }()); var s; var t; + var s2; var t2; + var a; var b; + var a2 = { '1.0': '' }; var b2 = { 1.: '' }; + s = t; // ok t = s; // ok s = s2; // ok s = a2; // error + s2 = t2; // ok t2 = s2; // ok s2 = t; // ok s2 = b; // ok s2 = a2; // error + a = b; // error b = a; // error a = s; // error a = s2; // error a = a2; // error a = b2; // error + a2 = b2; // error b2 = a2; // error a2 = b; // error diff --git a/tests/baselines/reference/assignmentCompatWithOverloads.js b/tests/baselines/reference/assignmentCompatWithOverloads.js index 8955dd409755a..0eb1929cefa2b 100644 --- a/tests/baselines/reference/assignmentCompatWithOverloads.js +++ b/tests/baselines/reference/assignmentCompatWithOverloads.js @@ -32,18 +32,28 @@ d = C; // Error //// [assignmentCompatWithOverloads.js] function f1(x) { return null; } + function f2(x) { return null; } + function f3(x) { return null; } + + function f4(x) { return undefined; } + var g; + g = f1; // OK + g = f2; // Error + g = f3; // Error + g = f4; // Error + var C = /** @class */ (function () { - function C(x) { - } + function C(x) {} return C; }()); var d; + d = C; // Error diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.js b/tests/baselines/reference/assignmentCompatWithStringIndexer.js index 9a67a00bac026..7f774a527e642 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer.js +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.js @@ -68,15 +68,19 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + + var A = /** @class */ (function () { function A() { } return A; }()); var a; + var b; a = b; // ok b = a; // error + var b2; a = b2; // ok b2 = a; // error @@ -98,6 +102,7 @@ var Generics; var a1; a1 = b1; // ok b1 = a1; // error + var B2 = /** @class */ (function (_super) { __extends(B2, _super); function B2() { @@ -108,11 +113,13 @@ var Generics; var b2; a1 = b2; // ok b2 = a1; // error + function foo() { var b3; var a3; a3 = b3; // error b3 = a3; // error + var b4; a3 = b4; // error b4 = a3; // error diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer2.js b/tests/baselines/reference/assignmentCompatWithStringIndexer2.js index 50fe7b3f8b9be..80b5fea6bbe6f 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer2.js +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer2.js @@ -55,27 +55,36 @@ module Generics { //// [assignmentCompatWithStringIndexer2.js] // index signatures must be compatible in assignments + + var a; + var b; a = b; // ok b = a; // error + var b2; a = b2; // ok b2 = a; // error var Generics; (function (Generics) { + var b1; var a1; a1 = b1; // ok b1 = a1; // error + + var b2; a1 = b2; // ok b2 = a1; // error + function foo() { var b3; var a3; a3 = b3; // error b3 = a3; // error + var b4; a3 = b4; // error b4 = a3; // error diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer3.js b/tests/baselines/reference/assignmentCompatWithStringIndexer3.js index d3306949906e2..f0400afaaccbc 100644 --- a/tests/baselines/reference/assignmentCompatWithStringIndexer3.js +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer3.js @@ -25,6 +25,8 @@ module Generics { //// [assignmentCompatWithStringIndexer3.js] // Derived type indexer must be subtype of base type indexer + + var a; var b1; a = b1; // error diff --git a/tests/baselines/reference/assignmentCompatability1.js b/tests/baselines/reference/assignmentCompatability1.js index f629d5eba27e7..20f9141034bff 100644 --- a/tests/baselines/reference/assignmentCompatability1.js +++ b/tests/baselines/reference/assignmentCompatability1.js @@ -12,15 +12,12 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability1.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; (function (__test2__) { - __test2__.aa = {}; - ; + __test2__.aa = {};; __test2__.__val__aa = __test2__.aa; })(__test2__ || (__test2__ = {})); __test2__.__val__aa = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability10.js b/tests/baselines/reference/assignmentCompatability10.js index c21d0d57abdaf..ec674be5586a2 100644 --- a/tests/baselines/reference/assignmentCompatability10.js +++ b/tests/baselines/reference/assignmentCompatability10.js @@ -12,9 +12,7 @@ __test2__.__val__x4 = __test1__.__val__obj4 //// [assignmentCompatability10.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; @@ -27,8 +25,7 @@ var __test2__; return classWithPublicAndOptional; }()); __test2__.classWithPublicAndOptional = classWithPublicAndOptional; - var x4 = new classWithPublicAndOptional(1); - ; + var x4 = new classWithPublicAndOptional(1);; __test2__.__val__x4 = x4; })(__test2__ || (__test2__ = {})); __test2__.__val__x4 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability11.js b/tests/baselines/reference/assignmentCompatability11.js index 992e38f772634..563ea0453140b 100644 --- a/tests/baselines/reference/assignmentCompatability11.js +++ b/tests/baselines/reference/assignmentCompatability11.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability11.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability12.js b/tests/baselines/reference/assignmentCompatability12.js index 3c802aab6e3d6..d21f17823d1e9 100644 --- a/tests/baselines/reference/assignmentCompatability12.js +++ b/tests/baselines/reference/assignmentCompatability12.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability12.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability13.js b/tests/baselines/reference/assignmentCompatability13.js index ef4f24f710029..8e87b885b90ad 100644 --- a/tests/baselines/reference/assignmentCompatability13.js +++ b/tests/baselines/reference/assignmentCompatability13.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability13.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability14.js b/tests/baselines/reference/assignmentCompatability14.js index bd4445cb515b0..d6f40356fe259 100644 --- a/tests/baselines/reference/assignmentCompatability14.js +++ b/tests/baselines/reference/assignmentCompatability14.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability14.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability15.js b/tests/baselines/reference/assignmentCompatability15.js index 37f1be4bc99d4..abd17377bd987 100644 --- a/tests/baselines/reference/assignmentCompatability15.js +++ b/tests/baselines/reference/assignmentCompatability15.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability15.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability16.js b/tests/baselines/reference/assignmentCompatability16.js index 43c832016b0e3..5da393382f507 100644 --- a/tests/baselines/reference/assignmentCompatability16.js +++ b/tests/baselines/reference/assignmentCompatability16.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability16.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability17.js b/tests/baselines/reference/assignmentCompatability17.js index 09ce24b8f5da6..6ffd921637c10 100644 --- a/tests/baselines/reference/assignmentCompatability17.js +++ b/tests/baselines/reference/assignmentCompatability17.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability17.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability18.js b/tests/baselines/reference/assignmentCompatability18.js index ad93e96303ff2..3debf23415fb4 100644 --- a/tests/baselines/reference/assignmentCompatability18.js +++ b/tests/baselines/reference/assignmentCompatability18.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability18.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability19.js b/tests/baselines/reference/assignmentCompatability19.js index f330f94e81c6b..4f6059fba5fbb 100644 --- a/tests/baselines/reference/assignmentCompatability19.js +++ b/tests/baselines/reference/assignmentCompatability19.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability19.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability2.js b/tests/baselines/reference/assignmentCompatability2.js index 0c45fa378c619..7294f5c916614 100644 --- a/tests/baselines/reference/assignmentCompatability2.js +++ b/tests/baselines/reference/assignmentCompatability2.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability2.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability20.js b/tests/baselines/reference/assignmentCompatability20.js index 321ec78ee17ce..6d8096f30b2aa 100644 --- a/tests/baselines/reference/assignmentCompatability20.js +++ b/tests/baselines/reference/assignmentCompatability20.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability20.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability21.js b/tests/baselines/reference/assignmentCompatability21.js index 215ab5dc3979b..fc73215b0d90c 100644 --- a/tests/baselines/reference/assignmentCompatability21.js +++ b/tests/baselines/reference/assignmentCompatability21.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability21.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability22.js b/tests/baselines/reference/assignmentCompatability22.js index 04cc2a2d0abcf..ae6f6a73dcd16 100644 --- a/tests/baselines/reference/assignmentCompatability22.js +++ b/tests/baselines/reference/assignmentCompatability22.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability22.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability23.js b/tests/baselines/reference/assignmentCompatability23.js index 1d03236436059..ca139f6fd2359 100644 --- a/tests/baselines/reference/assignmentCompatability23.js +++ b/tests/baselines/reference/assignmentCompatability23.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability23.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability24.js b/tests/baselines/reference/assignmentCompatability24.js index e6961264de827..e7fad9944a221 100644 --- a/tests/baselines/reference/assignmentCompatability24.js +++ b/tests/baselines/reference/assignmentCompatability24.js @@ -12,15 +12,12 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability24.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; (function (__test2__) { - __test2__.obj = function f(a) { return a; }; - ; + __test2__.obj = function f(a) { return a; };; __test2__.__val__obj = __test2__.obj; })(__test2__ || (__test2__ = {})); __test2__.__val__obj = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability25.js b/tests/baselines/reference/assignmentCompatability25.js index 52cc4326eaaa3..dc7e25f16e2cb 100644 --- a/tests/baselines/reference/assignmentCompatability25.js +++ b/tests/baselines/reference/assignmentCompatability25.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability25.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability26.js b/tests/baselines/reference/assignmentCompatability26.js index 12479b7b8b94d..fe4df4fcc639f 100644 --- a/tests/baselines/reference/assignmentCompatability26.js +++ b/tests/baselines/reference/assignmentCompatability26.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability26.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability27.js b/tests/baselines/reference/assignmentCompatability27.js index aeac55d9c1703..565386f30e1b5 100644 --- a/tests/baselines/reference/assignmentCompatability27.js +++ b/tests/baselines/reference/assignmentCompatability27.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability27.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability28.js b/tests/baselines/reference/assignmentCompatability28.js index 27d2f7d09d0aa..0f3ef6e40cffb 100644 --- a/tests/baselines/reference/assignmentCompatability28.js +++ b/tests/baselines/reference/assignmentCompatability28.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability28.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability29.js b/tests/baselines/reference/assignmentCompatability29.js index 4488c5185309d..5b5006e543134 100644 --- a/tests/baselines/reference/assignmentCompatability29.js +++ b/tests/baselines/reference/assignmentCompatability29.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability29.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability3.js b/tests/baselines/reference/assignmentCompatability3.js index 7120e6ce3e24b..5ca3e528ac5a6 100644 --- a/tests/baselines/reference/assignmentCompatability3.js +++ b/tests/baselines/reference/assignmentCompatability3.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability3.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability30.js b/tests/baselines/reference/assignmentCompatability30.js index e6729ad31942b..b8950cf266d70 100644 --- a/tests/baselines/reference/assignmentCompatability30.js +++ b/tests/baselines/reference/assignmentCompatability30.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability30.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability31.js b/tests/baselines/reference/assignmentCompatability31.js index 20aab7d823bf7..665aa1e2d5824 100644 --- a/tests/baselines/reference/assignmentCompatability31.js +++ b/tests/baselines/reference/assignmentCompatability31.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability31.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability32.js b/tests/baselines/reference/assignmentCompatability32.js index c1656c8b4261a..c2bb431fbc9ed 100644 --- a/tests/baselines/reference/assignmentCompatability32.js +++ b/tests/baselines/reference/assignmentCompatability32.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability32.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability33.js b/tests/baselines/reference/assignmentCompatability33.js index f078421a65bb9..2a1a35a0cc127 100644 --- a/tests/baselines/reference/assignmentCompatability33.js +++ b/tests/baselines/reference/assignmentCompatability33.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability33.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability34.js b/tests/baselines/reference/assignmentCompatability34.js index d0e04eddf3f13..9523bf54dbacf 100644 --- a/tests/baselines/reference/assignmentCompatability34.js +++ b/tests/baselines/reference/assignmentCompatability34.js @@ -12,9 +12,7 @@ __test2__.__val__obj = __test1__.__val__obj4 //// [assignmentCompatability34.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability35.js b/tests/baselines/reference/assignmentCompatability35.js index c1a87636e82ef..609681194b1a3 100644 --- a/tests/baselines/reference/assignmentCompatability35.js +++ b/tests/baselines/reference/assignmentCompatability35.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability35.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability36.js b/tests/baselines/reference/assignmentCompatability36.js index c5d274ba0905b..3f275e17f126c 100644 --- a/tests/baselines/reference/assignmentCompatability36.js +++ b/tests/baselines/reference/assignmentCompatability36.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability36.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability37.js b/tests/baselines/reference/assignmentCompatability37.js index 8f4bf522854c3..47337122976c2 100644 --- a/tests/baselines/reference/assignmentCompatability37.js +++ b/tests/baselines/reference/assignmentCompatability37.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability37.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability38.js b/tests/baselines/reference/assignmentCompatability38.js index d89f5c735d6ea..3391bc93c5e77 100644 --- a/tests/baselines/reference/assignmentCompatability38.js +++ b/tests/baselines/reference/assignmentCompatability38.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability38.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability39.js b/tests/baselines/reference/assignmentCompatability39.js index 6a2c4e88e30b8..7a932b5b811b2 100644 --- a/tests/baselines/reference/assignmentCompatability39.js +++ b/tests/baselines/reference/assignmentCompatability39.js @@ -12,9 +12,7 @@ __test2__.__val__x2 = __test1__.__val__obj4 //// [assignmentCompatability39.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; @@ -27,8 +25,7 @@ var __test2__; return classWithTwoPublic; }()); __test2__.classWithTwoPublic = classWithTwoPublic; - var x2 = new classWithTwoPublic(1, "a"); - ; + var x2 = new classWithTwoPublic(1, "a");; __test2__.__val__x2 = x2; })(__test2__ || (__test2__ = {})); __test2__.__val__x2 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability4.js b/tests/baselines/reference/assignmentCompatability4.js index 7ce0f48bc18cc..343ceb1f7fe92 100644 --- a/tests/baselines/reference/assignmentCompatability4.js +++ b/tests/baselines/reference/assignmentCompatability4.js @@ -12,9 +12,7 @@ __test2__.__val__aa = __test1__.__val__obj4 //// [assignmentCompatability4.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; diff --git a/tests/baselines/reference/assignmentCompatability40.js b/tests/baselines/reference/assignmentCompatability40.js index ecfd29d6213dc..103f2488c61dc 100644 --- a/tests/baselines/reference/assignmentCompatability40.js +++ b/tests/baselines/reference/assignmentCompatability40.js @@ -12,9 +12,7 @@ __test2__.__val__x5 = __test1__.__val__obj4 //// [assignmentCompatability40.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; @@ -26,8 +24,7 @@ var __test2__; return classWithPrivate; }()); __test2__.classWithPrivate = classWithPrivate; - var x5 = new classWithPrivate(1); - ; + var x5 = new classWithPrivate(1);; __test2__.__val__x5 = x5; })(__test2__ || (__test2__ = {})); __test2__.__val__x5 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability41.js b/tests/baselines/reference/assignmentCompatability41.js index dbba1e012621a..7b003f14c094a 100644 --- a/tests/baselines/reference/assignmentCompatability41.js +++ b/tests/baselines/reference/assignmentCompatability41.js @@ -12,9 +12,7 @@ __test2__.__val__x6 = __test1__.__val__obj4 //// [assignmentCompatability41.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; @@ -27,8 +25,7 @@ var __test2__; return classWithTwoPrivate; }()); __test2__.classWithTwoPrivate = classWithTwoPrivate; - var x6 = new classWithTwoPrivate(1, "a"); - ; + var x6 = new classWithTwoPrivate(1, "a");; __test2__.__val__x6 = x6; })(__test2__ || (__test2__ = {})); __test2__.__val__x6 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability42.js b/tests/baselines/reference/assignmentCompatability42.js index 98ddf0bd4ec38..14a7d2bde9187 100644 --- a/tests/baselines/reference/assignmentCompatability42.js +++ b/tests/baselines/reference/assignmentCompatability42.js @@ -12,9 +12,7 @@ __test2__.__val__x7 = __test1__.__val__obj4 //// [assignmentCompatability42.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; @@ -27,8 +25,7 @@ var __test2__; return classWithPublicPrivate; }()); __test2__.classWithPublicPrivate = classWithPublicPrivate; - var x7 = new classWithPublicPrivate(1, "a"); - ; + var x7 = new classWithPublicPrivate(1, "a");; __test2__.__val__x7 = x7; })(__test2__ || (__test2__ = {})); __test2__.__val__x7 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability43.js b/tests/baselines/reference/assignmentCompatability43.js index 0ff9bdb481991..8e79b4c0e4f91 100644 --- a/tests/baselines/reference/assignmentCompatability43.js +++ b/tests/baselines/reference/assignmentCompatability43.js @@ -12,16 +12,12 @@ __test2__.__val__obj2 = __test1__.__val__obj4 //// [assignmentCompatability43.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; (function (__test2__) { - ; - var obj2 = { one: 1, two: "a" }; - ; + ;var obj2 = { one: 1, two: "a" };; __test2__.__val__obj2 = obj2; })(__test2__ || (__test2__ = {})); __test2__.__val__obj2 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability5.js b/tests/baselines/reference/assignmentCompatability5.js index ef38b738ad304..6e6250db512b6 100644 --- a/tests/baselines/reference/assignmentCompatability5.js +++ b/tests/baselines/reference/assignmentCompatability5.js @@ -12,16 +12,12 @@ __test2__.__val__obj1 = __test1__.__val__obj4 //// [assignmentCompatability5.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; (function (__test2__) { - ; - var obj1 = { one: 1 }; - ; + ;var obj1 = { one: 1 };; __test2__.__val__obj1 = obj1; })(__test2__ || (__test2__ = {})); __test2__.__val__obj1 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability6.js b/tests/baselines/reference/assignmentCompatability6.js index 7b1e2bb65d65f..f09c58b143921 100644 --- a/tests/baselines/reference/assignmentCompatability6.js +++ b/tests/baselines/reference/assignmentCompatability6.js @@ -12,16 +12,12 @@ __test2__.__val__obj3 = __test1__.__val__obj4 //// [assignmentCompatability6.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; (function (__test2__) { - ; - var obj3 = {}; - ; + ;var obj3 = {};; __test2__.__val__obj3 = obj3; })(__test2__ || (__test2__ = {})); __test2__.__val__obj3 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability7.js b/tests/baselines/reference/assignmentCompatability7.js index c6bf8e53bc168..ae32c1d9b94e2 100644 --- a/tests/baselines/reference/assignmentCompatability7.js +++ b/tests/baselines/reference/assignmentCompatability7.js @@ -12,16 +12,12 @@ __test2__.__val__obj4 = __test1__.__val__obj4 //// [assignmentCompatability7.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; (function (__test2__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test2__.__val__obj4 = obj4; })(__test2__ || (__test2__ = {})); __test2__.__val__obj4 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability8.js b/tests/baselines/reference/assignmentCompatability8.js index b0aa9b4374f33..13a6ce016eae2 100644 --- a/tests/baselines/reference/assignmentCompatability8.js +++ b/tests/baselines/reference/assignmentCompatability8.js @@ -12,9 +12,7 @@ __test2__.__val__x1 = __test1__.__val__obj4 //// [assignmentCompatability8.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; @@ -26,8 +24,7 @@ var __test2__; return classWithPublic; }()); __test2__.classWithPublic = classWithPublic; - var x1 = new classWithPublic(1); - ; + var x1 = new classWithPublic(1);; __test2__.__val__x1 = x1; })(__test2__ || (__test2__ = {})); __test2__.__val__x1 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability9.js b/tests/baselines/reference/assignmentCompatability9.js index 04fcec488b6f6..a1af3b7d50913 100644 --- a/tests/baselines/reference/assignmentCompatability9.js +++ b/tests/baselines/reference/assignmentCompatability9.js @@ -12,9 +12,7 @@ __test2__.__val__x3 = __test1__.__val__obj4 //// [assignmentCompatability9.js] var __test1__; (function (__test1__) { - ; - var obj4 = { one: 1 }; - ; + ;var obj4 = { one: 1 };; __test1__.__val__obj4 = obj4; })(__test1__ || (__test1__ = {})); var __test2__; @@ -26,8 +24,7 @@ var __test2__; return classWithOptional; }()); __test2__.classWithOptional = classWithOptional; - var x3 = new classWithOptional(); - ; + var x3 = new classWithOptional();; __test2__.__val__x3 = x3; })(__test2__ || (__test2__ = {})); __test2__.__val__x3 = __test1__.__val__obj4; diff --git a/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.js b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.js index 760631ffbb5f5..5ad3263af8cbc 100644 --- a/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.js +++ b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.js @@ -32,21 +32,28 @@ fn(a => { }); //// [assignmentCompatability_checking-apply-member-off-of-function-interface.js] // 3.8.4 Assignment Compatibility + + var x; + // Should fail x = ''; x = ['']; x = 4; x = {}; + // Should work -function f() { } -; +function f() { }; x = f; + function fn(c) { } + // Should Fail fn(''); fn(['']); fn(4); fn({}); + + // Should work fn(function (a) { }); diff --git a/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.js b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.js index 2e61521eefb84..7677210e2461d 100644 --- a/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.js +++ b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.js @@ -32,21 +32,28 @@ fn(a => { }); //// [assignmentCompatability_checking-call-member-off-of-function-interface.js] // 3.8.4 Assignment Compatibility + + var x; + // Should fail x = ''; x = ['']; x = 4; x = {}; + // Should work -function f() { } -; +function f() { }; x = f; + function fn(c) { } + // Should Fail fn(''); fn(['']); fn(4); fn({}); + + // Should work fn(function (a) { }); diff --git a/tests/baselines/reference/assignmentGenericLookupTypeNarrowing.js b/tests/baselines/reference/assignmentGenericLookupTypeNarrowing.js index 7f757ef24c3c7..0bb3942f23ae5 100644 --- a/tests/baselines/reference/assignmentGenericLookupTypeNarrowing.js +++ b/tests/baselines/reference/assignmentGenericLookupTypeNarrowing.js @@ -14,7 +14,9 @@ function bar(key: K) { //// [assignmentGenericLookupTypeNarrowing.js] // Repro from #26130 + var mappedObject = { foo: { x: "hello" } }; + function bar(key) { var element = foo(mappedObject[key]); if (element == null) diff --git a/tests/baselines/reference/assignmentIndexedToPrimitives.js b/tests/baselines/reference/assignmentIndexedToPrimitives.js index 363d41fc14de9..dbb3747b73228 100644 --- a/tests/baselines/reference/assignmentIndexedToPrimitives.js +++ b/tests/baselines/reference/assignmentIndexedToPrimitives.js @@ -21,11 +21,14 @@ var n1 = [0]; var n2 = ["0"]; var n3 = [0, "1"]; var n4 = [0]; + var s1 = [0]; var s2 = ["0"]; var s3 = [0, "1"]; var s4 = ["0", "1"]; + var no1 = { 0: 1 }; + var so1 = { 0: 1 }; var so2 = { "0": 1 }; var so3 = { 0: "1" }; diff --git a/tests/baselines/reference/assignmentLHSIsReference.js b/tests/baselines/reference/assignmentLHSIsReference.js index 85d2aab2c46d3..3c58c13674317 100644 --- a/tests/baselines/reference/assignmentLHSIsReference.js +++ b/tests/baselines/reference/assignmentLHSIsReference.js @@ -26,20 +26,26 @@ function fn2(x4: number) { //// [assignmentLHSIsReference.js] var value; + // identifiers: variable and parameter var x1; x1 = value; + function fn1(x2) { x2 = value; } + // property accesses var x3; x3.a = value; x3['a'] = value; + // parentheses, the contained expression is reference (x1) = value; + function fn2(x4) { (x4) = value; } + (x3.a) = value; (x3['a']) = value; diff --git a/tests/baselines/reference/assignmentLHSIsValue.js b/tests/baselines/reference/assignmentLHSIsValue.js index dd7f28cb0039e..666f55188867a 100644 --- a/tests/baselines/reference/assignmentLHSIsValue.js +++ b/tests/baselines/reference/assignmentLHSIsValue.js @@ -86,6 +86,7 @@ var __extends = (this && this.__extends) || (function () { })(); // expected error for all the LHS of assignments var value; + // this var C = /** @class */ (function () { function C() { @@ -96,18 +97,20 @@ var C = /** @class */ (function () { return C; }()); function foo() { this = value; } + this = value; // identifiers: module, class, enum, function var M; -(function (M) { -})(M || (M = {})); +(function (M) {})(M || (M = {})); M = value; + C = value; var E; -(function (E) { -})(E || (E = {})); +(function (E) {})(E || (E = {})); E = value; + foo = value; + // literals null = value; true = value; @@ -115,13 +118,13 @@ false = value; 0 = value; '' = value; /d+/ = value; + // object literals -{ - a: 0; -} -value; +{a: 0;}value; + // array literals '' = value[0], '' = value[1]; + // super var Derived = /** @class */ (function (_super) { __extends(Derived, _super); @@ -130,17 +133,20 @@ var Derived = /** @class */ (function (_super) { _super.prototype. = value; return _this; } + Derived.prototype.foo = function () { _super.prototype. = value; }; + Derived.sfoo = function () { _super. = value; }; return Derived; }(C)); // function expression -function bar() { } -value; -(function () { }); -value; +function bar() { }value; +( + function () { });value; + // function calls foo() = value; + // parentheses, the containted expression is value (this) = value; (M) = value; diff --git a/tests/baselines/reference/assignmentNestedInLiterals.js b/tests/baselines/reference/assignmentNestedInLiterals.js index 8a048082565d4..fe3bd3d1518e6 100644 --- a/tests/baselines/reference/assignmentNestedInLiterals.js +++ b/tests/baselines/reference/assignmentNestedInLiterals.js @@ -13,8 +13,10 @@ for (kowloona of [c = 1, d = c]) { //// [assignmentNestedInLiterals.js] var target, x, y; target = [x = 1, y = x]; + var aegis, a, b; aegis = { x: a = 1, y: b = a }; + var kowloona, c, d; for (var _i = 0, _a = [c = 1, d = c]; _i < _a.length; _i++) { kowloona = _a[_i]; diff --git a/tests/baselines/reference/assignmentNonObjectTypeConstraints.js b/tests/baselines/reference/assignmentNonObjectTypeConstraints.js index 35d6d7c1ff327..647e4232b98a4 100644 --- a/tests/baselines/reference/assignmentNonObjectTypeConstraints.js +++ b/tests/baselines/reference/assignmentNonObjectTypeConstraints.js @@ -20,23 +20,25 @@ bar(new B); //// [assignmentNonObjectTypeConstraints.js] + function foo(x) { var y = x; // Ok } + foo(5); foo(0 /* A */); + var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); var B = /** @class */ (function () { - function B() { - } + function B() {} return B; }()); function bar(x) { var y = x; // Ok } + bar(new A); bar(new B); diff --git a/tests/baselines/reference/assignmentStricterConstraints.js b/tests/baselines/reference/assignmentStricterConstraints.js index a7f554ade7d45..b86728eb96ea5 100644 --- a/tests/baselines/reference/assignmentStricterConstraints.js +++ b/tests/baselines/reference/assignmentStricterConstraints.js @@ -13,6 +13,8 @@ g(1, "") var f = function (x, y) { x = y; }; + var g = function (x, y) { }; + g = f; g(1, ""); diff --git a/tests/baselines/reference/assignmentToObjectAndFunction.js b/tests/baselines/reference/assignmentToObjectAndFunction.js index d60e2de4a5a78..a4cc96e0d1d87 100644 --- a/tests/baselines/reference/assignmentToObjectAndFunction.js +++ b/tests/baselines/reference/assignmentToObjectAndFunction.js @@ -36,18 +36,22 @@ var goodObj = { return ""; } }; // Ok, because toString is a subtype of Object's toString + var errFun = {}; // Error for no call signature + function foo() { } (function (foo) { foo.boom = 0; })(foo || (foo = {})); var goodFundule = foo; // ok + function bar() { } (function (bar) { function apply(thisArg, argArray) { } bar.apply = apply; })(bar || (bar = {})); var goodFundule2 = bar; // ok + function bad() { } (function (bad) { bad.apply = 0; diff --git a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.js b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.js index 543a54ca10e94..3676c8a94a095 100644 --- a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.js +++ b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.js @@ -86,6 +86,7 @@ M.y = 3; // OK M.y = ''; // Error (M).y = ''; // Error (M.y) = ''; // Error + M = { y: 3 }; // Error (M) = { y: 3 }; // Error var M2; @@ -98,21 +99,27 @@ var M2; M2.M3 = { x: 3 }; // OK (M2).M3 = { x: 3 }; // OK (M2.M3) = { x: 3 }; // OK + M2.M3 = { x: '' }; // Error (M2).M3 = { x: '' }; // Error (M2.M3) = { x: '' }; // Error + + function fn() { } fn = function () { return 3; }; // Bug 823548: Should be error (fn is not a reference) (fn) = function () { return 3; }; // Should be error + function fn2(x, y) { x = 3; (x) = 3; // OK x = ''; // Error (x) = ''; // Error + (y).t = 3; // OK (y.t) = 3; // OK (y).t = ''; // Error (y.t) = ''; // Error + y['t'] = 3; // OK (y)['t'] = 3; // OK (y['t']) = 3; // OK @@ -126,6 +133,7 @@ var E; })(E || (E = {})); E = undefined; // Error (E) = undefined; // Error + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/assignmentToReferenceTypes.js b/tests/baselines/reference/assignmentToReferenceTypes.js index b593240aec35d..f16aaf40320eb 100644 --- a/tests/baselines/reference/assignmentToReferenceTypes.js +++ b/tests/baselines/reference/assignmentToReferenceTypes.js @@ -25,7 +25,9 @@ function g(x) { //// [assignmentToReferenceTypes.js] // Should all be allowed + M = null; + var C = /** @class */ (function () { function C() { } @@ -33,13 +35,15 @@ var C = /** @class */ (function () { }()); C = null; var E; -(function (E) { -})(E || (E = {})); +(function (E) {})(E || (E = {})); E = null; + function f() { } f = null; + var x = 1; x = null; + function g(x) { x = null; } diff --git a/tests/baselines/reference/assignmentTypeNarrowing.js b/tests/baselines/reference/assignmentTypeNarrowing.js index 24a08539eb7d2..20757e618e148 100644 --- a/tests/baselines/reference/assignmentTypeNarrowing.js +++ b/tests/baselines/reference/assignmentTypeNarrowing.js @@ -38,20 +38,28 @@ arr.push({ x: "ok" }); //// [assignmentTypeNarrowing.js] var _a, _b, _c; var x; + x = ""; x; // string + x = [true][0]; x; // boolean + _a = [1][0], x = _a === void 0 ? "" : _a; x; // string | number + (x = { x: true }.x); x; // boolean + (x = { y: 1 }.y); x; // number + (_b = { x: true }.x, x = _b === void 0 ? "" : _b); x; // string | boolean + (_c = { y: 1 }.y, x = _c === void 0 ? /a/ : _c); x; // number | RegExp + var a; for (var _i = 0, a_1 = a; _i < a_1.length; _i++) { x = a_1[_i]; diff --git a/tests/baselines/reference/assignments.js b/tests/baselines/reference/assignments.js index 8143490083424..38136b87acf2f 100644 --- a/tests/baselines/reference/assignments.js +++ b/tests/baselines/reference/assignments.js @@ -40,10 +40,11 @@ I = null; // Error // Assign to a variable // Assign to a parameter // Assign to an interface + M = null; // Error + var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); C = null; // Error @@ -53,11 +54,15 @@ var E; })(E || (E = {})); E = null; // Error E.A = null; // OK per spec, Error per implementation (509581) + function fn() { } fn = null; // Should be error + var v; v = null; // OK + function fn2(p) { p = null; // OK } + I = null; // Error diff --git a/tests/baselines/reference/asyncAliasReturnType_es5.js b/tests/baselines/reference/asyncAliasReturnType_es5.js index 7684b413405f4..2ec6a0af6263c 100644 --- a/tests/baselines/reference/asyncAliasReturnType_es5.js +++ b/tests/baselines/reference/asyncAliasReturnType_es5.js @@ -5,6 +5,7 @@ async function f(): PromiseAlias { } //// [asyncAliasReturnType_es5.js] + function f() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { diff --git a/tests/baselines/reference/asyncAliasReturnType_es6.js b/tests/baselines/reference/asyncAliasReturnType_es6.js index 45fe3228f6ebd..aa4cf8a38caed 100644 --- a/tests/baselines/reference/asyncAliasReturnType_es6.js +++ b/tests/baselines/reference/asyncAliasReturnType_es6.js @@ -5,6 +5,7 @@ async function f(): PromiseAlias { } //// [asyncAliasReturnType_es6.js] + function f() { return __awaiter(this, void 0, void 0, function* () { }); diff --git a/tests/baselines/reference/asyncArrowFunction3_es5.js b/tests/baselines/reference/asyncArrowFunction3_es5.js index 3c73e6f9f58f9..a641571c1466d 100644 --- a/tests/baselines/reference/asyncArrowFunction3_es5.js +++ b/tests/baselines/reference/asyncArrowFunction3_es5.js @@ -3,6 +3,4 @@ function f(await = await) { } //// [asyncArrowFunction3_es5.js] -function f(await) { - if (await === void 0) { await = await; } -} +function f(await) {if (await === void 0) { await = await; }} diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.js b/tests/baselines/reference/asyncArrowFunction5_es2017.js index c3ce23ad103a4..86f67685d0fa1 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es2017.js +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.js @@ -3,7 +3,5 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es2017.js] -var foo = async(await), Promise; -; -{ +var foo = async(await), Promise;;{ } diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.js b/tests/baselines/reference/asyncArrowFunction5_es5.js index ac1e880155177..7642884e6f344 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es5.js +++ b/tests/baselines/reference/asyncArrowFunction5_es5.js @@ -3,7 +3,5 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es5.js] -var foo = async(await), Promise; -; -{ +var foo = async(await), Promise;;{ } diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.js b/tests/baselines/reference/asyncArrowFunction5_es6.js index 170962c6fd514..79f39408c280e 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es6.js +++ b/tests/baselines/reference/asyncArrowFunction5_es6.js @@ -3,7 +3,5 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es6.js] -var foo = async(await), Promise; -; -{ +var foo = async(await), Promise;;{ } diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.js b/tests/baselines/reference/asyncArrowFunction9_es2017.js index a101892eb1622..b43c5758be4ab 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es2017.js +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.js @@ -3,7 +3,5 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es2017.js] -var foo = async(a = await => await), Promise; -; -{ +var foo = async(a = await => await), Promise;;{ } diff --git a/tests/baselines/reference/asyncArrowFunction9_es5.js b/tests/baselines/reference/asyncArrowFunction9_es5.js index 457d5ddc4c4d7..41b6c30d7290e 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es5.js +++ b/tests/baselines/reference/asyncArrowFunction9_es5.js @@ -3,7 +3,5 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es5.js] -var foo = async(a = function (await) { return await; }), Promise; -; -{ +var foo = async(a = function (await) { return await; }), Promise;;{ } diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.js b/tests/baselines/reference/asyncArrowFunction9_es6.js index d7d5a16758367..b957bfb727161 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.js +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -3,7 +3,5 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es6.js] -var foo = async(a = await => await), Promise; -; -{ +var foo = async(a = await => await), Promise;;{ } diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js index 065aa675b6e57..5eb8f6870a594 100644 --- a/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js @@ -40,12 +40,17 @@ module M { } //// [asyncAwaitIsolatedModules_es2017.js] + + + async function f0() { } async function f1() { } async function f3() { } + let f4 = async function () { }; let f5 = async function () { }; let f6 = async function () { }; + let f7 = async () => { }; let f8 = async () => { }; let f9 = async () => { }; @@ -53,11 +58,13 @@ let f10 = async () => p; let f11 = async () => mp; let f12 = async () => mp; let f13 = async () => p; + let o = { async m1() { }, async m2() { }, async m3() { } }; + class C { async m1() { } async m2() { } diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es5.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.js index ec3837911ded0..51f97156ffbdd 100644 --- a/tests/baselines/reference/asyncAwaitIsolatedModules_es5.js +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.js @@ -79,6 +79,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; Object.defineProperty(exports, "__esModule", { value: true }); var missing_1 = require("missing"); + + function f0() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; @@ -94,6 +96,7 @@ function f3() { return [2 /*return*/]; }); }); } + var f4 = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; @@ -109,6 +112,7 @@ var f6 = function () { return [2 /*return*/]; }); }); }; + var f7 = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; }); }); }; @@ -130,6 +134,7 @@ var f12 = function () { return __awaiter(void 0, void 0, void 0, function () { r var f13 = function () { return __awaiter(void 0, void 0, missing_1.MyPromise, function () { return __generator(this, function (_a) { return [2 /*return*/, p]; }); }); }; + var o = { m1: function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { @@ -147,6 +152,7 @@ var o = { }); }); } }; + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js index 015992805bcbd..445bf61f189a1 100644 --- a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.js @@ -49,6 +49,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; + + function f0() { return __awaiter(this, void 0, void 0, function* () { }); } @@ -58,6 +60,7 @@ function f1() { function f3() { return __awaiter(this, void 0, void 0, function* () { }); } + let f4 = function () { return __awaiter(this, void 0, void 0, function* () { }); }; @@ -67,6 +70,7 @@ let f5 = function () { let f6 = function () { return __awaiter(this, void 0, void 0, function* () { }); }; + let f7 = () => __awaiter(void 0, void 0, void 0, function* () { }); let f8 = () => __awaiter(void 0, void 0, void 0, function* () { }); let f9 = () => __awaiter(void 0, void 0, void 0, function* () { }); @@ -74,6 +78,7 @@ let f10 = () => __awaiter(void 0, void 0, void 0, function* () { return p; }); let f11 = () => __awaiter(void 0, void 0, void 0, function* () { return mp; }); let f12 = () => __awaiter(void 0, void 0, void 0, function* () { return mp; }); let f13 = () => __awaiter(void 0, void 0, void 0, function* () { return p; }); + let o = { m1() { return __awaiter(this, void 0, void 0, function* () { }); @@ -85,6 +90,7 @@ let o = { return __awaiter(this, void 0, void 0, function* () { }); } }; + class C { m1() { return __awaiter(this, void 0, void 0, function* () { }); diff --git a/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js b/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js index 6d167a000894a..5cde97c259f99 100644 --- a/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js +++ b/tests/baselines/reference/asyncAwaitWithCapturedBlockScopeVar.js @@ -70,6 +70,7 @@ function fn1() { }); }); } + function fn2() { return __awaiter(this, void 0, void 0, function () { var ar, _loop_2, i, state_1; @@ -106,6 +107,7 @@ function fn2() { }); }); } + function fn3() { return __awaiter(this, void 0, void 0, function () { var ar, _loop_3, i; @@ -140,6 +142,7 @@ function fn3() { }); }); } + function fn4() { return __awaiter(this, void 0, void 0, function () { var ar, _loop_4, i, state_2; diff --git a/tests/baselines/reference/asyncAwait_es2017.js b/tests/baselines/reference/asyncAwait_es2017.js index 70a4c63be2e12..d65274ed38c57 100644 --- a/tests/baselines/reference/asyncAwait_es2017.js +++ b/tests/baselines/reference/asyncAwait_es2017.js @@ -47,12 +47,16 @@ async function f14() { } //// [asyncAwait_es2017.js] + + async function f0() { } async function f1() { } async function f3() { } + let f4 = async function () { }; let f5 = async function () { }; let f6 = async function () { }; + let f7 = async () => { }; let f8 = async () => { }; let f9 = async () => { }; @@ -60,11 +64,13 @@ let f10 = async () => p; let f11 = async () => mp; let f12 = async () => mp; let f13 = async () => p; + let o = { async m1() { }, async m2() { }, async m3() { } }; + class C { async m1() { } async m2() { } @@ -78,6 +84,7 @@ var M; async function f1() { } M.f1 = f1; })(M || (M = {})); + async function f14() { block: { await 1; diff --git a/tests/baselines/reference/asyncAwait_es5.js b/tests/baselines/reference/asyncAwait_es5.js index 6a6433e85c6fe..3b867b5e582fa 100644 --- a/tests/baselines/reference/asyncAwait_es5.js +++ b/tests/baselines/reference/asyncAwait_es5.js @@ -84,6 +84,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { } }; var _this = this; + function f0() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; @@ -99,6 +100,7 @@ function f3() { return [2 /*return*/]; }); }); } + var f4 = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; @@ -114,6 +116,7 @@ var f6 = function () { return [2 /*return*/]; }); }); }; + var f7 = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; }); }); }; @@ -135,6 +138,7 @@ var f12 = function () { return __awaiter(_this, void 0, void 0, function () { re var f13 = function () { return __awaiter(_this, void 0, MyPromise, function () { return __generator(this, function (_a) { return [2 /*return*/, p]; }); }); }; + var o = { m1: function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { @@ -152,6 +156,7 @@ var o = { }); }); } }; + var C = /** @class */ (function () { function C() { } diff --git a/tests/baselines/reference/asyncAwait_es6.js b/tests/baselines/reference/asyncAwait_es6.js index caab72bad9a99..da54251a16455 100644 --- a/tests/baselines/reference/asyncAwait_es6.js +++ b/tests/baselines/reference/asyncAwait_es6.js @@ -56,6 +56,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; + function f0() { return __awaiter(this, void 0, void 0, function* () { }); } @@ -65,6 +66,7 @@ function f1() { function f3() { return __awaiter(this, void 0, void 0, function* () { }); } + let f4 = function () { return __awaiter(this, void 0, void 0, function* () { }); }; @@ -74,6 +76,7 @@ let f5 = function () { let f6 = function () { return __awaiter(this, void 0, void 0, function* () { }); }; + let f7 = () => __awaiter(this, void 0, void 0, function* () { }); let f8 = () => __awaiter(this, void 0, void 0, function* () { }); let f9 = () => __awaiter(this, void 0, void 0, function* () { }); @@ -81,6 +84,7 @@ let f10 = () => __awaiter(this, void 0, void 0, function* () { return p; }); let f11 = () => __awaiter(this, void 0, void 0, function* () { return mp; }); let f12 = () => __awaiter(this, void 0, void 0, function* () { return mp; }); let f13 = () => __awaiter(this, void 0, void 0, function* () { return p; }); + let o = { m1() { return __awaiter(this, void 0, void 0, function* () { }); @@ -92,6 +96,7 @@ let o = { return __awaiter(this, void 0, void 0, function* () { }); } }; + class C { m1() { return __awaiter(this, void 0, void 0, function* () { }); diff --git a/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.js b/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.js index e06a4bde5e493..e0617bc81e180 100644 --- a/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.js +++ b/tests/baselines/reference/asyncFunctionContextuallyTypedReturns.js @@ -26,7 +26,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; f(v => v ? [0] : Promise.reject()); f((v) => __awaiter(void 0, void 0, void 0, function* () { return v ? [0] : Promise.reject(); })); + g(v => v ? "contextuallyTypable" : Promise.reject()); g((v) => __awaiter(void 0, void 0, void 0, function* () { return v ? "contextuallyTypable" : Promise.reject(); })); + + h(v => v ? (abc) => { } : Promise.reject()); h((v) => __awaiter(void 0, void 0, void 0, function* () { return v ? (def) => { } : Promise.reject(); })); diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js index f8a22204311e5..866e1301aaff9 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js @@ -3,6 +3,4 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es2017.js] -async function foo(a = await ) { } -await; -Promise < void > {}; +async function foo(a = await ) { }await;Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.js b/tests/baselines/reference/asyncFunctionDeclaration10_es5.js index 758bdab5dc902..51844aefc4df5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.js @@ -3,11 +3,8 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es5.js] -function foo(a) { - if (a === void 0) { a = yield ; } +function foo(a) {if (a === void 0) { a = yield ; } return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; }); }); -} -await; -Promise < void > {}; +}await;Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js index 1f175035bf085..e91a0e5f79e61 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -5,6 +5,4 @@ async function foo(a = await => await): Promise { //// [asyncFunctionDeclaration10_es6.js] function foo(a = yield ) { return __awaiter(this, void 0, void 0, function* () { }); -} -await; -Promise < void > {}; +}await;Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js index 2ed6cf3191f10..75802aebd29a2 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js @@ -2,5 +2,4 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es2017.js] -var v = async function () { }, await; -() => { }; +var v = async function () { }, await;() => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js index 19bca54f524a8..8ab24b54f3f05 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js @@ -6,5 +6,4 @@ var v = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; }); }); -}, await; -(function () { }); +}, await;(function () { }); diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js index 17829af6f20e2..f4dd6742208a5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js @@ -4,5 +4,4 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es6.js] var v = function () { return __awaiter(this, void 0, void 0, function* () { }); -}, await; -() => { }; +}, await;() => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es5.js b/tests/baselines/reference/asyncFunctionDeclaration3_es5.js index 0bcc99b6bc7b2..0e1d8caf53054 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration3_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es5.js @@ -3,6 +3,4 @@ function f(await = await) { } //// [asyncFunctionDeclaration3_es5.js] -function f(await) { - if (await === void 0) { await = await; } -} +function f(await) {if (await === void 0) { await = await; }} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js index 904bbe62f0ba8..dac4d1a5ab00b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js @@ -3,6 +3,4 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es2017.js] -async function foo() { } -await; -Promise < void > {}; +async function foo() { }await;Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.js b/tests/baselines/reference/asyncFunctionDeclaration5_es5.js index 5f8f8f4273589..f54e8d581d7d7 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.js @@ -7,6 +7,4 @@ function foo() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; }); }); -} -await; -Promise < void > {}; +}await;Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js index 9521b76041585..d71751a7be7cb 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js @@ -5,6 +5,4 @@ async function foo(await): Promise { //// [asyncFunctionDeclaration5_es6.js] function foo() { return __awaiter(this, void 0, void 0, function* () { }); -} -await; -Promise < void > {}; +}await;Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es5.js b/tests/baselines/reference/asyncFunctionDeclaration6_es5.js index 282036f97def1..982f9c0af37f5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration6_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es5.js @@ -3,8 +3,7 @@ async function foo(a = await): Promise { } //// [asyncFunctionDeclaration6_es5.js] -function foo(a) { - if (a === void 0) { a = yield ; } +function foo(a) {if (a === void 0) { a = yield ; } return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es5.js b/tests/baselines/reference/asyncFunctionDeclaration7_es5.js index 60dd0d6e3bf32..3f00d168ad29f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration7_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es5.js @@ -9,8 +9,7 @@ async function bar(): Promise { function bar() { return __awaiter(this, void 0, void 0, function () { // 'await' here is an identifier, and not a yield expression. - function foo(a) { - if (a === void 0) { a = yield ; } + function foo(a) {if (a === void 0) { a = yield ; } return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; diff --git a/tests/baselines/reference/asyncFunctionReturnExpressionErrorSpans.js b/tests/baselines/reference/asyncFunctionReturnExpressionErrorSpans.js index 887484e933a2a..1e827c97ed4d0 100644 --- a/tests/baselines/reference/asyncFunctionReturnExpressionErrorSpans.js +++ b/tests/baselines/reference/asyncFunctionReturnExpressionErrorSpans.js @@ -58,6 +58,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; + function asyncFoo() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { diff --git a/tests/baselines/reference/asyncFunctionReturnType.js b/tests/baselines/reference/asyncFunctionReturnType.js index 04b3a04a036d3..c269b442775d1 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.js +++ b/tests/baselines/reference/asyncFunctionReturnType.js @@ -91,82 +91,99 @@ function fAsync() { return [1, true]; }); } + function fAsyncExplicit() { return __awaiter(this, void 0, void 0, function* () { // This is contextually typed as a tuple. return [1, true]; }); } + + function fIndexedTypeForStringProp(obj) { return __awaiter(this, void 0, void 0, function* () { return obj.stringProp; }); } + function fIndexedTypeForPromiseOfStringProp(obj) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj.stringProp); }); } + function fIndexedTypeForExplicitPromiseOfStringProp(obj) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj.stringProp); }); } + function fIndexedTypeForAnyProp(obj) { return __awaiter(this, void 0, void 0, function* () { return obj.anyProp; }); } + function fIndexedTypeForPromiseOfAnyProp(obj) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj.anyProp); }); } + function fIndexedTypeForExplicitPromiseOfAnyProp(obj) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj.anyProp); }); } + function fGenericIndexedTypeForStringProp(obj) { return __awaiter(this, void 0, void 0, function* () { return obj.stringProp; }); } + function fGenericIndexedTypeForPromiseOfStringProp(obj) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj.stringProp); }); } + function fGenericIndexedTypeForExplicitPromiseOfStringProp(obj) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj.stringProp); }); } + function fGenericIndexedTypeForAnyProp(obj) { return __awaiter(this, void 0, void 0, function* () { return obj.anyProp; }); } + function fGenericIndexedTypeForPromiseOfAnyProp(obj) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj.anyProp); }); } + function fGenericIndexedTypeForExplicitPromiseOfAnyProp(obj) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj.anyProp); }); } + function fGenericIndexedTypeForKProp(obj, key) { return __awaiter(this, void 0, void 0, function* () { return obj[key]; }); } + function fGenericIndexedTypeForPromiseOfKProp(obj, key) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj[key]); }); } + function fGenericIndexedTypeForExplicitPromiseOfKProp(obj, key) { return __awaiter(this, void 0, void 0, function* () { return Promise.resolve(obj[key]); diff --git a/tests/baselines/reference/asyncFunctionTempVariableScoping.js b/tests/baselines/reference/asyncFunctionTempVariableScoping.js index 3a6da56c993f8..8c0a75e12ae07 100644 --- a/tests/baselines/reference/asyncFunctionTempVariableScoping.js +++ b/tests/baselines/reference/asyncFunctionTempVariableScoping.js @@ -53,15 +53,17 @@ var __rest = (this && this.__rest) || function (s, e) { return t; }; var _this = this; -(function (_a) { return __awaiter(_this, void 0, void 0, function () { - var _b; - var foo = _a.foo, bar = _a.bar, rest = __rest(_a, ["foo", "bar"]); - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _b = bar; - return [4 /*yield*/, foo]; - case 1: return [2 /*return*/, _b.apply(void 0, [_c.sent()])]; - } - }); -}); }); +( + + function (_a) { return __awaiter(_this, void 0, void 0, function () { + var _b; + var foo = _a.foo, bar = _a.bar, rest = __rest(_a, ["foo", "bar"]); + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + _b = bar; + return [4 /*yield*/, foo]; + case 1: return [2 /*return*/, _b.apply(void 0, [_c.sent()])]; + } + }); + }); }); diff --git a/tests/baselines/reference/asyncFunctionWithForStatementNoInitializer.js b/tests/baselines/reference/asyncFunctionWithForStatementNoInitializer.js index 055a751f523d1..f1c3a11126481 100644 --- a/tests/baselines/reference/asyncFunctionWithForStatementNoInitializer.js +++ b/tests/baselines/reference/asyncFunctionWithForStatementNoInitializer.js @@ -73,6 +73,7 @@ function test1() { }); }); } + function test2() { return __awaiter(this, void 0, void 0, function () { var i, limit; @@ -85,6 +86,7 @@ function test2() { }); }); } + function test3() { return __awaiter(this, void 0, void 0, function () { var i; @@ -96,6 +98,7 @@ function test3() { }); }); } + function test4() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { diff --git a/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.js b/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.js index a13f2f8b2195a..dd274280c9343 100644 --- a/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.js +++ b/tests/baselines/reference/asyncFunctionsAndStrictNullChecks.js @@ -35,11 +35,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; + function sample(promise) { return __awaiter(this, void 0, void 0, function* () { var number = yield promise; }); } + + + function sample2(x) { return __awaiter(this, void 0, void 0, function* () { let x1 = yield resolve1(x); diff --git a/tests/baselines/reference/asyncIIFE.js b/tests/baselines/reference/asyncIIFE.js index e2096b4c6dea1..5c0f73124d101 100644 --- a/tests/baselines/reference/asyncIIFE.js +++ b/tests/baselines/reference/asyncIIFE.js @@ -24,5 +24,6 @@ function f1() { yield 10; throw new Error(); }))(); + var x = 1; } diff --git a/tests/baselines/reference/asyncImportedPromise_es6.js b/tests/baselines/reference/asyncImportedPromise_es6.js index 3ba87df293912..380d23dce68b7 100644 --- a/tests/baselines/reference/asyncImportedPromise_es6.js +++ b/tests/baselines/reference/asyncImportedPromise_es6.js @@ -13,8 +13,7 @@ class Test { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Task = void 0; -class Task extends Promise { -} +class Task extends Promise {} exports.Task = Task; //// [test.js] "use strict"; diff --git a/tests/baselines/reference/asyncMethodWithSuperConflict_es6.js b/tests/baselines/reference/asyncMethodWithSuperConflict_es6.js index 5e2a152b9e003..39e644b203759 100644 --- a/tests/baselines/reference/asyncMethodWithSuperConflict_es6.js +++ b/tests/baselines/reference/asyncMethodWithSuperConflict_es6.js @@ -75,6 +75,7 @@ class A { y() { } } + class B extends A { // async method with only call/get on 'super' does not require a binding simple() { @@ -90,14 +91,18 @@ class B extends A { _super_1.x.call(this); // call additional property. _super_1.y.call(this); + // call with element access _superIndex_1("x").call(this); + // property access (read) const a = _super_1.x; + // element access (read) const b = _superIndex_1("x"); }); } + // async method with assignment/destructuring on 'super' requires a binding advanced() { const _superIndex_1 = (function (geti, seti) { @@ -111,20 +116,28 @@ class B extends A { const _super = null; const _superIndex = null; const f = () => { }; + // call with property access _super_1.x.call(this); + // call with element access _superIndex_1("x").value.call(this); + // property access (read) const a = _super_1.x; + // element access (read) const b = _superIndex_1("x").value; + // property access (assign) _super_1.x = f; + // element access (assign) _superIndex_1("x").value = f; + // destructuring assign with property access ({ f: _super_1.x } = { f }); + // destructuring assign with element access ({ f: _superIndex_1("x").value } = { f }); }); diff --git a/tests/baselines/reference/asyncMethodWithSuper_es2017.js b/tests/baselines/reference/asyncMethodWithSuper_es2017.js index 4c5a7aa9866fc..832535ad75af8 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es2017.js +++ b/tests/baselines/reference/asyncMethodWithSuper_es2017.js @@ -62,6 +62,7 @@ class A { y() { } } + class B extends A { // async method with only call/get on 'super' does not require a binding async simple() { @@ -69,30 +70,43 @@ class B extends A { super.x(); // call additional property. super.y(); + // call with element access super["x"](); + // property access (read) const a = super.x; + // element access (read) const b = super["x"]; } + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { const f = () => { }; + // call with property access super.x(); + // call with element access super["x"](); + // property access (read) const a = super.x; + // element access (read) const b = super["x"]; + // property access (assign) super.x = f; + // element access (assign) super["x"] = f; + // destructuring assign with property access ({ f: super.x } = { f }); + // destructuring assign with element access ({ f: super["x"] } = { f }); } diff --git a/tests/baselines/reference/asyncMethodWithSuper_es5.js b/tests/baselines/reference/asyncMethodWithSuper_es5.js index 441ad8875c412..acd5e3cbe52fc 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es5.js +++ b/tests/baselines/reference/asyncMethodWithSuper_es5.js @@ -79,6 +79,7 @@ var B = /** @class */ (function (_super) { _super.prototype.x.call(this); // call additional property. _super.prototype.y.call(this); + // call with element access _super.prototype["x"].call(this); a = _super.prototype.x; @@ -87,6 +88,7 @@ var B = /** @class */ (function (_super) { }); }); }; + // async method with assignment/destructuring on 'super' requires a binding B.prototype.advanced = function () { return __awaiter(this, void 0, void 0, function () { @@ -95,16 +97,20 @@ var B = /** @class */ (function (_super) { f = function () { }; // call with property access _super.prototype.x.call(this); + // call with element access _super.prototype["x"].call(this); a = _super.prototype.x; b = _super.prototype["x"]; // property access (assign) _super.prototype.x = f; + // element access (assign) _super.prototype["x"] = f; + // destructuring assign with property access (_super.prototype.x = { f: f }.f); + // destructuring assign with element access (_super.prototype["x"] = { f: f }.f); return [2 /*return*/]; diff --git a/tests/baselines/reference/asyncMethodWithSuper_es6.js b/tests/baselines/reference/asyncMethodWithSuper_es6.js index a5f216d221a7d..b11719dfe4139 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es6.js +++ b/tests/baselines/reference/asyncMethodWithSuper_es6.js @@ -194,6 +194,7 @@ class A { y() { } } + class B extends A { // async method with only call/get on 'super' does not require a binding simple() { @@ -207,14 +208,18 @@ class B extends A { _super.x.call(this); // call additional property. _super.y.call(this); + // call with element access _superIndex("x").call(this); + // property access (read) const a = _super.x; + // element access (read) const b = _superIndex("x"); }); } + // async method with assignment/destructuring on 'super' requires a binding advanced() { const _superIndex = (function (geti, seti) { @@ -226,32 +231,45 @@ class B extends A { }); return __awaiter(this, void 0, void 0, function* () { const f = () => { }; + // call with property access _super.x.call(this); + // call with element access _superIndex("x").value.call(this); + // property access (read) const a = _super.x; + // element access (read) const b = _superIndex("x").value; + // property access (assign) _super.x = f; + // element access (assign) _superIndex("x").value = f; + // destructuring assign with property access ({ f: _super.x } = { f }); + // destructuring assign with element access ({ f: _superIndex("x").value } = { f }); + // property access in arrow (() => _super.x.call(this)); + // element access in arrow (() => _superIndex("x").value.call(this)); + // property access in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _super.x.call(this); })); + // element access in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _superIndex("x").value.call(this); })); }); } + property_access_only_read_only() { const _super = Object.create(null, { x: { get: () => super.x } @@ -259,43 +277,56 @@ class B extends A { return __awaiter(this, void 0, void 0, function* () { // call with property access _super.x.call(this); + // property access (read) const a = _super.x; + // property access in arrow (() => _super.x.call(this)); + // property access in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _super.x.call(this); })); }); } + property_access_only_write_only() { const _super = Object.create(null, { x: { get: () => super.x, set: v => super.x = v } }); return __awaiter(this, void 0, void 0, function* () { const f = () => { }; + // property access (assign) _super.x = f; + // destructuring assign with property access ({ f: _super.x } = { f }); + // property access (assign) in arrow (() => _super.x = f); + // property access (assign) in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _super.x = f; })); }); } + element_access_only_read_only() { const _superIndex = name => super[name]; return __awaiter(this, void 0, void 0, function* () { // call with element access _superIndex("x").call(this); + // element access (read) const a = _superIndex("x"); + // element access in arrow (() => _superIndex("x").call(this)); + // element access in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _superIndex("x").call(this); })); }); } + element_access_only_write_only() { const _superIndex = (function (geti, seti) { const cache = Object.create(null); @@ -303,16 +334,21 @@ class B extends A { })(name => super[name], (name, value) => super[name] = value); return __awaiter(this, void 0, void 0, function* () { const f = () => { }; + // element access (assign) _superIndex("x").value = f; + // destructuring assign with element access ({ f: _superIndex("x").value } = { f }); + // element access (assign) in arrow (() => _superIndex("x").value = f); + // element access (assign) in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _superIndex("x").value = f; })); }); } + property_access_only_read_only_in_generator() { const _super = Object.create(null, { x: { get: () => super.x } @@ -320,44 +356,57 @@ class B extends A { return __asyncGenerator(this, arguments, function* property_access_only_read_only_in_generator_1() { // call with property access _super.x.call(this); + // property access (read) const a = _super.x; + // property access in arrow (() => _super.x.call(this)); + // property access in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _super.x.call(this); })); }); } + property_access_only_write_only_in_generator() { const _super = Object.create(null, { x: { get: () => super.x, set: v => super.x = v } }); return __asyncGenerator(this, arguments, function* property_access_only_write_only_in_generator_1() { const f = () => { }; + // property access (assign) _super.x = f; + // destructuring assign with property access ({ f: _super.x } = { f }); + // property access (assign) in arrow (() => _super.x = f); + // property access (assign) in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _super.x = f; })); }); } + element_access_only_read_only_in_generator() { const _superIndex = name => super[name]; const _super = Object.create(null, {}); return __asyncGenerator(this, arguments, function* element_access_only_read_only_in_generator_1() { // call with element access _superIndex("x").call(this); + // element access (read) const a = _superIndex("x"); + // element access in arrow (() => _superIndex("x").call(this)); + // element access in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _superIndex("x").call(this); })); }); } + element_access_only_write_only_in_generator() { const _superIndex = (function (geti, seti) { const cache = Object.create(null); @@ -366,12 +415,16 @@ class B extends A { const _super = Object.create(null, {}); return __asyncGenerator(this, arguments, function* element_access_only_write_only_in_generator_1() { const f = () => { }; + // element access (assign) _superIndex("x").value = f; + // destructuring assign with element access ({ f: _superIndex("x").value } = { f }); + // element access (assign) in arrow (() => _superIndex("x").value = f); + // element access (assign) in async arrow (() => __awaiter(this, void 0, void 0, function* () { return _superIndex("x").value = f; })); }); diff --git a/tests/baselines/reference/asyncWithVarShadowing_es6.js b/tests/baselines/reference/asyncWithVarShadowing_es6.js index ecdffcd25a588..1165ceddb2089 100644 --- a/tests/baselines/reference/asyncWithVarShadowing_es6.js +++ b/tests/baselines/reference/asyncWithVarShadowing_es6.js @@ -223,115 +223,135 @@ async function fn40(x) { //// [asyncWithVarShadowing_es6.js] + function fn1(x) { var x; return __awaiter(this, void 0, void 0, function* () { }); } + function fn2(x) { var x, z; return __awaiter(this, void 0, void 0, function* () { }); } + function fn3(x) { return __awaiter(this, void 0, void 0, function* () { var z; }); } + function fn4(x) { var x; return __awaiter(this, void 0, void 0, function* () { x = y; }); } + function fn5(x) { var x; return __awaiter(this, void 0, void 0, function* () { ({ x } = y); }); } + function fn6(x) { var x, z; return __awaiter(this, void 0, void 0, function* () { ({ x, z } = y); }); } + function fn7(x) { var x; return __awaiter(this, void 0, void 0, function* () { ({ x = y } = y); }); } + function fn8(x) { var x; return __awaiter(this, void 0, void 0, function* () { ({ z: x } = y); }); } + function fn9(x) { var x; return __awaiter(this, void 0, void 0, function* () { ({ z: { x } } = y); }); } + function fn10(x) { var x; return __awaiter(this, void 0, void 0, function* () { ({ z: { x } = y } = y); }); } + function fn11(x) { var x; return __awaiter(this, void 0, void 0, function* () { x = __rest(y, []); }); } + function fn12(x) { var x; return __awaiter(this, void 0, void 0, function* () { [x] = y; }); } + function fn13(x) { var x; return __awaiter(this, void 0, void 0, function* () { [x = y] = y; }); } + function fn14(x) { var x; return __awaiter(this, void 0, void 0, function* () { [, x] = y; }); } + function fn15(x) { var x; return __awaiter(this, void 0, void 0, function* () { [...x] = y; }); } + function fn16(x) { var x; return __awaiter(this, void 0, void 0, function* () { [[x]] = y; }); } + function fn17(x) { var x; return __awaiter(this, void 0, void 0, function* () { [[x] = y] = y; }); } + function fn18({ x }) { var x; return __awaiter(this, void 0, void 0, function* () { }); } + function fn19([x]) { var x; return __awaiter(this, void 0, void 0, function* () { }); } + function fn20(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -339,6 +359,7 @@ function fn20(x) { } }); } + function fn21(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -346,6 +367,7 @@ function fn21(x) { } }); } + function fn22(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -355,6 +377,7 @@ function fn22(x) { } }); } + function fn23(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -364,6 +387,7 @@ function fn23(x) { } }); } + function fn24(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -373,6 +397,7 @@ function fn24(x) { } }); } + function fn25(x) { return __awaiter(this, void 0, void 0, function* () { try { @@ -382,6 +407,7 @@ function fn25(x) { } }); } + function fn26(x) { return __awaiter(this, void 0, void 0, function* () { try { @@ -391,6 +417,7 @@ function fn26(x) { } }); } + function fn27(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -400,6 +427,7 @@ function fn27(x) { } }); } + function fn28(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -407,6 +435,7 @@ function fn28(x) { } }); } + function fn29(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -414,6 +443,7 @@ function fn29(x) { } while (y); }); } + function fn30(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -421,6 +451,7 @@ function fn30(x) { } }); } + function fn31(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -428,6 +459,7 @@ function fn31(x) { } }); } + function fn32(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -435,6 +467,7 @@ function fn32(x) { } }); } + function fn33(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -442,6 +475,7 @@ function fn33(x) { } }); } + function fn34(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -449,6 +483,7 @@ function fn34(x) { } }); } + function fn35(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -456,6 +491,7 @@ function fn35(x) { } }); } + function fn36(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -463,6 +499,7 @@ function fn36(x) { } }); } + function fn37(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -470,6 +507,7 @@ function fn37(x) { } }); } + function fn38(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -478,6 +516,7 @@ function fn38(x) { } }); } + function fn39(x) { var x; return __awaiter(this, void 0, void 0, function* () { @@ -486,6 +525,7 @@ function fn39(x) { } }); } + function fn40(x) { var x; return __awaiter(this, void 0, void 0, function* () { diff --git a/tests/baselines/reference/augmentExportEquals3.js b/tests/baselines/reference/augmentExportEquals3.js index 3ff5f574488e4..4c749fb219286 100644 --- a/tests/baselines/reference/augmentExportEquals3.js +++ b/tests/baselines/reference/augmentExportEquals3.js @@ -37,6 +37,7 @@ define(["require", "exports", "./file1"], function (require, exports, x) { "use strict"; exports.__esModule = true; x.b = 1; + }); //// [file3.js] define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { diff --git a/tests/baselines/reference/augmentExportEquals3_1.js b/tests/baselines/reference/augmentExportEquals3_1.js index e91ca4498dd86..303fcf8693ad2 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.js +++ b/tests/baselines/reference/augmentExportEquals3_1.js @@ -32,6 +32,7 @@ define(["require", "exports", "file1"], function (require, exports, x) { "use strict"; exports.__esModule = true; x.b = 1; + }); //// [file3.js] define(["require", "exports", "file1", "file2"], function (require, exports, x) { diff --git a/tests/baselines/reference/augmentExportEquals4.js b/tests/baselines/reference/augmentExportEquals4.js index be6c6859ba76e..2ced85b482f50 100644 --- a/tests/baselines/reference/augmentExportEquals4.js +++ b/tests/baselines/reference/augmentExportEquals4.js @@ -27,8 +27,7 @@ let b = x.b; define(["require", "exports"], function (require, exports) { "use strict"; var foo = /** @class */ (function () { - function foo() { - } + function foo() {} return foo; }()); (function (foo) { @@ -41,6 +40,7 @@ define(["require", "exports", "./file1"], function (require, exports, x) { "use strict"; exports.__esModule = true; x.b = 1; + }); //// [file3.js] define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { diff --git a/tests/baselines/reference/augmentExportEquals4_1.js b/tests/baselines/reference/augmentExportEquals4_1.js index cd2f54599699e..ea2f6660238d6 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.js +++ b/tests/baselines/reference/augmentExportEquals4_1.js @@ -32,6 +32,7 @@ define(["require", "exports", "file1"], function (require, exports, x) { "use strict"; exports.__esModule = true; x.b = 1; + }); //// [file3.js] define(["require", "exports", "file1", "file2"], function (require, exports, x) { diff --git a/tests/baselines/reference/augmentExportEquals6.js b/tests/baselines/reference/augmentExportEquals6.js index 99c6c1602bd76..708acdf3153b7 100644 --- a/tests/baselines/reference/augmentExportEquals6.js +++ b/tests/baselines/reference/augmentExportEquals6.js @@ -31,20 +31,17 @@ let c = x.B.b; define(["require", "exports"], function (require, exports) { "use strict"; var foo = /** @class */ (function () { - function foo() { - } + function foo() {} return foo; }()); (function (foo) { var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); foo.A = A; var B; - (function (B) { - })(B = foo.B || (foo.B = {})); + (function (B) {})(B = foo.B || (foo.B = {})); })(foo || (foo = {})); return foo; }); @@ -53,6 +50,7 @@ define(["require", "exports", "./file1"], function (require, exports, x) { "use strict"; exports.__esModule = true; x.B.b = 1; + }); //// [file3.js] define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { diff --git a/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.js b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.js index 32fed237a2ea0..2f92b331841f2 100644 --- a/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.js +++ b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.js @@ -22,7 +22,10 @@ var v2: { } = f; // Should be allowed //// [augmentedTypeAssignmentCompatIndexSignature.js] + var o = {}; var f = function () { }; + var v1 = o; // Should be allowed + var v2 = f; // Should be allowed diff --git a/tests/baselines/reference/augmentedTypeBracketAccessIndexSignature.js b/tests/baselines/reference/augmentedTypeBracketAccessIndexSignature.js index 8d2c94899dce7..716e2adc538f5 100644 --- a/tests/baselines/reference/augmentedTypeBracketAccessIndexSignature.js +++ b/tests/baselines/reference/augmentedTypeBracketAccessIndexSignature.js @@ -14,5 +14,6 @@ var a = {}[0]; // Should be Foo var b = (() => { })[0]; // Should be Bar //// [augmentedTypeBracketAccessIndexSignature.js] + var a = {}[0]; // Should be Foo var b = (function () { })[0]; // Should be Bar diff --git a/tests/baselines/reference/augmentedTypeBracketNamedPropertyAccess.js b/tests/baselines/reference/augmentedTypeBracketNamedPropertyAccess.js index 6ec653c69b598..cb5ce1642f1c4 100644 --- a/tests/baselines/reference/augmentedTypeBracketNamedPropertyAccess.js +++ b/tests/baselines/reference/augmentedTypeBracketNamedPropertyAccess.js @@ -16,6 +16,7 @@ var r4 = f['data']; // Should be number //// [augmentedTypeBracketNamedPropertyAccess.js] var o = {}; var f = function () { }; + var r1 = o['data']; // Should be number var r2 = o['functionData']; // Should be any (no property found) var r3 = f['functionData']; // Should be string diff --git a/tests/baselines/reference/augmentedTypesClass.js b/tests/baselines/reference/augmentedTypesClass.js index 01c39c98a1a49..bb7a1e3a40d30 100644 --- a/tests/baselines/reference/augmentedTypesClass.js +++ b/tests/baselines/reference/augmentedTypesClass.js @@ -10,16 +10,16 @@ enum c4 { One } // error //// [augmentedTypesClass.js] //// class then var var c1 = /** @class */ (function () { - function c1() { - } + function c1() {} c1.prototype.foo = function () { }; return c1; }()); var c1 = 1; // error + + //// class then enum var c4 = /** @class */ (function () { - function c4() { - } + function c4() {} c4.prototype.foo = function () { }; return c4; }()); diff --git a/tests/baselines/reference/augmentedTypesClass2.js b/tests/baselines/reference/augmentedTypesClass2.js index a289446e53fdb..c5e202995c67f 100644 --- a/tests/baselines/reference/augmentedTypesClass2.js +++ b/tests/baselines/reference/augmentedTypesClass2.js @@ -41,6 +41,7 @@ var c11 = /** @class */ (function () { }; return c11; }()); + // class then class - covered // class then enum var c33 = /** @class */ (function () { @@ -55,6 +56,7 @@ var c33 = /** @class */ (function () { c33[c33["One"] = 0] = "One"; })(c33 || (c33 = {})); ; + // class then import var c44 = /** @class */ (function () { function c44() { diff --git a/tests/baselines/reference/augmentedTypesClass2a.js b/tests/baselines/reference/augmentedTypesClass2a.js index cbda0bb256536..f3e70c5c01b54 100644 --- a/tests/baselines/reference/augmentedTypesClass2a.js +++ b/tests/baselines/reference/augmentedTypesClass2a.js @@ -7,8 +7,7 @@ var c2 = () => { } //// [augmentedTypesClass2a.js] //// class then function var c2 = /** @class */ (function () { - function c2() { - } + function c2() {} c2.prototype.foo = function () { }; return c2; }()); // error diff --git a/tests/baselines/reference/augmentedTypesClass3.js b/tests/baselines/reference/augmentedTypesClass3.js index 045109f858777..5625e56a20368 100644 --- a/tests/baselines/reference/augmentedTypesClass3.js +++ b/tests/baselines/reference/augmentedTypesClass3.js @@ -16,33 +16,26 @@ class c5c { public foo() { } } //// [augmentedTypesClass3.js] // class then module var c5 = /** @class */ (function () { - function c5() { - } + function c5() {} c5.prototype.foo = function () { }; return c5; }()); + var c5a = /** @class */ (function () { - function c5a() { - } + function c5a() {} c5a.prototype.foo = function () { }; return c5a; }()); -(function (c5a) { - var y = 2; -})(c5a || (c5a = {})); // should be ok +(function (c5a) {var y = 2;})(c5a || (c5a = {})); // should be ok var c5b = /** @class */ (function () { - function c5b() { - } + function c5b() {} c5b.prototype.foo = function () { }; return c5b; }()); -(function (c5b) { - c5b.y = 2; -})(c5b || (c5b = {})); // should be ok +(function (c5b) {c5b.y = 2;})(c5b || (c5b = {})); // should be ok //// class then import var c5c = /** @class */ (function () { - function c5c() { - } + function c5c() {} c5c.prototype.foo = function () { }; return c5c; }()); diff --git a/tests/baselines/reference/augmentedTypesClass4.js b/tests/baselines/reference/augmentedTypesClass4.js index 086748bad61c0..4d826a364b052 100644 --- a/tests/baselines/reference/augmentedTypesClass4.js +++ b/tests/baselines/reference/augmentedTypesClass4.js @@ -7,14 +7,12 @@ class c3 { public bar() { } } // error //// [augmentedTypesClass4.js] //// class then class var c3 = /** @class */ (function () { - function c3() { - } + function c3() {} c3.prototype.foo = function () { }; return c3; }()); // error var c3 = /** @class */ (function () { - function c3() { - } + function c3() {} c3.prototype.bar = function () { }; return c3; }()); // error diff --git a/tests/baselines/reference/augmentedTypesEnum.js b/tests/baselines/reference/augmentedTypesEnum.js index edd4a92d76706..3d7b1ee74043d 100644 --- a/tests/baselines/reference/augmentedTypesEnum.js +++ b/tests/baselines/reference/augmentedTypesEnum.js @@ -59,8 +59,7 @@ var e4; e4[e4["One"] = 0] = "One"; })(e4 || (e4 = {})); // error var e4 = /** @class */ (function () { - function e4() { - } + function e4() {} e4.prototype.foo = function () { }; return e4; }()); // error @@ -88,16 +87,12 @@ var e6a; (function (e6a) { e6a[e6a["One"] = 0] = "One"; })(e6a || (e6a = {})); -(function (e6a) { - var y = 2; -})(e6a || (e6a = {})); // should be error +(function (e6a) {var y = 2;})(e6a || (e6a = {})); // should be error var e6b; (function (e6b) { e6b[e6b["One"] = 0] = "One"; })(e6b || (e6b = {})); -(function (e6b) { - e6b.y = 2; -})(e6b || (e6b = {})); // should be error +(function (e6b) {e6b.y = 2;})(e6b || (e6b = {})); // should be error // enum then import, messes with error reporting //enum e7 { One } //import e7 = require(''); // should be error diff --git a/tests/baselines/reference/augmentedTypesEnum3.js b/tests/baselines/reference/augmentedTypesEnum3.js index 4df9dada5305e..503a02f9f5ff3 100644 --- a/tests/baselines/reference/augmentedTypesEnum3.js +++ b/tests/baselines/reference/augmentedTypesEnum3.js @@ -25,14 +25,10 @@ var E; (function (E) { var t; })(E || (E = {})); -(function (E) { -})(E || (E = {})); +(function (E) {})(E || (E = {})); var F; -(function (F) { -})(F || (F = {})); -(function (F) { - var t; -})(F || (F = {})); +(function (F) {})(F || (F = {})); +(function (F) {var t;})(F || (F = {})); var A; (function (A) { var o; diff --git a/tests/baselines/reference/augmentedTypesExternalModule1.js b/tests/baselines/reference/augmentedTypesExternalModule1.js index 4f4e90029a6cf..53ce7a5973b0e 100644 --- a/tests/baselines/reference/augmentedTypesExternalModule1.js +++ b/tests/baselines/reference/augmentedTypesExternalModule1.js @@ -10,8 +10,7 @@ define(["require", "exports"], function (require, exports) { exports.a = void 0; exports.a = 1; var c5 = /** @class */ (function () { - function c5() { - } + function c5() {} c5.prototype.foo = function () { }; return c5; }()); diff --git a/tests/baselines/reference/augmentedTypesFunction.js b/tests/baselines/reference/augmentedTypesFunction.js index a2dd4a664a3a7..5357bafd1132b 100644 --- a/tests/baselines/reference/augmentedTypesFunction.js +++ b/tests/baselines/reference/augmentedTypesFunction.js @@ -42,22 +42,25 @@ module y5c { export interface I { foo(): void } } // should be an error // function then var function y1() { } // error var y1 = 1; // error + + // function then function function y2() { } // error function y2() { } // error + function y2a() { } // error var y2a = function () { }; // error + + // function then class function y3() { } // error var y3 = /** @class */ (function () { - function y3() { - } + function y3() {} return y3; }()); // error function y3a() { } // error var y3a = /** @class */ (function () { - function y3a() { - } + function y3a() {} y3a.prototype.foo = function () { }; return y3a; }()); // error @@ -68,15 +71,15 @@ function y4() { } // error })(y4 || (y4 = {})); // error // function then internal module function y5() { } + function y5a() { } -(function (y5a) { - var y = 2; -})(y5a || (y5a = {})); // should be an error +(function (y5a) {var y = 2;})(y5a || (y5a = {})); // should be an error function y5b() { } -(function (y5b) { - y5b.y = 3; -})(y5b || (y5b = {})); // should be an error +(function (y5b) {y5b.y = 3;})(y5b || (y5b = {})); // should be an error function y5c() { } + + + // function then import, messes with other errors //function y6() { } //import y6 = require(''); diff --git a/tests/baselines/reference/augmentedTypesInterface.js b/tests/baselines/reference/augmentedTypesInterface.js index 0409e157584a3..51297a707e5fd 100644 --- a/tests/baselines/reference/augmentedTypesInterface.js +++ b/tests/baselines/reference/augmentedTypesInterface.js @@ -35,6 +35,8 @@ interface i4 { //// [augmentedTypesInterface.js] // interface then interface + + var i2 = /** @class */ (function () { function i2() { } @@ -48,4 +50,7 @@ var i3; i3[i3["One"] = 0] = "One"; })(i3 || (i3 = {})); ; // error + + + //import i4 = require(''); // error diff --git a/tests/baselines/reference/augmentedTypesModules.js b/tests/baselines/reference/augmentedTypesModules.js index c0bb1747e6dc6..6a63cddbfdbd2 100644 --- a/tests/baselines/reference/augmentedTypesModules.js +++ b/tests/baselines/reference/augmentedTypesModules.js @@ -100,125 +100,92 @@ module m6 { export var y = 2; } //// [augmentedTypesModules.js] var m1 = 1; // Should be allowed var m1a; -(function (m1a) { - var y = 2; -})(m1a || (m1a = {})); // error +(function (m1a) {var y = 2;})(m1a || (m1a = {})); // error var m1a = 1; // error var m1b; -(function (m1b) { - m1b.y = 2; -})(m1b || (m1b = {})); // error +(function (m1b) {m1b.y = 2;})(m1b || (m1b = {})); // error var m1b = 1; // error + var m1c = 1; // Should be allowed var m1d; (function (m1d) { var I = /** @class */ (function () { - function I() { - } + function I() {} I.prototype.foo = function () { }; return I; }()); m1d.I = I; })(m1d || (m1d = {})); var m1d = 1; // error -function m2() { } -; // ok since the module is not instantiated + + +function m2() { }; // ok since the module is not instantiated var m2a; -(function (m2a) { - var y = 2; -})(m2a || (m2a = {})); -function m2a() { } -; // error since the module is instantiated +(function (m2a) {var y = 2;})(m2a || (m2a = {})); +function m2a() { }; // error since the module is instantiated var m2b; -(function (m2b) { - m2b.y = 2; -})(m2b || (m2b = {})); -function m2b() { } -; // error since the module is instantiated +(function (m2b) {m2b.y = 2;})(m2b || (m2b = {})); +function m2b() { }; // error since the module is instantiated + + // should be errors to have function first -function m2c() { } -; -(function (m2c) { - m2c.y = 2; -})(m2c || (m2c = {})); -function m2f() { } -; -function m2g() { } -; -(function (m2g) { - var C = /** @class */ (function () { - function C() { - } +function m2c() { }; +(function (m2c) {m2c.y = 2;})(m2c || (m2c = {})); + +function m2f() { }; + +function m2g() { }; +(function (m2g) {var C = /** @class */ (function () { + function C() {} C.prototype.foo = function () { }; return C; }()); m2g.C = C; })(m2g || (m2g = {})); var m3 = /** @class */ (function () { - function m3() { - } + function m3() {} return m3; }()); // ok since the module is not instantiated var m3a; -(function (m3a) { - var y = 2; -})(m3a || (m3a = {})); +(function (m3a) {var y = 2;})(m3a || (m3a = {})); var m3a = /** @class */ (function () { - function m3a() { - } + function m3a() {} m3a.prototype.foo = function () { }; return m3a; }()); // error, class isn't ambient or declared before the module var m3b = /** @class */ (function () { - function m3b() { - } + function m3b() {} m3b.prototype.foo = function () { }; return m3b; }()); -(function (m3b) { - var y = 2; -})(m3b || (m3b = {})); +(function (m3b) {var y = 2;})(m3b || (m3b = {})); var m3c = /** @class */ (function () { - function m3c() { - } + function m3c() {} m3c.prototype.foo = function () { }; return m3c; }()); -(function (m3c) { - m3c.y = 2; -})(m3c || (m3c = {})); +(function (m3c) {m3c.y = 2;})(m3c || (m3c = {})); var m3d; -(function (m3d) { - m3d.y = 2; -})(m3d || (m3d = {})); +(function (m3d) {m3d.y = 2;})(m3d || (m3d = {})); var m3e; -(function (m3e) { - m3e.y = 2; -})(m3e || (m3e = {})); +(function (m3e) {m3e.y = 2;})(m3e || (m3e = {})); var m3g; -(function (m3g) { - var C = /** @class */ (function () { - function C() { - } +(function (m3g) {var C = /** @class */ (function () { + function C() {} C.prototype.foo = function () { }; return C; }()); m3g.C = C; })(m3g || (m3g = {})); var m4; -(function (m4) { -})(m4 || (m4 = {})); +(function (m4) {})(m4 || (m4 = {})); var m4a; -(function (m4a) { - var y = 2; -})(m4a || (m4a = {})); +(function (m4a) {var y = 2;})(m4a || (m4a = {})); (function (m4a) { m4a[m4a["One"] = 0] = "One"; })(m4a || (m4a = {})); var m4b; -(function (m4b) { - m4b.y = 2; -})(m4b || (m4b = {})); +(function (m4b) {m4b.y = 2;})(m4b || (m4b = {})); (function (m4b) { m4b[m4b["One"] = 0] = "One"; })(m4b || (m4b = {})); @@ -227,10 +194,8 @@ var m4c; m4c[m4c["One"] = 0] = "One"; })(m4c || (m4c = {})); var m4d; -(function (m4d) { - var C = /** @class */ (function () { - function C() { - } +(function (m4d) {var C = /** @class */ (function () { + function C() {} C.prototype.foo = function () { }; return C; }()); @@ -240,12 +205,8 @@ var m4d; })(m4d || (m4d = {})); //// module then module var m5; -(function (m5) { - m5.y = 2; -})(m5 || (m5 = {})); +(function (m5) {m5.y = 2;})(m5 || (m5 = {})); // module then import var m6; -(function (m6) { - m6.y = 2; -})(m6 || (m6 = {})); +(function (m6) {m6.y = 2;})(m6 || (m6 = {})); //import m6 = require(''); diff --git a/tests/baselines/reference/augmentedTypesModules2.js b/tests/baselines/reference/augmentedTypesModules2.js index 995a85f39600d..c94d6c472162f 100644 --- a/tests/baselines/reference/augmentedTypesModules2.js +++ b/tests/baselines/reference/augmentedTypesModules2.js @@ -29,39 +29,26 @@ module m2g { export class C { foo() { } } } //// [augmentedTypesModules2.js] -function m2() { } -; // ok since the module is not instantiated +function m2() { }; // ok since the module is not instantiated var m2a; -(function (m2a) { - var y = 2; -})(m2a || (m2a = {})); -function m2a() { } -; // error since the module is instantiated +(function (m2a) {var y = 2;})(m2a || (m2a = {})); +function m2a() { }; // error since the module is instantiated var m2b; -(function (m2b) { - m2b.y = 2; -})(m2b || (m2b = {})); -function m2b() { } -; // error since the module is instantiated -function m2c() { } -; -(function (m2c) { - m2c.y = 2; -})(m2c || (m2c = {})); +(function (m2b) {m2b.y = 2;})(m2b || (m2b = {})); +function m2b() { }; // error since the module is instantiated + +function m2c() { }; +(function (m2c) {m2c.y = 2;})(m2c || (m2c = {})); var m2cc; -(function (m2cc) { - m2cc.y = 2; -})(m2cc || (m2cc = {})); -function m2cc() { } -; // error to have module first -function m2f() { } -; -function m2g() { } -; -(function (m2g) { - var C = /** @class */ (function () { - function C() { - } +(function (m2cc) {m2cc.y = 2;})(m2cc || (m2cc = {})); +function m2cc() { }; // error to have module first + + +function m2f() { }; + +function m2g() { }; +(function (m2g) {var C = /** @class */ (function () { + function C() {} C.prototype.foo = function () { }; return C; }()); diff --git a/tests/baselines/reference/augmentedTypesModules3.js b/tests/baselines/reference/augmentedTypesModules3.js index 0537bd092b012..a231265d3d019 100644 --- a/tests/baselines/reference/augmentedTypesModules3.js +++ b/tests/baselines/reference/augmentedTypesModules3.js @@ -8,17 +8,13 @@ class m3a { foo() { } } // error, class isn't ambient or declared before the mod //// [augmentedTypesModules3.js] var m3 = /** @class */ (function () { - function m3() { - } + function m3() {} return m3; }()); // ok since the module is not instantiated var m3a; -(function (m3a) { - var y = 2; -})(m3a || (m3a = {})); +(function (m3a) {var y = 2;})(m3a || (m3a = {})); var m3a = /** @class */ (function () { - function m3a() { - } + function m3a() {} m3a.prototype.foo = function () { }; return m3a; }()); // error, class isn't ambient or declared before the module diff --git a/tests/baselines/reference/augmentedTypesModules3b.js b/tests/baselines/reference/augmentedTypesModules3b.js index 57957c13b8082..175eff79453c2 100644 --- a/tests/baselines/reference/augmentedTypesModules3b.js +++ b/tests/baselines/reference/augmentedTypesModules3b.js @@ -20,36 +20,24 @@ module m3g { export class C { foo() { } } } //// [augmentedTypesModules3b.js] var m3b = /** @class */ (function () { - function m3b() { - } + function m3b() {} m3b.prototype.foo = function () { }; return m3b; }()); -(function (m3b) { - var y = 2; -})(m3b || (m3b = {})); +(function (m3b) {var y = 2;})(m3b || (m3b = {})); var m3c = /** @class */ (function () { - function m3c() { - } + function m3c() {} m3c.prototype.foo = function () { }; return m3c; }()); -(function (m3c) { - m3c.y = 2; -})(m3c || (m3c = {})); +(function (m3c) {m3c.y = 2;})(m3c || (m3c = {})); var m3d; -(function (m3d) { - m3d.y = 2; -})(m3d || (m3d = {})); +(function (m3d) {m3d.y = 2;})(m3d || (m3d = {})); var m3e; -(function (m3e) { - m3e.y = 2; -})(m3e || (m3e = {})); +(function (m3e) {m3e.y = 2;})(m3e || (m3e = {})); var m3g; -(function (m3g) { - var C = /** @class */ (function () { - function C() { - } +(function (m3g) {var C = /** @class */ (function () { + function C() {} C.prototype.foo = function () { }; return C; }()); diff --git a/tests/baselines/reference/augmentedTypesModules4.js b/tests/baselines/reference/augmentedTypesModules4.js index b7a776ca16435..675812964637b 100644 --- a/tests/baselines/reference/augmentedTypesModules4.js +++ b/tests/baselines/reference/augmentedTypesModules4.js @@ -24,19 +24,14 @@ module m5 { export interface I { foo(): void } } // should already be reasonably //// [augmentedTypesModules4.js] var m4; -(function (m4) { -})(m4 || (m4 = {})); +(function (m4) {})(m4 || (m4 = {})); var m4a; -(function (m4a) { - var y = 2; -})(m4a || (m4a = {})); +(function (m4a) {var y = 2;})(m4a || (m4a = {})); (function (m4a) { m4a[m4a["One"] = 0] = "One"; })(m4a || (m4a = {})); var m4b; -(function (m4b) { - m4b.y = 2; -})(m4b || (m4b = {})); +(function (m4b) {m4b.y = 2;})(m4b || (m4b = {})); (function (m4b) { m4b[m4b["One"] = 0] = "One"; })(m4b || (m4b = {})); @@ -45,10 +40,8 @@ var m4c; m4c[m4c["One"] = 0] = "One"; })(m4c || (m4c = {})); var m4d; -(function (m4d) { - var C = /** @class */ (function () { - function C() { - } +(function (m4d) {var C = /** @class */ (function () { + function C() {} C.prototype.foo = function () { }; return C; }()); @@ -58,6 +51,4 @@ var m4d; })(m4d || (m4d = {})); //// module then module var m5; -(function (m5) { - m5.y = 2; -})(m5 || (m5 = {})); +(function (m5) {m5.y = 2;})(m5 || (m5 = {})); diff --git a/tests/baselines/reference/augmentedTypesVar.js b/tests/baselines/reference/augmentedTypesVar.js index 9945737410d3a..900d9db891e63 100644 --- a/tests/baselines/reference/augmentedTypesVar.js +++ b/tests/baselines/reference/augmentedTypesVar.js @@ -40,22 +40,24 @@ module x6b { export var y = 2; } // error // var then var var x1 = 1; var x1 = 2; + // var then function var x2 = 1; // error function x2() { } // error + var x3 = 1; var x3 = function () { }; // error + + // var then class var x4 = 1; // error var x4 = /** @class */ (function () { - function x4() { - } + function x4() {} return x4; }()); // error var x4a = 1; // error var x4a = /** @class */ (function () { - function x4a() { - } + function x4a() {} x4a.prototype.foo = function () { }; return x4a; }()); // error @@ -67,16 +69,13 @@ var x5; })(x5 || (x5 = {})); // error // var then module var x6 = 1; + var x6a = 1; // error var x6a; -(function (x6a) { - var y = 2; -})(x6a || (x6a = {})); // error since instantiated +(function (x6a) {var y = 2;})(x6a || (x6a = {})); // error since instantiated var x6b = 1; // error var x6b; -(function (x6b) { - x6b.y = 2; -})(x6b || (x6b = {})); // error +(function (x6b) {x6b.y = 2;})(x6b || (x6b = {})); // error // var then import, messes with other error reporting //var x7 = 1; //import x7 = require(''); diff --git a/tests/baselines/reference/autoLift2.js b/tests/baselines/reference/autoLift2.js index 002e320e85377..e80d6a0db126f 100644 --- a/tests/baselines/reference/autoLift2.js +++ b/tests/baselines/reference/autoLift2.js @@ -34,19 +34,24 @@ a.baz(); //// [autoLift2.js] var A = /** @class */ (function () { function A() { - this.foo; - any; - this.bar; - any; + this.foo;any; + this.bar;any; } + + A.prototype.baz = function () { var _this = this; this.foo = "foo"; + this.bar = "bar"; + [1, 2].forEach(function (p) { return _this.foo; }); + [1, 2].forEach(function (p) { return _this.bar; }); + }; return A; }()); var a = new A(); + a.baz(); diff --git a/tests/baselines/reference/autolift3.js b/tests/baselines/reference/autolift3.js index b7355aaef0e77..dbf5b85ab8463 100644 --- a/tests/baselines/reference/autolift3.js +++ b/tests/baselines/reference/autolift3.js @@ -34,11 +34,14 @@ b.foo(); var B = /** @class */ (function () { function B() { function foo() { } + foo(); + var a = 0; var inner = (function () { var CScriptIO = (function () { var fso = 0; + return { readFile: function (path) { return fso.toString(); @@ -51,4 +54,5 @@ var B = /** @class */ (function () { return B; }()); var b = new B(); + b.foo(); diff --git a/tests/baselines/reference/autolift4.js b/tests/baselines/reference/autolift4.js index 53ce6dc9dc3c4..674c6692334ff 100644 --- a/tests/baselines/reference/autolift4.js +++ b/tests/baselines/reference/autolift4.js @@ -55,6 +55,7 @@ var Point3D = /** @class */ (function (_super) { _this.z = z; return _this; } + Point3D.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.m); }; diff --git a/tests/baselines/reference/avoid.js b/tests/baselines/reference/avoid.js index 5882fe6c3cc24..99343cbe8964e 100644 --- a/tests/baselines/reference/avoid.js +++ b/tests/baselines/reference/avoid.js @@ -23,10 +23,12 @@ var N=new f(); // ok with void fn function f() { var x = 1; } + var y = f(); // error void fn var why = f(); // error void fn var w; w = f(); // error void fn + var C = /** @class */ (function () { function C() { } @@ -36,3 +38,4 @@ var C = /** @class */ (function () { }()); var z = new C().g(); // error void fn var N = new f(); // ok with void fn + diff --git a/tests/baselines/reference/awaitAndYieldInProperty.js b/tests/baselines/reference/awaitAndYieldInProperty.js index 238666278a8f1..93e8da2ba9378 100644 --- a/tests/baselines/reference/awaitAndYieldInProperty.js +++ b/tests/baselines/reference/awaitAndYieldInProperty.js @@ -26,19 +26,16 @@ async function* test(x) { constructor() { this[_e] = await x; this[_g] = yield 2; - } - } + }} _e = await x, _f = await x, _g = yield 1, _h = yield 3; C[_f] = await x; C[_h] = yield 4; return C; })(); - return _e = class { - constructor() { + return _e = class {constructor() { this[_a] = await x; this[_c] = yield 2; - } - }, + }}, _a = await x, _b = await x, _c = yield 1, diff --git a/tests/baselines/reference/awaitClassExpression_es2017.js b/tests/baselines/reference/awaitClassExpression_es2017.js index d84f01f61cfa4..b28cf8d6c4593 100644 --- a/tests/baselines/reference/awaitClassExpression_es2017.js +++ b/tests/baselines/reference/awaitClassExpression_es2017.js @@ -8,6 +8,7 @@ async function func(): Promise { } //// [awaitClassExpression_es2017.js] + async function func() { class D extends (await p) { } diff --git a/tests/baselines/reference/awaitClassExpression_es5.js b/tests/baselines/reference/awaitClassExpression_es5.js index ecd98628c15b0..5ee87e8e75b90 100644 --- a/tests/baselines/reference/awaitClassExpression_es5.js +++ b/tests/baselines/reference/awaitClassExpression_es5.js @@ -8,6 +8,7 @@ async function func(): Promise { } //// [awaitClassExpression_es5.js] + function func() { return __awaiter(this, void 0, void 0, function () { var D, _a; diff --git a/tests/baselines/reference/awaitClassExpression_es6.js b/tests/baselines/reference/awaitClassExpression_es6.js index 26740b9de6daf..540f0988aa859 100644 --- a/tests/baselines/reference/awaitClassExpression_es6.js +++ b/tests/baselines/reference/awaitClassExpression_es6.js @@ -8,6 +8,7 @@ async function func(): Promise { } //// [awaitClassExpression_es6.js] + function func() { return __awaiter(this, void 0, void 0, function* () { class D extends (yield p) { diff --git a/tests/baselines/reference/awaitInClassInAsyncFunction.js b/tests/baselines/reference/awaitInClassInAsyncFunction.js index a9d3c38f5c640..af2e469afea83 100644 --- a/tests/baselines/reference/awaitInClassInAsyncFunction.js +++ b/tests/baselines/reference/awaitInClassInAsyncFunction.js @@ -14,13 +14,13 @@ async function foo() { //// [awaitInClassInAsyncFunction.js] // https://github.com/microsoft/TypeScript/issues/34887 + async function bar() { return 2; } + async function foo() { - return new class { - constructor() { + return new class {constructor() { this.baz = await bar(); - } - }; + }}; } diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.js b/tests/baselines/reference/awaitInNonAsyncFunction.js index 83f75aa5633eb..54ec4858b88ef 100644 --- a/tests/baselines/reference/awaitInNonAsyncFunction.js +++ b/tests/baselines/reference/awaitInNonAsyncFunction.js @@ -42,31 +42,37 @@ await null; //// [awaitInNonAsyncFunction.js] // https://github.com/Microsoft/TypeScript/issues/26586 + function normalFunc(p) { for await (const _ of []) ; return await p; } + export function exportedFunc(p) { for await (const _ of []) ; return await p; } + const functionExpression = function (p) { for await (const _ of []) ; await p; }; + const arrowFunc = (p) => { for await (const _ of []) ; return await p; }; + function* generatorFunc(p) { for await (const _ of []) ; yield await p; } + class clazz { constructor(p) { for await (const _ of []) @@ -79,6 +85,7 @@ class clazz { await p; } } + for await (const _ of []) ; await null; diff --git a/tests/baselines/reference/awaitLiteralValues.js b/tests/baselines/reference/awaitLiteralValues.js index cc5a06a0c1909..9a53b0ee2f76f 100644 --- a/tests/baselines/reference/awaitLiteralValues.js +++ b/tests/baselines/reference/awaitLiteralValues.js @@ -28,18 +28,23 @@ function awaitUndefined() { function awaitString() { yield 'literal'; } + function awaitNumber() { yield 1; } + function awaitTrue() { yield true; } + function awaitFalse() { yield false; } + function awaitNull() { yield null; } + function awaitUndefined() { yield undefined; } diff --git a/tests/baselines/reference/awaitUnionPromise.js b/tests/baselines/reference/awaitUnionPromise.js index 723339b9f7170..c0c636d651289 100644 --- a/tests/baselines/reference/awaitUnionPromise.js +++ b/tests/baselines/reference/awaitUnionPromise.js @@ -58,12 +58,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; + var AsyncEnumeratorDone = /** @class */ (function () { - function AsyncEnumeratorDone() { - } + function AsyncEnumeratorDone() {} return AsyncEnumeratorDone; }()); ; + + function main() { return __awaiter(this, void 0, void 0, function () { var x, a, b, c, d; diff --git a/tests/baselines/reference/await_unaryExpression_es2017.js b/tests/baselines/reference/await_unaryExpression_es2017.js index f05bda125fc11..a53e35bde6f8f 100644 --- a/tests/baselines/reference/await_unaryExpression_es2017.js +++ b/tests/baselines/reference/await_unaryExpression_es2017.js @@ -19,12 +19,18 @@ async function bar4() { async function bar() { !await 42; // OK } + + async function bar1() { +await 42; // OK } + + async function bar3() { -await 42; // OK } + + async function bar4() { ~await 42; // OK } diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.js b/tests/baselines/reference/await_unaryExpression_es2017_1.js index 49a3b34b172e4..7559b4463b968 100644 --- a/tests/baselines/reference/await_unaryExpression_es2017_1.js +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.js @@ -23,15 +23,23 @@ async function bar4() { async function bar() { !await 42; // OK } + + async function bar1() { delete await 42; // OK } + + async function bar2() { delete await 42; // OK } + + async function bar3() { void await 42; } + + async function bar4() { +await 42; } diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.js b/tests/baselines/reference/await_unaryExpression_es2017_2.js index 8978e460e7df9..7b760ea7dd002 100644 --- a/tests/baselines/reference/await_unaryExpression_es2017_2.js +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.js @@ -15,9 +15,13 @@ async function bar3() { async function bar1() { delete await 42; } + + async function bar2() { delete await 42; } + + async function bar3() { void await 42; } diff --git a/tests/baselines/reference/await_unaryExpression_es2017_3.js b/tests/baselines/reference/await_unaryExpression_es2017_3.js index b2a1593a9d0bd..906af06e40efb 100644 --- a/tests/baselines/reference/await_unaryExpression_es2017_3.js +++ b/tests/baselines/reference/await_unaryExpression_es2017_3.js @@ -19,17 +19,21 @@ async function bar4() { //// [await_unaryExpression_es2017_3.js] async function bar1() { - ++; - await 42; // Error + ++;await 42; // Error } + + async function bar2() { - --; - await 42; // Error + --;await 42; // Error } + + async function bar3() { var x = 42; await x++; // OK but shouldn't need parenthesis } + + async function bar4() { var x = 42; await x--; // OK but shouldn't need parenthesis diff --git a/tests/baselines/reference/await_unaryExpression_es6.js b/tests/baselines/reference/await_unaryExpression_es6.js index 69eef17361396..86c878cd3e83d 100644 --- a/tests/baselines/reference/await_unaryExpression_es6.js +++ b/tests/baselines/reference/await_unaryExpression_es6.js @@ -30,16 +30,19 @@ function bar() { !(yield 42); // OK }); } + function bar1() { return __awaiter(this, void 0, void 0, function* () { +(yield 42); // OK }); } + function bar3() { return __awaiter(this, void 0, void 0, function* () { -(yield 42); // OK }); } + function bar4() { return __awaiter(this, void 0, void 0, function* () { ~(yield 42); // OK diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.js b/tests/baselines/reference/await_unaryExpression_es6_1.js index 3a205f05ea9b1..3de9d01081062 100644 --- a/tests/baselines/reference/await_unaryExpression_es6_1.js +++ b/tests/baselines/reference/await_unaryExpression_es6_1.js @@ -34,21 +34,25 @@ function bar() { !(yield 42); // OK }); } + function bar1() { return __awaiter(this, void 0, void 0, function* () { delete (yield 42); // OK }); } + function bar2() { return __awaiter(this, void 0, void 0, function* () { delete (yield 42); // OK }); } + function bar3() { return __awaiter(this, void 0, void 0, function* () { void (yield 42); }); } + function bar4() { return __awaiter(this, void 0, void 0, function* () { +(yield 42); diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.js b/tests/baselines/reference/await_unaryExpression_es6_2.js index ee59f5825ae43..6564d7402eaed 100644 --- a/tests/baselines/reference/await_unaryExpression_es6_2.js +++ b/tests/baselines/reference/await_unaryExpression_es6_2.js @@ -26,11 +26,13 @@ function bar1() { delete (yield 42); }); } + function bar2() { return __awaiter(this, void 0, void 0, function* () { delete (yield 42); }); } + function bar3() { return __awaiter(this, void 0, void 0, function* () { void (yield 42); diff --git a/tests/baselines/reference/await_unaryExpression_es6_3.js b/tests/baselines/reference/await_unaryExpression_es6_3.js index 42643caa262ae..097b0b116daeb 100644 --- a/tests/baselines/reference/await_unaryExpression_es6_3.js +++ b/tests/baselines/reference/await_unaryExpression_es6_3.js @@ -29,22 +29,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; function bar1() { return __awaiter(this, void 0, void 0, function* () { - ++; - yield 42; // Error + ++;yield 42; // Error }); } + function bar2() { return __awaiter(this, void 0, void 0, function* () { - --; - yield 42; // Error + --;yield 42; // Error }); } + function bar3() { return __awaiter(this, void 0, void 0, function* () { var x = 42; yield x++; // OK but shouldn't need parenthesis }); } + function bar4() { return __awaiter(this, void 0, void 0, function* () { var x = 42; diff --git a/tests/baselines/reference/badInferenceLowerPriorityThanGoodInference.js b/tests/baselines/reference/badInferenceLowerPriorityThanGoodInference.js index a089d4eb93549..89eebba59fc67 100644 --- a/tests/baselines/reference/badInferenceLowerPriorityThanGoodInference.js +++ b/tests/baselines/reference/badInferenceLowerPriorityThanGoodInference.js @@ -25,12 +25,17 @@ goofus((a: string) => ({ dog: function() { return a; } })); //// [badInferenceLowerPriorityThanGoodInference.js] // Repro from #13118 + + var result = canYouInferThis(function () { return ({ a: { BLAH: 33 }, b: function (x) { } }); }); + result.BLAH; + // Repro from #26629 function goofus(f) { } + goofus(function (a) { return ({ dog: function () { return a; } }); }); goofus(function (a) { return ({ dog: function () { return a; } }); }); diff --git a/tests/baselines/reference/badThisBinding.js b/tests/baselines/reference/badThisBinding.js index d4ffc6731d148..39de3d69f2aef 100644 --- a/tests/baselines/reference/badThisBinding.js +++ b/tests/baselines/reference/badThisBinding.js @@ -14,6 +14,7 @@ class Greeter { } //// [badThisBinding.js] + var Greeter = /** @class */ (function () { function Greeter() { var _this = this; diff --git a/tests/baselines/reference/baseCheck.js b/tests/baselines/reference/baseCheck.js index 114bbf655e491..1f89fdcb08dda 100644 --- a/tests/baselines/reference/baseCheck.js +++ b/tests/baselines/reference/baseCheck.js @@ -44,8 +44,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); var C = /** @class */ (function () { - function C(x, y) { - } + function C(x, y) {} return C; }()); var ELoc = /** @class */ (function (_super) { @@ -60,6 +59,7 @@ var ELocVar = /** @class */ (function (_super) { function ELocVar(x) { return _super.call(this, 0, loc) || this; } + ELocVar.prototype.m = function () { var loc = 10; }; diff --git a/tests/baselines/reference/baseConstraintOfDecorator.js b/tests/baselines/reference/baseConstraintOfDecorator.js index 8b496c83a0334..cf0f054a5abca 100644 --- a/tests/baselines/reference/baseConstraintOfDecorator.js +++ b/tests/baselines/reference/baseConstraintOfDecorator.js @@ -39,8 +39,7 @@ exports.classExtender2 = exports.classExtender = void 0; function classExtender(superClass, _instanceModifier) { return /** @class */ (function (_super) { __extends(decoratorFunc, _super); - function decoratorFunc() { - var args = []; + function decoratorFunc() {var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } @@ -53,15 +52,13 @@ function classExtender(superClass, _instanceModifier) { } exports.classExtender = classExtender; var MyClass = /** @class */ (function () { - function MyClass() { - } + function MyClass() {} return MyClass; }()); function classExtender2(superClass, _instanceModifier) { return /** @class */ (function (_super) { __extends(decoratorFunc, _super); - function decoratorFunc() { - var args = []; + function decoratorFunc() {var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } diff --git a/tests/baselines/reference/baseExpressionTypeParameters.js b/tests/baselines/reference/baseExpressionTypeParameters.js index aa16fcebf5577..b1708011f81a3 100644 --- a/tests/baselines/reference/baseExpressionTypeParameters.js +++ b/tests/baselines/reference/baseExpressionTypeParameters.js @@ -28,6 +28,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + function base() { var Base = /** @class */ (function () { function Base() { @@ -36,6 +37,7 @@ function base() { }()); return Base; } + var Gen = /** @class */ (function (_super) { __extends(Gen, _super); function Gen() { diff --git a/tests/baselines/reference/baseIndexSignatureResolution.js b/tests/baselines/reference/baseIndexSignatureResolution.js index 09aabe21ac4b1..0462f1212bbed 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.js +++ b/tests/baselines/reference/baseIndexSignatureResolution.js @@ -39,8 +39,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -52,6 +51,7 @@ var Derived = /** @class */ (function (_super) { }(Base)); var x = null; var y = x[0]; + /* // Note - the equivalent for normal interface methods works fine: interface A { diff --git a/tests/baselines/reference/baseTypeAfterDerivedType.js b/tests/baselines/reference/baseTypeAfterDerivedType.js index c7cd84283c32e..dd52e514256bc 100644 --- a/tests/baselines/reference/baseTypeAfterDerivedType.js +++ b/tests/baselines/reference/baseTypeAfterDerivedType.js @@ -17,11 +17,11 @@ interface Base2 { //// [baseTypeAfterDerivedType.js] + var Derived2 = /** @class */ (function () { function Derived2() { } - Derived2.prototype.method = function () { - var args = []; + Derived2.prototype.method = function () {var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } diff --git a/tests/baselines/reference/baseTypeOrderChecking.js b/tests/baselines/reference/baseTypeOrderChecking.js index 31fa3391af5e2..ba39488acc5b8 100644 --- a/tests/baselines/reference/baseTypeOrderChecking.js +++ b/tests/baselines/reference/baseTypeOrderChecking.js @@ -51,6 +51,9 @@ var __extends = (this && this.__extends) || (function () { }; })(); var someVariable; + + + var Class1 = /** @class */ (function () { function Class1() { } diff --git a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js index de50a58205dbf..4f302a14adeb4 100644 --- a/tests/baselines/reference/baseTypeWrappingInstantiationChain.js +++ b/tests/baselines/reference/baseTypeWrappingInstantiationChain.js @@ -42,8 +42,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); var CBaseBase = /** @class */ (function () { - function CBaseBase(x) { - } + function CBaseBase(x) {} return CBaseBase; }()); var CBase = /** @class */ (function (_super) { @@ -75,6 +74,7 @@ var C = /** @class */ (function (_super) { C.prototype.alsoWorks = function () { new CBase(this); // Should not error, parameter is of type Parameter> }; + C.prototype.method = function (t) { }; return C; }(CBase)); diff --git a/tests/baselines/reference/bases.js b/tests/baselines/reference/bases.js index 25cf4073d5cc8..3f5a80e10f210 100644 --- a/tests/baselines/reference/bases.js +++ b/tests/baselines/reference/bases.js @@ -34,10 +34,10 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var B = /** @class */ (function () { function B() { - this.y; - any; + this.y;any; } return B; }()); @@ -45,8 +45,7 @@ var C = /** @class */ (function (_super) { __extends(C, _super); function C() { var _this = this; - _this.x; - any; + _this.x;any; return _this; } return C; diff --git a/tests/baselines/reference/bestChoiceType.js b/tests/baselines/reference/bestChoiceType.js index edd36f77be96c..7fea97c24555b 100644 --- a/tests/baselines/reference/bestChoiceType.js +++ b/tests/baselines/reference/bestChoiceType.js @@ -20,13 +20,16 @@ function f2() { //// [bestChoiceType.js] // Repro from #10041 + (''.match(/ /) || []).map(function (s) { return s.toLowerCase(); }); + // Similar cases function f1() { var x = ''.match(/ /); var y = x || []; var z = y.map(function (s) { return s.toLowerCase(); }); } + function f2() { var x = ''.match(/ /); var y = x ? x : []; diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js index b755bf200a5f1..e212277ab3895 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.js @@ -42,11 +42,12 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var a; var b; + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -66,6 +67,7 @@ var Derived2 = /** @class */ (function (_super) { var base; var derived; var derived2; + var r = true ? 1 : 2; var r3 = true ? 1 : {}; var r4 = true ? a : b; // typeof a @@ -75,6 +77,7 @@ var r7 = true ? function (x) { } : function (x) { }; var r8 = true ? function (x) { } : function (x) { }; // returns Object => void var r10 = true ? derived : derived2; // no error since we use the contextual type in BCT var r11 = true ? base : derived2; + function foo5(t, u) { return true ? t : u; // BCT is Object } diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js index b7afc3eee41f4..123cf0d510500 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.js @@ -40,9 +40,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { @@ -62,14 +62,18 @@ var Derived2 = /** @class */ (function (_super) { var base; var derived; var derived2; + var r2 = true ? 1 : ''; var r9 = true ? derived : derived2; + function foo(t, u) { return true ? t : u; } + function foo2(t, u) { return true ? t : u; // Ok because BCT(T, U) = U } + function foo3(t, u) { return true ? t : u; } diff --git a/tests/baselines/reference/bestCommonTypeOfTuple.js b/tests/baselines/reference/bestCommonTypeOfTuple.js index 81cfa752f5de5..e1f8709e179e8 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple.js +++ b/tests/baselines/reference/bestCommonTypeOfTuple.js @@ -27,7 +27,9 @@ var e4 = t4[3]; // number //// [bestCommonTypeOfTuple.js] function f1(x) { return "foo"; } + function f2(x) { return 10; } + function f3(x) { return true; } var E1; (function (E1) { @@ -41,6 +43,7 @@ var t1; var t2; var t3; var t4; + // no error t1 = [f1, f2]; t2 = [E1.one, E2.two]; diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.js b/tests/baselines/reference/bestCommonTypeOfTuple2.js index a3672a7642370..f83e5b9662182 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple2.js +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.js @@ -37,18 +37,15 @@ var __extends = (this && this.__extends) || (function () { }; })(); var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); var D = /** @class */ (function () { - function D() { - } + function D() {} return D; }()); var E = /** @class */ (function () { - function E() { - } + function E() {} return E; }()); var F = /** @class */ (function (_super) { @@ -78,6 +75,7 @@ var t2; var t3; var t4; var t5; + var e11 = t1[4]; // base var e21 = t2[4]; // {} var e31 = t3[4]; // C1 diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.js b/tests/baselines/reference/bestCommonTypeReturnStatement.js index f4ab98ed1c68a..d1feb2aae9e44 100644 --- a/tests/baselines/reference/bestCommonTypeReturnStatement.js +++ b/tests/baselines/reference/bestCommonTypeReturnStatement.js @@ -13,10 +13,13 @@ function b(): IPromise { return null; } function d(): IPromise { return null; } //// [bestCommonTypeReturnStatement.js] + function f() { if (true) return b(); return d(); } + + function b() { return null; } function d() { return null; } diff --git a/tests/baselines/reference/bestCommonTypeWithContextualTyping.js b/tests/baselines/reference/bestCommonTypeWithContextualTyping.js index c45ae88458fd9..f6f41a48d3815 100644 --- a/tests/baselines/reference/bestCommonTypeWithContextualTyping.js +++ b/tests/baselines/reference/bestCommonTypeWithContextualTyping.js @@ -21,11 +21,14 @@ var conditional: Contextual = null ? e : e; // Ellement var contextualOr: Contextual = e || e; // Ellement //// [bestCommonTypeWithContextualTyping.js] + var e; + // All of these should pass. Neither type is a supertype of the other, but the RHS should // always use Ellement in these examples (not Contextual). Because Ellement is assignable // to Contextual, no errors. var arr = [e]; // Ellement[] var obj = { s: e }; // { s: Ellement; [s: string]: Ellement } + var conditional = null ? e : e; // Ellement var contextualOr = e || e; // Ellement diff --git a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.js b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.js index 25622c3d4f37a..dac306249e938 100644 --- a/tests/baselines/reference/bestCommonTypeWithOptionalProperties.js +++ b/tests/baselines/reference/bestCommonTypeWithOptionalProperties.js @@ -16,9 +16,11 @@ var b5 = [z, x, y]; var b6 = [z, y, x]; //// [bestCommonTypeWithOptionalProperties.js] + var x; var y; var z; + // All these arrays should be X[] var b1 = [x, y, z]; var b2 = [x, z, y]; diff --git a/tests/baselines/reference/betterErrorForAccidentalCall.js b/tests/baselines/reference/betterErrorForAccidentalCall.js index deb2b22d2f608..61f3d68e4ca59 100644 --- a/tests/baselines/reference/betterErrorForAccidentalCall.js +++ b/tests/baselines/reference/betterErrorForAccidentalCall.js @@ -16,8 +16,13 @@ foo() //// [betterErrorForAccidentalCall.js] + foo()(1).toString(); + foo()(1).toString(); + foo()(1).toString(); + foo()(1 + 2).toString(); + foo()(1).toString(); diff --git a/tests/baselines/reference/betterErrorForUnionCall.js b/tests/baselines/reference/betterErrorForUnionCall.js index 5386599113602..a3a5628eeba43 100644 --- a/tests/baselines/reference/betterErrorForUnionCall.js +++ b/tests/baselines/reference/betterErrorForUnionCall.js @@ -11,5 +11,7 @@ fnUnion2(""); //// [betterErrorForUnionCall.js] union(""); + fnUnion(""); + fnUnion2(""); diff --git a/tests/baselines/reference/bigintIndex.js b/tests/baselines/reference/bigintIndex.js index e24aee68dcfb1..9ff2f5ca0f7f0 100644 --- a/tests/baselines/reference/bigintIndex.js +++ b/tests/baselines/reference/bigintIndex.js @@ -33,15 +33,19 @@ const c = {[bigNum]: 789}; //// [a.js] + const arr = [1, 2, 3]; let num = arr[1]; num = arr["1"]; num = arr[1n]; // should error + let key; // should be type "string | number | symbol" key = 123; key = "abc"; key = Symbol(); key = 123n; // should error + + // Show correct usage of bigint index: explicitly convert to string const bigNum = 0n; const typedArray = new Uint8Array(3); @@ -52,9 +56,6 @@ typedArray[2] = 0xCC; // {1n: 123} is a syntax error; must go in separate file so BigIntIndex error is shown //// [b.js] // BigInt cannot be used as an object literal property -const a = {}; -1n; -123; -; +const a = {};1n;123;; const b = { [1n]: 456 }; const c = { [bigNum]: 789 }; diff --git a/tests/baselines/reference/bigintWithLib.js b/tests/baselines/reference/bigintWithLib.js index 13aeaa877e82b..453e32cac44aa 100644 --- a/tests/baselines/reference/bigintWithLib.js +++ b/tests/baselines/reference/bigintWithLib.js @@ -65,6 +65,7 @@ bigintVal = bigintVal.valueOf(); let stringVal = bigintVal.toString(); stringVal = bigintVal.toString(2); stringVal = bigintVal.toLocaleString(); + // Test BigInt64Array let bigIntArray = new BigInt64Array(); bigIntArray = new BigInt64Array(10); @@ -76,6 +77,7 @@ bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3); let len = bigIntArray.length; bigIntArray.length = 10; // should error let arrayBufferLike = bigIntArray; + // Test BigUint64Array let bigUintArray = new BigUint64Array(); bigUintArray = new BigUint64Array(10); @@ -87,6 +89,7 @@ bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3); len = bigIntArray.length; bigIntArray.length = 10; // should error arrayBufferLike = bigIntArray; + // Test added DataView methods const dataView = new DataView(new ArrayBuffer(80)); dataView.setBigInt64(1, -1n); @@ -99,6 +102,7 @@ bigintVal = dataView.getBigInt64(1); bigintVal = dataView.getBigInt64(1, true); bigintVal = dataView.getBigUint64(2); bigintVal = dataView.getBigUint64(2, true); + // Test emitted declarations files const w = 12n; // should emit as const w = 12n const x = -12n; // should emit as const x = -12n diff --git a/tests/baselines/reference/bigintWithoutLib.js b/tests/baselines/reference/bigintWithoutLib.js index 31a59fcbaf03b..ba33914f4b6c0 100644 --- a/tests/baselines/reference/bigintWithoutLib.js +++ b/tests/baselines/reference/bigintWithoutLib.js @@ -61,6 +61,8 @@ bigintVal = bigintVal.valueOf(); // should error - bigintVal inferred as {} var stringVal = bigintVal.toString(); // should not error - bigintVal inferred as {} stringVal = bigintVal.toString(2); // should error - bigintVal inferred as {} stringVal = bigintVal.toLocaleString(); // should not error - bigintVal inferred as {} + + // Test BigInt64Array var bigIntArray = new BigInt64Array(); bigIntArray = new BigInt64Array(10); @@ -72,6 +74,7 @@ bigIntArray = new BigInt64Array(new ArrayBuffer(80), 8, 3); var len = bigIntArray.length; bigIntArray.length = 10; var arrayBufferLike = bigIntArray; + // Test BigUint64Array var bigUintArray = new BigUint64Array(); bigUintArray = new BigUint64Array(10); @@ -83,6 +86,7 @@ bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3); len = bigIntArray.length; bigIntArray.length = 10; arrayBufferLike = bigIntArray; + // Test added DataView methods var dataView = new DataView(new ArrayBuffer(80)); dataView.setBigInt64(1, -1n); diff --git a/tests/baselines/reference/binaryArithmeticControlFlowGraphNotTooLarge.js b/tests/baselines/reference/binaryArithmeticControlFlowGraphNotTooLarge.js index ab5cd46e5996c..b2b11dfb43caf 100644 --- a/tests/baselines/reference/binaryArithmeticControlFlowGraphNotTooLarge.js +++ b/tests/baselines/reference/binaryArithmeticControlFlowGraphNotTooLarge.js @@ -1301,6 +1301,7 @@ const foo = function (this: any) { // Repro from #29926 (expanded 10x for good measure) var foo = function () { var a, b, c, d, ab, bc, cd, da, blocks = this.blocks; + if (this.first) { a = blocks[0] - 1; a = (a << 3) | (a >>> 29); @@ -1325,6 +1326,7 @@ var foo = function () { b += ((c & d) | (~c & a)) + blocks[3]; b = (b << 19) | (b >>> 13); } + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -1349,6 +1351,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -1396,6 +1399,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -1436,6 +1440,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -1460,6 +1465,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -1507,6 +1513,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -1547,6 +1554,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -1571,6 +1579,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -1618,6 +1627,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -1658,6 +1668,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -1682,6 +1693,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -1729,6 +1741,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -1769,6 +1782,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -1793,6 +1807,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -1840,6 +1855,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -1880,6 +1896,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -1904,6 +1921,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -1951,6 +1969,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -1991,6 +2010,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -2015,6 +2035,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -2062,6 +2083,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -2102,6 +2124,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -2126,6 +2149,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -2173,6 +2197,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -2213,6 +2238,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -2237,6 +2263,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -2284,6 +2311,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -2324,6 +2352,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -2348,6 +2377,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -2395,6 +2425,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -2435,6 +2466,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + a += ((b & c) | (~b & d)) + blocks[4]; a = (a << 3) | (a >>> 29); d += ((a & b) | (~a & c)) + blocks[5]; @@ -2459,6 +2491,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += ((c & d) | (~c & a)) + blocks[15]; b = (b << 19) | (b >>> 13); + bc = b & c; a += (bc | (b & d) | (c & d)) + blocks[0] + 1518500249; a = (a << 3) | (a >>> 29); @@ -2506,6 +2539,7 @@ var foo = function () { c = (c << 9) | (c >>> 23); b += ((c & d) | (c & a) | da) + blocks[15] + 1518500249; b = (b << 13) | (b >>> 19); + bc = b ^ c; a += (bc ^ d) + blocks[0] + 1859775393; a = (a << 3) | (a >>> 29); @@ -2546,6 +2580,7 @@ var foo = function () { c = (c << 11) | (c >>> 21); b += (da ^ c) + blocks[15] + 1859775393; b = (b << 15) | (b >>> 17); + if (this.first) { this.h0 = a + 1732584193 << 0; this.h1 = b - 271733879 << 0; diff --git a/tests/baselines/reference/binaryIntegerLiteral.js b/tests/baselines/reference/binaryIntegerLiteral.js index 6f4270cf2b826..074b52bc382db 100644 --- a/tests/baselines/reference/binaryIntegerLiteral.js +++ b/tests/baselines/reference/binaryIntegerLiteral.js @@ -47,6 +47,7 @@ var bin1 = 26; var bin2 = 26; var bin3 = 9.671406556917009e+24; var bin4 = Infinity; + var obj1 = { 26: "Hello", a: bin1, @@ -54,6 +55,7 @@ var obj1 = { b: 26, Infinity: true, }; + var obj2 = { 26: "World", a: bin2, @@ -61,6 +63,7 @@ var obj2 = { b: 26, 9.671406556917009e+24: false, }; + obj1[26]; // string obj1[26]; // string obj1["26"]; // string @@ -69,6 +72,7 @@ obj1["a"]; // number obj1["b"]; // number obj1["bin1"]; // number obj1["Infinity"]; // boolean + obj2[26]; // string obj2[26]; // string obj2["26"]; // string diff --git a/tests/baselines/reference/binaryIntegerLiteralES6.js b/tests/baselines/reference/binaryIntegerLiteralES6.js index bfb85a241d354..21d0323e80293 100644 --- a/tests/baselines/reference/binaryIntegerLiteralES6.js +++ b/tests/baselines/reference/binaryIntegerLiteralES6.js @@ -48,6 +48,7 @@ var bin1 = 0b11010; var bin2 = 0B11010; var bin3 = 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111; var bin4 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111; + var obj1 = { 0b11010: "Hello", a: bin1, @@ -55,6 +56,7 @@ var obj1 = { b: 0b11010, 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true, }; + var obj2 = { 0B11010: "World", a: bin2, @@ -62,6 +64,7 @@ var obj2 = { b: 0B11010, 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false, }; + obj1[0b11010]; // string obj1[26]; // string obj1["26"]; // string @@ -70,6 +73,7 @@ obj1["a"]; // number obj1["b"]; // number obj1["bin1"]; // number obj1["Infinity"]; // boolean + obj2[0B11010]; // string obj2[26]; // string obj2["26"]; // string @@ -80,3 +84,5 @@ obj2["bin2"]; // number obj2[9.671406556917009e+24]; // boolean obj2["9.671406556917009e+24"]; // boolean obj2["Infinity"]; // any + + diff --git a/tests/baselines/reference/binaryIntegerLiteralError.js b/tests/baselines/reference/binaryIntegerLiteralError.js index 215514982c045..5f4378d477e99 100644 --- a/tests/baselines/reference/binaryIntegerLiteralError.js +++ b/tests/baselines/reference/binaryIntegerLiteralError.js @@ -12,10 +12,9 @@ var obj1 = { //// [binaryIntegerLiteralError.js] // error -var bin1 = 6; -2110; -var bin1 = 6; -23410; +var bin1 = 6;2110; +var bin1 = 6;23410; + var obj1 = { 26: "hi", 26: "Hello", diff --git a/tests/baselines/reference/bind1.js b/tests/baselines/reference/bind1.js index de83d56ab8ef8..218332fb871c7 100644 --- a/tests/baselines/reference/bind1.js +++ b/tests/baselines/reference/bind1.js @@ -9,8 +9,7 @@ module M { var M; (function (M) { var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); // this should be an unresolved symbol I error M.C = C; diff --git a/tests/baselines/reference/binderBinaryExpressionStress.js b/tests/baselines/reference/binderBinaryExpressionStress.js index 7f903e39cf05a..bb4b5dce03723 100644 --- a/tests/baselines/reference/binderBinaryExpressionStress.js +++ b/tests/baselines/reference/binderBinaryExpressionStress.js @@ -4971,6 +4971,7 @@ var caps = //// [binderBinaryExpressionStress.js] 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 + 100 + 101 + 102 + 103 + 104 + 105 + 106 + 107 + 108 + 109 + 110 + 111 + 112 + 113 + 114 + 115 + 116 + 117 + 118 + 119 + 120 + 121 + 122 + 123 + 124 + 125 + 126 + 127 + 128 + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + 139 + 140 + 141 + 142 + 143 + 144 + 145 + 146 + 147 + 148 + 149 + 150 + 151 + 152 + 153 + 154 + 155 + 156 + 157 + 158 + 159 + 160 + 161 + 162 + 163 + 164 + 165 + 166 + 167 + 168 + 169 + 170 + 171 + 172 + 173 + 174 + 175 + 176 + 177 + 178 + 179 + 180 + 181 + 182 + 183 + 184 + 185 + 186 + 187 + 188 + 189 + 190 + 191 + 192 + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + 202 + 203 + 204 + 205 + 206 + 207 + 208 + 209 + 210 + 211 + 212 + 213 + 214 + 215 + 216 + 217 + 218 + 219 + 220 + 221 + 222 + 223 + 224 + 225 + 226 + 227 + 228 + 229 + 230 + 231 + 232 + 233 + 234 + 235 + 236 + 237 + 238 + 239 + 240 + 241 + 242 + 243 + 244 + 245 + 246 + 247 + 248 + 249 + 250 + 251 + 252 + 253 + 254 + 255 + 256 + 257 + 258 + 259 + 260 + 261 + 262 + 263 + 264 + 265 + 266 + 267 + 268 + 269 + 270 + 271 + 272 + 273 + 274 + 275 + 276 + 277 + 278 + 279 + 280 + 281 + 282 + 283 + 284 + 285 + 286 + 287 + 288 + 289 + 290 + 291 + 292 + 293 + 294 + 295 + 296 + 297 + 298 + 299 + 300 + 301 + 302 + 303 + 304 + 305 + 306 + 307 + 308 + 309 + 310 + 311 + 312 + 313 + 314 + 315 + 316 + 317 + 318 + 319 + 320 + 321 + 322 + 323 + 324 + 325 + 326 + 327 + 328 + 329 + 330 + 331 + 332 + 333 + 334 + 335 + 336 + 337 + 338 + 339 + 340 + 341 + 342 + 343 + 344 + 345 + 346 + 347 + 348 + 349 + 350 + 351 + 352 + 353 + 354 + 355 + 356 + 357 + 358 + 359 + 360 + 361 + 362 + 363 + 364 + 365 + 366 + 367 + 368 + 369 + 370 + 371 + 372 + 373 + 374 + 375 + 376 + 377 + 378 + 379 + 380 + 381 + 382 + 383 + 384 + 385 + 386 + 387 + 388 + 389 + 390 + 391 + 392 + 393 + 394 + 395 + 396 + 397 + 398 + 399 + 400 + 401 + 402 + 403 + 404 + 405 + 406 + 407 + 408 + 409 + 410 + 411 + 412 + 413 + 414 + 415 + 416 + 417 + 418 + 419 + 420 + 421 + 422 + 423 + 424 + 425 + 426 + 427 + 428 + 429 + 430 + 431 + 432 + 433 + 434 + 435 + 436 + 437 + 438 + 439 + 440 + 441 + 442 + 443 + 444 + 445 + 446 + 447 + 448 + 449 + 450 + 451 + 452 + 453 + 454 + 455 + 456 + 457 + 458 + 459 + 460 + 461 + 462 + 463 + 464 + 465 + 466 + 467 + 468 + 469 + 470 + 471 + 472 + 473 + 474 + 475 + 476 + 477 + 478 + 479 + 480 + 481 + 482 + 483 + 484 + 485 + 486 + 487 + 488 + 489 + 490 + 491 + 492 + 493 + 494 + 495 + 496 + 497 + 498 + 499 + 500 + 501 + 502 + 503 + 504 + 505 + 506 + 507 + 508 + 509 + 510 + 511 + 512 + 513 + 514 + 515 + 516 + 517 + 518 + 519 + 520 + 521 + 522 + 523 + 524 + 525 + 526 + 527 + 528 + 529 + 530 + 531 + 532 + 533 + 534 + 535 + 536 + 537 + 538 + 539 + 540 + 541 + 542 + 543 + 544 + 545 + 546 + 547 + 548 + 549 + 550 + 551 + 552 + 553 + 554 + 555 + 556 + 557 + 558 + 559 + 560 + 561 + 562 + 563 + 564 + 565 + 566 + 567 + 568 + 569 + 570 + 571 + 572 + 573 + 574 + 575 + 576 + 577 + 578 + 579 + 580 + 581 + 582 + 583 + 584 + 585 + 586 + 587 + 588 + 589 + 590 + 591 + 592 + 593 + 594 + 595 + 596 + 597 + 598 + 599 + 600 + 601 + 602 + 603 + 604 + 605 + 606 + 607 + 608 + 609 + 610 + 611 + 612 + 613 + 614 + 615 + 616 + 617 + 618 + 619 + 620 + 621 + 622 + 623 + 624 + 625 + 626 + 627 + 628 + 629 + 630 + 631 + 632 + 633 + 634 + 635 + 636 + 637 + 638 + 639 + 640 + 641 + 642 + 643 + 644 + 645 + 646 + 647 + 648 + 649 + 650 + 651 + 652 + 653 + 654 + 655 + 656 + 657 + 658 + 659 + 660 + 661 + 662 + 663 + 664 + 665 + 666 + 667 + 668 + 669 + 670 + 671 + 672 + 673 + 674 + 675 + 676 + 677 + 678 + 679 + 680 + 681 + 682 + 683 + 684 + 685 + 686 + 687 + 688 + 689 + 690 + 691 + 692 + 693 + 694 + 695 + 696 + 697 + 698 + 699 + 700 + 701 + 702 + 703 + 704 + 705 + 706 + 707 + 708 + 709 + 710 + 711 + 712 + 713 + 714 + 715 + 716 + 717 + 718 + 719 + 720 + 721 + 722 + 723 + 724 + 725 + 726 + 727 + 728 + 729 + 730 + 731 + 732 + 733 + 734 + 735 + 736 + 737 + 738 + 739 + 740 + 741 + 742 + 743 + 744 + 745 + 746 + 747 + 748 + 749 + 750 + 751 + 752 + 753 + 754 + 755 + 756 + 757 + 758 + 759 + 760 + 761 + 762 + 763 + 764 + 765 + 766 + 767 + 768 + 769 + 770 + 771 + 772 + 773 + 774 + 775 + 776 + 777 + 778 + 779 + 780 + 781 + 782 + 783 + 784 + 785 + 786 + 787 + 788 + 789 + 790 + 791 + 792 + 793 + 794 + 795 + 796 + 797 + 798 + 799 + 800 + 801 + 802 + 803 + 804 + 805 + 806 + 807 + 808 + 809 + 810 + 811 + 812 + 813 + 814 + 815 + 816 + 817 + 818 + 819 + 820 + 821 + 822 + 823 + 824 + 825 + 826 + 827 + 828 + 829 + 830 + 831 + 832 + 833 + 834 + 835 + 836 + 837 + 838 + 839 + 840 + 841 + 842 + 843 + 844 + 845 + 846 + 847 + 848 + 849 + 850 + 851 + 852 + 853 + 854 + 855 + 856 + 857 + 858 + 859 + 860 + 861 + 862 + 863 + 864 + 865 + 866 + 867 + 868 + 869 + 870 + 871 + 872 + 873 + 874 + 875 + 876 + 877 + 878 + 879 + 880 + 881 + 882 + 883 + 884 + 885 + 886 + 887 + 888 + 889 + 890 + 891 + 892 + 893 + 894 + 895 + 896 + 897 + 898 + 899 + 900 + 901 + 902 + 903 + 904 + 905 + 906 + 907 + 908 + 909 + 910 + 911 + 912 + 913 + 914 + 915 + 916 + 917 + 918 + 919 + 920 + 921 + 922 + 923 + 924 + 925 + 926 + 927 + 928 + 929 + 930 + 931 + 932 + 933 + 934 + 935 + 936 + 937 + 938 + 939 + 940 + 941 + 942 + 943 + 944 + 945 + 946 + 947 + 948 + 949 + 950 + 951 + 952 + 953 + 954 + 955 + 956 + 957 + 958 + 959 + 960 + 961 + 962 + 963 + 964 + 965 + 966 + 967 + 968 + 969 + 970 + 971 + 972 + 973 + 974 + 975 + 976 + 977 + 978 + 979 + 980 + 981 + 982 + 983 + 984 + 985 + 986 + 987 + 988 + 989 + 990 + 991 + 992 + 993 + 994 + 995 + 996 + 997 + 998 + 999 + 1000 + 1001 + 1002 + 1003 + 1004 + 1005 + 1006 + 1007 + 1008 + 1009 + 1010 + 1011 + 1012 + 1013 + 1014 + 1015 + 1016 + 1017 + 1018 + 1019 + 1020 + 1021 + 1022 + 1023 + 1024 + 1025 + 1026 + 1027 + 1028 + 1029 + 1030 + 1031 + 1032 + 1033 + 1034 + 1035 + 1036 + 1037 + 1038 + 1039 + 1040 + 1041 + 1042 + 1043 + 1044 + 1045 + 1046 + 1047 + 1048 + 1049 + 1050 + 1051 + 1052 + 1053 + 1054 + 1055 + 1056 + 1057 + 1058 + 1059 + 1060 + 1061 + 1062 + 1063 + 1064 + 1065 + 1066 + 1067 + 1068 + 1069 + 1070 + 1071 + 1072 + 1073 + 1074 + 1075 + 1076 + 1077 + 1078 + 1079 + 1080 + 1081 + 1082 + 1083 + 1084 + 1085 + 1086 + 1087 + 1088 + 1089 + 1090 + 1091 + 1092 + 1093 + 1094 + 1095 + 1096 + 1097 + 1098 + 1099 + 1100 + 1101 + 1102 + 1103 + 1104 + 1105 + 1106 + 1107 + 1108 + 1109 + 1110 + 1111 + 1112 + 1113 + 1114 + 1115 + 1116 + 1117 + 1118 + 1119 + 1120 + 1121 + 1122 + 1123 + 1124 + 1125 + 1126 + 1127 + 1128 + 1129 + 1130 + 1131 + 1132 + 1133 + 1134 + 1135 + 1136 + 1137 + 1138 + 1139 + 1140 + 1141 + 1142 + 1143 + 1144 + 1145 + 1146 + 1147 + 1148 + 1149 + 1150 + 1151 + 1152 + 1153 + 1154 + 1155 + 1156 + 1157 + 1158 + 1159 + 1160 + 1161 + 1162 + 1163 + 1164 + 1165 + 1166 + 1167 + 1168 + 1169 + 1170 + 1171 + 1172 + 1173 + 1174 + 1175 + 1176 + 1177 + 1178 + 1179 + 1180 + 1181 + 1182 + 1183 + 1184 + 1185 + 1186 + 1187 + 1188 + 1189 + 1190 + 1191 + 1192 + 1193 + 1194 + 1195 + 1196 + 1197 + 1198 + 1199 + 1200 + 1201 + 1202 + 1203 + 1204 + 1205 + 1206 + 1207 + 1208 + 1209 + 1210 + 1211 + 1212 + 1213 + 1214 + 1215 + 1216 + 1217 + 1218 + 1219 + 1220 + 1221 + 1222 + 1223 + 1224 + 1225 + 1226 + 1227 + 1228 + 1229 + 1230 + 1231 + 1232 + 1233 + 1234 + 1235 + 1236 + 1237 + 1238 + 1239 + 1240 + 1241 + 1242 + 1243 + 1244 + 1245 + 1246 + 1247 + 1248 + 1249 + 1250 + 1251 + 1252 + 1253 + 1254 + 1255 + 1256 + 1257 + 1258 + 1259 + 1260 + 1261 + 1262 + 1263 + 1264 + 1265 + 1266 + 1267 + 1268 + 1269 + 1270 + 1271 + 1272 + 1273 + 1274 + 1275 + 1276 + 1277 + 1278 + 1279 + 1280 + 1281 + 1282 + 1283 + 1284 + 1285 + 1286 + 1287 + 1288 + 1289 + 1290 + 1291 + 1292 + 1293 + 1294 + 1295 + 1296 + 1297 + 1298 + 1299 + 1300 + 1301 + 1302 + 1303 + 1304 + 1305 + 1306 + 1307 + 1308 + 1309 + 1310 + 1311 + 1312 + 1313 + 1314 + 1315 + 1316 + 1317 + 1318 + 1319 + 1320 + 1321 + 1322 + 1323 + 1324 + 1325 + 1326 + 1327 + 1328 + 1329 + 1330 + 1331 + 1332 + 1333 + 1334 + 1335 + 1336 + 1337 + 1338 + 1339 + 1340 + 1341 + 1342 + 1343 + 1344 + 1345 + 1346 + 1347 + 1348 + 1349 + 1350 + 1351 + 1352 + 1353 + 1354 + 1355 + 1356 + 1357 + 1358 + 1359 + 1360 + 1361 + 1362 + 1363 + 1364 + 1365 + 1366 + 1367 + 1368 + 1369 + 1370 + 1371 + 1372 + 1373 + 1374 + 1375 + 1376 + 1377 + 1378 + 1379 + 1380 + 1381 + 1382 + 1383 + 1384 + 1385 + 1386 + 1387 + 1388 + 1389 + 1390 + 1391 + 1392 + 1393 + 1394 + 1395 + 1396 + 1397 + 1398 + 1399 + 1400 + 1401 + 1402 + 1403 + 1404 + 1405 + 1406 + 1407 + 1408 + 1409 + 1410 + 1411 + 1412 + 1413 + 1414 + 1415 + 1416 + 1417 + 1418 + 1419 + 1420 + 1421 + 1422 + 1423 + 1424 + 1425 + 1426 + 1427 + 1428 + 1429 + 1430 + 1431 + 1432 + 1433 + 1434 + 1435 + 1436 + 1437 + 1438 + 1439 + 1440 + 1441 + 1442 + 1443 + 1444 + 1445 + 1446 + 1447 + 1448 + 1449 + 1450 + 1451 + 1452 + 1453 + 1454 + 1455 + 1456 + 1457 + 1458 + 1459 + 1460 + 1461 + 1462 + 1463 + 1464 + 1465 + 1466 + 1467 + 1468 + 1469 + 1470 + 1471 + 1472 + 1473 + 1474 + 1475 + 1476 + 1477 + 1478 + 1479 + 1480 + 1481 + 1482 + 1483 + 1484 + 1485 + 1486 + 1487 + 1488 + 1489 + 1490 + 1491 + 1492 + 1493 + 1494 + 1495 + 1496 + 1497 + 1498 + 1499; + var caps = '' + '' + '' + diff --git a/tests/baselines/reference/bindingPatternInParameter01.js b/tests/baselines/reference/bindingPatternInParameter01.js index 27b3a59e81ed7..fc80a1ea5645d 100644 --- a/tests/baselines/reference/bindingPatternInParameter01.js +++ b/tests/baselines/reference/bindingPatternInParameter01.js @@ -8,6 +8,7 @@ nestedArray.forEach(([[a, b]]) => { //// [bindingPatternInParameter01.js] var nestedArray = [[[1, 2]], [[3, 4]]]; + nestedArray.forEach(function (_a) { var _b = _a[0], a = _b[0], b = _b[1]; console.log(a, b); diff --git a/tests/baselines/reference/bitwiseCompoundAssignmentOperators.js b/tests/baselines/reference/bitwiseCompoundAssignmentOperators.js index c148fc0142cb1..a88a49a015b7f 100644 --- a/tests/baselines/reference/bitwiseCompoundAssignmentOperators.js +++ b/tests/baselines/reference/bitwiseCompoundAssignmentOperators.js @@ -43,6 +43,7 @@ a ^= b; a = true; b ^= a; b = 1; + var c = false; var d = 2; c &= c; @@ -52,6 +53,7 @@ d = 2; c &= d; c = false; d &= c; + var e = true; var f = 0; e |= e; diff --git a/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.js b/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.js index 1b64091c048f5..2455ee7cdc2eb 100644 --- a/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.js +++ b/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.js @@ -14,11 +14,14 @@ var b =~; //// [bitwiseNotOperatorInvalidOperations.js] // Unary operator ~ var q; + // operand before ~ -var a = q; -~; //expect error +var a = q;~; //expect error + + // multiple operands after ~ -var mul = ~[1, 2, "abc"]; -""; //expect error +var mul = ~[1, 2, "abc"];""; //expect error + + // miss an operand var b = ~; diff --git a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.js b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.js index 8827aa2d57fa1..2db81c4b7c006 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.js +++ b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.js @@ -64,11 +64,13 @@ var ResultIsNumber20 = ~~~(ANY + ANY1); //// [bitwiseNotOperatorWithAnyOtherType.js] // ~ operator on any type + var ANY; var ANY1; var ANY2 = ["", ""]; var obj; var obj1 = { x: "", y: function () { } }; + function foo() { var a; return a; @@ -86,6 +88,7 @@ var M; (function (M) { })(M || (M = {})); var objA = new A(); + // any other type var var ResultIsNumber = ~ANY1; var ResultIsNumber1 = ~ANY2; @@ -93,9 +96,11 @@ var ResultIsNumber2 = ~A; var ResultIsNumber3 = ~M; var ResultIsNumber4 = ~obj; var ResultIsNumber5 = ~obj1; + // any type literal var ResultIsNumber6 = ~undefined; var ResultIsNumber7 = ~null; + // any type expressions var ResultIsNumber8 = ~ANY2[0]; var ResultIsNumber9 = ~obj1.x; @@ -108,9 +113,11 @@ var ResultIsNumber15 = ~(ANY + ANY1); var ResultIsNumber16 = ~(null + undefined); var ResultIsNumber17 = ~(null + null); var ResultIsNumber18 = ~(undefined + undefined); + // multiple ~ operators var ResultIsNumber19 = ~~ANY; var ResultIsNumber20 = ~~~(ANY + ANY1); + //miss assignment operators ~ANY; ~ANY1; diff --git a/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.js b/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.js index 00766ee43033d..21817bd91184e 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.js +++ b/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.js @@ -41,7 +41,9 @@ var ResultIsNumber8 = ~~BOOLEAN; //// [bitwiseNotOperatorWithBooleanType.js] // ~ operator on boolean type var BOOLEAN; + function foo() { return true; } + var A = /** @class */ (function () { function A() { } @@ -52,18 +54,23 @@ var M; (function (M) { })(M || (M = {})); var objA = new A(); + // boolean type var var ResultIsNumber1 = ~BOOLEAN; + // boolean type literal var ResultIsNumber2 = ~true; var ResultIsNumber3 = ~{ x: true, y: false }; + // boolean type expressions var ResultIsNumber4 = ~objA.a; var ResultIsNumber5 = ~M.n; var ResultIsNumber6 = ~foo(); var ResultIsNumber7 = ~A.foo(); + // multiple ~ operators var ResultIsNumber8 = ~~BOOLEAN; + // miss assignment operators ~true; ~BOOLEAN; diff --git a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js index 0bcf2fa39569b..915bd6de1521c 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js +++ b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js @@ -27,13 +27,17 @@ var ENUM1; ENUM1[ENUM1[""] = 2] = ""; })(ENUM1 || (ENUM1 = {})); ; + // enum type var var ResultIsNumber1 = ~ENUM1; + // enum type expressions var ResultIsNumber2 = ~ENUM1["A"]; var ResultIsNumber3 = ~(ENUM1.A + ENUM1["B"]); + // multiple ~ operators var ResultIsNumber4 = ~~~(ENUM1["A"] + ENUM1.B); + // miss assignment operators ~ENUM1; ~ENUM1["A"]; diff --git a/tests/baselines/reference/bitwiseNotOperatorWithNumberType.js b/tests/baselines/reference/bitwiseNotOperatorWithNumberType.js index d446532caf88c..f7fdfa708b46b 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithNumberType.js +++ b/tests/baselines/reference/bitwiseNotOperatorWithNumberType.js @@ -48,7 +48,9 @@ var ResultIsNumber13 = ~~~(NUMBER + NUMBER); // ~ operator on number type var NUMBER; var NUMBER1 = [1, 2]; + function foo() { return 1; } + var A = /** @class */ (function () { function A() { } @@ -59,13 +61,16 @@ var M; (function (M) { })(M || (M = {})); var objA = new A(); + // number type var var ResultIsNumber1 = ~NUMBER; var ResultIsNumber2 = ~NUMBER1; + // number type literal var ResultIsNumber3 = ~1; var ResultIsNumber4 = ~{ x: 1, y: 2 }; var ResultIsNumber5 = ~{ x: 1, y: function (n) { return n; } }; + // number type expressions var ResultIsNumber6 = ~objA.a; var ResultIsNumber7 = ~M.n; @@ -73,9 +78,11 @@ var ResultIsNumber8 = ~NUMBER1[0]; var ResultIsNumber9 = ~foo(); var ResultIsNumber10 = ~A.foo(); var ResultIsNumber11 = ~(NUMBER + NUMBER); + // multiple ~ operators var ResultIsNumber12 = ~~NUMBER; var ResultIsNumber13 = ~~~(NUMBER + NUMBER); + // miss assignment operators ~NUMBER; ~NUMBER1; diff --git a/tests/baselines/reference/bitwiseNotOperatorWithStringType.js b/tests/baselines/reference/bitwiseNotOperatorWithStringType.js index 481e75e3378a2..b9b27cdd60fc8 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithStringType.js +++ b/tests/baselines/reference/bitwiseNotOperatorWithStringType.js @@ -47,7 +47,9 @@ var ResultIsNumber14 = ~~~(STRING + STRING); // ~ operator on string type var STRING; var STRING1 = ["", "abc"]; + function foo() { return "abc"; } + var A = /** @class */ (function () { function A() { } @@ -58,13 +60,16 @@ var M; (function (M) { })(M || (M = {})); var objA = new A(); + // string type var var ResultIsNumber1 = ~STRING; var ResultIsNumber2 = ~STRING1; + // string type literal var ResultIsNumber3 = ~""; var ResultIsNumber4 = ~{ x: "", y: "" }; var ResultIsNumber5 = ~{ x: "", y: function (s) { return s; } }; + // string type expressions var ResultIsNumber6 = ~objA.a; var ResultIsNumber7 = ~M.n; @@ -73,9 +78,11 @@ var ResultIsNumber9 = ~foo(); var ResultIsNumber10 = ~A.foo(); var ResultIsNumber11 = ~(STRING + STRING); var ResultIsNumber12 = ~STRING.charAt(0); + // multiple ~ operators var ResultIsNumber13 = ~~STRING; var ResultIsNumber14 = ~~~(STRING + STRING); + //miss assignment operators ~STRING; ~STRING1; diff --git a/tests/baselines/reference/bivariantInferences.js b/tests/baselines/reference/bivariantInferences.js index a910ca15e93bb..e3d59c4adb22b 100644 --- a/tests/baselines/reference/bivariantInferences.js +++ b/tests/baselines/reference/bivariantInferences.js @@ -14,4 +14,5 @@ let x = a.equalsShallow(b); //// [bivariantInferences.js] "use strict"; // Repro from #27337 + var x = a.equalsShallow(b); diff --git a/tests/baselines/reference/blockScopedBindingCaptureThisInFunction.js b/tests/baselines/reference/blockScopedBindingCaptureThisInFunction.js index 27568fd51ec36..e3f9049ecf3f8 100644 --- a/tests/baselines/reference/blockScopedBindingCaptureThisInFunction.js +++ b/tests/baselines/reference/blockScopedBindingCaptureThisInFunction.js @@ -9,13 +9,15 @@ //// [blockScopedBindingCaptureThisInFunction.js] // https://github.com/Microsoft/TypeScript/issues/11038 -(function () { return function () { - var _loop_1 = function (someKey) { - this_1.helloWorld(); - (function () { return someKey; }); - }; - var this_1 = this; - for (var someKey in {}) { - _loop_1(someKey); - } -}; }); +( + function () { return function () { + var _loop_1 = function (someKey) { + this_1.helloWorld(); + ( + function () { return someKey; }); + }; + var this_1 = this; + for (var someKey in {}) { + _loop_1(someKey); + } + }; }); diff --git a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js index adbba8ee8ae6a..172b61f16e85e 100644 --- a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js +++ b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js @@ -17,5 +17,6 @@ for (var _i = 0, _a = [{}]; _i < _a.length; _i++) { // 2: for (var _c = {}, _d = a, a = _c[_d]; false;) continue; + // 3: var _e = {}, _f = b, b = _e[_f]; diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js index bcc16e499a207..5cceef83d01fb 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.js @@ -116,6 +116,7 @@ var _loop_1 = function (x, y) { if (state_4 === "break") break; } + y = 5; } out_x_1 = x; @@ -151,6 +152,7 @@ var _loop_2 = function (x, y) { _loop_6(a_2); a_2 = out_a_2; } + y = 5; } out_x_2 = x; @@ -189,6 +191,7 @@ var _loop_3 = function (x, y) { case "break-loop2": return state_5; } } + y = 5; } out_x_3 = x; @@ -230,6 +233,7 @@ var _loop_4 = function (x, y) { case "continue-loop2": return state_6; } } + y = 5; } out_x_4 = x; diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js index 584d8b21100fa..13c81885162d6 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.js @@ -53,6 +53,7 @@ function f1() { break; } } + function f2() { var _loop_2 = function (x, y) { var a = function () { return x++ + y++; }; @@ -76,3 +77,8 @@ function f2() { break; } } + + + + + diff --git a/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.js b/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.js index 6559548ddff28..81a7733b7205a 100644 --- a/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.js +++ b/tests/baselines/reference/blockScopedClassDeclarationAcrossFiles.js @@ -9,7 +9,6 @@ class C { } //// [foo.js] var foo; var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.js b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.js index 552d099b07cf1..a8a84ccb77598 100644 --- a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.js +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.js @@ -17,6 +17,7 @@ function foo1() { E[E["A"] = 0] = "A"; })(E || (E = {})); } + function foo2() { return 0 /* A */; } diff --git a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.js b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.js index 239a87f00426f..a6c74fe37727a 100644 --- a/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.js +++ b/tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.js @@ -17,6 +17,7 @@ function foo1() { E[E["A"] = 0] = "A"; })(E || (E = {})); } + function foo2() { return 0 /* A */; var E; diff --git a/tests/baselines/reference/blockScopedNamespaceDifferentFile.js b/tests/baselines/reference/blockScopedNamespaceDifferentFile.js index 1ddb284f55cc0..488551e1b51c3 100644 --- a/tests/baselines/reference/blockScopedNamespaceDifferentFile.js +++ b/tests/baselines/reference/blockScopedNamespaceDifferentFile.js @@ -25,8 +25,7 @@ declare namespace A { var C; (function (C) { var Name = /** @class */ (function () { - function Name(parameters) { - } + function Name(parameters) {} Name.funcData = A.AA.func(); Name.someConst = A.AA.foo; return Name; diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js index 9ca3f8998a2eb..9daf4114e2ecb 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js @@ -109,14 +109,17 @@ function foo0() { var a = x; var x; } + function foo1() { var a = function () { return x; }; var x; } + function foo2() { var a = function () { return x; }; var x; } + function foo3() { var X = /** @class */ (function () { function X() { @@ -126,6 +129,7 @@ function foo3() { }()); var x; } + function foo4() { var y = /** @class */ (function () { function y() { @@ -135,16 +139,19 @@ function foo4() { }()); var x; } + function foo5() { var x = function () { return y; }; var y = function () { return x; }; } + function foo6() { function f() { return x; } var x; } + function foo7() { var A = /** @class */ (function () { function A() { @@ -154,6 +161,7 @@ function foo7() { }()); var x; } + function foo8() { var y = /** @class */ (function () { function class_1() { @@ -163,6 +171,7 @@ function foo8() { }()); var x; } + function foo9() { var _a; var y = (_a = /** @class */ (function () { @@ -174,6 +183,7 @@ function foo9() { _a); var x; } + function foo10() { var A = /** @class */ (function () { function A() { @@ -183,6 +193,7 @@ function foo10() { }()); var x; } + function foo11() { function f() { var _a; @@ -196,6 +207,7 @@ function foo11() { } var x; } + function foo12() { function f() { var y = /** @class */ (function () { @@ -207,12 +219,14 @@ function foo12() { } var x; } + function foo13() { var a = { get a() { return x; } }; var x; } + function foo14() { var a = { a: x diff --git a/tests/baselines/reference/bluebirdStaticThis.js b/tests/baselines/reference/bluebirdStaticThis.js index 1d8d8f2ec43a2..33e3285b3f866 100644 --- a/tests/baselines/reference/bluebirdStaticThis.js +++ b/tests/baselines/reference/bluebirdStaticThis.js @@ -145,6 +145,7 @@ var x; var arr; var foo; var fooProm; + fooProm = Promise["try"](Promise, function () { return foo; }); diff --git a/tests/baselines/reference/booleanAssignment.js b/tests/baselines/reference/booleanAssignment.js index 573367a429357..a2a9e448ff0a5 100644 --- a/tests/baselines/reference/booleanAssignment.js +++ b/tests/baselines/reference/booleanAssignment.js @@ -17,8 +17,11 @@ var b = new Boolean(); b = 1; // Error b = "a"; // Error b = {}; // Error + var o = {}; o = b; // OK + b = true; // OK + var b2; b = b2; // OK diff --git a/tests/baselines/reference/booleanFilterAnyArray.js b/tests/baselines/reference/booleanFilterAnyArray.js index 2cd319ca440ad..61903e066fded 100644 --- a/tests/baselines/reference/booleanFilterAnyArray.js +++ b/tests/baselines/reference/booleanFilterAnyArray.js @@ -28,8 +28,10 @@ var foos = [true, true, false, null].filter((thing): thing is boolean => thing ! //// [booleanFilterAnyArray.js] var xs; var xs = anys.filter(Bullean); + var ys; var ys = realanys.filter(Boolean); + var foo = [{ name: 'x' }]; var foor; var foor = foo.filter(function (x) { return x.name; }); diff --git a/tests/baselines/reference/booleanLiteralTypes1.js b/tests/baselines/reference/booleanLiteralTypes1.js index 6fb0244ac687d..a4b70ae992663 100644 --- a/tests/baselines/reference/booleanLiteralTypes1.js +++ b/tests/baselines/reference/booleanLiteralTypes1.js @@ -96,21 +96,25 @@ function f21(x: Item) { } //// [booleanLiteralTypes1.js] + function f1() { var a; var a; var a; var a; } + function f2(a, b) { a = b; b = a; } + function f3(a, b) { var x = a || b; var x = a && b; var x = !a; } + function f4(t, f) { var x1 = t && f; var x2 = f && t; @@ -119,20 +123,25 @@ function f4(t, f) { var x5 = !t; var x6 = !f; } + + function f5(b) { var z1 = g(true); var z2 = g(false); var z3 = g(b); } + function assertNever(x) { throw new Error("Unexpected value"); } + function f10(x) { switch (x) { case true: return "true"; case false: return "false"; } } + function f11(x) { switch (x) { case true: return "true"; @@ -140,6 +149,7 @@ function f11(x) { } return assertNever(x); } + function f12(x) { if (x) { x; @@ -148,6 +158,7 @@ function f12(x) { x; } } + function f13(x) { if (x === true) { x; @@ -156,12 +167,18 @@ function f13(x) { x; } } + + + + + function f20(x) { switch (x.kind) { case true: return x.a; case false: return x.b; } } + function f21(x) { switch (x.kind) { case true: return x.a; diff --git a/tests/baselines/reference/booleanLiteralTypes2.js b/tests/baselines/reference/booleanLiteralTypes2.js index 19bac7c362c5b..b99de6431ca38 100644 --- a/tests/baselines/reference/booleanLiteralTypes2.js +++ b/tests/baselines/reference/booleanLiteralTypes2.js @@ -96,21 +96,25 @@ function f21(x: Item) { } //// [booleanLiteralTypes2.js] + function f1() { var a; var a; var a; var a; } + function f2(a, b) { a = b; b = a; } + function f3(a, b) { var x = a || b; var x = a && b; var x = !a; } + function f4(t, f) { var x1 = t && f; var x2 = f && t; @@ -119,20 +123,25 @@ function f4(t, f) { var x5 = !t; var x6 = !f; } + + function f5(b) { var z1 = g(true); var z2 = g(false); var z3 = g(b); } + function assertNever(x) { throw new Error("Unexpected value"); } + function f10(x) { switch (x) { case true: return "true"; case false: return "false"; } } + function f11(x) { switch (x) { case true: return "true"; @@ -140,6 +149,7 @@ function f11(x) { } return assertNever(x); } + function f12(x) { if (x) { x; @@ -148,6 +158,7 @@ function f12(x) { x; } } + function f13(x) { if (x === true) { x; @@ -156,12 +167,18 @@ function f13(x) { x; } } + + + + + function f20(x) { switch (x.kind) { case true: return x.a; case false: return x.b; } } + function f21(x) { switch (x.kind) { case true: return x.a; diff --git a/tests/baselines/reference/booleanLiteralsContextuallyTypedFromUnion.js b/tests/baselines/reference/booleanLiteralsContextuallyTypedFromUnion.js index cf590eeaaaf62..b1fa2ce52828b 100644 --- a/tests/baselines/reference/booleanLiteralsContextuallyTypedFromUnion.js +++ b/tests/baselines/reference/booleanLiteralsContextuallyTypedFromUnion.js @@ -26,10 +26,22 @@ let Success = () => //// [booleanLiteralsContextuallyTypedFromUnion.jsx] "use strict"; + var isIt = Math.random() > 0.5; var c = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; var cc = isIt ? { isIt: isIt, text: 'hey' } : { isIt: isIt, value: 123 }; + + + + + + + + + + var Funk = function (_props) { return
Hello
; }; + var Fail1 = function () { return ; }; var Fail2 = function () { return ; }; var True = true; diff --git a/tests/baselines/reference/booleanPropertyAccess.js b/tests/baselines/reference/booleanPropertyAccess.js index 5d816253c37eb..b65e428e99550 100644 --- a/tests/baselines/reference/booleanPropertyAccess.js +++ b/tests/baselines/reference/booleanPropertyAccess.js @@ -6,5 +6,6 @@ var b = x['toString'](); //// [booleanPropertyAccess.js] var x = true; + var a = x.toString(); var b = x['toString'](); diff --git a/tests/baselines/reference/callChain.2.js b/tests/baselines/reference/callChain.2.js index 89070f410033e..541412b9997f5 100644 --- a/tests/baselines/reference/callChain.2.js +++ b/tests/baselines/reference/callChain.2.js @@ -12,5 +12,7 @@ o3.b?.().c; //// [callChain.2.js] var _a; o1 === null || o1 === void 0 ? void 0 : o1(); + o2 === null || o2 === void 0 ? void 0 : o2.b(); + (_a = o3.b) === null || _a === void 0 ? void 0 : _a.call(o3).c; diff --git a/tests/baselines/reference/callChain.3.js b/tests/baselines/reference/callChain.3.js index b34458a26e755..b59fab8ca9ee2 100644 --- a/tests/baselines/reference/callChain.3.js +++ b/tests/baselines/reference/callChain.3.js @@ -17,6 +17,8 @@ var n1 = (_a = a === null || a === void 0 ? void 0 : a.m) === null || _a === voi var n2 = (_b = a === null || a === void 0 ? void 0 : a.m) === null || _b === void 0 ? void 0 : _b.call(a, { x: absorb() }); // likewise var n3 = (_c = a === null || a === void 0 ? void 0 : a.m) === null || _c === void 0 ? void 0 : _c.call(a, { x: 12 }); // should be ok var n4 = (_d = a === null || a === void 0 ? void 0 : a.m) === null || _d === void 0 ? void 0 : _d.call(a, { x: absorb() }); // likewise + + // Also a test showing `!` vs `?` for good measure var t1 = (_e = a === null || a === void 0 ? void 0 : a.m) === null || _e === void 0 ? void 0 : _e.call(a, { x: 12 }); t1 = a.m({ x: 12 }); diff --git a/tests/baselines/reference/callChain.js b/tests/baselines/reference/callChain.js index 13fb9c717a397..c32bb8c622c7f 100644 --- a/tests/baselines/reference/callChain.js +++ b/tests/baselines/reference/callChain.js @@ -55,6 +55,7 @@ o1 === null || o1 === void 0 ? void 0 : o1(); o1 === null || o1 === void 0 ? void 0 : o1(1); o1 === null || o1 === void 0 ? void 0 : o1.apply(void 0, [1, 2]); o1 === null || o1 === void 0 ? void 0 : o1.apply(void 0, __spreadArrays([1], [2, 3], [4])); + o2 === null || o2 === void 0 ? void 0 : o2.b(); o2 === null || o2 === void 0 ? void 0 : o2.b(1); o2 === null || o2 === void 0 ? void 0 : o2.b.apply(o2, [1, 2]); @@ -63,6 +64,7 @@ o2 === null || o2 === void 0 ? void 0 : o2["b"](); o2 === null || o2 === void 0 ? void 0 : o2["b"](1); o2 === null || o2 === void 0 ? void 0 : o2["b"].apply(o2, [1, 2]); o2 === null || o2 === void 0 ? void 0 : o2["b"].apply(o2, __spreadArrays([1], [2, 3], [4])); + (_a = o3.b) === null || _a === void 0 ? void 0 : _a.call(o3).c; (_b = o3.b) === null || _b === void 0 ? void 0 : _b.call(o3, 1).c; (_c = o3.b) === null || _c === void 0 ? void 0 : _c.call.apply(_c, __spreadArrays([o3], [1, 2])).c; @@ -75,8 +77,11 @@ o2 === null || o2 === void 0 ? void 0 : o2["b"].apply(o2, __spreadArrays([1], [2 (_k = o3["b"]) === null || _k === void 0 ? void 0 : _k.call(o3, 1).c; (_l = o3["b"]) === null || _l === void 0 ? void 0 : _l.call.apply(_l, __spreadArrays([o3], [1, 2])).c; (_m = o3["b"]) === null || _m === void 0 ? void 0 : _m.call.apply(_m, __spreadArrays([o3, 1], [2, 3], [4])).c; + var v = o4 === null || o4 === void 0 ? void 0 : o4(incr); + (_o = o5()) === null || _o === void 0 ? void 0 : _o(); + // GH#36031 o2 === null || o2 === void 0 ? void 0 : o2.b().toString; o2 === null || o2 === void 0 ? void 0 : o2.b().toString; diff --git a/tests/baselines/reference/callChainWithSuper(target=es2016).js b/tests/baselines/reference/callChainWithSuper(target=es2016).js index fcfbb5db553f4..dd997e762c6b7 100644 --- a/tests/baselines/reference/callChainWithSuper(target=es2016).js +++ b/tests/baselines/reference/callChainWithSuper(target=es2016).js @@ -9,9 +9,7 @@ class Derived extends Base { //// [callChainWithSuper.js] "use strict"; // GH#34952 -class Base { - method() { } -} +class Base {method() { }} class Derived extends Base { method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } diff --git a/tests/baselines/reference/callChainWithSuper(target=es2017).js b/tests/baselines/reference/callChainWithSuper(target=es2017).js index fcfbb5db553f4..dd997e762c6b7 100644 --- a/tests/baselines/reference/callChainWithSuper(target=es2017).js +++ b/tests/baselines/reference/callChainWithSuper(target=es2017).js @@ -9,9 +9,7 @@ class Derived extends Base { //// [callChainWithSuper.js] "use strict"; // GH#34952 -class Base { - method() { } -} +class Base {method() { }} class Derived extends Base { method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } diff --git a/tests/baselines/reference/callChainWithSuper(target=es2018).js b/tests/baselines/reference/callChainWithSuper(target=es2018).js index fcfbb5db553f4..dd997e762c6b7 100644 --- a/tests/baselines/reference/callChainWithSuper(target=es2018).js +++ b/tests/baselines/reference/callChainWithSuper(target=es2018).js @@ -9,9 +9,7 @@ class Derived extends Base { //// [callChainWithSuper.js] "use strict"; // GH#34952 -class Base { - method() { } -} +class Base {method() { }} class Derived extends Base { method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } diff --git a/tests/baselines/reference/callChainWithSuper(target=es2019).js b/tests/baselines/reference/callChainWithSuper(target=es2019).js index fcfbb5db553f4..dd997e762c6b7 100644 --- a/tests/baselines/reference/callChainWithSuper(target=es2019).js +++ b/tests/baselines/reference/callChainWithSuper(target=es2019).js @@ -9,9 +9,7 @@ class Derived extends Base { //// [callChainWithSuper.js] "use strict"; // GH#34952 -class Base { - method() { } -} +class Base {method() { }} class Derived extends Base { method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } diff --git a/tests/baselines/reference/callChainWithSuper(target=es2020).js b/tests/baselines/reference/callChainWithSuper(target=es2020).js index 30e1ad3886dc5..d1913608f87b8 100644 --- a/tests/baselines/reference/callChainWithSuper(target=es2020).js +++ b/tests/baselines/reference/callChainWithSuper(target=es2020).js @@ -9,9 +9,7 @@ class Derived extends Base { //// [callChainWithSuper.js] "use strict"; // GH#34952 -class Base { - method() { } -} +class Base {method() { }} class Derived extends Base { method1() { return super.method?.(); } method2() { return super["method"]?.(); } diff --git a/tests/baselines/reference/callChainWithSuper(target=es5).js b/tests/baselines/reference/callChainWithSuper(target=es5).js index 5487991bc2925..8a99dc663427e 100644 --- a/tests/baselines/reference/callChainWithSuper(target=es5).js +++ b/tests/baselines/reference/callChainWithSuper(target=es5).js @@ -23,8 +23,7 @@ var __extends = (this && this.__extends) || (function () { })(); // GH#34952 var Base = /** @class */ (function () { - function Base() { - } + function Base() {} Base.prototype.method = function () { }; return Base; }()); diff --git a/tests/baselines/reference/callChainWithSuper(target=es6).js b/tests/baselines/reference/callChainWithSuper(target=es6).js index fcfbb5db553f4..dd997e762c6b7 100644 --- a/tests/baselines/reference/callChainWithSuper(target=es6).js +++ b/tests/baselines/reference/callChainWithSuper(target=es6).js @@ -9,9 +9,7 @@ class Derived extends Base { //// [callChainWithSuper.js] "use strict"; // GH#34952 -class Base { - method() { } -} +class Base {method() { }} class Derived extends Base { method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } diff --git a/tests/baselines/reference/callChainWithSuper(target=esnext).js b/tests/baselines/reference/callChainWithSuper(target=esnext).js index 30e1ad3886dc5..d1913608f87b8 100644 --- a/tests/baselines/reference/callChainWithSuper(target=esnext).js +++ b/tests/baselines/reference/callChainWithSuper(target=esnext).js @@ -9,9 +9,7 @@ class Derived extends Base { //// [callChainWithSuper.js] "use strict"; // GH#34952 -class Base { - method() { } -} +class Base {method() { }} class Derived extends Base { method1() { return super.method?.(); } method2() { return super["method"]?.(); } diff --git a/tests/baselines/reference/callConstructAssignment.js b/tests/baselines/reference/callConstructAssignment.js index 3266df5314b6b..c5a59b4fcd260 100644 --- a/tests/baselines/reference/callConstructAssignment.js +++ b/tests/baselines/reference/callConstructAssignment.js @@ -8,6 +8,8 @@ bar = foo; // error //// [callConstructAssignment.js] var foo; + var bar; + foo = bar; // error bar = foo; // error diff --git a/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.js b/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.js index 3f5fb14b1a953..4613216b181bf 100644 --- a/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.js +++ b/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.js @@ -47,15 +47,19 @@ var r7b = i2.f(1, ''); //// [callGenericFunctionWithIncorrectNumberOfTypeArguments.js] // type parameter lists must exactly match type argument lists // all of these invocations are errors + function f(x, y) { return null; } var r1 = f(1, ''); var r1b = f(1, ''); + var f2 = function (x, y) { return null; }; var r2 = f2(1, ''); var r2b = f2(1, ''); + var f3; var r3 = f3(1, ''); var r3b = f3(1, ''); + var C = /** @class */ (function () { function C() { } @@ -66,9 +70,11 @@ var C = /** @class */ (function () { }()); var r4 = (new C()).f(1, ''); var r4b = (new C()).f(1, ''); + var i; var r5 = i.f(1, ''); var r5b = i.f(1, ''); + var C2 = /** @class */ (function () { function C2() { } @@ -79,6 +85,7 @@ var C2 = /** @class */ (function () { }()); var r6 = (new C2()).f(1, ''); var r6b = (new C2()).f(1, ''); + var i2; var r7 = i2.f(1, ''); var r7b = i2.f(1, ''); diff --git a/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.js b/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.js index fd46b841a0284..9daacac613c05 100644 --- a/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.js +++ b/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.js @@ -38,12 +38,16 @@ var r7 = i2.f(1); //// [callGenericFunctionWithZeroTypeArguments.js] // valid invocations of generic functions with no explicit type arguments provided + function f(x) { return null; } var r = f(1); + var f2 = function (x) { return null; }; var r2 = f2(1); + var f3; var r3 = f3(1); + var C = /** @class */ (function () { function C() { } @@ -53,8 +57,10 @@ var C = /** @class */ (function () { return C; }()); var r4 = (new C()).f(1); + var i; var r5 = i.f(1); + var C2 = /** @class */ (function () { function C2() { } @@ -64,5 +70,6 @@ var C2 = /** @class */ (function () { return C2; }()); var r6 = (new C2()).f(1); + var i2; var r7 = i2.f(1); diff --git a/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.js b/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.js index b94a3208c5c86..79b1a9372a79a 100644 --- a/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.js +++ b/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.js @@ -46,12 +46,16 @@ var r8 = a2(); //// [callNonGenericFunctionWithTypeArguments.js] // it is always illegal to provide type arguments to a non-generic function // all invocations here are illegal + function f(x) { return null; } var r = f(1); + var f2 = function (x) { return null; }; var r2 = f2(1); + var f3; var r3 = f3(1); + var C = /** @class */ (function () { function C() { } @@ -61,8 +65,10 @@ var C = /** @class */ (function () { return C; }()); var r4 = (new C()).f(1); + var i; var r5 = i.f(1); + var C2 = /** @class */ (function () { function C2() { } @@ -72,9 +78,12 @@ var C2 = /** @class */ (function () { return C2; }()); var r6 = (new C2()).f(1); + var i2; var r7 = i2.f(1); + var a; var r8 = a(); + var a2; var r8 = a2(); diff --git a/tests/baselines/reference/callOnClass.js b/tests/baselines/reference/callOnClass.js index 1a6333945b759..59b636770f566 100644 --- a/tests/baselines/reference/callOnClass.js +++ b/tests/baselines/reference/callOnClass.js @@ -6,8 +6,8 @@ var c = C(); //// [callOnClass.js] var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); var c = C(); + diff --git a/tests/baselines/reference/callOnInstance.js b/tests/baselines/reference/callOnInstance.js index 3b07d0affc8e9..b771118fa27c3 100644 --- a/tests/baselines/reference/callOnInstance.js +++ b/tests/baselines/reference/callOnInstance.js @@ -11,6 +11,9 @@ declare class C { constructor(value: number); } (new C(1))(); // Error for calling an instance //// [callOnInstance.js] + var s1 = D(); // OK + var s2 = (new D(1))(); + (new C(1))(); // Error for calling an instance diff --git a/tests/baselines/reference/callOverload.js b/tests/baselines/reference/callOverload.js index 05cb5acff8771..1ef1e91c557e3 100644 --- a/tests/baselines/reference/callOverload.js +++ b/tests/baselines/reference/callOverload.js @@ -20,6 +20,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { return r; }; var n; + fn(1); // no error fn(1, 2, 3, 4); takeTwo(1, 2, 3, 4); diff --git a/tests/baselines/reference/callOverloads1.js b/tests/baselines/reference/callOverloads1.js index ac5a15d953c9d..2887136991d74 100644 --- a/tests/baselines/reference/callOverloads1.js +++ b/tests/baselines/reference/callOverloads1.js @@ -21,11 +21,14 @@ Foo(); var Foo = /** @class */ (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); - } + }// error Foo.prototype.bar1 = function () { }; return Foo; }()); function F1(a) { return a; } + var f1 = new Foo("hey"); + + f1.bar1(); Foo(); diff --git a/tests/baselines/reference/callOverloads2.js b/tests/baselines/reference/callOverloads2.js index ee1300ee5dedb..fd5d91ff3b63f 100644 --- a/tests/baselines/reference/callOverloads2.js +++ b/tests/baselines/reference/callOverloads2.js @@ -27,12 +27,17 @@ Foo(); var Foo = /** @class */ (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); - } + }// error Foo.prototype.bar1 = function () { }; return Foo; }()); + function F1(s) { return s; } // error function F1(a) { return a; } // error + + var f1 = new Foo("hey"); + + f1.bar1(); Foo(); diff --git a/tests/baselines/reference/callOverloads3.js b/tests/baselines/reference/callOverloads3.js index f2f3498c83189..dce0bf7ae1639 100644 --- a/tests/baselines/reference/callOverloads3.js +++ b/tests/baselines/reference/callOverloads3.js @@ -21,12 +21,14 @@ Foo("s"); var Foo = /** @class */ (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); - } + }// error Foo.prototype.bar1 = function () { }; return Foo; }()); //class Foo(s: String); var f1 = new Foo("hey"); + + f1.bar1(); Foo(); Foo("s"); diff --git a/tests/baselines/reference/callOverloads4.js b/tests/baselines/reference/callOverloads4.js index 60757da34bd78..410d3c3bbccc5 100644 --- a/tests/baselines/reference/callOverloads4.js +++ b/tests/baselines/reference/callOverloads4.js @@ -21,11 +21,13 @@ Foo("s"); var Foo = /** @class */ (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); - } + }// error Foo.prototype.bar1 = function () { }; return Foo; }()); var f1 = new Foo("hey"); + + f1.bar1(); Foo(); Foo("s"); diff --git a/tests/baselines/reference/callOverloads5.js b/tests/baselines/reference/callOverloads5.js index 4ccc1f5ea2699..35580baa5aa58 100644 --- a/tests/baselines/reference/callOverloads5.js +++ b/tests/baselines/reference/callOverloads5.js @@ -23,12 +23,13 @@ Foo("s"); var Foo = /** @class */ (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); - } - Foo.prototype.bar1 = function (a) { }; + }Foo.prototype.bar1 = function (a) { }; return Foo; }()); //class Foo(s: String); var f1 = new Foo("hey"); + + f1.bar1("a"); Foo(); Foo("s"); diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js index e139bcca5986f..4616cf54db767 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js @@ -84,9 +84,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js index b8a024a8a091a..96d785e774ce6 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.js @@ -132,8 +132,7 @@ var __extends = (this && this.__extends) || (function () { var Errors; (function (Errors) { var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js index a969d77fb030a..de1ea1633d883 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance4.js @@ -64,9 +64,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js index cf8889cbf2793..21185db924a02 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js @@ -64,9 +64,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js index baa98cb72d504..67165f00e0075 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.js @@ -67,9 +67,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var Base = /** @class */ (function () { - function Base() { - } + function Base() {} return Base; }()); var Derived = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/callSignatureFunctionOverload.js b/tests/baselines/reference/callSignatureFunctionOverload.js index 6da28693bced3..de66be6460d1b 100644 --- a/tests/baselines/reference/callSignatureFunctionOverload.js +++ b/tests/baselines/reference/callSignatureFunctionOverload.js @@ -16,4 +16,5 @@ var foo2: { //// [callSignatureFunctionOverload.js] var foo; + var foo2; diff --git a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.js b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.js index 4ff809379193b..1343ea34910c3 100644 --- a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.js +++ b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.js @@ -57,53 +57,48 @@ b.b(1); //// [callSignatureWithOptionalParameterAndInitializer.js] // Optional parameters cannot also have initializer expressions, these are all errors -function foo(x) { - if (x === void 0) { x = 1; } -} -var f = function foo(x) { - if (x === void 0) { x = 1; } -}; -var f2 = function (x, y) { - if (y === void 0) { y = 1; } -}; + +function foo(x) {if (x === void 0) { x = 1; }} +var f = function foo(x) {if (x === void 0) { x = 1; }}; +var f2 = function (x, y) {if (y === void 0) { y = 1; }}; + foo(1); foo(); f(1); f(); f2(1); f2(1, 2); + var C = /** @class */ (function () { function C() { } - C.prototype.foo = function (x) { - if (x === void 0) { x = 1; } - }; + C.prototype.foo = function (x) {if (x === void 0) { x = 1; }}; return C; }()); var c; c.foo(); c.foo(1); + + var i; i(); i(1); i.foo(1); i.foo(1, 2); + var a; + a(); a(1); a.foo(); a.foo(1); + var b = { - foo: function (x) { - if (x === void 0) { x = 1; } - }, - a: function foo(x, y) { - if (y === void 0) { y = ''; } - }, - b: function (x) { - if (x === void 0) { x = ''; } - } + foo: function (x) {if (x === void 0) { x = 1; }}, + a: function foo(x, y) {if (y === void 0) { y = ''; }}, + b: function (x) {if (x === void 0) { x = ''; }} }; + b.foo(); b.foo(1); b.a(1); diff --git a/tests/baselines/reference/callSignatureWithoutAnnotationsOrBody.js b/tests/baselines/reference/callSignatureWithoutAnnotationsOrBody.js index 24c71c985057c..1f9c83270c76f 100644 --- a/tests/baselines/reference/callSignatureWithoutAnnotationsOrBody.js +++ b/tests/baselines/reference/callSignatureWithoutAnnotationsOrBody.js @@ -23,9 +23,11 @@ var r5 = a.f(); // Call signatures without a return type annotation and function body return 'any' function foo(x) { } var r = foo(1); // void since there's a body + var i; var r2 = i(); var r3 = i.f(); + var a; var r4 = a(); var r5 = a.f(); diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.js b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.js index 9ecceb3ff4fa1..f11c76038af5a 100644 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.js +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.js @@ -127,18 +127,22 @@ function foo(x) { return 1; } var r = foo(1); + function foo2(x) { return foo(x); } var r2 = foo2(1); + function foo3() { return foo3(); } var r3 = foo3(); + function foo4(x) { return x; } var r4 = foo4(1); + function foo5(x) { if (true) { return 1; @@ -148,6 +152,7 @@ function foo5(x) { } } var r5 = foo5(1); + function foo6(x) { try { } @@ -159,20 +164,24 @@ function foo6(x) { } } var r6 = foo6(1); + function foo7(x) { return typeof x; } var r7 = foo7(1); + // object types function foo8(x) { return { x: x }; } var r8 = foo8(1); + function foo9(x) { var i; return i; } var r9 = foo9(1); + var C = /** @class */ (function () { function C() { } @@ -187,8 +196,7 @@ var M; (function (M) { M.x = 1; var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); M.C = C; @@ -197,22 +205,22 @@ function foo11() { return M; } var r11 = foo11(); + function foo12() { var i2; return i2; } var r12 = foo12(); + function m1() { return 1; } -(function (m1) { - m1.y = 2; -})(m1 || (m1 = {})); +(function (m1) {m1.y = 2;})(m1 || (m1 = {})); function foo13() { return m1; } var r13 = foo13(); + var c1 = /** @class */ (function () { - function c1(x) { - } + function c1(x) {} return c1; }()); (function (c1) { @@ -226,9 +234,7 @@ var e1; (function (e1) { e1[e1["A"] = 0] = "A"; })(e1 || (e1 = {})); -(function (e1) { - e1.y = 1; -})(e1 || (e1 = {})); +(function (e1) {e1.y = 1;})(e1 || (e1 = {})); function foo15() { return e1; } diff --git a/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.js b/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.js index b2cf7d5f5c517..d6124c21f17d8 100644 --- a/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.js +++ b/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.js @@ -11,6 +11,7 @@ function foo() { } //// [callSignaturesShouldBeResolvedBeforeSpecialization.js] + function foo() { var test; test("expects boolean instead of string"); // should not error - "test" should not expect a boolean diff --git a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType.js b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType.js index 8d5b59f84d125..a8f6e3e5cbd08 100644 --- a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType.js +++ b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType.js @@ -29,5 +29,7 @@ var a2: { } //// [callSignaturesThatDifferOnlyByReturnType.js] + var a; + var a2; diff --git a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.js b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.js index ae6f4db7e38ba..343d6688aa50f 100644 --- a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.js +++ b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.js @@ -17,6 +17,8 @@ var r2 = x.foo(''); // error //// [callSignaturesThatDifferOnlyByReturnType2.js] // Normally it is an error to have multiple overloads which differ only by return type in a single type declaration. // Here the multiple overloads come from multiple bases. + + var x; // BUG 822524 var r = x.foo(1); // no error diff --git a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType3.js b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType3.js index b67b619d7390b..a105b39c08085 100644 --- a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType3.js +++ b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType3.js @@ -21,3 +21,4 @@ interface I2 { //// [callSignaturesThatDifferOnlyByReturnType3.js] // Normally it is an error to have multiple overloads with identical signatures in a single type declaration. // Here the multiple overloads come from multiple merged declarations. + diff --git a/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.js b/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.js index e2a3599f0daa7..4c098731fbcaf 100644 --- a/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.js +++ b/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.js @@ -40,16 +40,19 @@ var b = { //// [callSignaturesWithAccessibilityModifiersOnParameters.js] // Call signature parameters do not allow accessibility modifiers + function foo(x, y) { } var f = function foo(x, y) { }; var f2 = function (x, y) { }; var f3 = function (x, y) { }; var f4 = function (x, y) { }; + function foo2(x, y) { } var f5 = function foo(x, y) { }; var f6 = function (x, y) { }; var f7 = function (x, y) { }; var f8 = function (x, y) { }; + var C = /** @class */ (function () { function C() { } @@ -58,7 +61,9 @@ var C = /** @class */ (function () { C.prototype.foo3 = function (x, y) { }; return C; }()); + var a; + var b = { foo: function (x, y) { }, a: function foo(x, y) { }, diff --git a/tests/baselines/reference/callSignaturesWithDuplicateParameters.js b/tests/baselines/reference/callSignaturesWithDuplicateParameters.js index ed9d2cb3e3573..a6e9e14de1d50 100644 --- a/tests/baselines/reference/callSignaturesWithDuplicateParameters.js +++ b/tests/baselines/reference/callSignaturesWithDuplicateParameters.js @@ -45,11 +45,13 @@ var f = function foo(x, x) { }; var f2 = function (x, x) { }; var f3 = function (x, x) { }; var f4 = function (x, x) { }; + function foo2(x, x) { } var f5 = function foo(x, x) { }; var f6 = function (x, x) { }; var f7 = function (x, x) { }; var f8 = function (x, y) { }; + var C = /** @class */ (function () { function C() { } @@ -58,7 +60,9 @@ var C = /** @class */ (function () { C.prototype.foo3 = function (x, x) { }; return C; }()); + var a; + var b = { foo: function (x, x) { }, a: function foo(x, x) { }, diff --git a/tests/baselines/reference/callSignaturesWithOptionalParameters.js b/tests/baselines/reference/callSignaturesWithOptionalParameters.js index 1a5aad8c0e19e..e56b58f6f702d 100644 --- a/tests/baselines/reference/callSignaturesWithOptionalParameters.js +++ b/tests/baselines/reference/callSignaturesWithOptionalParameters.js @@ -57,15 +57,18 @@ b.b(1); //// [callSignaturesWithOptionalParameters.js] // Optional parameters should be valid in all the below casts + function foo(x) { } var f = function foo(x) { }; var f2 = function (x, y) { }; + foo(1); foo(); f(1); f(); f2(1); f2(1, 2); + var C = /** @class */ (function () { function C() { } @@ -75,21 +78,27 @@ var C = /** @class */ (function () { var c; c.foo(); c.foo(1); + + var i; i(); i(1); i.foo(1); i.foo(1, 2); + var a; + a(); a(1); a.foo(); a.foo(1); + var b = { foo: function (x) { }, a: function foo(x, y) { }, b: function (x) { } }; + b.foo(); b.foo(1); b.a(1); diff --git a/tests/baselines/reference/callSignaturesWithOptionalParameters2.js b/tests/baselines/reference/callSignaturesWithOptionalParameters2.js index dbd8ad1f424e1..bae2721281d5a 100644 --- a/tests/baselines/reference/callSignaturesWithOptionalParameters2.js +++ b/tests/baselines/reference/callSignaturesWithOptionalParameters2.js @@ -61,24 +61,35 @@ a.foo(1, 2, 3); //// [callSignaturesWithOptionalParameters2.js] // Optional parameters should be valid in all the below casts + function foo(x) { } + foo(1); foo(); + function foo2(x, y) { } + foo2(1); foo2(1, 2); + var C = /** @class */ (function () { function C() { } C.prototype.foo = function (x) { }; + + + C.prototype.foo2 = function (x, y) { }; return C; }()); var c; c.foo(); c.foo(1); + c.foo2(1); c.foo2(1, 2); + + var i; i(); i(1); @@ -86,7 +97,9 @@ i(1, 2); i.foo(1); i.foo(1, 2); i.foo(1, 2, 3); + var a; + a(); a(1); a(1, 2); diff --git a/tests/baselines/reference/callSignaturesWithParameterInitializers.js b/tests/baselines/reference/callSignaturesWithParameterInitializers.js index 528b2a3d00e3d..5c9882fb12f17 100644 --- a/tests/baselines/reference/callSignaturesWithParameterInitializers.js +++ b/tests/baselines/reference/callSignaturesWithParameterInitializers.js @@ -59,54 +59,49 @@ b.b(1); //// [callSignaturesWithParameterInitializers.js] // Optional parameters allow initializers only in implementation signatures -function foo(x) { - if (x === void 0) { x = 1; } -} -var f = function foo(x) { - if (x === void 0) { x = 1; } -}; -var f2 = function (x, y) { - if (y === void 0) { y = 1; } -}; + +function foo(x) {if (x === void 0) { x = 1; }} +var f = function foo(x) {if (x === void 0) { x = 1; }}; +var f2 = function (x, y) {if (y === void 0) { y = 1; }}; + foo(1); foo(); f(1); f(); f2(1); f2(1, 2); + var C = /** @class */ (function () { function C() { } - C.prototype.foo = function (x) { - if (x === void 0) { x = 1; } - }; + C.prototype.foo = function (x) {if (x === void 0) { x = 1; }}; return C; }()); var c; c.foo(); c.foo(1); + + var i; i(); i(1); i.foo(1); i.foo(1, 2); + // these are errors var a; + a(); a(1); a.foo(); a.foo(1); + var b = { - foo: function (x) { - if (x === void 0) { x = 1; } - }, - a: function foo(x, y) { - if (y === void 0) { y = 1; } - }, - b: function (x) { - if (x === void 0) { x = 1; } - } + foo: function (x) {if (x === void 0) { x = 1; }}, + a: function foo(x, y) {if (y === void 0) { y = 1; }}, + b: function (x) {if (x === void 0) { x = 1; }} }; + b.foo(); b.foo(1); b.a(1); diff --git a/tests/baselines/reference/callSignaturesWithParameterInitializers2.js b/tests/baselines/reference/callSignaturesWithParameterInitializers2.js index 10aaaf44b6ec2..33f6b0ebf9038 100644 --- a/tests/baselines/reference/callSignaturesWithParameterInitializers2.js +++ b/tests/baselines/reference/callSignaturesWithParameterInitializers2.js @@ -28,29 +28,26 @@ b.foo(1); //// [callSignaturesWithParameterInitializers2.js] // Optional parameters allow initializers only in implementation signatures // All the below declarations are errors -function foo(x) { - if (x === void 0) { x = 1; } -} + +function foo(x) {if (x === void 0) { x = 1; }} + foo(1); foo(); + var C = /** @class */ (function () { function C() { } - C.prototype.foo = function (x) { - if (x === void 0) { x = 1; } - }; + C.prototype.foo = function (x) {if (x === void 0) { x = 1; }}; return C; }()); var c; c.foo(); c.foo(1); + var b = { - foo: function (x) { - if (x === void 0) { x = 1; } - }, - foo: function (x) { - if (x === void 0) { x = 1; } - } + foo: function (x) {if (x === void 0) { x = 1; }}, + foo: function (x) {if (x === void 0) { x = 1; }} }; + b.foo(); b.foo(1); diff --git a/tests/baselines/reference/callWithMissingVoid.js b/tests/baselines/reference/callWithMissingVoid.js index 50282931fa68f..72507b5e7138d 100644 --- a/tests/baselines/reference/callWithMissingVoid.js +++ b/tests/baselines/reference/callWithMissingVoid.js @@ -96,11 +96,19 @@ var X = /** @class */ (function () { return X; }()); x.f(); // no error because f expects void + xUnion.f(42); // no error because f accepts number xUnion.f(); // no error because f accepts void + xAny.f(); // error, any still expects an argument + xUnknown.f(); // error, unknown still expects an argument + xNever.f(); // error, never still expects an argument + + + + // Promise has previously been updated to work without arguments, but to show this fixes the issue too. var MyPromise = /** @class */ (function () { function MyPromise(executor) { @@ -112,26 +120,41 @@ new MyPromise(function (resolve) { return resolve(); }); // no error new MyPromise(function (resolve) { return resolve(); }); // error, `any` arguments cannot be omitted new MyPromise(function (resolve) { return resolve(); }); // error, `unknown` arguments cannot be omitted new MyPromise(function (resolve) { return resolve(); }); // error, `never` arguments cannot be omitted + + + + // Multiple parameters function a(x, y, z) { } + a(4, "hello"); // ok a(4, "hello", void 0); // ok a(4); // not ok + function b(x, y, z, what) { } + b(4, "hello", void 0, 2); // ok b(4, "hello"); // not ok b(4, "hello", void 0); // not ok b(4); // not ok + function c(x, y, z) { } + c(3, void 0, void 0); // ok c(3, void 0); // ok c(3); // ok c(); // ok + + + + + call(function (x, y) { return x + y; }); // error call(function (x, y) { return x + y; }, 4, 2); // ok + call(function (x, y) { return x; }, 4, void 0); // ok call(function (x, y) { return x; }, 4); // ok call(function (x, y) { return 42; }); // ok diff --git a/tests/baselines/reference/callWithSpread.js b/tests/baselines/reference/callWithSpread.js index ee0ab6fe8a716..e317f59cbe780 100644 --- a/tests/baselines/reference/callWithSpread.js +++ b/tests/baselines/reference/callWithSpread.js @@ -80,46 +80,57 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { return r; }; var _a, _b, _c, _d, _e, _f, _g; -function foo(x, y) { - var z = []; + +function foo(x, y) {var z = []; for (var _i = 2; _i < arguments.length; _i++) { z[_i - 2] = arguments[_i]; } } + var a; var z; var obj; var xa; + foo(1, 2, "abc"); foo.apply(void 0, __spreadArrays([1, 2], a)); foo.apply(void 0, __spreadArrays([1, 2], a, ["abc"])); + obj.foo(1, 2, "abc"); obj.foo.apply(obj, __spreadArrays([1, 2], a)); obj.foo.apply(obj, __spreadArrays([1, 2], a, ["abc"])); + obj.foo.apply(obj, __spreadArrays([1, 2], a)).foo(1, 2, "abc"); -(_a = obj.foo.apply(obj, __spreadArrays([1, 2], a))).foo.apply(_a, __spreadArrays([1, 2], a)); -(_b = obj.foo.apply(obj, __spreadArrays([1, 2], a))).foo.apply(_b, __spreadArrays([1, 2], a, ["abc"])); +( + _a = obj.foo.apply(obj, __spreadArrays([1, 2], a))).foo.apply(_a, __spreadArrays([1, 2], a)); +( + _b = obj.foo.apply(obj, __spreadArrays([1, 2], a))).foo.apply(_b, __spreadArrays([1, 2], a, ["abc"])); + (obj.foo)(1, 2, "abc"); obj.foo.apply(obj, __spreadArrays([1, 2], a)); obj.foo.apply(obj, __spreadArrays([1, 2], a, ["abc"])); + (obj.foo.apply(obj, __spreadArrays([1, 2], a)).foo)(1, 2, "abc"); (_c = obj.foo.apply(obj, __spreadArrays([1, 2], a))).foo.apply(_c, __spreadArrays([1, 2], a)); (_d = obj.foo.apply(obj, __spreadArrays([1, 2], a))).foo.apply(_d, __spreadArrays([1, 2], a, ["abc"])); + xa[1].foo(1, 2, "abc"); -(_e = xa[1]).foo.apply(_e, __spreadArrays([1, 2], a)); -(_f = xa[1]).foo.apply(_f, __spreadArrays([1, 2], a, ["abc"])); +( + _e = xa[1]).foo.apply(_e, __spreadArrays([1, 2], a)); +( + _f = xa[1]).foo.apply(_f, __spreadArrays([1, 2], a, ["abc"])); + (_g = xa[1]).foo.apply(_g, [1, 2, "abc"]); + var C = /** @class */ (function () { - function C(x, y) { - var z = []; + function C(x, y) {var z = []; for (var _i = 2; _i < arguments.length; _i++) { z[_i - 2] = arguments[_i]; } this.foo(x, y); this.foo.apply(this, __spreadArrays([x, y], z)); } - C.prototype.foo = function (x, y) { - var z = []; + C.prototype.foo = function (x, y) {var z = []; for (var _i = 2; _i < arguments.length; _i++) { z[_i - 2] = arguments[_i]; } diff --git a/tests/baselines/reference/callWithSpread2.js b/tests/baselines/reference/callWithSpread2.js index bf5bd87b6c569..2a0313f92037f 100644 --- a/tests/baselines/reference/callWithSpread2.js +++ b/tests/baselines/reference/callWithSpread2.js @@ -45,6 +45,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { r[k] = a[j]; return r; }; + // good all.apply(void 0, ns); weird.apply(void 0, ns); @@ -52,9 +53,12 @@ weird.apply(void 0, mixed); weird.apply(void 0, tuple); prefix.apply(void 0, __spreadArrays(["a"], ns)); rest.apply(void 0, __spreadArrays(["d"], ns)); + + // extra arguments normal.apply(void 0, __spreadArrays(["g"], ns)); thunk.apply(void 0, ns); + // bad all.apply(void 0, mixed); all.apply(void 0, tuple); diff --git a/tests/baselines/reference/callWithSpread3.js b/tests/baselines/reference/callWithSpread3.js index bcb30625f46ce..bbd14c60dd2be 100644 --- a/tests/baselines/reference/callWithSpread3.js +++ b/tests/baselines/reference/callWithSpread3.js @@ -18,6 +18,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { r[k] = a[j]; return r; }; + takeTwo.apply(void 0, __spreadArrays(['a'], t2)); // error on ...t2 takeTwo.apply(void 0, __spreadArrays(['a', 'b', 'c'], t2)); // error on 'c' and ...t2 takeTwo.apply(void 0, __spreadArrays(['a', 'b'], t2, ['c'])); // error on ...t2 and 'c' diff --git a/tests/baselines/reference/callWithSpreadES6.js b/tests/baselines/reference/callWithSpreadES6.js index 9e7f244d41a5e..b9afd4a6ce309 100644 --- a/tests/baselines/reference/callWithSpreadES6.js +++ b/tests/baselines/reference/callWithSpreadES6.js @@ -51,25 +51,33 @@ class D extends C { //// [callWithSpreadES6.js] + function foo(x, y, ...z) { } + var a; var z; var obj; var xa; + foo(1, 2, "abc"); foo(1, 2, ...a); foo(1, 2, ...a, "abc"); + obj.foo(1, 2, "abc"); obj.foo(1, 2, ...a); obj.foo(1, 2, ...a, "abc"); + (obj.foo)(1, 2, "abc"); (obj.foo)(1, 2, ...a); (obj.foo)(1, 2, ...a, "abc"); + xa[1].foo(1, 2, "abc"); xa[1].foo(1, 2, ...a); xa[1].foo(1, 2, ...a, "abc"); + xa[1].foo(...[1, 2, "abc"]); + class C { constructor(x, y, ...z) { this.foo(x, y); @@ -78,6 +86,7 @@ class C { foo(x, y, ...z) { } } + class D extends C { constructor() { super(1, 2); diff --git a/tests/baselines/reference/callWithWrongNumberOfTypeArguments.js b/tests/baselines/reference/callWithWrongNumberOfTypeArguments.js index 74ea401ae3bce..7cec17f370b3f 100644 --- a/tests/baselines/reference/callWithWrongNumberOfTypeArguments.js +++ b/tests/baselines/reference/callWithWrongNumberOfTypeArguments.js @@ -7,6 +7,7 @@ f(); //// [callWithWrongNumberOfTypeArguments.js] function f() { } + f(); f(); f(); diff --git a/tests/baselines/reference/callbacksDontShareTypes.js b/tests/baselines/reference/callbacksDontShareTypes.js index e6483638058ea..7941300f1ba4d 100644 --- a/tests/baselines/reference/callbacksDontShareTypes.js +++ b/tests/baselines/reference/callbacksDontShareTypes.js @@ -19,8 +19,10 @@ var r5a = _.map(c2, (x) => { return x.toFixed() }); var r5b = _.map(c2, rf1); //// [callbacksDontShareTypes.js] + var _; var c2; + var rf1 = function (x) { return x.toFixed(); }; var r1a = _.map(c2, function (x) { return x.toFixed(); }); var r1b = _.map(c2, rf1); // this line should not cause the following 2 to have errors diff --git a/tests/baselines/reference/callsOnComplexSignatures.js b/tests/baselines/reference/callsOnComplexSignatures.js index f631f674269cf..50afa3b532141 100644 --- a/tests/baselines/reference/callsOnComplexSignatures.js +++ b/tests/baselines/reference/callsOnComplexSignatures.js @@ -112,43 +112,62 @@ var __importDefault = (this && this.__importDefault) || function (mod) { exports.__esModule = true; /// var react_1 = __importDefault(require("react")); + // Simple calls from real usecases function test1() { + + function test(t) { var z = t.getValue("bar"); // Should be fine } } + function test2() { + var messages = { foo: function (options) { return "Foo"; }, bar: function (options) { return "Bar"; } }; + var test1 = function (type) { - return messages[type]({ a: "A", b: 0 }); - }; + return messages[type]({ a: "A", b: 0 });}; } + function test3(items) { items.forEach(function (item) { return console.log(item); }); } -function test4(arg1, arg2, arg3, arg4, arg5, arg6) { + +function test4( +arg1, + arg2, + arg3, + arg4, + arg5, + arg6) { arg1(); arg1({ x: 0, y: 0 }); arg1({ x: 0, y: 0 }, { x: 1, y: 1 }); + arg2({ x: 0 }, { x: 0 }); + arg3({ x: 0 }); arg3({ x: 0 }, { x: 0, y: 0 }); arg3({ x: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }); + arg4(); arg4({ x: 0, y: 0 }); arg4({ x: 0, y: 0 }, { x: 0 }); + arg5(); arg5({ x: 0, y: 0 }); arg5({ x: 0, y: 0 }, { x: 0 }); + arg6(); arg6({ x: 0, y: 0 }); arg6({ x: 0, y: 0 }, { x: 0, y: 0 }); arg6({ x: 0, y: 0 }, { x: 0, y: 0 }, { y: 0 }); } + // JSX Tag names function test5() { // Pair of non-like intrinsics @@ -156,14 +175,18 @@ function test5() { var Tag = url ? 'a' : 'button'; return react_1["default"].createElement(Tag, null, "test"); } + // Union of all intrinsics and components of `any` function App(props) { var Comp = props.component; return (react_1["default"].createElement(Comp, null)); } + // custom components with non-subset props function render2() { + var C = null; + var a = react_1["default"].createElement(C, { p: true }); } } diff --git a/tests/baselines/reference/cannotInvokeNewOnErrorExpression.js b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.js index 129b17acdc64d..5602d3c637cc9 100644 --- a/tests/baselines/reference/cannotInvokeNewOnErrorExpression.js +++ b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.js @@ -9,8 +9,7 @@ var t = new M.ClassA[]; var M; (function (M) { var ClassA = /** @class */ (function () { - function ClassA() { - } + function ClassA() {} return ClassA; }()); })(M || (M = {})); diff --git a/tests/baselines/reference/captureThisInSuperCall.js b/tests/baselines/reference/captureThisInSuperCall.js index 919f849111486..b3f5aa84ea3a0 100644 --- a/tests/baselines/reference/captureThisInSuperCall.js +++ b/tests/baselines/reference/captureThisInSuperCall.js @@ -23,8 +23,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); var A = /** @class */ (function () { - function A(p) { - } + function A(p) {} return A; }()); var B = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/capturedLetConstInLoop1.js b/tests/baselines/reference/capturedLetConstInLoop1.js index 7acaf851cc214..4eac1a4687a87 100644 --- a/tests/baselines/reference/capturedLetConstInLoop1.js +++ b/tests/baselines/reference/capturedLetConstInLoop1.js @@ -347,6 +347,7 @@ var _loop_23 = function (y) { for (var y = 0; y < 1;) { _loop_23(y); } + var _loop_24 = function (sx) { (function () { return sobj[sx]; }); }; diff --git a/tests/baselines/reference/capturedLetConstInLoop10.js b/tests/baselines/reference/capturedLetConstInLoop10.js index 304486e172475..78e56535437a1 100644 --- a/tests/baselines/reference/capturedLetConstInLoop10.js +++ b/tests/baselines/reference/capturedLetConstInLoop10.js @@ -62,6 +62,7 @@ var A = /** @class */ (function () { }; A.prototype.bar = function (a) { }; + A.prototype.baz = function () { var _loop_2 = function (x) { var a = function () { return x; }; diff --git a/tests/baselines/reference/capturedLetConstInLoop10_ES6.js b/tests/baselines/reference/capturedLetConstInLoop10_ES6.js index 705a5e6ba9f63..24cbe2fb588dc 100644 --- a/tests/baselines/reference/capturedLetConstInLoop10_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop10_ES6.js @@ -55,6 +55,7 @@ class A { } bar(a) { } + baz() { for (let x of [1]) { let a = function () { return x; }; @@ -76,6 +77,7 @@ class A { } } } + class B { foo() { let a = () => { diff --git a/tests/baselines/reference/capturedLetConstInLoop11.js b/tests/baselines/reference/capturedLetConstInLoop11.js index 8e9ca71580e6c..9e6d0ab77e857 100644 --- a/tests/baselines/reference/capturedLetConstInLoop11.js +++ b/tests/baselines/reference/capturedLetConstInLoop11.js @@ -16,11 +16,13 @@ function foo() { //// [capturedLetConstInLoop11.js] var _loop_1 = function () { var x = 1; - (function () { return x; }); + ( + function () { return x; }); }; for (;;) { _loop_1(); } + function foo() { var _loop_2 = function () { var a = 0; diff --git a/tests/baselines/reference/capturedLetConstInLoop11_ES6.js b/tests/baselines/reference/capturedLetConstInLoop11_ES6.js index df288953f1e94..8e61c6ad05c8a 100644 --- a/tests/baselines/reference/capturedLetConstInLoop11_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop11_ES6.js @@ -18,6 +18,7 @@ for (;;) { let x = 1; () => x; } + function foo() { for (;;) { const a = 0; diff --git a/tests/baselines/reference/capturedLetConstInLoop12.js b/tests/baselines/reference/capturedLetConstInLoop12.js index 3625556c89a90..738ffbc496c56 100644 --- a/tests/baselines/reference/capturedLetConstInLoop12.js +++ b/tests/baselines/reference/capturedLetConstInLoop12.js @@ -21,8 +21,7 @@ var _loop_1 = function (i) { (function () { var _a; - return _a = [i + 1], i = _a[0], _a; - })(); + return _a = [i + 1], i = _a[0], _a;})(); out_i_1 = i; }; var out_i_1; @@ -31,13 +30,13 @@ i = out_i_1; } })(); + (function () { "use strict"; var _loop_2 = function (i) { (function () { var _a; - return (_a = { a: i + 1 }, i = _a.a, _a); - })(); + return (_a = { a: i + 1 }, i = _a.a, _a);})(); out_i_2 = i; }; var out_i_2; diff --git a/tests/baselines/reference/capturedLetConstInLoop13.js b/tests/baselines/reference/capturedLetConstInLoop13.js index 628faa1048587..526ea5a00c455 100644 --- a/tests/baselines/reference/capturedLetConstInLoop13.js +++ b/tests/baselines/reference/capturedLetConstInLoop13.js @@ -27,6 +27,7 @@ var Main = /** @class */ (function () { function Main() { this.register("a", "b", "c"); } + Main.prototype.register = function () { var _this = this; var names = []; @@ -45,7 +46,9 @@ var Main = /** @class */ (function () { _loop_1(name_1); } }; + Main.prototype.bar = function (a) { }; + Main.prototype.foo = function (name) { }; return Main; }()); diff --git a/tests/baselines/reference/capturedLetConstInLoop1_ES6.js b/tests/baselines/reference/capturedLetConstInLoop1_ES6.js index 0a68f8e1cf63b..199c1b94e38ac 100644 --- a/tests/baselines/reference/capturedLetConstInLoop1_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop1_ES6.js @@ -119,90 +119,109 @@ 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;) { (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;) { const x = 1; (function () { return x; }); (() => x); } + for (const x = 0, y = 1; x < 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;) { const x = 1; (function () { return x + y; }); diff --git a/tests/baselines/reference/capturedLetConstInLoop2.js b/tests/baselines/reference/capturedLetConstInLoop2.js index 94bc8669cf593..47e7885d135a2 100644 --- a/tests/baselines/reference/capturedLetConstInLoop2.js +++ b/tests/baselines/reference/capturedLetConstInLoop2.js @@ -188,6 +188,7 @@ function foo0(x) { _loop_1(x_1); } } + function foo0_1(x) { var _loop_2 = function (x_2) { var a = arguments_2.length; @@ -199,6 +200,7 @@ function foo0_1(x) { _loop_2(x_2); } } + function foo1(x) { var _loop_3 = function (x_3) { var a = arguments_3.length; @@ -210,6 +212,7 @@ function foo1(x) { _loop_3(x_3); } } + function foo2(x) { var _loop_4 = function () { var a = arguments_4.length; @@ -221,6 +224,7 @@ function foo2(x) { _loop_4(); } } + function foo3(x) { var _loop_5 = function () { var x_4; @@ -233,6 +237,7 @@ function foo3(x) { _loop_5(); } while (1 === 1); } + function foo4(x) { var _loop_6 = function (y) { var a = arguments_6.length; @@ -245,6 +250,7 @@ function foo4(x) { _loop_6(y); } } + function foo5(x) { var _loop_7 = function (x_6, y) { var a = arguments_7.length; @@ -256,6 +262,8 @@ function foo5(x) { _loop_7(x_6, y); } } + + function foo6(x) { var _loop_8 = function () { var x_7, y; @@ -268,6 +276,7 @@ function foo6(x) { _loop_8(); } } + function foo7(x) { var _loop_9 = function () { var x_8, y; @@ -280,6 +289,8 @@ function foo7(x) { _loop_9(); } while (1 === 1); } + + function foo8(x) { var _loop_10 = function (y) { var x_9 = 1; @@ -305,6 +316,7 @@ function foo0_c(x) { _loop_11(x_10); } } + function foo0_1_c(x) { var _loop_12 = function (x_11) { var a = arguments_12.length; @@ -316,6 +328,7 @@ function foo0_1_c(x) { _loop_12(x_11); } } + function foo1_c(x) { var _loop_13 = function (x_12) { var a = arguments_13.length; @@ -327,6 +340,7 @@ function foo1_c(x) { _loop_13(x_12); } } + function foo2_c(x) { var _loop_14 = function () { var a = arguments_14.length; @@ -338,6 +352,7 @@ function foo2_c(x) { _loop_14(); } } + function foo3_c(x) { var _loop_15 = function () { var x_13 = 1; @@ -350,6 +365,7 @@ function foo3_c(x) { _loop_15(); } while (1 === 1); } + function foo4_c(x) { var _loop_16 = function (y) { var a = arguments_16.length; @@ -362,6 +378,7 @@ function foo4_c(x) { _loop_16(y); } } + function foo5_c(x) { var _loop_17 = function (x_15, y) { var a = arguments_17.length; @@ -373,6 +390,8 @@ function foo5_c(x) { _loop_17(x_15, y); } } + + function foo6_c(x) { var _loop_18 = function () { var x_16 = 1, y = 1; @@ -385,6 +404,7 @@ function foo6_c(x) { _loop_18(); } } + function foo7_c(x) { var _loop_19 = function () { var x_17 = 1, y = 1; @@ -397,6 +417,8 @@ function foo7_c(x) { _loop_19(); } while (1 === 1); } + + function foo8_c(x) { var _loop_20 = function (y) { var x_18 = 1; diff --git a/tests/baselines/reference/capturedLetConstInLoop2_ES6.js b/tests/baselines/reference/capturedLetConstInLoop2_ES6.js index 59bd81b5a4de7..2794e693ae69b 100644 --- a/tests/baselines/reference/capturedLetConstInLoop2_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop2_ES6.js @@ -183,6 +183,7 @@ function foo0(x) { (() => x + a); } } + function foo0_1(x) { for (let x in []) { let a = arguments.length; @@ -190,6 +191,7 @@ function foo0_1(x) { (() => x + a); } } + function foo1(x) { for (let x = 0; x < 1; ++x) { let a = arguments.length; @@ -197,6 +199,7 @@ function foo1(x) { (() => x + a); } } + function foo2(x) { while (1 === 1) { let a = arguments.length; @@ -204,6 +207,7 @@ function foo2(x) { (() => x + a); } } + function foo3(x) { do { let x; @@ -212,6 +216,7 @@ function foo3(x) { (() => x + a); } while (1 === 1); } + function foo4(x) { for (let y = 0; y < 1; ++y) { let a = arguments.length; @@ -220,6 +225,7 @@ function foo4(x) { (() => x + a); } } + function foo5(x) { for (let x = 0, y = 1; x < 1; ++x) { let a = arguments.length; @@ -227,6 +233,8 @@ function foo5(x) { (() => x + y + a); } } + + function foo6(x) { while (1 === 1) { let x, y; @@ -235,6 +243,7 @@ function foo6(x) { (() => x + y + a); } } + function foo7(x) { do { let x, y; @@ -243,6 +252,8 @@ function foo7(x) { (() => x + y + a); } while (1 === 1); } + + function foo8(x) { for (let y = 0; y < 1; ++y) { let x = 1; @@ -259,6 +270,7 @@ function foo0_c(x) { (() => x + a); } } + function foo0_1_c(x) { for (const x in []) { const a = arguments.length; @@ -266,6 +278,7 @@ function foo0_1_c(x) { (() => x + a); } } + function foo1_c(x) { for (const x = 0; x < 1;) { const a = arguments.length; @@ -273,6 +286,7 @@ function foo1_c(x) { (() => x + a); } } + function foo2_c(x) { while (1 === 1) { const a = arguments.length; @@ -280,6 +294,7 @@ function foo2_c(x) { (() => x + a); } } + function foo3_c(x) { do { const x = 1; @@ -288,6 +303,7 @@ function foo3_c(x) { (() => x + a); } while (1 === 1); } + function foo4_c(x) { for (const y = 0; y < 1;) { const a = arguments.length; @@ -296,6 +312,7 @@ function foo4_c(x) { (() => x + a); } } + function foo5_c(x) { for (const x = 0, y = 1; x < 1;) { const a = arguments.length; @@ -303,6 +320,8 @@ function foo5_c(x) { (() => x + y + a); } } + + function foo6_c(x) { while (1 === 1) { const x = 1, y = 1; @@ -311,6 +330,7 @@ function foo6_c(x) { (() => x + y + a); } } + function foo7_c(x) { do { const x = 1, y = 1; @@ -319,6 +339,8 @@ function foo7_c(x) { (() => x + y + a); } while (1 === 1); } + + function foo8_c(x) { for (const y = 0; y < 1;) { const x = 1; diff --git a/tests/baselines/reference/capturedLetConstInLoop3.js b/tests/baselines/reference/capturedLetConstInLoop3.js index f3bae712c5b2c..67205932dc4b2 100644 --- a/tests/baselines/reference/capturedLetConstInLoop3.js +++ b/tests/baselines/reference/capturedLetConstInLoop3.js @@ -231,6 +231,7 @@ function foo0(x) { } use(v); } + function foo0_1(x) { var _loop_2 = function (x_2) { v = x_2; @@ -241,8 +242,10 @@ function foo0_1(x) { for (var x_2 in []) { _loop_2(x_2); } + use(v); } + function foo1(x) { var _loop_3 = function (x_3) { v = x_3; @@ -253,8 +256,10 @@ function foo1(x) { for (var x_3 = 0; x_3 < 1; ++x_3) { _loop_3(x_3); } + use(v); } + function foo2(x) { var _loop_4 = function () { var x_4 = 1; @@ -266,11 +271,14 @@ function foo2(x) { while (1 === 1) { _loop_4(); } + use(v); } + function foo3(x) { var _loop_5 = function () { var x_5; + (function () { return x_5 + v; }); (function () { return x_5 + v; }); }; @@ -278,8 +286,10 @@ function foo3(x) { do { _loop_5(); } while (1 === 1); + use(v); } + function foo4(x) { var _loop_6 = function (y) { v = y; @@ -291,8 +301,10 @@ function foo4(x) { for (var y = 0; y < 1; ++y) { _loop_6(y); } + use(v); } + function foo5(x) { var _loop_7 = function (x_7, y) { v = x_7; @@ -303,8 +315,11 @@ function foo5(x) { for (var x_7 = 0, y = 1; x_7 < 1; ++x_7) { _loop_7(x_7, y); } + use(v); } + + function foo6(x) { var _loop_8 = function () { var x_8, y; @@ -316,8 +331,10 @@ function foo6(x) { while (1 === 1) { _loop_8(); } + use(v); } + function foo7(x) { var _loop_9 = function () { var x_9, y; @@ -329,8 +346,11 @@ function foo7(x) { do { _loop_9(); } while (1 === 1); + use(v); } + + function foo8(x) { var _loop_10 = function (y) { var x_10 = 1; @@ -342,6 +362,7 @@ function foo8(x) { for (var y = 0; y < 1; ++y) { _loop_10(y); } + use(v); } //===const @@ -358,6 +379,7 @@ function foo0_c(x) { } use(v); } + function foo0_1_c(x) { var _loop_12 = function (x_12) { v = x_12; @@ -368,8 +390,10 @@ function foo0_1_c(x) { for (var x_12 in []) { _loop_12(x_12); } + use(v); } + function foo1_c(x) { var _loop_13 = function (x_13) { v = x_13; @@ -380,8 +404,10 @@ function foo1_c(x) { for (var x_13 = 0; x_13 < 1;) { _loop_13(x_13); } + use(v); } + function foo2_c(x) { var _loop_14 = function () { var x_14 = 1; @@ -393,11 +419,14 @@ function foo2_c(x) { while (1 === 1) { _loop_14(); } + use(v); } + function foo3_c(x) { var _loop_15 = function () { var x_15 = 1; + (function () { return x_15 + v; }); (function () { return x_15 + v; }); }; @@ -405,8 +434,10 @@ function foo3_c(x) { do { _loop_15(); } while (1 === 1); + use(v); } + function foo4_c(x) { var _loop_16 = function (y) { v = y; @@ -418,8 +449,10 @@ function foo4_c(x) { for (var y = 0; y < 1;) { _loop_16(y); } + use(v); } + function foo5_c(x) { var _loop_17 = function (x_17, y) { v = x_17; @@ -430,8 +463,11 @@ function foo5_c(x) { for (var x_17 = 0, y = 1; x_17 < 1;) { _loop_17(x_17, y); } + use(v); } + + function foo6_c(x) { var _loop_18 = function () { var x_18 = 1, y = 1; @@ -443,8 +479,10 @@ function foo6_c(x) { while (1 === 1) { _loop_18(); } + use(v); } + function foo7_c(x) { var _loop_19 = function () { var x_19 = 1, y = 1; @@ -456,8 +494,11 @@ function foo7_c(x) { do { _loop_19(); } while (1 === 1); + use(v); } + + function foo8_c(x) { var _loop_20 = function (y) { var x_20 = 1; @@ -469,5 +510,6 @@ function foo8_c(x) { for (var y = 0; y < 1;) { _loop_20(y); } + use(v); } diff --git a/tests/baselines/reference/capturedLetConstInLoop3_ES6.js b/tests/baselines/reference/capturedLetConstInLoop3_ES6.js index 367db066edd43..a14d3ac3d37bd 100644 --- a/tests/baselines/reference/capturedLetConstInLoop3_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop3_ES6.js @@ -224,24 +224,30 @@ function foo0(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; @@ -249,8 +255,10 @@ function foo2(x) { (function () { return x + v; }); (() => x + v); } + use(v); } + function foo3(x) { do { let x; @@ -258,8 +266,10 @@ function foo3(x) { (function () { return x + v; }); (() => x + v); } while (1 === 1); + use(v); } + function foo4(x) { for (let y = 0; y < 1; ++y) { var v = y; @@ -267,16 +277,21 @@ function foo4(x) { (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; @@ -284,8 +299,10 @@ function foo6(x) { (function () { return x + y + v; }); (() => x + y + v); } + use(v); } + function foo7(x) { do { let x, y; @@ -293,8 +310,11 @@ function foo7(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; @@ -302,6 +322,7 @@ function foo8(x) { (function () { return x + y + v; }); (() => x + y + v); } + use(v); } //===const @@ -311,24 +332,30 @@ function foo0_c(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;) { var v = x; (function () { return x + v; }); (() => x + v); } + use(v); } + function foo2_c(x) { while (1 === 1) { const x = 1; @@ -336,8 +363,10 @@ function foo2_c(x) { (function () { return x + v; }); (() => x + v); } + use(v); } + function foo3_c(x) { do { const x = 1; @@ -345,8 +374,10 @@ function foo3_c(x) { (function () { return x + v; }); (() => x + v); } while (1 === 1); + use(v); } + function foo4_c(x) { for (const y = 0; y < 1;) { var v = y; @@ -354,16 +385,21 @@ function foo4_c(x) { (function () { return x + v; }); (() => x + v); } + use(v); } + function foo5_c(x) { for (const x = 0, y = 1; x < 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; @@ -371,8 +407,10 @@ function foo6_c(x) { (function () { return x + y + v; }); (() => x + y + v); } + use(v); } + function foo7_c(x) { do { const x = 1, y = 1; @@ -380,8 +418,11 @@ function foo7_c(x) { (function () { return x + y + v; }); (() => x + y + v); } while (1 === 1); + use(v); } + + function foo8_c(x) { for (const y = 0; y < 1;) { const x = 1; @@ -389,5 +430,6 @@ function foo8_c(x) { (function () { return x + y + v; }); (() => x + y + v); } + use(v); } diff --git a/tests/baselines/reference/capturedLetConstInLoop4_ES6.js b/tests/baselines/reference/capturedLetConstInLoop4_ES6.js index e7a16aa01c67d..e49198152e357 100644 --- a/tests/baselines/reference/capturedLetConstInLoop4_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop4_ES6.js @@ -147,116 +147,138 @@ for (const y = 0; y < 1;) { 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;) { 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;) { const x = 1; var v4_c = x; (function () { return x + v4_c; }); (() => x); } + for (const x = 0, y = 1; x < 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;) { const x = 1; var v8_c = x; diff --git a/tests/baselines/reference/capturedLetConstInLoop5.js b/tests/baselines/reference/capturedLetConstInLoop5.js index 4ea4c85c0d74a..f851ac51dff30 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5.js +++ b/tests/baselines/reference/capturedLetConstInLoop5.js @@ -280,6 +280,7 @@ function foo8_c(x) { } //// [capturedLetConstInLoop5.js] + //====let function foo0(x) { var _loop_1 = function (x_1) { @@ -299,6 +300,7 @@ function foo0(x) { } use(v); } + function foo00(x) { var _loop_2 = function (x_2) { v = x_2; @@ -314,8 +316,10 @@ function foo00(x) { if (typeof state_2 === "object") return state_2.value; } + use(v); } + function foo1(x) { var _loop_3 = function (x_3) { v = x_3; @@ -331,8 +335,10 @@ function foo1(x) { if (typeof state_3 === "object") return state_3.value; } + use(v); } + function foo2(x) { var _loop_4 = function () { var x_4 = 1; @@ -349,11 +355,14 @@ function foo2(x) { if (typeof state_4 === "object") return state_4.value; } + use(v); } + function foo3(x) { var _loop_5 = function () { var x_5; + (function () { return x_5 + v; }); (function () { return x_5 + v; }); if (x_5 == 1) { @@ -366,8 +375,10 @@ function foo3(x) { if (typeof state_5 === "object") return state_5.value; } while (1 === 1); + use(v); } + function foo4(x) { var _loop_6 = function (y) { v = y; @@ -384,8 +395,10 @@ function foo4(x) { if (typeof state_6 === "object") return state_6.value; } + use(v); } + function foo5(x) { var _loop_7 = function (x_7, y) { v = x_7; @@ -401,8 +414,11 @@ function foo5(x) { if (typeof state_7 === "object") return state_7.value; } + use(v); } + + function foo6(x) { var _loop_8 = function () { var x_8, y; @@ -418,10 +434,11 @@ function foo6(x) { var state_8 = _loop_8(); if (typeof state_8 === "object") return state_8.value; - } - ; + }; + use(v); } + function foo7(x) { var _loop_9 = function () { var x_9, y; @@ -438,8 +455,11 @@ function foo7(x) { if (typeof state_9 === "object") return state_9.value; } while (1 === 1); + use(v); } + + function foo8(x) { var _loop_10 = function (y) { var x_10 = 1; @@ -456,8 +476,10 @@ function foo8(x) { if (typeof state_10 === "object") return state_10.value; } + use(v); } + //====const function foo0_c(x) { var _loop_11 = function (x_11) { @@ -477,6 +499,7 @@ function foo0_c(x) { } use(v); } + function foo00_c(x) { var _loop_12 = function (x_12) { v = x_12; @@ -492,8 +515,10 @@ function foo00_c(x) { if (typeof state_12 === "object") return state_12.value; } + use(v); } + function foo1_c(x) { var _loop_13 = function (x_13) { v = x_13; @@ -509,8 +534,10 @@ function foo1_c(x) { if (typeof state_13 === "object") return state_13.value; } + use(v); } + function foo2_c(x) { var _loop_14 = function () { var x_14 = 1; @@ -527,11 +554,14 @@ function foo2_c(x) { if (typeof state_14 === "object") return state_14.value; } + use(v); } + function foo3_c(x) { var _loop_15 = function () { var x_15 = 1; + (function () { return x_15 + v; }); (function () { return x_15 + v; }); if (x_15 == 1) { @@ -544,8 +574,10 @@ function foo3_c(x) { if (typeof state_15 === "object") return state_15.value; } while (1 === 1); + use(v); } + function foo4_c(x) { var _loop_16 = function (y) { v = y; @@ -562,8 +594,10 @@ function foo4_c(x) { if (typeof state_16 === "object") return state_16.value; } + use(v); } + function foo5_c(x) { var _loop_17 = function (x_17, y) { v = x_17; @@ -579,8 +613,11 @@ function foo5_c(x) { if (typeof state_17 === "object") return state_17.value; } + use(v); } + + function foo6_c(x) { var _loop_18 = function () { var x_18 = 1, y = 1; @@ -597,8 +634,10 @@ function foo6_c(x) { if (typeof state_18 === "object") return state_18.value; } + use(v); } + function foo7_c(x) { var _loop_19 = function () { var x_19 = 1, y = 1; @@ -615,8 +654,11 @@ function foo7_c(x) { if (typeof state_19 === "object") return state_19.value; } while (1 === 1); + use(v); } + + function foo8_c(x) { var _loop_20 = function (y) { var x_20 = 1; @@ -633,5 +675,6 @@ function foo8_c(x) { if (typeof state_20 === "object") return state_20.value; } + use(v); } diff --git a/tests/baselines/reference/capturedLetConstInLoop5_ES6.js b/tests/baselines/reference/capturedLetConstInLoop5_ES6.js index da48929c959e8..a5749832881f2 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop5_ES6.js @@ -280,6 +280,7 @@ function foo8_c(x) { } //// [capturedLetConstInLoop5_ES6.js] + //====let function foo0(x) { for (let x of []) { @@ -290,8 +291,10 @@ function foo0(x) { return; } } + use(v); } + function foo00(x) { for (let x in []) { var v = x; @@ -301,8 +304,10 @@ function foo00(x) { return; } } + use(v); } + function foo1(x) { for (let x = 0; x < 1; ++x) { var v = x; @@ -312,8 +317,10 @@ function foo1(x) { return; } } + use(v); } + function foo2(x) { while (1 === 1) { let x = 1; @@ -324,8 +331,10 @@ function foo2(x) { return; } } + use(v); } + function foo3(x) { do { let x; @@ -336,8 +345,10 @@ function foo3(x) { return; } } while (1 === 1); + use(v); } + function foo4(x) { for (let y = 0; y < 1; ++y) { var v = y; @@ -348,8 +359,10 @@ function foo4(x) { return; } } + use(v); } + function foo5(x) { for (let x = 0, y = 1; x < 1; ++x) { var v = x; @@ -359,8 +372,11 @@ function foo5(x) { return; } } + use(v); } + + function foo6(x) { while (1 === 1) { let x, y; @@ -370,10 +386,11 @@ function foo6(x) { if (x == 1) { return; } - } - ; + }; + use(v); } + function foo7(x) { do { let x, y; @@ -384,8 +401,11 @@ function foo7(x) { return; } } while (1 === 1); + use(v); } + + function foo8(x) { for (let y = 0; y < 1; ++y) { let x = 1; @@ -396,8 +416,10 @@ function foo8(x) { return; } } + use(v); } + //====const function foo0_c(x) { for (const x of []) { @@ -408,8 +430,10 @@ function foo0_c(x) { return; } } + use(v); } + function foo00_c(x) { for (const x in []) { var v = x; @@ -419,8 +443,10 @@ function foo00_c(x) { return; } } + use(v); } + function foo1_c(x) { for (const x = 0; x < 1;) { var v = x; @@ -430,8 +456,10 @@ function foo1_c(x) { return; } } + use(v); } + function foo2_c(x) { while (1 === 1) { const x = 1; @@ -442,8 +470,10 @@ function foo2_c(x) { return; } } + use(v); } + function foo3_c(x) { do { const x = 1; @@ -454,8 +484,10 @@ function foo3_c(x) { return; } } while (1 === 1); + use(v); } + function foo4_c(x) { for (const y = 0; y < 1;) { var v = y; @@ -466,8 +498,10 @@ function foo4_c(x) { return; } } + use(v); } + function foo5_c(x) { for (const x = 0, y = 1; x < 1;) { var v = x; @@ -477,8 +511,11 @@ function foo5_c(x) { return; } } + use(v); } + + function foo6_c(x) { while (1 === 1) { const x = 1, y = 1; @@ -489,8 +526,10 @@ function foo6_c(x) { return; } } + use(v); } + function foo7_c(x) { do { const x = 1, y = 1; @@ -501,8 +540,11 @@ function foo7_c(x) { return; } } while (1 === 1); + use(v); } + + function foo8_c(x) { for (const y = 0; y < 1;) { const x = 1; @@ -513,5 +555,6 @@ function foo8_c(x) { return; } } + use(v); } diff --git a/tests/baselines/reference/capturedLetConstInLoop6.js b/tests/baselines/reference/capturedLetConstInLoop6.js index cf813da44e14e..318c733a776ef 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6.js +++ b/tests/baselines/reference/capturedLetConstInLoop6.js @@ -555,3 +555,4 @@ for (var y = 0; y < 1;) { if (state_20 === "break") break; } + diff --git a/tests/baselines/reference/capturedLetConstInLoop6_ES6.js b/tests/baselines/reference/capturedLetConstInLoop6_ES6.js index 33d64e889276a..f789c30ccdefb 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop6_ES6.js @@ -250,6 +250,7 @@ for (let x of []) { continue; } } + for (let x in []) { (function () { return x; }); (() => x); @@ -260,6 +261,8 @@ for (let x in []) { continue; } } + + for (let x = 0; x < 1; ++x) { (function () { return x; }); (() => x); @@ -270,6 +273,7 @@ for (let x = 0; x < 1; ++x) { continue; } } + while (1 === 1) { let x; (function () { return x; }); @@ -281,6 +285,7 @@ while (1 === 1) { continue; } } + do { let x; (function () { return x; }); @@ -292,6 +297,7 @@ do { continue; } } while (1 === 1); + for (let y = 0; y < 1; ++y) { let x = 1; (function () { return x; }); @@ -303,6 +309,7 @@ for (let y = 0; y < 1; ++y) { continue; } } + for (let x = 0, y = 1; x < 1; ++x) { (function () { return x + y; }); (() => x + y); @@ -313,6 +320,7 @@ for (let x = 0, y = 1; x < 1; ++x) { continue; } } + while (1 === 1) { let x, y; (function () { return x + y; }); @@ -324,6 +332,7 @@ while (1 === 1) { continue; } } + do { let x, y; (function () { return x + y; }); @@ -335,6 +344,7 @@ do { continue; } } while (1 === 1); + for (let y = 0; y < 1; ++y) { let x = 1; (function () { return x + y; }); @@ -346,6 +356,7 @@ for (let y = 0; y < 1; ++y) { continue; } } + // ====const for (const x of []) { (function () { return x; }); @@ -357,6 +368,7 @@ for (const x of []) { continue; } } + for (const x in []) { (function () { return x; }); (() => x); @@ -367,6 +379,8 @@ for (const x in []) { continue; } } + + for (const x = 0; x < 1;) { (function () { return x; }); (() => x); @@ -377,6 +391,7 @@ for (const x = 0; x < 1;) { continue; } } + while (1 === 1) { const x = 1; (function () { return x; }); @@ -388,6 +403,7 @@ while (1 === 1) { continue; } } + do { const x = 1; (function () { return x; }); @@ -399,6 +415,7 @@ do { continue; } } while (1 === 1); + for (const y = 0; y < 1;) { const x = 1; (function () { return x; }); @@ -410,6 +427,7 @@ for (const y = 0; y < 1;) { continue; } } + for (const x = 0, y = 1; x < 1;) { (function () { return x + y; }); (() => x + y); @@ -420,6 +438,7 @@ for (const x = 0, y = 1; x < 1;) { continue; } } + while (1 === 1) { const x = 1, y = 1; (function () { return x + y; }); @@ -431,6 +450,7 @@ while (1 === 1) { continue; } } + do { const x = 1, y = 1; (function () { return x + y; }); @@ -442,6 +462,7 @@ do { continue; } } while (1 === 1); + for (const y = 0; y < 1;) { const x = 1; (function () { return x + y; }); @@ -453,3 +474,4 @@ for (const y = 0; y < 1;) { continue; } } + diff --git a/tests/baselines/reference/capturedLetConstInLoop7_ES6.js b/tests/baselines/reference/capturedLetConstInLoop7_ES6.js index 13c69a883921f..9368194c602ae 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop7_ES6.js @@ -393,6 +393,7 @@ l0: for (let x of []) { continue l0; } } + l00: for (let x in []) { (function () { return x; }); (() => x); @@ -409,6 +410,7 @@ l00: for (let x in []) { continue l00; } } + l1: for (let x = 0; x < 1; ++x) { (function () { return x; }); (() => x); @@ -425,6 +427,7 @@ l1: for (let x = 0; x < 1; ++x) { continue l1; } } + l2: while (1 === 1) { let x; (function () { return x; }); @@ -442,6 +445,7 @@ l2: while (1 === 1) { continue l2; } } + l3: do { let x; (function () { return x; }); @@ -459,6 +463,7 @@ l3: do { continue l3; } } while (1 === 1); + l4: for (let y = 0; y < 1; ++y) { let x = 1; (function () { return x; }); @@ -476,6 +481,7 @@ l4: for (let y = 0; y < 1; ++y) { continue l4; } } + l5: for (let x = 0, y = 1; x < 1; ++x) { (function () { return x + y; }); (() => x + y); @@ -492,6 +498,7 @@ l5: for (let x = 0, y = 1; x < 1; ++x) { continue l5; } } + l6: while (1 === 1) { let x, y; (function () { return x + y; }); @@ -508,7 +515,9 @@ l6: while (1 === 1) { if (x == 2) { continue l6; } + } + l7: do { let x, y; (function () { return x + y; }); @@ -526,6 +535,7 @@ l7: do { continue l7; } } while (1 === 1); + l8: for (let y = 0; y < 1; ++y) { let x = 1; (function () { return x + y; }); @@ -543,6 +553,7 @@ l8: for (let y = 0; y < 1; ++y) { continue l8; } } + //===const l0_c: for (const x of []) { (function () { return x; }); @@ -560,6 +571,7 @@ l0_c: for (const x of []) { continue l0_c; } } + l00_c: for (const x in []) { (function () { return x; }); (() => x); @@ -576,6 +588,7 @@ l00_c: for (const x in []) { continue l00_c; } } + l1_c: for (const x = 0; x < 1;) { (function () { return x; }); (() => x); @@ -592,6 +605,7 @@ l1_c: for (const x = 0; x < 1;) { continue l1_c; } } + l2_c: while (1 === 1) { const x = 1; (function () { return x; }); @@ -609,6 +623,7 @@ l2_c: while (1 === 1) { continue l2_c; } } + l3_c: do { const x = 1; (function () { return x; }); @@ -626,6 +641,7 @@ l3_c: do { continue l3_c; } } while (1 === 1); + l4_c: for (const y = 0; y < 1;) { const x = 1; (function () { return x; }); @@ -643,6 +659,7 @@ l4_c: for (const y = 0; y < 1;) { continue l4_c; } } + l5_c: for (const x = 0, y = 1; x < 1;) { (function () { return x + y; }); (() => x + y); @@ -659,6 +676,7 @@ l5_c: for (const x = 0, y = 1; x < 1;) { continue l5_c; } } + l6_c: while (1 === 1) { const x = 1, y = 1; (function () { return x + y; }); @@ -675,7 +693,9 @@ l6_c: while (1 === 1) { if (x == 2) { continue l6_c; } + } + l7_c: do { const x = 1, y = 1; (function () { return x + y; }); @@ -693,6 +713,7 @@ l7_c: do { continue l7_c; } } while (1 === 1); + l8_c: for (const y = 0; y < 1;) { const x = 1; (function () { return x + y; }); diff --git a/tests/baselines/reference/capturedLetConstInLoop8.js b/tests/baselines/reference/capturedLetConstInLoop8.js index cb13f76ac6160..19cb90ef9bb75 100644 --- a/tests/baselines/reference/capturedLetConstInLoop8.js +++ b/tests/baselines/reference/capturedLetConstInLoop8.js @@ -145,6 +145,7 @@ function foo() { if (y == 1) { return "continue-l0"; } + if (x == 2) { return "continue"; } @@ -211,6 +212,7 @@ function foo() { } } } + function foo_c() { l0: for (var z = 0; z < 1;) { var _loop_3 = function (x) { @@ -229,6 +231,7 @@ function foo_c() { if (y == 1) { return "continue-l0"; } + if (x == 2) { return "continue"; } diff --git a/tests/baselines/reference/capturedLetConstInLoop8_ES6.js b/tests/baselines/reference/capturedLetConstInLoop8_ES6.js index 71d0ecd4c4c7f..f0967e135134e 100644 --- a/tests/baselines/reference/capturedLetConstInLoop8_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop8_ES6.js @@ -145,6 +145,7 @@ function foo() { if (y == 1) { continue l0; } + if (x == 2) { continue; } @@ -185,6 +186,7 @@ function foo() { } } } + function foo_c() { l0: for (const z = 0; z < 1;) { l1: for (const x = 0; x < 1;) { @@ -203,6 +205,7 @@ function foo_c() { if (y == 1) { continue l0; } + if (x == 2) { continue; } diff --git a/tests/baselines/reference/capturedLetConstInLoop9.js b/tests/baselines/reference/capturedLetConstInLoop9.js index 0795d509f9baf..6249c28e788b2 100644 --- a/tests/baselines/reference/capturedLetConstInLoop9.js +++ b/tests/baselines/reference/capturedLetConstInLoop9.js @@ -146,11 +146,13 @@ var _loop_1 = function (x) { var x_2; (function () { return x_2; }); } + try { } catch (e) { var x_3; (function () { return x_3; }); } + switch (x_1) { case 1: var x_4; @@ -164,6 +166,7 @@ var _loop_1 = function (x) { while (1 == 1) { _loop_2(); } + var A = /** @class */ (function () { function A() { } @@ -176,12 +179,15 @@ var _loop_1 = function (x) { for (var x = 0; x < 1; ++x) { _loop_1(x); } + + function foo() { var _loop_3 = function (a) { var _a; if (a === 1) { return "break"; } + if (a === 2) { return "break-l0"; } @@ -191,9 +197,12 @@ function foo() { if (b === 1) { break; } + + if (b === 2) { return "break-l0"; } + l1: if (b === 3) { break l1; } @@ -205,10 +214,14 @@ function foo() { if (b === 1) { return "break"; } + if (b === 2) { return "break-l0"; } - (function () { return b; }); + + ( + + function () { return b; }); return { value: 100 }; }; for (var _c = 0, _d = []; _c < _d.length; _c++) { @@ -222,7 +235,10 @@ function foo() { case "break-l0": return state_2; } } - (function () { return a; }); + ( + + + function () { return a; }); }; var arguments_1 = arguments, x, z, x1, z1; l0: for (var _i = 0, _a = []; _i < _a.length; _i++) { @@ -236,11 +252,13 @@ function foo() { case "break-l0": break l0; } } + use(x); use(z); use(x1); use(z1); } + function foo2() { for (var _i = 0, _a = []; _i < _a.length; _i++) { var x = _a[_i]; @@ -250,6 +268,7 @@ function foo2() { else if (x === 2) { continue; } + while (1 === 1) { if (x) { break; @@ -258,6 +277,7 @@ function foo2() { continue; } } + switch (x) { case 1: break; case 2: continue; @@ -271,6 +291,7 @@ function foo2() { } } } + var C = /** @class */ (function () { function C(N) { this.N = N; diff --git a/tests/baselines/reference/capturedLetConstInLoop9_ES6.js b/tests/baselines/reference/capturedLetConstInLoop9_ES6.js index 783140426d267..51168db07e239 100644 --- a/tests/baselines/reference/capturedLetConstInLoop9_ES6.js +++ b/tests/baselines/reference/capturedLetConstInLoop9_ES6.js @@ -145,66 +145,85 @@ for (let x = 0; x < 1; ++x) { let x; (function () { return x; }); } + try { } catch (e) { let x; (function () { return x; }); } + switch (x) { case 1: let x; (function () { return x; }); break; } + while (1 == 1) { let x; (function () { return x; }); } + class A { m() { return x + 1; } } } + + function foo() { l0: for (let a of []) { + if (a === 1) { break; } + if (a === 2) { break l0; } + for (let b of []) { var [{ x, y: z }] = [{ x: 1, y: 2 }]; if (b === 1) { break; } + + if (b === 2) { break l0; } + l1: if (b === 3) { break l1; } + return 50; } + for (let b of []) { var [{ x1, y: z1 }] = [{ x1: 1, y: arguments.length }]; if (b === 1) { break; } + if (b === 2) { break l0; } () => b; return 100; } + + () => a; } + use(x); use(z); use(x1); use(z1); } + function foo2() { for (let x of []) { if (x === 1) { @@ -213,6 +232,7 @@ function foo2() { else if (x === 2) { continue; } + while (1 === 1) { if (x) { break; @@ -221,10 +241,12 @@ function foo2() { continue; } } + switch (x) { case 1: break; case 2: continue; } + for (let y of []) { switch (y) { case 1: break; @@ -233,6 +255,7 @@ function foo2() { } } } + class C { constructor(N) { this.N = N; @@ -243,6 +266,7 @@ class C { } } } + function foo3() { let x = arguments.length; for (let y of []) { diff --git a/tests/baselines/reference/capturedParametersInInitializers1.js b/tests/baselines/reference/capturedParametersInInitializers1.js index ec5ff77d84b92..9573d2c939bd6 100644 --- a/tests/baselines/reference/capturedParametersInInitializers1.js +++ b/tests/baselines/reference/capturedParametersInInitializers1.js @@ -51,35 +51,41 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; // ok - usage is deferred -function foo1(y = class { - constructor() { +function foo1(y = class {constructor() { this.c = x; - } -}, x = 1) { + }}, x = 1) { new y().c; } + // ok - used in file function foo2(y = function (x) { }, z = 1) { } + // ok -used in type let a; function foo3(y = { x: a }, z = 1) { } + // error - used before declaration function foo4(y = { z }, z = 1) { } + // error - used before declaration, IIFEs are inlined function foo5(y = (() => z)(), z = 1) { } + // ok - IIFE inside another function function foo6(y = () => (() => z)(), z = 1) { } + // ok - used inside immediately invoked generator function function foo7(y = (function* () { yield z; })(), z = 1) { } + // ok - used inside immediately invoked async function function foo8(y = (() => __awaiter(this, void 0, void 0, function* () { return z; }))(), z = 1) { } + // error - used as computed name of method function foo9(y = { [z]() { return z; } }, z = 1) { } diff --git a/tests/baselines/reference/capturedParametersInInitializers2.js b/tests/baselines/reference/capturedParametersInInitializers2.js index 53d5da5d44532..43965d52978da 100644 --- a/tests/baselines/reference/capturedParametersInInitializers2.js +++ b/tests/baselines/reference/capturedParametersInInitializers2.js @@ -15,8 +15,11 @@ function foo2(y = class {[x] = x}, x = 1) { } //// [capturedParametersInInitializers2.js] -function foo(y, x, z) { - if (y === void 0) { y = (_a = /** @class */ (function () { +function foo( +y, + x, + z +) {if (y === void 0) { y = (_a = /** @class */ (function () { function class_1() { x; } @@ -35,8 +38,7 @@ function foo(y, x, z) { var _a; y.c; } -function foo2(y, x) { - if (y === void 0) { y = (_b = /** @class */ (function () { +function foo2(y, x) {if (y === void 0) { y = (_b = /** @class */ (function () { function class_2() { this[_a] = x; } diff --git a/tests/baselines/reference/castExpressionParentheses.js b/tests/baselines/reference/castExpressionParentheses.js index b1f4507f98292..703f77294ae15 100644 --- a/tests/baselines/reference/castExpressionParentheses.js +++ b/tests/baselines/reference/castExpressionParentheses.js @@ -51,9 +51,12 @@ new (A()); //// [castExpressionParentheses.js] + // parentheses should be omitted // literals -({ a: 0 }); +( + + { a: 0 }); [1, 3,]; "string"; 23.0; @@ -79,16 +82,28 @@ a().x; 1.0.foo; 12e+34.foo; 0xff.foo; + + // should keep the parentheses in emit (1.0); -(new A).foo; -(typeof A).x; -(-A).x; +( + new A).foo; +( + typeof A).x; +( + -A).x; new (A()); (function () { })(); -(function foo() { })(); -(-A).x; +( + function foo() { })(); +( + -A).x; + // nested cast, should keep one pair of parenthese -(-A).x; +( + + -A).x; + // nested parenthesized expression, should keep one pair of parenthese (A); + diff --git a/tests/baselines/reference/castTest.js b/tests/baselines/reference/castTest.js index 930086bdd9464..b5b55faa87ee6 100644 --- a/tests/baselines/reference/castTest.js +++ b/tests/baselines/reference/castTest.js @@ -35,11 +35,16 @@ var p_cast = ({ var x = 0; var z = x; var y = x + z; + var a = 0; var b = true; var s = ""; + var ar = null; + var f = null; + + var p_cast = ({ x: 0, y: 0, @@ -48,3 +53,4 @@ var p_cast = ({ }, mult: function (p) { return p; } }); + diff --git a/tests/baselines/reference/castingTuple.js b/tests/baselines/reference/castingTuple.js index ac21b229a3ce4..c66b4ab1189b9 100644 --- a/tests/baselines/reference/castingTuple.js +++ b/tests/baselines/reference/castingTuple.js @@ -55,14 +55,12 @@ var A = /** @class */ (function () { return A; }()); var C = /** @class */ (function () { - function C() { - } + function C() {} return C; }()); ; var D = /** @class */ (function () { - function D() { - } + function D() {} return D; }()); ; @@ -108,6 +106,7 @@ var unionTuple = [new C(), "foo"]; var unionTuple2 = [new C(), "foo", new D()]; var unionTuple3 = [10, "foo"]; var unionTuple4 = unionTuple3; + // error var t3 = numStrTuple; var t9 = classCDTuple; diff --git a/tests/baselines/reference/cf.js b/tests/baselines/reference/cf.js index 7e95dca1944cc..0b4de1938779b 100644 --- a/tests/baselines/reference/cf.js +++ b/tests/baselines/reference/cf.js @@ -62,6 +62,7 @@ function f() { var z; var x = 10; var y = 3; + L1: for (var i = 0; i < 19; i++) { if (y == 7) { continue L1; diff --git a/tests/baselines/reference/chained.js b/tests/baselines/reference/chained.js index e37d6361b2441..0f65c5d53f63d 100644 --- a/tests/baselines/reference/chained.js +++ b/tests/baselines/reference/chained.js @@ -23,8 +23,7 @@ const d: D = {}; "use strict"; exports.__esModule = true; var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); //// [b.js] diff --git a/tests/baselines/reference/chained2.js b/tests/baselines/reference/chained2.js index 9604b64e63341..355737cc5351a 100644 --- a/tests/baselines/reference/chained2.js +++ b/tests/baselines/reference/chained2.js @@ -25,8 +25,7 @@ const b: types.B = {}; "use strict"; exports.__esModule = true; var A = /** @class */ (function () { - function A() { - } + function A() {} return A; }()); //// [b.js] diff --git a/tests/baselines/reference/chainedAssignment2.js b/tests/baselines/reference/chainedAssignment2.js index 482d97da80947..0197953cdac1e 100644 --- a/tests/baselines/reference/chainedAssignment2.js +++ b/tests/baselines/reference/chainedAssignment2.js @@ -15,4 +15,5 @@ var b; var c; var d; var e; + a = b = c = d = e = null; diff --git a/tests/baselines/reference/chainedAssignment3.js b/tests/baselines/reference/chainedAssignment3.js index c3e73310188b4..a38ac6df70233 100644 --- a/tests/baselines/reference/chainedAssignment3.js +++ b/tests/baselines/reference/chainedAssignment3.js @@ -53,7 +53,9 @@ var b; a = b = null; a = b = new B(); b = a = new B(); + a.id = b.value = null; + // error cases b = a = new A(); a = b = new A(); diff --git a/tests/baselines/reference/chainedAssignmentChecking.js b/tests/baselines/reference/chainedAssignmentChecking.js index 9ea4020199017..73de88b6dfd44 100644 --- a/tests/baselines/reference/chainedAssignmentChecking.js +++ b/tests/baselines/reference/chainedAssignmentChecking.js @@ -43,4 +43,5 @@ var Z = /** @class */ (function () { var c1 = new X(3); var c2 = new Y(5); var c3 = new Z(); + c1 = c2 = c3; // Should be error diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.js b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.js index 15c723524807a..b5569bf0b4fd2 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.js +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.js @@ -51,11 +51,14 @@ var Chain = /** @class */ (function () { var s; // Ok to go down the chain, but error to climb up the chain (new Chain(t)).then(function (tt) { return s; }).then(function (ss) { return t; }); + // But error to try to climb up the chain (new Chain(s)).then(function (ss) { return t; }); + // Staying at T or S should be fine (new Chain(t)).then(function (tt) { return t; }).then(function (tt) { return t; }).then(function (tt) { return t; }); (new Chain(s)).then(function (ss) { return s; }).then(function (ss) { return s; }).then(function (ss) { return s; }); + return null; }; return Chain; @@ -71,10 +74,12 @@ var Chain2 = /** @class */ (function () { // Ok to go down the chain, check the constraint at the end. // Should get an error that we are assigning a string to a number (new Chain2(i)).then(function (ii) { return t; }).then(function (tt) { return s; }).value.x = ""; + // Staying at T or S should keep the constraint. // Get an error when we assign a string to a number in both cases (new Chain2(i)).then(function (ii) { return t; }).then(function (tt) { return t; }).then(function (tt) { return t; }).then(function (tt) { return t; }).value.x = ""; (new Chain2(i)).then(function (ii) { return s; }).then(function (ss) { return s; }).then(function (ss) { return s; }).then(function (ss) { return s; }).value.x = ""; + return null; }; return Chain2; diff --git a/tests/baselines/reference/chainedSpecializationToObjectTypeLiteral.js b/tests/baselines/reference/chainedSpecializationToObjectTypeLiteral.js index 1884967aa9ecc..564fed96df951 100644 --- a/tests/baselines/reference/chainedSpecializationToObjectTypeLiteral.js +++ b/tests/baselines/reference/chainedSpecializationToObjectTypeLiteral.js @@ -12,6 +12,7 @@ var s3 = s2.each(x => { x.key /* Type is K, should be number */ }); //// [chainedSpecializationToObjectTypeLiteral.js] + var s; var s2 = s.groupBy(function (s) { return s.length; }); var s3 = s2.each(function (x) { x.key; /* Type is K, should be number */ }); diff --git a/tests/baselines/reference/checkForObjectTooStrict.js b/tests/baselines/reference/checkForObjectTooStrict.js index d03127eaa7d96..fb2c48d56d211 100644 --- a/tests/baselines/reference/checkForObjectTooStrict.js +++ b/tests/baselines/reference/checkForObjectTooStrict.js @@ -47,6 +47,7 @@ var __extends = (this && this.__extends) || (function () { })(); var Foo; (function (Foo) { + var Object = /** @class */ (function () { function Object() { } diff --git a/tests/baselines/reference/checkInfiniteExpansionTermination.js b/tests/baselines/reference/checkInfiniteExpansionTermination.js index ed52ea6b4190c..cbc50b20998ae 100644 --- a/tests/baselines/reference/checkInfiniteExpansionTermination.js +++ b/tests/baselines/reference/checkInfiniteExpansionTermination.js @@ -20,6 +20,8 @@ values = values2; //// [checkInfiniteExpansionTermination.js] // Regression test for #1002 // Before fix this code would cause infinite loop + + var values; var values2; values = values2; diff --git a/tests/baselines/reference/checkInfiniteExpansionTermination2.js b/tests/baselines/reference/checkInfiniteExpansionTermination2.js index 6175b34e52216..6202a43afae9e 100644 --- a/tests/baselines/reference/checkInfiniteExpansionTermination2.js +++ b/tests/baselines/reference/checkInfiniteExpansionTermination2.js @@ -20,6 +20,8 @@ function fn() { //// [checkInfiniteExpansionTermination2.js] // Regression test for #1002 // Before fix this code would cause infinite loop + + function fn() { var values = []; // Hang when using , but not diff --git a/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.js b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.js index 66c46c9214d77..14830eeca342a 100644 --- a/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.js +++ b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.js @@ -18,6 +18,7 @@ var obj = { x: 1, y: 2 }; + /** * @type {keyof typeof obj} */ diff --git a/tests/baselines/reference/checkJsObjectLiteralIndexSignatures.js b/tests/baselines/reference/checkJsObjectLiteralIndexSignatures.js index bc9c08b552477..db383be440070 100644 --- a/tests/baselines/reference/checkJsObjectLiteralIndexSignatures.js +++ b/tests/baselines/reference/checkJsObjectLiteralIndexSignatures.js @@ -17,7 +17,9 @@ stringIndex[s].toFixed(); var _a, _b; var n = Math.random(); var s = "" + n; + var numericIndex = (_a = {}, _a[n] = 1, _a); numericIndex[n].toFixed(); + var stringIndex = (_b = {}, _b[s] = 1, _b); stringIndex[s].toFixed(); diff --git a/tests/baselines/reference/checkJsdocParamOnVariableDeclaredFunctionExpression.js b/tests/baselines/reference/checkJsdocParamOnVariableDeclaredFunctionExpression.js index 59d2fe5b14b96..1472194088938 100644 --- a/tests/baselines/reference/checkJsdocParamOnVariableDeclaredFunctionExpression.js +++ b/tests/baselines/reference/checkJsdocParamOnVariableDeclaredFunctionExpression.js @@ -29,6 +29,7 @@ var y; * @param {boolean!} b */ y = function bar(b) { }; + /** * @param {string} s */ diff --git a/tests/baselines/reference/checkJsdocParamTag1.js b/tests/baselines/reference/checkJsdocParamTag1.js index 577460626a18f..3246f00f4c843 100644 --- a/tests/baselines/reference/checkJsdocParamTag1.js +++ b/tests/baselines/reference/checkJsdocParamTag1.js @@ -17,6 +17,7 @@ foo(1, "hi"); * @param {string} [s] */ function foo(n, s) { } + foo(); foo(1); foo(1, "hi"); diff --git a/tests/baselines/reference/checkJsdocReturnTag1.js b/tests/baselines/reference/checkJsdocReturnTag1.js index 31c30e54dfc40..e6ef822de1eb4 100644 --- a/tests/baselines/reference/checkJsdocReturnTag1.js +++ b/tests/baselines/reference/checkJsdocReturnTag1.js @@ -29,12 +29,14 @@ function f2() { function f() { return "hello"; } + /** * @returns {string=} This comment is not currently exposed */ function f1() { return "hello world"; } + /** * @returns {string|number} This comment is not currently exposed */ diff --git a/tests/baselines/reference/checkJsdocReturnTag2.js b/tests/baselines/reference/checkJsdocReturnTag2.js index 4a68e5d85b7fd..d14d7a581ba54 100644 --- a/tests/baselines/reference/checkJsdocReturnTag2.js +++ b/tests/baselines/reference/checkJsdocReturnTag2.js @@ -22,6 +22,7 @@ function f1() { function f() { return 5; } + /** * @returns {string | number} This comment is not currently exposed */ diff --git a/tests/baselines/reference/checkJsdocTypeTag1.js b/tests/baselines/reference/checkJsdocTypeTag1.js index 0613a237d7bd2..f7af2ebdca0af 100644 --- a/tests/baselines/reference/checkJsdocTypeTag1.js +++ b/tests/baselines/reference/checkJsdocTypeTag1.js @@ -45,30 +45,39 @@ var props = {}; // @ts-check /** @type {String} */ var S = "hello world"; + /** @type {number} */ var n = 10; + /** @type {*} */ var anyT = 2; anyT = "hello"; + /** @type {?} */ var anyT1 = 2; anyT1 = "hi"; + /** @type {Function} */ var x = function (a) { return a + 1; }; x(1); + /** @type {function} */ var y = function (a) { return a + 1; }; y(1); + /** @type {function (number)} */ var x1 = function (a) { return a + 1; }; x1(0); + /** @type {function (number): number} */ var x2 = function (a) { return a + 1; }; x2(0); + /** * @type {object} */ var props = {}; + /** * @type {Object} */ diff --git a/tests/baselines/reference/checkJsdocTypeTag2.js b/tests/baselines/reference/checkJsdocTypeTag2.js index 0e550d3ba333f..05033499d1bc6 100644 --- a/tests/baselines/reference/checkJsdocTypeTag2.js +++ b/tests/baselines/reference/checkJsdocTypeTag2.js @@ -29,19 +29,25 @@ x4(0); // @ts-check /** @type {String} */ var S = true; + /** @type {number} */ var n = "hello"; + /** @type {function (number)} */ var x1 = function (a) { return a + 1; }; x1("string"); + /** @type {function (number): number} */ var x2 = function (a) { return a + 1; }; + /** @type {string} */ var a; a = x2(0); + /** @type {function (number): number} */ var x3 = function (a) { return a.concat("hi"); }; x3(0); + /** @type {function (number): string} */ var x4 = function (a) { return a + 1; }; x4(0); diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.js b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.js index ab574fddcedbf..a154378ede132 100644 --- a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.js +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.js @@ -35,15 +35,14 @@ var obj = { /** @type {function(number): number} */ method2: function (n1) { return "lol"; }, /** @type {function(number): number} */ - arrowFunc: function (num) { - if (num === void 0) { num = "0"; } - return num + 42; - }, + arrowFunc: function (num) {if (num === void 0) { num = "0"; } + return num + 42;}, /** @type {string} */ lol: lol }; lol = "string"; /** @type {string} */ var s = obj.method1(0); + /** @type {string} */ var s1 = obj.method2("0"); diff --git a/tests/baselines/reference/checkJsdocTypedefInParamTag1.js b/tests/baselines/reference/checkJsdocTypedefInParamTag1.js index d50f126c54e1d..395988aed8ef5 100644 --- a/tests/baselines/reference/checkJsdocTypedefInParamTag1.js +++ b/tests/baselines/reference/checkJsdocTypedefInParamTag1.js @@ -57,7 +57,9 @@ foo2({x: 'abc'}); function foo(opts) { opts.x; } + foo({ x: 'abc' }); + /** * @typedef {Object} AnotherOpts * @property anotherX {string} @@ -68,7 +70,9 @@ foo({ x: 'abc' }); function foo1(opts) { opts.anotherX; } + foo1({ anotherX: "world" }); + /** * @typedef {object} Opts1 * @property {string} x diff --git a/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.js b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.js index 7f4d7f4bcfd59..1ae2dab2b0eb8 100644 --- a/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.js +++ b/tests/baselines/reference/checkJsdocTypedefOnlySourceFile.js @@ -14,10 +14,13 @@ const myString = 'str'; //// [0.js] // @ts-check + var exports = {}; + /** * @typedef {string} */ exports.SomeName; + /** @type {exports.SomeName} */ var myString = 'str'; diff --git a/tests/baselines/reference/checkJsxChildrenCanBeTupleType.js b/tests/baselines/reference/checkJsxChildrenCanBeTupleType.js index 30e59613eb902..0e8a755cd0ea7 100644 --- a/tests/baselines/reference/checkJsxChildrenCanBeTupleType.js +++ b/tests/baselines/reference/checkJsxChildrenCanBeTupleType.js @@ -42,6 +42,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; exports.__esModule = true; var react_1 = __importDefault(require("react")); + + var ResizablePanel = /** @class */ (function (_super) { __extends(ResizablePanel, _super); function ResizablePanel() { @@ -49,10 +51,8 @@ var ResizablePanel = /** @class */ (function (_super) { } return ResizablePanel; }(react_1["default"].Component)); -var test = react_1["default"].createElement(ResizablePanel, null, - react_1["default"].createElement("div", null), - react_1["default"].createElement("div", null)); -var testErr = react_1["default"].createElement(ResizablePanel, null, - react_1["default"].createElement("div", null), - react_1["default"].createElement("div", null), - react_1["default"].createElement("div", null)); +var test = react_1["default"].createElement(ResizablePanel, null, react_1["default"].createElement("div", null), react_1["default"].createElement("div", null) +); + +var testErr = react_1["default"].createElement(ResizablePanel, null, react_1["default"].createElement("div", null), react_1["default"].createElement("div", null), react_1["default"].createElement("div", null) +); diff --git a/tests/baselines/reference/checkJsxChildrenProperty1.js b/tests/baselines/reference/checkJsxChildrenProperty1.js index 44c1ca8a72945..7a37fb7646ebc 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty1.js +++ b/tests/baselines/reference/checkJsxChildrenProperty1.js @@ -26,9 +26,12 @@ let k2 = "use strict"; exports.__esModule = true; var React = require("react"); + + function Comp(p) { return
{p.b}
; } + // OK var k = ; var k1 = diff --git a/tests/baselines/reference/checkJsxChildrenProperty10.js b/tests/baselines/reference/checkJsxChildrenProperty10.js index 18d1f3affa33e..632f6145955f5 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty10.js +++ b/tests/baselines/reference/checkJsxChildrenProperty10.js @@ -23,6 +23,7 @@ let k3 =
{1} {"That is a number"}
; let k4 = ; //// [file.jsx] + var Button = /** @class */ (function () { function Button() { } diff --git a/tests/baselines/reference/checkJsxChildrenProperty11.js b/tests/baselines/reference/checkJsxChildrenProperty11.js index 18d1f3affa33e..632f6145955f5 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty11.js +++ b/tests/baselines/reference/checkJsxChildrenProperty11.js @@ -23,6 +23,7 @@ let k3 =
{1} {"That is a number"}
; let k4 = ; //// [file.jsx] + var Button = /** @class */ (function () { function Button() { } diff --git a/tests/baselines/reference/checkJsxChildrenProperty12.js b/tests/baselines/reference/checkJsxChildrenProperty12.js index 44fe4e1053d68..878956c76b8f9 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty12.js +++ b/tests/baselines/reference/checkJsxChildrenProperty12.js @@ -49,6 +49,8 @@ var __extends = (this && this.__extends) || (function () { })(); exports.__esModule = true; var React = require("react"); + + var Button = /** @class */ (function (_super) { __extends(Button, _super); function Button() { @@ -67,6 +69,7 @@ var Button = /** @class */ (function (_super) { }; return Button; }(React.Component)); + var InnerButton = /** @class */ (function (_super) { __extends(InnerButton, _super); function InnerButton() { diff --git a/tests/baselines/reference/checkJsxChildrenProperty13.js b/tests/baselines/reference/checkJsxChildrenProperty13.js index dcdf7ac1e88fc..a32d737b58962 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty13.js +++ b/tests/baselines/reference/checkJsxChildrenProperty13.js @@ -44,6 +44,8 @@ var __extends = (this && this.__extends) || (function () { })(); exports.__esModule = true; var React = require("react"); + + var Button = /** @class */ (function (_super) { __extends(Button, _super); function Button() { @@ -57,6 +59,7 @@ var Button = /** @class */ (function (_super) { }; return Button; }(React.Component)); + var InnerButton = /** @class */ (function (_super) { __extends(InnerButton, _super); function InnerButton() { diff --git a/tests/baselines/reference/checkJsxChildrenProperty14.js b/tests/baselines/reference/checkJsxChildrenProperty14.js index 12051095b6a88..6fbc6cb677a76 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty14.js +++ b/tests/baselines/reference/checkJsxChildrenProperty14.js @@ -59,6 +59,8 @@ var __extends = (this && this.__extends) || (function () { })(); exports.__esModule = true; var React = require("react"); + + var Button = /** @class */ (function (_super) { __extends(Button, _super); function Button() { @@ -72,17 +74,23 @@ var Button = /** @class */ (function (_super) { function AnotherButton(p) { return

Just Another Button

; } + function Comp(p) { return
{p.b}
; } + // OK var k1 = <>