From 0255adc4076b7b963e2db2b0c8bba4e330fbfd01 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Tue, 8 Aug 2017 10:08:48 +0800 Subject: [PATCH 001/216] fix #16567: better coloring on light theme terminal --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 64e8eb0c803..db83f740253 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -243,7 +243,7 @@ namespace ts { const redForegroundEscapeSequence = "\u001b[91m"; const yellowForegroundEscapeSequence = "\u001b[93m"; const blueForegroundEscapeSequence = "\u001b[93m"; - const gutterStyleSequence = "\u001b[100;30m"; + const gutterStyleSequence = "\u001b[30;47m"; const gutterSeparator = " "; const resetEscapeSequence = "\u001b[0m"; const ellipsis = "..."; From 5b860557867bed3a10b33a98c0ac99a8e9cd5dab Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Tue, 25 Jul 2017 14:21:57 -0700 Subject: [PATCH 002/216] Excluded the default library from rename service. --- src/compiler/program.ts | 5 +++++ src/compiler/types.ts | 1 + src/services/services.ts | 43 ++++++++++++++++++++++++++-------------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 305058285f9..55edb377373 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -555,6 +555,7 @@ namespace ts { getFileProcessingDiagnostics: () => fileProcessingDiagnostics, getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives, isSourceFileFromExternalLibrary, + isSourceFileDefaultLibrary, dropDiagnosticsProducingTypeChecker, getSourceFileFromReference, sourceFileToPackageName, @@ -975,6 +976,10 @@ namespace ts { return sourceFilesFoundSearchingNodeModules.get(file.path); } + function isSourceFileDefaultLibrary(file: SourceFile): boolean { + return file.fileName === host.getDefaultLibFileName(options); + } + function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ true)); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2b3e5ab36df..66a4517a5bd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2452,6 +2452,7 @@ namespace ts { /* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection; /* @internal */ getResolvedTypeReferenceDirectives(): Map; /* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean; + /* @internal */ isSourceFileDefaultLibrary(file: SourceFile): boolean; // For testing purposes only. /* @internal */ structureIsReused?: StructureIsReused; diff --git a/src/services/services.ts b/src/services/services.ts index ed9732cc9cf..998a5d36898 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -670,7 +670,7 @@ namespace ts { if (!hasModifier(node, ModifierFlags.ParameterPropertyModifier)) { break; } - // falls through + // falls through case SyntaxKind.VariableDeclaration: case SyntaxKind.BindingElement: { const decl = node; @@ -682,7 +682,7 @@ namespace ts { visit(decl.initializer); } } - // falls through + // falls through case SyntaxKind.EnumMember: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: @@ -729,7 +729,7 @@ namespace ts { class SourceMapSourceObject implements SourceMapSource { lineMap: number[]; - constructor (public fileName: string, public text: string, public skipTrivia?: (pos: number) => number) {} + constructor(public fileName: string, public text: string, public skipTrivia?: (pos: number) => number) { } public getLineAndCharacterOfPosition(pos: number): LineAndCharacter { return ts.getLineAndCharacterOfPosition(this, pos); @@ -1130,14 +1130,14 @@ namespace ts { const newSettings = hostCache.compilationSettings(); const shouldCreateNewSourceFiles = oldSettings && (oldSettings.target !== newSettings.target || - oldSettings.module !== newSettings.module || - oldSettings.moduleResolution !== newSettings.moduleResolution || - oldSettings.noResolve !== newSettings.noResolve || - oldSettings.jsx !== newSettings.jsx || - oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || - oldSettings.baseUrl !== newSettings.baseUrl || - !equalOwnProperties(oldSettings.paths, newSettings.paths)); + oldSettings.module !== newSettings.module || + oldSettings.moduleResolution !== newSettings.moduleResolution || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx || + oldSettings.allowJs !== newSettings.allowJs || + oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.baseUrl !== newSettings.baseUrl || + !equalOwnProperties(oldSettings.paths, newSettings.paths)); // Now create a new compiler const compilerHost: CompilerHost = { @@ -1365,7 +1365,7 @@ namespace ts { function getCompilerOptionsDiagnostics() { synchronizeHostData(); return program.getOptionsDiagnostics(cancellationToken).concat( - program.getGlobalDiagnostics(cancellationToken)); + program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo { @@ -1510,7 +1510,20 @@ namespace ts { function getReferences(fileName: string, position: number, options?: FindAllReferences.Options) { synchronizeHostData(); - return FindAllReferences.findReferencedEntries(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); + + //Exclude default library when renaming as commonly user don't want to change that file. + let sourceFiles: SourceFile[] = []; + if (options.isForRename) { + for (let sourceFile of program.getSourceFiles()) { + if (!program.isSourceFileDefaultLibrary(sourceFile)) { + sourceFiles.push(sourceFile); + } + } + } else { + sourceFiles = program.getSourceFiles(); + } + + return FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName: string, position: number): ReferencedSymbol[] { @@ -2100,7 +2113,7 @@ namespace ts { isLiteralComputedPropertyDeclarationName(node); } - function isObjectLiteralElement(node: Node): node is ObjectLiteralElement { + function isObjectLiteralElement(node: Node): node is ObjectLiteralElement { switch (node.kind) { case SyntaxKind.JsxAttribute: case SyntaxKind.JsxSpreadAttribute: @@ -2125,7 +2138,7 @@ namespace ts { if (node.parent.kind === SyntaxKind.ComputedPropertyName) { return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } - // falls through + // falls through case SyntaxKind.Identifier: return isObjectLiteralElement(node.parent) && (node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression || node.parent.parent.kind === SyntaxKind.JsxAttributes) && From 675b6fb90ce3b8e659a6acc4f161a64cb31b111a Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Tue, 25 Jul 2017 16:29:08 -0700 Subject: [PATCH 003/216] Fixed failing tests and lint. Added unit tests. --- src/services/services.ts | 9 +++++---- tests/cases/fourslash/renameDefaultLibDontWork.ts | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/renameDefaultLibDontWork.ts diff --git a/src/services/services.ts b/src/services/services.ts index 998a5d36898..2a1b0bf4eb0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1511,15 +1511,16 @@ namespace ts { function getReferences(fileName: string, position: number, options?: FindAllReferences.Options) { synchronizeHostData(); - //Exclude default library when renaming as commonly user don't want to change that file. + // Exclude default library when renaming as commonly user don't want to change that file. let sourceFiles: SourceFile[] = []; - if (options.isForRename) { - for (let sourceFile of program.getSourceFiles()) { + if (options && options.isForRename) { + for (const sourceFile of program.getSourceFiles()) { if (!program.isSourceFileDefaultLibrary(sourceFile)) { sourceFiles.push(sourceFile); } } - } else { + } + else { sourceFiles = program.getSourceFiles(); } diff --git a/tests/cases/fourslash/renameDefaultLibDontWork.ts b/tests/cases/fourslash/renameDefaultLibDontWork.ts new file mode 100644 index 00000000000..5d2cfb43eb4 --- /dev/null +++ b/tests/cases/fourslash/renameDefaultLibDontWork.ts @@ -0,0 +1,11 @@ +/// + +// Tests that tokens found on the default library are not renamed. +// "test" is a comment on the default library. + +// @Filename: file1.ts +//// var [|test|] = "foo"; +//// console.log([|test|]); + +const ranges = test.ranges(); +verify.renameLocations(ranges[0], { findInComments: true, ranges }); \ No newline at end of file From 88262dbeb0dfb60af0e27735c10c5a8d9e7b3e27 Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Mon, 14 Aug 2017 18:19:43 -0700 Subject: [PATCH 004/216] Changed check for default library by first checking hasNoDefaultLib, second library path and third name of file. --- src/compiler/program.ts | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 55edb377373..25a526ddaf4 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -436,6 +436,7 @@ namespace ts { host = host || createCompilerHost(options); let skipDefaultLib = options.noLib; + const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options)); const programDiagnostics = createDiagnosticCollection(); const currentDirectory = host.getCurrentDirectory(); const supportedExtensions = getSupportedExtensions(options); @@ -977,7 +978,15 @@ namespace ts { } function isSourceFileDefaultLibrary(file: SourceFile): boolean { - return file.fileName === host.getDefaultLibFileName(options); + if (file.hasNoDefaultLib) { + return true; + } + + if (defaultLibraryPath !== undefined && defaultLibraryPath.length !== 0) { + return comparePaths(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ true) === Comparison.EqualTo; + } + + return compareStrings(file.fileName, host.getDefaultLibFileName(options), /*ignoreCase*/ true) === Comparison.EqualTo; } function getDiagnosticsProducingTypeChecker() { @@ -1209,7 +1218,7 @@ namespace ts { diagnostics.push(createDiagnosticForNode(node, Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - // falls through + // falls through case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: @@ -1291,7 +1300,7 @@ namespace ts { diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - // falls through + // falls through case SyntaxKind.VariableStatement: // Check modifiers if (nodes === (parent).modifiers) { @@ -1339,8 +1348,8 @@ namespace ts { if (isConstValid) { continue; } - // to report error, - // falls through + // to report error, + // falls through case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: @@ -1556,10 +1565,10 @@ namespace ts { } function getSourceFileFromReferenceWorker( - fileName: string, - getSourceFile: (fileName: string) => SourceFile | undefined, - fail?: (diagnostic: DiagnosticMessage, ...argument: string[]) => void, - refFile?: SourceFile): SourceFile | undefined { + fileName: string, + getSourceFile: (fileName: string) => SourceFile | undefined, + fail?: (diagnostic: DiagnosticMessage, ...argument: string[]) => void, + refFile?: SourceFile): SourceFile | undefined { if (hasExtension(fileName)) { if (!options.allowNonTsExtensions && !forEach(supportedExtensions, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) { From 9dd574b1a92d02dc941a3160d92671281265161b Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Tue, 15 Aug 2017 18:44:28 -0700 Subject: [PATCH 005/216] Added host.useCaseSens..., memoized getDefaultLibFileName. --- src/compiler/program.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 25a526ddaf4..bc8f65b35cb 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -325,12 +325,12 @@ namespace ts { } output += sys.newLine; - output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; + output += `${relativeFileName}(${firstLine + 1},${firstLineChar + 1}): `; } const categoryColor = getCategoryFormat(diagnostic.category); const category = DiagnosticCategory[diagnostic.category].toLowerCase(); - output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; + output += `${formatAndReset(category, categoryColor)} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine)}`; output += sys.newLine; } return output; @@ -436,7 +436,8 @@ namespace ts { host = host || createCompilerHost(options); let skipDefaultLib = options.noLib; - const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options)); + const getDefaultLibraryFileName = memoize(() => host.getDefaultLibFileName(options)); + const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(getDefaultLibraryFileName()); const programDiagnostics = createDiagnosticCollection(); const currentDirectory = host.getCurrentDirectory(); const supportedExtensions = getSupportedExtensions(options); @@ -512,12 +513,11 @@ namespace ts { // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file if (!options.lib) { - processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib*/ true); + processRootFile(getDefaultLibraryFileName(), /*isDefaultLib*/ true); } else { - const libDirectory = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(host.getDefaultLibFileName(options)); forEach(options.lib, libFileName => { - processRootFile(combinePaths(libDirectory, libFileName), /*isDefaultLib*/ true); + processRootFile(combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true); }); } } @@ -982,11 +982,11 @@ namespace ts { return true; } - if (defaultLibraryPath !== undefined && defaultLibraryPath.length !== 0) { - return comparePaths(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ true) === Comparison.EqualTo; + if (defaultLibraryPath && defaultLibraryPath.length !== 0) { + return containsPath(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ !host.useCaseSensitiveFileNames()); } - return compareStrings(file.fileName, host.getDefaultLibFileName(options), /*ignoreCase*/ true) === Comparison.EqualTo; + return compareStrings(file.fileName, getDefaultLibraryFileName(), /*ignoreCase*/ !host.useCaseSensitiveFileNames()) === Comparison.EqualTo; } function getDiagnosticsProducingTypeChecker() { From 345622d22d3466bba17a6a33454e6bde63ef6431 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 18 Aug 2017 23:53:20 +0100 Subject: [PATCH 006/216] Add test that demonstrates bug --- .../reference/propertyAccessOnEmptyObjectLiteral.js | 12 ++++++++++++ .../propertyAccessOnEmptyObjectLiteral.symbols | 9 +++++++++ .../propertyAccessOnEmptyObjectLiteral.types | 13 +++++++++++++ .../compiler/propertyAccessOnEmptyObjectLiteral.ts | 3 +++ 4 files changed, 37 insertions(+) create mode 100644 tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.js create mode 100644 tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.symbols create mode 100644 tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.types create mode 100644 tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts diff --git a/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.js b/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.js new file mode 100644 index 00000000000..f485e4fa618 --- /dev/null +++ b/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.js @@ -0,0 +1,12 @@ +//// [propertyAccessOnEmptyObjectLiteral.ts] +class A { } + +({}).toString(); + +//// [propertyAccessOnEmptyObjectLiteral.js] +var A = /** @class */ (function () { + function A() { + } + return A; +}()); +({}).toString(); diff --git a/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.symbols b/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.symbols new file mode 100644 index 00000000000..721cce14900 --- /dev/null +++ b/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts === +class A { } +>A : Symbol(A, Decl(propertyAccessOnEmptyObjectLiteral.ts, 0, 0)) + +({}).toString(); +>({}).toString : Symbol(Object.toString, Decl(lib.d.ts, --, --)) +>A : Symbol(A, Decl(propertyAccessOnEmptyObjectLiteral.ts, 0, 0)) +>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.types b/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.types new file mode 100644 index 00000000000..ac92f934066 --- /dev/null +++ b/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts === +class A { } +>A : A + +({}).toString(); +>({}).toString() : string +>({}).toString : () => string +>({}) : A +>{} : A +>A : A +>{} : {} +>toString : () => string + diff --git a/tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts b/tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts new file mode 100644 index 00000000000..6112f269ee8 --- /dev/null +++ b/tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts @@ -0,0 +1,3 @@ +class A { } + +({}).toString(); \ No newline at end of file From 424e84c112d02ac4e193267630f05748c9fae0d0 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Sat, 19 Aug 2017 00:01:14 +0100 Subject: [PATCH 007/216] Fix empty object literal property access --- src/compiler/factory.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index daec1bce1e8..576f59e590f 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3811,14 +3811,18 @@ namespace ts { */ export function parenthesizeForAccess(expression: Expression): LeftHandSideExpression { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. The known exception is: + // to parenthesize the expression before a dot. There are two known exceptions: // // NewExpression: // new C.x -> not the same as (new C).x // + // EmptyObjectLiteral: + // {}.toString() -> is incorrect syntax, should be ({}).x + // const emittedExpression = skipPartiallyEmittedExpressions(expression); if (isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== SyntaxKind.NewExpression || (emittedExpression).arguments)) { + && (emittedExpression.kind !== SyntaxKind.NewExpression || (emittedExpression).arguments) + && !isEmptyObjectLiteral(emittedExpression)) { return expression; } From eff6a3a7b637b3dc43826b0800920d5dc2a18859 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Sat, 19 Aug 2017 01:00:56 +0100 Subject: [PATCH 008/216] Clean up other statement to match style --- src/compiler/factory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 576f59e590f..7a20a6d8a41 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3821,7 +3821,7 @@ namespace ts { // const emittedExpression = skipPartiallyEmittedExpressions(expression); if (isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== SyntaxKind.NewExpression || (emittedExpression).arguments) + && (!isNewExpression(emittedExpression) || (emittedExpression).arguments) && !isEmptyObjectLiteral(emittedExpression)) { return expression; } From 70c4aa8fdc0db5d67310b985c0ebae1be5028a23 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Sat, 19 Aug 2017 01:33:28 +0100 Subject: [PATCH 009/216] Fix tests that had syntax errors with empty object literal property accesses --- .../baselines/reference/blockScopedBindingUsedBeforeDef.js | 4 ++-- .../reference/computedPropertiesInDestructuring2.js | 2 +- .../reference/controlFlowDestructuringDeclaration.js | 6 +++--- .../destructuringObjectBindingPatternAndAssignment1ES5.js | 2 +- .../shorthandPropertyAssignmentsInDestructuring.js | 4 ++-- tests/baselines/reference/templateStringInPropertyName1.js | 2 +- tests/baselines/reference/templateStringInPropertyName2.js | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js index cc9ad56be88..78fd3dfc92a 100644 --- a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js +++ b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js @@ -15,7 +15,7 @@ for (var _i = 0, _a = [{}]; _i < _a.length; _i++) { continue; } // 2: -for (var _c = a, a = {}[_c]; false;) +for (var _c = a, a = ({})[_c]; false;) continue; // 3: -var _d = b, b = {}[_d]; +var _d = b, b = ({})[_d]; diff --git a/tests/baselines/reference/computedPropertiesInDestructuring2.js b/tests/baselines/reference/computedPropertiesInDestructuring2.js index 8579881b775..872cf7831c7 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring2.js +++ b/tests/baselines/reference/computedPropertiesInDestructuring2.js @@ -4,4 +4,4 @@ let {[foo2()]: bar3} = {}; //// [computedPropertiesInDestructuring2.js] var foo2 = function () { return "bar"; }; -var _a = foo2(), bar3 = {}[_a]; +var _a = foo2(), bar3 = ({})[_a]; diff --git a/tests/baselines/reference/controlFlowDestructuringDeclaration.js b/tests/baselines/reference/controlFlowDestructuringDeclaration.js index 39192f1baad..2e007f2cad8 100644 --- a/tests/baselines/reference/controlFlowDestructuringDeclaration.js +++ b/tests/baselines/reference/controlFlowDestructuringDeclaration.js @@ -98,11 +98,11 @@ function f5() { z; } function f6() { - var x = {}.x; + var x = ({}).x; x; - var y = {}.y; + var y = ({}).y; y; - var _a = {}.z, z = _a === void 0 ? "" : _a; + var _a = ({}).z, z = _a === void 0 ? "" : _a; z; } function f7() { diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js index f201b17deda..21889807f6f 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js @@ -60,7 +60,7 @@ var {"prop2": d1} = foo1(); // V is an object assignment pattern and, for each assignment property P in V, // S is the type Any, or var a1 = undefined.a1; -var a2 = {}.a2; +var a2 = ({}).a2; // V is an object assignment pattern and, for each assignment property P in V, // S has an apparent property with the property name specified in // P of a type that is assignable to the target given in P, or diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js index ca874652de8..a92f3b6a63d 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js @@ -194,12 +194,12 @@ function foo({a = 4, b = { x: 5 }}) { }); (function () { var y1; - (_a = {}.y1, y1 = _a === void 0 ? 5 : _a); + (_a = ({}).y1, y1 = _a === void 0 ? 5 : _a); var _a; }); (function () { var y1; - (_a = {}.y1, y1 = _a === void 0 ? 5 : _a); + (_a = ({}).y1, y1 = _a === void 0 ? 5 : _a); var _a; }); (function () { diff --git a/tests/baselines/reference/templateStringInPropertyName1.js b/tests/baselines/reference/templateStringInPropertyName1.js index 239ba78d827..18e35c475e3 100644 --- a/tests/baselines/reference/templateStringInPropertyName1.js +++ b/tests/baselines/reference/templateStringInPropertyName1.js @@ -4,6 +4,6 @@ var x = { } //// [templateStringInPropertyName1.js] -var x = (_a = ["a"], _a.raw = ["a"], {}(_a)); +var x = (_a = ["a"], _a.raw = ["a"], ({})(_a)); 321; var _a; diff --git a/tests/baselines/reference/templateStringInPropertyName2.js b/tests/baselines/reference/templateStringInPropertyName2.js index 8a71a6e30be..1a2995ca08f 100644 --- a/tests/baselines/reference/templateStringInPropertyName2.js +++ b/tests/baselines/reference/templateStringInPropertyName2.js @@ -4,6 +4,6 @@ var x = { } //// [templateStringInPropertyName2.js] -var x = (_a = ["abc", "def", "ghi"], _a.raw = ["abc", "def", "ghi"], {}(_a, 123, 456)); +var x = (_a = ["abc", "def", "ghi"], _a.raw = ["abc", "def", "ghi"], ({})(_a, 123, 456)); 321; var _a; From 9726ba1198dddce9dc2d8a5508d1dc8904185444 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 8 Aug 2017 09:50:07 -0700 Subject: [PATCH 010/216] Add support for custom outlining regions --- src/compiler/types.ts | 4 ++ src/services/outliningElementsCollector.ts | 69 ++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 608bc779042..4bf180c595a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2037,6 +2037,10 @@ namespace ts { end: -1; } + export interface RegionRange extends TextRange { + name?: string; + } + // represents a top level: { type } expression in a JSDoc comment. export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index e0d99d1d271..3bd53f86301 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -6,6 +6,10 @@ namespace ts.OutliningElementsCollector { export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; let depth = 0; + const regions: RegionRange[] = []; + const regionText = "#region"; + const regionStart = new RegExp("// #region( .+| *)", "g"); + const regionEnd = new RegExp("// #endregion *"); walk(sourceFile); return elements; @@ -35,6 +39,18 @@ namespace ts.OutliningElementsCollector { } } + function addOutliningSpanRegions(regionSpan: RegionRange) { + if (regionSpan) { + const span: OutliningSpan = { + textSpan: createTextSpanFromBounds(regionSpan.pos, regionSpan.end), + hintSpan: createTextSpanFromBounds(regionSpan.pos, regionSpan.end), + bannerText: regionSpan.name, + autoCollapse: false, + }; + elements.push(span); + } + } + function addOutliningForLeadingCommentsForNode(n: Node) { const comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); @@ -89,12 +105,65 @@ namespace ts.OutliningElementsCollector { return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction; } + function isRegionStart(range: CommentRange) { + const comment = sourceFile.text.substring(range.pos, range.end); + const result = comment.match(regionStart); + + if (result && result.length > 0) { + const name = result[0].substring(10).trim(); + if (name) { + return name; + } + else { + return regionText; + } + } + return ""; + } + + function isRegionEnd(range: CommentRange) { + const comment = sourceFile.text.substring(range.pos, range.end); + return comment.match(regionEnd); + } + + function addRegionsNearNode(n: Node) { + const comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + + if (n.kind !== SyntaxKind.SourceFile && comments) { + for (const currentComment of comments) { + cancellationToken.throwIfCancellationRequested(); + + if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) { + const name = isRegionStart(currentComment); + if (name) { + const region: RegionRange = { + pos: currentComment.pos, + end: currentComment.end, + name, + }; + regions.push(region); + } + else if (isRegionEnd(currentComment)) { + const region = regions.pop(); + + if (region) { + region.end = currentComment.end; + addOutliningSpanRegions(region); + } + } + } + } + } + } + function walk(n: Node): void { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { return; } + addRegionsNearNode(n); + if (isDeclaration(n)) { addOutliningForLeadingCommentsForNode(n); } From f91c23b25f63913124a60366fe7365424611144d Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 8 Aug 2017 15:58:42 -0700 Subject: [PATCH 011/216] Add regex sweep implementation --- src/services/outliningElementsCollector.ts | 55 +++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 3bd53f86301..e79175b4b24 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -12,6 +12,7 @@ namespace ts.OutliningElementsCollector { const regionEnd = new RegExp("// #endregion *"); walk(sourceFile); + gatherRegions(); return elements; /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ @@ -127,7 +128,10 @@ namespace ts.OutliningElementsCollector { } function addRegionsNearNode(n: Node) { - const comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + const precedingToken = ts.findPrecedingToken(n.pos, sourceFile); + const trailingComments = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); + const leadingComments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + const comments = concatenate(trailingComments, leadingComments); if (n.kind !== SyntaxKind.SourceFile && comments) { for (const currentComment of comments) { @@ -148,7 +152,7 @@ namespace ts.OutliningElementsCollector { if (region) { region.end = currentComment.end; - addOutliningSpanRegions(region); + // addOutliningSpanRegions(region); } } } @@ -156,6 +160,53 @@ namespace ts.OutliningElementsCollector { } } + function isRegionStartBoundaries(start: number, end: number) { + const comment = sourceFile.text.substring(start, end); + const result = comment.match(regionStart); + + if (result && result.length > 0) { + const name = result[0].substring(10).trim(); + if (name) { + return name; + } + else { + return regionText; + } + } + return ""; + } + + function isRegionEndBoundaries(start: number, end: number) { + const comment = sourceFile.text.substring(start, end); + return comment.match(regionEnd); + } + + function gatherRegions(): void { + const lineStarts = sourceFile.getLineStarts(); + + for (const currentLineStart of lineStarts) { + const lineEnd = sourceFile.getLineEndOfPosition(currentLineStart); + + const name = isRegionStartBoundaries(currentLineStart, lineEnd); + if (name) { + const region: RegionRange = { + pos: currentLineStart, + end: lineEnd, + name, + }; + regions.push(region); + } + else if (isRegionEndBoundaries(currentLineStart, lineEnd)) { + const region = regions.pop(); + + if (region) { + region.end = lineEnd; + addOutliningSpanRegions(region); + } + } + } + } + function walk(n: Node): void { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { From 0b3ec247bcbce77115b4155688f5b718ce7f7ee1 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Wed, 9 Aug 2017 09:00:46 -0700 Subject: [PATCH 012/216] Fix name capture logic --- src/services/outliningElementsCollector.ts | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index e79175b4b24..255e7c9aad6 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -8,8 +8,8 @@ namespace ts.OutliningElementsCollector { let depth = 0; const regions: RegionRange[] = []; const regionText = "#region"; - const regionStart = new RegExp("// #region( .+| *)", "g"); - const regionEnd = new RegExp("// #endregion *"); + const regionStart = new RegExp("//\\s*#region(\\s+.*)?$", "gm"); + const regionEnd = new RegExp("//\\s*#endregion(\\s|$)", "gm"); walk(sourceFile); gatherRegions(); @@ -165,12 +165,23 @@ namespace ts.OutliningElementsCollector { const result = comment.match(regionStart); if (result && result.length > 0) { - const name = result[0].substring(10).trim(); - if (name) { - return name; + const sections = result[0].split(" ").filter(function (s) { return s !== ""; }); + + if (sections[0] === "//") { + if (sections.length > 2) { + return result[0].substring(result[0].indexOf(sections[2])); + } + else { + return regionText; + } } else { - return regionText; + if (sections.length > 1) { + return result[0].substring(result[0].indexOf(sections[1])); + } + else { + return regionText; + } } } return ""; From 0ef5498de3aff69da3a7e56574f98e0b4e6b5e10 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Wed, 9 Aug 2017 09:13:18 -0700 Subject: [PATCH 013/216] Clean up unused functions --- src/services/outliningElementsCollector.ts | 64 ++-------------------- 1 file changed, 4 insertions(+), 60 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 255e7c9aad6..cad56fe1ced 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -106,61 +106,7 @@ namespace ts.OutliningElementsCollector { return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction; } - function isRegionStart(range: CommentRange) { - const comment = sourceFile.text.substring(range.pos, range.end); - const result = comment.match(regionStart); - - if (result && result.length > 0) { - const name = result[0].substring(10).trim(); - if (name) { - return name; - } - else { - return regionText; - } - } - return ""; - } - - function isRegionEnd(range: CommentRange) { - const comment = sourceFile.text.substring(range.pos, range.end); - return comment.match(regionEnd); - } - - function addRegionsNearNode(n: Node) { - const precedingToken = ts.findPrecedingToken(n.pos, sourceFile); - const trailingComments = precedingToken && ts.getTrailingCommentRanges(sourceFile.text, precedingToken.end); - const leadingComments = ts.getLeadingCommentRangesOfNode(n, sourceFile); - const comments = concatenate(trailingComments, leadingComments); - - if (n.kind !== SyntaxKind.SourceFile && comments) { - for (const currentComment of comments) { - cancellationToken.throwIfCancellationRequested(); - - if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) { - const name = isRegionStart(currentComment); - if (name) { - const region: RegionRange = { - pos: currentComment.pos, - end: currentComment.end, - name, - }; - regions.push(region); - } - else if (isRegionEnd(currentComment)) { - const region = regions.pop(); - - if (region) { - region.end = currentComment.end; - // addOutliningSpanRegions(region); - } - } - } - } - } - } - - function isRegionStartBoundaries(start: number, end: number) { + function isRegionStart(start: number, end: number) { const comment = sourceFile.text.substring(start, end); const result = comment.match(regionStart); @@ -187,7 +133,7 @@ namespace ts.OutliningElementsCollector { return ""; } - function isRegionEndBoundaries(start: number, end: number) { + function isRegionEnd(start: number, end: number) { const comment = sourceFile.text.substring(start, end); return comment.match(regionEnd); } @@ -198,7 +144,7 @@ namespace ts.OutliningElementsCollector { for (const currentLineStart of lineStarts) { const lineEnd = sourceFile.getLineEndOfPosition(currentLineStart); - const name = isRegionStartBoundaries(currentLineStart, lineEnd); + const name = isRegionStart(currentLineStart, lineEnd); if (name) { const region: RegionRange = { pos: currentLineStart, @@ -207,7 +153,7 @@ namespace ts.OutliningElementsCollector { }; regions.push(region); } - else if (isRegionEndBoundaries(currentLineStart, lineEnd)) { + else if (isRegionEnd(currentLineStart, lineEnd)) { const region = regions.pop(); if (region) { @@ -224,8 +170,6 @@ namespace ts.OutliningElementsCollector { return; } - addRegionsNearNode(n); - if (isDeclaration(n)) { addOutliningForLeadingCommentsForNode(n); } From 4971e3152c2ba1d5256c986b936322aeb22be436 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Wed, 9 Aug 2017 10:14:52 -0700 Subject: [PATCH 014/216] Ensure region boundaries are entire line --- src/services/outliningElementsCollector.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index cad56fe1ced..7c4bf24d580 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -8,8 +8,8 @@ namespace ts.OutliningElementsCollector { let depth = 0; const regions: RegionRange[] = []; const regionText = "#region"; - const regionStart = new RegExp("//\\s*#region(\\s+.*)?$", "gm"); - const regionEnd = new RegExp("//\\s*#endregion(\\s|$)", "gm"); + const regionStart = new RegExp("^\\s*//\\s*#region(\\s+.*)?$", "gm"); + const regionEnd = new RegExp("^\\s*//\\s*#endregion(\\s|$)", "gm"); walk(sourceFile); gatherRegions(); From 562d988614e967910f06da72ce9d0f57c7c8a39a Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 21 Aug 2017 11:19:21 -0700 Subject: [PATCH 015/216] Exclude region delimiters in multiline comments --- src/services/outliningElementsCollector.ts | 41 ++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 7c4bf24d580..82ac22e644c 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -107,26 +107,28 @@ namespace ts.OutliningElementsCollector { } function isRegionStart(start: number, end: number) { - const comment = sourceFile.text.substring(start, end); - const result = comment.match(regionStart); + if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { + const comment = sourceFile.text.substring(start, end); + const result = comment.match(regionStart); - if (result && result.length > 0) { - const sections = result[0].split(" ").filter(function (s) { return s !== ""; }); + if (result && result.length > 0) { + const sections = result[0].split(" ").filter(function (s) { return s !== ""; }); - if (sections[0] === "//") { - if (sections.length > 2) { - return result[0].substring(result[0].indexOf(sections[2])); + if (sections[0] === "//") { + if (sections.length > 2) { + return result[0].substring(result[0].indexOf(sections[2])); + } + else { + return regionText; + } } else { - return regionText; - } - } - else { - if (sections.length > 1) { - return result[0].substring(result[0].indexOf(sections[1])); - } - else { - return regionText; + if (sections.length > 1) { + return result[0].substring(result[0].indexOf(sections[1])); + } + else { + return regionText; + } } } } @@ -134,8 +136,11 @@ namespace ts.OutliningElementsCollector { } function isRegionEnd(start: number, end: number) { - const comment = sourceFile.text.substring(start, end); - return comment.match(regionEnd); + if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { + const comment = sourceFile.text.substring(start, end); + return comment.match(regionEnd); + } + return undefined; } function gatherRegions(): void { From fb462c91a4a4089a05eeb83a3d6b5333d4385c2d Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 21 Aug 2017 15:28:40 -0700 Subject: [PATCH 016/216] Ensure returned spans are ordered by start --- src/services/outliningElementsCollector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 82ac22e644c..59f8e9f5549 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -13,7 +13,7 @@ namespace ts.OutliningElementsCollector { walk(sourceFile); gatherRegions(); - return elements; + return elements.sort((span1, span2) => span1.textSpan.start - span2.textSpan.start); /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean, useFullStart: boolean) { From 442bc56fc2b1a4ba862cd33895f3185dafc85044 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 21 Aug 2017 15:39:58 -0700 Subject: [PATCH 017/216] Add test for region spans --- .../fourslash/getOutliningSpansForRegions.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/cases/fourslash/getOutliningSpansForRegions.ts diff --git a/tests/cases/fourslash/getOutliningSpansForRegions.ts b/tests/cases/fourslash/getOutliningSpansForRegions.ts new file mode 100644 index 00000000000..73202fb9c9c --- /dev/null +++ b/tests/cases/fourslash/getOutliningSpansForRegions.ts @@ -0,0 +1,46 @@ +/// + +////// basic region +////[|// #region +//// +////// #endregion|] +//// +////// region with label +////[|// #region label1 +//// +////// #endregion|] +//// +////// region with extra whitespace in all valid locations +////[| // #region label2 label3 +//// +//// // #endregion|] +//// +////// No space before directive +////[|//#region label4 +//// +//////#endregion|] +//// +////// Nested regions +////[|// #region outer +//// +////[|// #region inner +//// +////// #endregion inner|] +//// +////// #endregion outer|] +//// +////// region delimiters not valid when preceding text on line +//// test // #region invalid1 +//// +////test // #endregion +//// +////// region delimiters not valid when in multiline comment +/////* +////// #region invalid2 +////*/ +//// +/////* +////// #endregion +////*/ + +verify.outliningSpansInCurrentFile(test.ranges()); \ No newline at end of file From 509d347ab9c922daec779ef6c7c64b841d2e3201 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 22 Aug 2017 12:59:47 -0700 Subject: [PATCH 018/216] Region now starts at beginning of comment, and reviewer edits --- src/services/outliningElementsCollector.ts | 42 ++++++++----------- .../fourslash/getOutliningSpansForRegions.ts | 2 +- ...getOutliningSpansForUnbalancedEndRegion.ts | 10 +++++ .../getOutliningSpansForUnbalancedRegion.ts | 11 +++++ 4 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts create mode 100644 tests/cases/fourslash/getOutliningSpansForUnbalancedRegion.ts diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 59f8e9f5549..748085bd041 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -2,14 +2,14 @@ namespace ts.OutliningElementsCollector { const collapseText = "..."; const maxDepth = 20; + const regionText = "#region"; + const regionStart = new RegExp("^\\s*//\\s*#region(\\s+.*)?$"); + const regionEnd = new RegExp("^\\s*//\\s*#endregion(\\s|$)"); export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; let depth = 0; const regions: RegionRange[] = []; - const regionText = "#region"; - const regionStart = new RegExp("^\\s*//\\s*#region(\\s+.*)?$", "gm"); - const regionEnd = new RegExp("^\\s*//\\s*#endregion(\\s|$)", "gm"); walk(sourceFile); gatherRegions(); @@ -42,9 +42,10 @@ namespace ts.OutliningElementsCollector { function addOutliningSpanRegions(regionSpan: RegionRange) { if (regionSpan) { + const textSpan = createTextSpanFromBounds(regionSpan.pos, regionSpan.end); const span: OutliningSpan = { - textSpan: createTextSpanFromBounds(regionSpan.pos, regionSpan.end), - hintSpan: createTextSpanFromBounds(regionSpan.pos, regionSpan.end), + textSpan, + hintSpan: textSpan, bannerText: regionSpan.name, autoCollapse: false, }; @@ -106,29 +107,18 @@ namespace ts.OutliningElementsCollector { return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction; } - function isRegionStart(start: number, end: number) { + function getRegionName(start: number, end: number) { if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { const comment = sourceFile.text.substring(start, end); const result = comment.match(regionStart); if (result && result.length > 0) { - const sections = result[0].split(" ").filter(function (s) { return s !== ""; }); - - if (sections[0] === "//") { - if (sections.length > 2) { - return result[0].substring(result[0].indexOf(sections[2])); - } - else { - return regionText; - } + const label = result.pop(); + if (label) { + return label.trim(); } else { - if (sections.length > 1) { - return result[0].substring(result[0].indexOf(sections[1])); - } - else { - return regionText; - } + return regionText; } } } @@ -146,13 +136,15 @@ namespace ts.OutliningElementsCollector { function gatherRegions(): void { const lineStarts = sourceFile.getLineStarts(); - for (const currentLineStart of lineStarts) { - const lineEnd = sourceFile.getLineEndOfPosition(currentLineStart); + for (let i = 0; i < lineStarts.length; i++) { + const currentLineStart = lineStarts[i]; + const lineEnd = lineStarts[i + 1] - 1 || sourceFile.getEnd(); - const name = isRegionStart(currentLineStart, lineEnd); + const name = getRegionName(currentLineStart, lineEnd); if (name) { + const start = sourceFile.getFullText().indexOf("//", currentLineStart); const region: RegionRange = { - pos: currentLineStart, + pos: start, end: lineEnd, name, }; diff --git a/tests/cases/fourslash/getOutliningSpansForRegions.ts b/tests/cases/fourslash/getOutliningSpansForRegions.ts index 73202fb9c9c..80e1c3113cf 100644 --- a/tests/cases/fourslash/getOutliningSpansForRegions.ts +++ b/tests/cases/fourslash/getOutliningSpansForRegions.ts @@ -11,7 +11,7 @@ ////// #endregion|] //// ////// region with extra whitespace in all valid locations -////[| // #region label2 label3 +//// [|// #region label2 label3 //// //// // #endregion|] //// diff --git a/tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts b/tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts new file mode 100644 index 00000000000..c15e23eba75 --- /dev/null +++ b/tests/cases/fourslash/getOutliningSpansForUnbalancedEndRegion.ts @@ -0,0 +1,10 @@ +/// + +////// bottom-heavy region balance +////[|// #region matched +//// +////// #endregion matched|] +//// +////// #endregion unmatched + +verify.outliningSpansInCurrentFile(test.ranges()); \ No newline at end of file diff --git a/tests/cases/fourslash/getOutliningSpansForUnbalancedRegion.ts b/tests/cases/fourslash/getOutliningSpansForUnbalancedRegion.ts new file mode 100644 index 00000000000..f50aae713a5 --- /dev/null +++ b/tests/cases/fourslash/getOutliningSpansForUnbalancedRegion.ts @@ -0,0 +1,11 @@ +/// + +////// top-heavy region balance +////// #region unmatched +//// +////[|// #region matched +//// +////// #endregion matched|] + +debugger; +verify.outliningSpansInCurrentFile(test.ranges()); \ No newline at end of file From c3f2648ba4d851ed9ab2dec9ded1ced7fbf144a9 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Tue, 22 Aug 2017 13:59:02 -0700 Subject: [PATCH 019/216] Edits from aozgaa review and simplify regex --- src/services/outliningElementsCollector.ts | 22 +++++++++---------- .../fourslash/getOutliningSpansForRegions.ts | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 748085bd041..d4f70d52eda 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -2,9 +2,9 @@ namespace ts.OutliningElementsCollector { const collapseText = "..."; const maxDepth = 20; - const regionText = "#region"; - const regionStart = new RegExp("^\\s*//\\s*#region(\\s+.*)?$"); - const regionEnd = new RegExp("^\\s*//\\s*#endregion(\\s|$)"); + const defaultLabel = "#region"; + const regionStart = new RegExp("^//\\s*#region(\\s+.*)?$"); + const regionEnd = new RegExp("^//\\s*#endregion(\\s|$)"); export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; @@ -42,7 +42,7 @@ namespace ts.OutliningElementsCollector { function addOutliningSpanRegions(regionSpan: RegionRange) { if (regionSpan) { - const textSpan = createTextSpanFromBounds(regionSpan.pos, regionSpan.end); + const textSpan = createTextSpanFromRange(regionSpan); const span: OutliningSpan = { textSpan, hintSpan: textSpan, @@ -108,8 +108,8 @@ namespace ts.OutliningElementsCollector { } function getRegionName(start: number, end: number) { - if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { - const comment = sourceFile.text.substring(start, end); + if (!isInComment(sourceFile, start)) { + const comment = sourceFile.text.substring(start, end).trim(); const result = comment.match(regionStart); if (result && result.length > 0) { @@ -118,7 +118,7 @@ namespace ts.OutliningElementsCollector { return label.trim(); } else { - return regionText; + return defaultLabel; } } } @@ -126,11 +126,11 @@ namespace ts.OutliningElementsCollector { } function isRegionEnd(start: number, end: number) { - if (!ts.formatting.getRangeOfEnclosingComment(sourceFile, start, /*onlyMultiLine*/ true)) { - const comment = sourceFile.text.substring(start, end); - return comment.match(regionEnd); + if (!isInComment(sourceFile, start)) { + const comment = sourceFile.text.substring(start, end).trim(); + return !!comment.match(regionEnd); } - return undefined; + return false; } function gatherRegions(): void { diff --git a/tests/cases/fourslash/getOutliningSpansForRegions.ts b/tests/cases/fourslash/getOutliningSpansForRegions.ts index 80e1c3113cf..151526c6b99 100644 --- a/tests/cases/fourslash/getOutliningSpansForRegions.ts +++ b/tests/cases/fourslash/getOutliningSpansForRegions.ts @@ -1,6 +1,6 @@ /// -////// basic region +////// region without label ////[|// #region //// ////// #endregion|] @@ -29,7 +29,7 @@ //// ////// #endregion outer|] //// -////// region delimiters not valid when preceding text on line +////// region delimiters not valid when there is preceding text on line //// test // #region invalid1 //// ////test // #endregion From 67f27161564beee44fb8665254bb35248a1d7dda Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 28 Aug 2017 13:32:20 -0700 Subject: [PATCH 020/216] Detect bad plugins and work around them --- src/server/project.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/server/project.ts b/src/server/project.ts index 623c43e8d3a..4fb5ef78d75 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -999,16 +999,22 @@ namespace ts.server { if (this.projectService.globalPlugins) { // Enable global plugins with synthetic configuration entries for (const globalPluginName of this.projectService.globalPlugins) { + // Skip empty names from odd commandline parses + if (!globalPluginName) continue; + // Skip already-locally-loaded plugins if (options.plugins && options.plugins.some(p => p.name === globalPluginName)) continue; // Provide global: true so plugins can detect why they can't find their config + this.projectService.logger.info(`Loading global plugin ${globalPluginName}`); this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths); } } } private enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[]) { + this.projectService.logger.info(`Enabling plugin ${pluginConfigEntry.name} from candidate paths: ${searchPaths.join(",")}`); + const log = (message: string) => { this.projectService.logger.info(message); }; @@ -1020,7 +1026,7 @@ namespace ts.server { return; } } - this.projectService.logger.info(`Couldn't find ${pluginConfigEntry.name} anywhere in paths: ${searchPaths.join(",")}`); + this.projectService.logger.info(`Couldn't find ${pluginConfigEntry.name}`); } private enableProxy(pluginModuleFactory: PluginModuleFactory, configEntry: PluginImport) { @@ -1039,7 +1045,15 @@ namespace ts.server { }; const pluginModule = pluginModuleFactory({ typescript: ts }); - this.languageService = pluginModule.create(info); + const newLS = pluginModule.create(info); + for (const k of Object.keys(this.languageService)) { + if (!(k in newLS)) { + this.projectService.logger.info(`Plugin activation warning: Missing proxied method ${k} in created LS. Patching.`); + (newLS as any)[k] = (this.languageService as any)[k]; + } + } + this.projectService.logger.info(`Plugin validation succeded`); + this.languageService = newLS; this.plugins.push(pluginModule); } catch (e) { From 2c028ae3e521a940e6abd8a663b3e9101e44f145 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Mon, 28 Aug 2017 23:14:19 +0100 Subject: [PATCH 021/216] Generalise empty object literal property access fix to all object literals --- src/compiler/factory.ts | 6 +- .../reference/assignmentTypeNarrowing.js | 8 +- .../reference/asyncMethodWithSuper_es5.js | 4 +- .../computedPropertiesInDestructuring1.js | 12 +- .../contextuallyTypedBindingInitializer.js | 2 +- ...extuallyTypedBindingInitializerNegative.js | 2 +- .../controlFlowDestructuringDeclaration.js | 12 +- ...onEmitDestructuringObjectLiteralPattern.js | 8 +- ...nEmitDestructuringObjectLiteralPattern1.js | 8 +- .../reference/declarationsAndAssignments.js | 8 +- ...ngObjectBindingPatternAndAssignment1ES5.js | 10 +- ...uringObjectBindingPatternAndAssignment3.js | 10 +- .../destructuringVariableDeclaration1ES5.js | 10 +- ...ucturingVariableDeclaration1ES5iterable.js | 10 +- .../destructuringVariableDeclaration2.js | 2 +- .../reference/downlevelLetConst12.js | 4 +- .../reference/downlevelLetConst13.js | 8 +- .../reference/downlevelLetConst14.js | 8 +- .../reference/downlevelLetConst15.js | 8 +- .../reference/downlevelLetConst16.js | 28 +- ...jectLiteralExpressionInArrowFunctionES5.js | 4 +- ...jectLiteralExpressionInArrowFunctionES6.js | 4 +- .../emitArrowFunctionWhenUsingArguments17.js | 2 +- .../emitArrowFunctionWhenUsingArguments18.js | 2 +- .../initializePropertiesWithRenamedLet.js | 8 +- .../baselines/reference/letInNonStrictMode.js | 2 +- .../literalTypesAndTypeAssertions.js | 8 +- .../reference/missingAndExcessProperties.js | 8 +- ...oImplicitAnyDestructuringVarDeclaration.js | 2 +- ...ImplicitAnyDestructuringVarDeclaration2.js | 2 +- ...bjectBindingPatternKeywordIdentifiers01.js | 2 +- ...bjectBindingPatternKeywordIdentifiers03.js | 2 +- ...bjectBindingPatternKeywordIdentifiers05.js | 2 +- ...bjectBindingPatternKeywordIdentifiers06.js | 2 +- .../shadowingViaLocalValueOrBindingElement.js | 8 +- ...thandPropertyAssignmentsInDestructuring.js | 12 +- ...ionDestructuringForObjectBindingPattern.js | 4 +- ...estructuringForObjectBindingPattern.js.map | 2 +- ...uringForObjectBindingPattern.sourcemap.txt | 200 +++++++------- ...ingForObjectBindingPatternDefaultValues.js | 4 +- ...orObjectBindingPatternDefaultValues.js.map | 2 +- ...tBindingPatternDefaultValues.sourcemap.txt | 258 +++++++++--------- ...gVariableStatementObjectBindingPattern1.js | 2 +- ...iableStatementObjectBindingPattern1.js.map | 2 +- ...atementObjectBindingPattern1.sourcemap.txt | 14 +- ...gVariableStatementObjectBindingPattern2.js | 2 +- ...iableStatementObjectBindingPattern2.js.map | 2 +- ...atementObjectBindingPattern2.sourcemap.txt | 14 +- ...gVariableStatementObjectBindingPattern3.js | 2 +- ...iableStatementObjectBindingPattern3.js.map | 2 +- ...atementObjectBindingPattern3.sourcemap.txt | 26 +- .../strictModeReservedWordInDestructuring.js | 2 +- .../strictModeUseContextualKeyword.js | 2 +- .../templateStringInObjectLiteral.js | 4 +- 54 files changed, 391 insertions(+), 391 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 7a20a6d8a41..0c863b38ca3 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3816,13 +3816,13 @@ namespace ts { // NewExpression: // new C.x -> not the same as (new C).x // - // EmptyObjectLiteral: - // {}.toString() -> is incorrect syntax, should be ({}).x + // ObjectLiteral: + // {a:1}.toString() -> is incorrect syntax, should be ({a:3}).toString() // const emittedExpression = skipPartiallyEmittedExpressions(expression); if (isLeftHandSideExpression(emittedExpression) && (!isNewExpression(emittedExpression) || (emittedExpression).arguments) - && !isEmptyObjectLiteral(emittedExpression)) { + && !isObjectLiteralExpression(emittedExpression)) { return expression; } diff --git a/tests/baselines/reference/assignmentTypeNarrowing.js b/tests/baselines/reference/assignmentTypeNarrowing.js index 92fd49d9941..7c85e7dccf6 100644 --- a/tests/baselines/reference/assignmentTypeNarrowing.js +++ b/tests/baselines/reference/assignmentTypeNarrowing.js @@ -37,13 +37,13 @@ x = [true][0]; x; // boolean _a = [1][0], x = _a === void 0 ? "" : _a; x; // string | number -(x = { x: true }.x); +(x = ({ x: true }).x); x; // boolean -(x = { y: 1 }.y); +(x = ({ y: 1 }).y); x; // number -(_b = { x: true }.x, x = _b === void 0 ? "" : _b); +(_b = ({ x: true }).x, x = _b === void 0 ? "" : _b); x; // string | boolean -(_c = { y: 1 }.y, x = _c === void 0 ? /a/ : _c); +(_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++) { diff --git a/tests/baselines/reference/asyncMethodWithSuper_es5.js b/tests/baselines/reference/asyncMethodWithSuper_es5.js index a2931b9f8e1..0dbeedabe52 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es5.js +++ b/tests/baselines/reference/asyncMethodWithSuper_es5.js @@ -95,9 +95,9 @@ var B = /** @class */ (function (_super) { // element access (assign) _super.prototype["x"] = f; // destructuring assign with property access - (_super.prototype.x = { f: f }.f); + (_super.prototype.x = ({ f: f }).f); // destructuring assign with element access - (_super.prototype["x"] = { f: f }.f); + (_super.prototype["x"] = ({ f: f }).f); return [2 /*return*/]; }); }); diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1.js b/tests/baselines/reference/computedPropertiesInDestructuring1.js index e4f15e6b8bf..39d411fb851 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1.js +++ b/tests/baselines/reference/computedPropertiesInDestructuring1.js @@ -40,10 +40,10 @@ let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; //// [computedPropertiesInDestructuring1.js] // destructuring in variable declarations var foo = "bar"; -var _a = foo, bar = { bar: "bar" }[_a]; -var bar2 = { bar: "bar" }["bar"]; +var _a = foo, bar = ({ bar: "bar" })[_a]; +var bar2 = ({ bar: "bar" })["bar"]; var foo2 = function () { return "bar"; }; -var _b = foo2(), bar3 = { bar: "bar" }[_b]; +var _b = foo2(), bar3 = ({ bar: "bar" })[_b]; var _c = foo, bar4 = [{ bar: "bar" }][0][_c]; var _d = foo2(), bar5 = [{ bar: "bar" }][0][_d]; function f1(_a) { @@ -65,9 +65,9 @@ function f5(_a) { var _e = foo(), bar6 = [{ bar: "bar" }][0][_e]; var _f = foo.toExponential(), bar7 = [{ bar: "bar" }][0][_f]; // destructuring assignment -(_g = foo, bar = { bar: "bar" }[_g]); -(bar2 = { bar: "bar" }["bar"]); -(_h = foo2(), bar3 = { bar: "bar" }[_h]); +(_g = foo, bar = ({ bar: "bar" })[_g]); +(bar2 = ({ bar: "bar" })["bar"]); +(_h = foo2(), bar3 = ({ bar: "bar" })[_h]); _j = foo, bar4 = [{ bar: "bar" }][0][_j]; _k = foo2(), bar5 = [{ bar: "bar" }][0][_k]; _l = foo(), bar4 = [{ bar: "bar" }][0][_l]; diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.js b/tests/baselines/reference/contextuallyTypedBindingInitializer.js index 6542e747edc..3b4956cb336 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializer.js +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.js @@ -48,4 +48,4 @@ function g(_a) { function h(_a) { var _b = _a.prop, prop = _b === void 0 ? "foo" : _b; } -var _a = { stringIdentity: function (x) { return x; } }.stringIdentity, id = _a === void 0 ? function (arg) { return arg; } : _a; +var _a = ({ stringIdentity: function (x) { return x; } }).stringIdentity, id = _a === void 0 ? function (arg) { return arg; } : _a; diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js index bdc7ed68b3f..a2d7ba8b1aa 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js @@ -40,7 +40,7 @@ function f3(_a) { function ff(_a) { var _b = _a.nested, nestedRename = _b === void 0 ? { show: function (v) { return v; } } : _b; } -var _a = { stringIdentity: function (x) { return x; } }.stringIdentity, id = _a === void 0 ? function (arg) { return arg.length; } : _a; +var _a = ({ stringIdentity: function (x) { return x; } }).stringIdentity, id = _a === void 0 ? function (arg) { return arg.length; } : _a; function g(_a) { var _b = _a.prop, prop = _b === void 0 ? [101, 1234] : _b; } diff --git a/tests/baselines/reference/controlFlowDestructuringDeclaration.js b/tests/baselines/reference/controlFlowDestructuringDeclaration.js index 2e007f2cad8..a26899849be 100644 --- a/tests/baselines/reference/controlFlowDestructuringDeclaration.js +++ b/tests/baselines/reference/controlFlowDestructuringDeclaration.js @@ -82,19 +82,19 @@ function f3() { z; } function f4() { - var x = { x: 1 }.x; + var x = ({ x: 1 }).x; x; - var y = { y: "" }.y; + var y = ({ y: "" }).y; y; - var _a = { z: undefined }.z, z = _a === void 0 ? "" : _a; + var _a = ({ z: undefined }).z, z = _a === void 0 ? "" : _a; z; } function f5() { - var x = { x: 1 }.x; + var x = ({ x: 1 }).x; x; - var y = { y: "" }.y; + var y = ({ y: "" }).y; y; - var _a = { z: undefined }.z, z = _a === void 0 ? "" : _a; + var _a = ({ z: undefined }).z, z = _a === void 0 ? "" : _a; z; } function f6() { diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js index 0414017b776..ef82e607758 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js @@ -23,11 +23,11 @@ module m { //// [declarationEmitDestructuringObjectLiteralPattern.js] var _a = { x: 5, y: "hello" }; -var x4 = { x4: 5, y4: "hello" }.x4; -var y5 = { x5: 5, y5: "hello" }.y5; +var x4 = ({ x4: 5, y4: "hello" }).x4; +var y5 = ({ x5: 5, y5: "hello" }).y5; var _b = { x6: 5, y6: "hello" }, x6 = _b.x6, y6 = _b.y6; -var a1 = { x7: 5, y7: "hello" }.x7; -var b1 = { x8: 5, y8: "hello" }.y8; +var a1 = ({ x7: 5, y7: "hello" }).x7; +var b1 = ({ x8: 5, y8: "hello" }).y8; var _c = { x9: 5, y9: "hello" }, a2 = _c.x9, b2 = _c.y9; var _d = { a: 1, b: { a: "hello", b: { a: true } } }, x11 = _d.a, _e = _d.b, y11 = _e.a, z11 = _e.b.a; function f15() { diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js index 1e8279597d5..974dc8cc24d 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js @@ -9,11 +9,11 @@ var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; //// [declarationEmitDestructuringObjectLiteralPattern1.js] var _a = { x: 5, y: "hello" }; -var x4 = { x4: 5, y4: "hello" }.x4; -var y5 = { x5: 5, y5: "hello" }.y5; +var x4 = ({ x4: 5, y4: "hello" }).x4; +var y5 = ({ x5: 5, y5: "hello" }).y5; var _b = { x6: 5, y6: "hello" }, x6 = _b.x6, y6 = _b.y6; -var a1 = { x7: 5, y7: "hello" }.x7; -var b1 = { x8: 5, y8: "hello" }.y8; +var a1 = ({ x7: 5, y7: "hello" }).x7; +var b1 = ({ x8: 5, y8: "hello" }).y8; var _c = { x9: 5, y9: "hello" }, a2 = _c.x9, b2 = _c.y9; diff --git a/tests/baselines/reference/declarationsAndAssignments.js b/tests/baselines/reference/declarationsAndAssignments.js index 3a2f9ef3b4e..d338b454b8b 100644 --- a/tests/baselines/reference/declarationsAndAssignments.js +++ b/tests/baselines/reference/declarationsAndAssignments.js @@ -201,13 +201,13 @@ function f1() { } function f2() { var _a = { x: 5, y: "hello" }; // Error, no x and y in target - var x = { x: 5, y: "hello" }.x; // Error, no y in target - var y = { x: 5, y: "hello" }.y; // Error, no x in target + var x = ({ x: 5, y: "hello" }).x; // Error, no y in target + var y = ({ x: 5, y: "hello" }).y; // Error, no x in target var _b = { x: 5, y: "hello" }, x = _b.x, y = _b.y; var x; var y; - var a = { x: 5, y: "hello" }.x; // Error, no y in target - var b = { x: 5, y: "hello" }.y; // Error, no x in target + var a = ({ x: 5, y: "hello" }).x; // Error, no y in target + var b = ({ x: 5, y: "hello" }).y; // Error, no x in target var _c = { x: 5, y: "hello" }, a = _c.x, b = _c.y; var a; var b; diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js index 21889807f6f..dee603bd47f 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js @@ -64,11 +64,11 @@ var a2 = ({}).a2; // V is an object assignment pattern and, for each assignment property P in V, // S has an apparent property with the property name specified in // P of a type that is assignable to the target given in P, or -var b1 = { b1: 1 }.b1; -var _a = { b2: { b21: "world" } }.b2, b21 = (_a === void 0 ? { b21: "string" } : _a).b21; -var b3 = { 1: "string" }[1]; -var _b = { b4: 100000 }.b4, b4 = _b === void 0 ? 1 : _b; -var b52 = { b5: { b52: b52 } }.b5.b52; +var b1 = ({ b1: 1 }).b1; +var _a = ({ b2: { b21: "world" } }).b2, b21 = (_a === void 0 ? { b21: "string" } : _a).b21; +var b3 = ({ 1: "string" })[1]; +var _b = ({ b4: 100000 }).b4, b4 = _b === void 0 ? 1 : _b; +var b52 = ({ b5: { b52: b52 } }).b5.b52; function foo() { return { 1: true diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js index 0872a71c73b..bec23431d98 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js @@ -10,9 +10,9 @@ var {"prop"} = { "prop": 1 }; //// [destructuringObjectBindingPatternAndAssignment3.js] // Error -var h = { h: 1 }.h; -var i = { i: 2 }.i; -var i1 = { i1: 2 }.i1; +var h = ({ h: 1 }).h; +var i = ({ i: 2 }).i; +var i1 = ({ i1: 2 }).i1; var _a = undefined.f2, f21 = (_a === void 0 ? { f212: "string" } : _a).f21; -var = { 1: }[1]; -var = { "prop": 1 }["prop"]; +var = ({ 1: })[1]; +var = ({ "prop": 1 })["prop"]; diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.js b/tests/baselines/reference/destructuringVariableDeclaration1ES5.js index 6d731538d18..d627a87a986 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.js +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.js @@ -48,7 +48,7 @@ var _a = { a1: 10, a2: "world" }, a1 = _a.a1, a2 = _a.a2; var _b = [1, [["hello"]], true], a3 = _b[0], a4 = _b[1][0][0], a5 = _b[2]; // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. -var _c = { b1: { b11: "world" } }.b1, b11 = (_c === void 0 ? { b11: "string" } : _c).b11; +var _c = ({ b1: { b11: "world" } }).b1, b11 = (_c === void 0 ? { b11: "string" } : _c).b11; var temp = { t1: true, t2: "false" }; var _d = [3, false, { t1: false, t2: "hello" }], _e = _d[0], b2 = _e === void 0 ? 3 : _e, _f = _d[1], b3 = _f === void 0 ? true : _f, _g = _d[2], b4 = _g === void 0 ? temp : _g; var _h = [undefined, undefined, undefined], _j = _h[0], b5 = _j === void 0 ? 3 : _j, _k = _h[1], b6 = _k === void 0 ? true : _k, _l = _h[2], b7 = _l === void 0 ? temp : _l; @@ -68,10 +68,10 @@ var _m = [1, "string"], d1 = _m[0], d2 = _m[1]; var temp1 = [true, false, true]; var _o = [1, "string"].concat(temp1), d3 = _o[0], d4 = _o[1]; // Combining both forms of destructuring, -var _p = { e: [1, 2, { b1: 4, b4: 0 }] }.e, e1 = _p[0], e2 = _p[1], _q = _p[2], e3 = _q === void 0 ? { b1: 1000, b4: 200 } : _q; -var _r = { f: [1, 2, { f3: 4, f5: 0 }] }.f, f1 = _r[0], f2 = _r[1], _s = _r[2], f4 = _s.f3, f5 = _s.f5; +var _p = ({ e: [1, 2, { b1: 4, b4: 0 }] }).e, e1 = _p[0], e2 = _p[1], _q = _p[2], e3 = _q === void 0 ? { b1: 1000, b4: 200 } : _q; +var _r = ({ f: [1, 2, { f3: 4, f5: 0 }] }).f, f1 = _r[0], f2 = _r[1], _s = _r[2], f4 = _s.f3, f5 = _s.f5; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. -var _t = { g: { g1: [1, 2] } }.g.g1, g1 = _t === void 0 ? [undefined, null] : _t; -var _u = { h: { h1: [1, 2] } }.h.h1, h1 = _u === void 0 ? [undefined, null] : _u; +var _t = ({ g: { g1: [1, 2] } }).g.g1, g1 = _t === void 0 ? [undefined, null] : _t; +var _u = ({ h: { h1: [1, 2] } }).h.h1, h1 = _u === void 0 ? [undefined, null] : _u; diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js index 83fb3de04fc..b59c7e1249b 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js @@ -68,7 +68,7 @@ var _a = { a1: 10, a2: "world" }, a1 = _a.a1, a2 = _a.a2; var _b = __read([1, [["hello"]], true], 3), a3 = _b[0], _c = __read(_b[1], 1), _d = __read(_c[0], 1), a4 = _d[0], a5 = _b[2]; // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. -var _e = { b1: { b11: "world" } }.b1, b11 = (_e === void 0 ? { b11: "string" } : _e).b11; +var _e = ({ b1: { b11: "world" } }).b1, b11 = (_e === void 0 ? { b11: "string" } : _e).b11; var temp = { t1: true, t2: "false" }; var _f = __read([3, false, { t1: false, t2: "hello" }], 3), _g = _f[0], b2 = _g === void 0 ? 3 : _g, _h = _f[1], b3 = _h === void 0 ? true : _h, _j = _f[2], b4 = _j === void 0 ? temp : _j; var _k = __read([undefined, undefined, undefined], 3), _l = _k[0], b5 = _l === void 0 ? 3 : _l, _m = _k[1], b6 = _m === void 0 ? true : _m, _o = _k[2], b7 = _o === void 0 ? temp : _o; @@ -88,10 +88,10 @@ var _r = __read([1, "string"], 2), d1 = _r[0], d2 = _r[1]; var temp1 = [true, false, true]; var _s = __read(__spread([1, "string"], temp1), 2), d3 = _s[0], d4 = _s[1]; // Combining both forms of destructuring, -var _t = __read({ e: [1, 2, { b1: 4, b4: 0 }] }.e, 3), e1 = _t[0], e2 = _t[1], _u = _t[2], e3 = _u === void 0 ? { b1: 1000, b4: 200 } : _u; -var _v = __read({ f: [1, 2, { f3: 4, f5: 0 }] }.f, 4), f1 = _v[0], f2 = _v[1], _w = _v[2], f4 = _w.f3, f5 = _w.f5; +var _t = __read(({ e: [1, 2, { b1: 4, b4: 0 }] }).e, 3), e1 = _t[0], e2 = _t[1], _u = _t[2], e3 = _u === void 0 ? { b1: 1000, b4: 200 } : _u; +var _v = __read(({ f: [1, 2, { f3: 4, f5: 0 }] }).f, 4), f1 = _v[0], f2 = _v[1], _w = _v[2], f4 = _w.f3, f5 = _w.f5; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. -var _x = { g: { g1: [1, 2] } }.g.g1, g1 = _x === void 0 ? [undefined, null] : _x; -var _y = { h: { h1: [1, 2] } }.h.h1, h1 = _y === void 0 ? [undefined, null] : _y; +var _x = ({ g: { g1: [1, 2] } }).g.g1, g1 = _x === void 0 ? [undefined, null] : _x; +var _y = ({ h: { h1: [1, 2] } }).h.h1, h1 = _y === void 0 ? [undefined, null] : _y; diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.js b/tests/baselines/reference/destructuringVariableDeclaration2.js index a4fadd850d7..b3d4152892a 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration2.js +++ b/tests/baselines/reference/destructuringVariableDeclaration2.js @@ -35,4 +35,4 @@ var _g = [1, 2, { c3: 4, c5: 0 }], c1 = _g[0], c2 = _g[1], _h = _g[2], c4 = _h.c // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. -var _j = { d: { d1: [1, 2] } }.d.d1, d1 = _j === void 0 ? ["string", null] : _j; // Error +var _j = ({ d: { d1: [1, 2] } }).d.d1, d1 = _j === void 0 ? ["string", null] : _j; // Error diff --git a/tests/baselines/reference/downlevelLetConst12.js b/tests/baselines/reference/downlevelLetConst12.js index bdc33aaba9d..3ab90cee98d 100644 --- a/tests/baselines/reference/downlevelLetConst12.js +++ b/tests/baselines/reference/downlevelLetConst12.js @@ -16,6 +16,6 @@ const {a: baz4} = { a: 1 }; var foo; var bar = 1; var baz = [][0]; -var baz2 = { a: 1 }.a; +var baz2 = ({ a: 1 }).a; var baz3 = [][0]; -var baz4 = { a: 1 }.a; +var baz4 = ({ a: 1 }).a; diff --git a/tests/baselines/reference/downlevelLetConst13.js b/tests/baselines/reference/downlevelLetConst13.js index 251468519ad..64d169c4013 100644 --- a/tests/baselines/reference/downlevelLetConst13.js +++ b/tests/baselines/reference/downlevelLetConst13.js @@ -26,14 +26,14 @@ exports.foo = 10; exports.bar = "123"; exports.bar1 = [1][0]; exports.bar2 = [2][0]; -exports.bar3 = { a: 1 }.a; -exports.bar4 = { a: 1 }.a; +exports.bar3 = ({ a: 1 }).a; +exports.bar4 = ({ a: 1 }).a; var M; (function (M) { M.baz = 100; M.baz2 = true; M.bar5 = [1][0]; M.bar6 = [2][0]; - M.bar7 = { a: 1 }.a; - M.bar8 = { a: 1 }.a; + M.bar7 = ({ a: 1 }).a; + M.bar8 = ({ a: 1 }).a; })(M = exports.M || (exports.M = {})); diff --git a/tests/baselines/reference/downlevelLetConst14.js b/tests/baselines/reference/downlevelLetConst14.js index cddfb967217..0d671dbaaa7 100644 --- a/tests/baselines/reference/downlevelLetConst14.js +++ b/tests/baselines/reference/downlevelLetConst14.js @@ -65,9 +65,9 @@ var z0, z1, z2, z3; use(z0_1); var z1_1 = [1][0]; use(z1_1); - var z2_1 = { a: 1 }.a; + var z2_1 = ({ a: 1 }).a; use(z2_1); - var z3_1 = { a: 1 }.a; + var z3_1 = ({ a: 1 }).a; use(z3_1); } use(x); @@ -82,7 +82,7 @@ var y = true; var z6_1 = [true][0]; { var y_2 = 1; - var z6_2 = { a: 1 }.a; + var z6_2 = ({ a: 1 }).a; use(y_2); use(z6_2); } @@ -98,7 +98,7 @@ var z5 = 1; var z5_1 = [5][0]; { var _z = 1; - var _z5 = { a: 1 }.a; + var _z5 = ({ a: 1 }).a; // try to step on generated name use(_z); } diff --git a/tests/baselines/reference/downlevelLetConst15.js b/tests/baselines/reference/downlevelLetConst15.js index 807f49bf84e..bd70cfe767c 100644 --- a/tests/baselines/reference/downlevelLetConst15.js +++ b/tests/baselines/reference/downlevelLetConst15.js @@ -65,9 +65,9 @@ var z0, z1, z2, z3; use(z0_1); var z1_1 = [{ a: 1 }][0].a; use(z1_1); - var z2_1 = { a: 1 }.a; + var z2_1 = ({ a: 1 }).a; use(z2_1); - var z3_1 = { a: { b: 1 } }.a.b; + var z3_1 = ({ a: { b: 1 } }).a.b; use(z3_1); } use(x); @@ -82,7 +82,7 @@ var y = true; var z6_1 = [true][0]; { var y_2 = 1; - var z6_2 = { a: 1 }.a; + var z6_2 = ({ a: 1 }).a; use(y_2); use(z6_2); } @@ -98,7 +98,7 @@ var z5 = 1; var z5_1 = [5][0]; { var _z = 1; - var _z5 = { a: 1 }.a; + var _z5 = ({ a: 1 }).a; // try to step on generated name use(_z); } diff --git a/tests/baselines/reference/downlevelLetConst16.js b/tests/baselines/reference/downlevelLetConst16.js index 338489b20c3..0231d98fec2 100644 --- a/tests/baselines/reference/downlevelLetConst16.js +++ b/tests/baselines/reference/downlevelLetConst16.js @@ -240,7 +240,7 @@ function foo1() { use(x); var y = [1][0]; use(y); - var z = { a: 1 }.a; + var z = ({ a: 1 }).a; use(z); } function foo2() { @@ -249,7 +249,7 @@ function foo2() { use(x_1); var y_1 = [1][0]; use(y_1); - var z_1 = { a: 1 }.a; + var z_1 = ({ a: 1 }).a; use(z_1); } use(x); @@ -262,7 +262,7 @@ var A = /** @class */ (function () { use(x); var y = [1][0]; use(y); - var z = { a: 1 }.a; + var z = ({ a: 1 }).a; use(z); }; A.prototype.m2 = function () { @@ -271,7 +271,7 @@ var A = /** @class */ (function () { use(x_2); var y_2 = [1][0]; use(y_2); - var z_2 = { a: 1 }.a; + var z_2 = ({ a: 1 }).a; use(z_2); } use(x); @@ -286,7 +286,7 @@ var B = /** @class */ (function () { use(x); var y = [1][0]; use(y); - var z = { a: 1 }.a; + var z = ({ a: 1 }).a; use(z); }; B.prototype.m2 = function () { @@ -295,7 +295,7 @@ var B = /** @class */ (function () { use(x_3); var y_3 = [1][0]; use(y_3); - var z_3 = { a: 1 }.a; + var z_3 = ({ a: 1 }).a; use(z_3); } use(x); @@ -307,7 +307,7 @@ function bar1() { use(x); var y = [1][0]; use(y); - var z = { a: 1 }.a; + var z = ({ a: 1 }).a; use(z); } function bar2() { @@ -316,7 +316,7 @@ function bar2() { use(x_4); var y_4 = [1][0]; use(y_4); - var z_4 = { a: 1 }.a; + var z_4 = ({ a: 1 }).a; use(z_4); } use(x); @@ -327,7 +327,7 @@ var M1; use(x); var y = [1][0]; use(y); - var z = { a: 1 }.a; + var z = ({ a: 1 }).a; use(z); })(M1 || (M1 = {})); var M2; @@ -337,7 +337,7 @@ var M2; use(x_5); var y_5 = [1][0]; use(y_5); - var z_5 = { a: 1 }.a; + var z_5 = ({ a: 1 }).a; use(z_5); } use(x); @@ -348,7 +348,7 @@ var M3; use(x); var y = [1][0]; use(y); - var z = { a: 1 }.a; + var z = ({ a: 1 }).a; use(z); })(M3 || (M3 = {})); var M4; @@ -358,7 +358,7 @@ var M4; use(x_6); var y_6 = [1][0]; use(y_6); - var z_6 = { a: 1 }.a; + var z_6 = ({ a: 1 }).a; use(z_6); } use(x); @@ -372,7 +372,7 @@ function foo3() { for (var y_7 = [][0];;) { use(y_7); } - for (var z_7 = { a: 1 }.a;;) { + for (var z_7 = ({ a: 1 }).a;;) { use(z_7); } use(x); @@ -384,7 +384,7 @@ function foo4() { for (var y_8 = [][0];;) { use(y_8); } - for (var z_8 = { a: 1 }.a;;) { + for (var z_8 = ({ a: 1 }).a;;) { use(z_8); } use(x); diff --git a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js index 182e678b7bf..5d99dad3c0c 100644 --- a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js +++ b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js @@ -3,5 +3,5 @@ (x) => ({ "1": "one", "2": "two" } as { [key: string]: string }).x; //// [emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js] -(function (x) { return ({ "1": "one", "2": "two" }[x]); }); -(function (x) { return ({ "1": "one", "2": "two" }.x); }); +(function (x) { return ({ "1": "one", "2": "two" })[x]; }); +(function (x) { return ({ "1": "one", "2": "two" }).x; }); diff --git a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js index 8d7999b0da7..dc3891a9bd4 100644 --- a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js +++ b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js @@ -3,5 +3,5 @@ (x) => ({ "1": "one", "2": "two" } as { [key: string]: string }).x; //// [emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js] -(x) => ({ "1": "one", "2": "two" }[x]); -(x) => ({ "1": "one", "2": "two" }.x); +(x) => ({ "1": "one", "2": "two" })[x]; +(x) => ({ "1": "one", "2": "two" }).x; diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17.js b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17.js index 60044ac5dc4..7572b0c3af1 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17.js +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17.js @@ -9,7 +9,7 @@ function f() { //// [emitArrowFunctionWhenUsingArguments17.js] function f() { - var arguments = { arguments: "hello" }.arguments; + var arguments = ({ arguments: "hello" }).arguments; if (Math.random()) { return function () { return arguments[0]; }; } diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18.js b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18.js index a88a01c7a56..3af9c580231 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18.js +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18.js @@ -8,7 +8,7 @@ function f() { //// [emitArrowFunctionWhenUsingArguments18.js] function f() { - var args = { arguments: arguments }.arguments; + var args = ({ arguments: arguments }).arguments; if (Math.random()) { return function () { return arguments; }; } diff --git a/tests/baselines/reference/initializePropertiesWithRenamedLet.js b/tests/baselines/reference/initializePropertiesWithRenamedLet.js index d6c53b7d525..0ed325b2a31 100644 --- a/tests/baselines/reference/initializePropertiesWithRenamedLet.js +++ b/tests/baselines/reference/initializePropertiesWithRenamedLet.js @@ -24,9 +24,9 @@ if (true) { } var x, y, z; if (true) { - var x_1 = { x: 0 }.x; - var y_1 = { y: 0 }.y; + var x_1 = ({ x: 0 }).x; + var y_1 = ({ y: 0 }).y; var z_1; - (z_1 = { z: 0 }.z); - (z_1 = { z: 0 }.z); + (z_1 = ({ z: 0 }).z); + (z_1 = ({ z: 0 }).z); } diff --git a/tests/baselines/reference/letInNonStrictMode.js b/tests/baselines/reference/letInNonStrictMode.js index 8e4920cc220..3627a72e7ff 100644 --- a/tests/baselines/reference/letInNonStrictMode.js +++ b/tests/baselines/reference/letInNonStrictMode.js @@ -4,4 +4,4 @@ let {a: y} = {a: 1}; //// [letInNonStrictMode.js] var x = [1][0]; -var y = { a: 1 }.a; +var y = ({ a: 1 }).a; diff --git a/tests/baselines/reference/literalTypesAndTypeAssertions.js b/tests/baselines/reference/literalTypesAndTypeAssertions.js index ab6a82852a5..6c95fd45802 100644 --- a/tests/baselines/reference/literalTypesAndTypeAssertions.js +++ b/tests/baselines/reference/literalTypesAndTypeAssertions.js @@ -22,7 +22,7 @@ var obj = { }; var x1 = 1; var x2 = 1; -var _a = { a: "foo" }.a, a = _a === void 0 ? "foo" : _a; -var _b = { b: "bar" }.b, b = _b === void 0 ? "foo" : _b; -var _c = { c: "bar" }.c, c = _c === void 0 ? "foo" : _c; -var _d = { d: "bar" }.d, d = _d === void 0 ? "foo" : _d; +var _a = ({ a: "foo" }).a, a = _a === void 0 ? "foo" : _a; +var _b = ({ b: "bar" }).b, b = _b === void 0 ? "foo" : _b; +var _c = ({ c: "bar" }).c, c = _c === void 0 ? "foo" : _c; +var _d = ({ d: "bar" }).d, d = _d === void 0 ? "foo" : _d; diff --git a/tests/baselines/reference/missingAndExcessProperties.js b/tests/baselines/reference/missingAndExcessProperties.js index daefe18eed7..28e0f13b4bd 100644 --- a/tests/baselines/reference/missingAndExcessProperties.js +++ b/tests/baselines/reference/missingAndExcessProperties.js @@ -54,16 +54,16 @@ function f2() { // Excess properties function f3() { var _a = { x: 0, y: 0 }; - var x = { x: 0, y: 0 }.x; - var y = { x: 0, y: 0 }.y; + var x = ({ x: 0, y: 0 }).x; + var y = ({ x: 0, y: 0 }).y; var _b = { x: 0, y: 0 }, x = _b.x, y = _b.y; } // Excess properties function f4() { var x, y; ({ x: 0, y: 0 }); - (x = { x: 0, y: 0 }.x); - (y = { x: 0, y: 0 }.y); + (x = ({ x: 0, y: 0 }).x); + (y = ({ x: 0, y: 0 }).y); (_a = { x: 0, y: 0 }, x = _a.x, y = _a.y); var _a; } diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js index 85358df666e..1dbc933cbf5 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js @@ -16,5 +16,5 @@ var a = (void 0)[0], b = (void 0).b, c, d; // error var _a = (void 0)[0], a1 = _a === void 0 ? undefined : _a, _b = (void 0).b1, b1 = _b === void 0 ? null : _b, c1 = undefined, d1 = null; // error var a2 = (void 0)[0], b2 = (void 0).b2, c2, d2; var b3 = (void 0).b3, c3; // error in type instead -var a4 = [undefined][0], b4 = { b4: null }.b4, c4 = undefined, d4 = null; // error +var a4 = [undefined][0], b4 = ({ b4: null }).b4, c4 = undefined, d4 = null; // error var _c = [][0], a5 = _c === void 0 ? undefined : _c; // error diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js index 79ee0b8830f..81d8ba6386f 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js @@ -22,4 +22,4 @@ var _p = { x: 1, y: 2, z: 3 }, x = _p.x, y = _p.y, z = _p.z; // no error var _q = { x1: 1, y1: 2, z1: 3 }, _r = _q.x1, x1 = _r === void 0 ? 10 : _r, _s = _q.y1, y1 = _s === void 0 ? 10 : _s, _t = _q.z1, z1 = _t === void 0 ? 10 : _t; // no error var _u = { x2: 1, y2: 2, z2: 3 }, _v = _u.x2, x2 = _v === void 0 ? undefined : _v, _w = _u.y2, y2 = _w === void 0 ? undefined : _w, _x = _u.z2, z2 = _x === void 0 ? undefined : _x; // no error var _y = { x3: 1, y3: 2, z3: 3 }, _z = _y.x3, x3 = _z === void 0 ? undefined : _z, _0 = _y.y3, y3 = _0 === void 0 ? null : _0, _1 = _y.z3, z3 = _1 === void 0 ? undefined : _1; // no error -var x4 = { x4: undefined }.x4, y4 = { y4: null }.y4; // no error +var x4 = ({ x4: undefined }).x4, y4 = ({ y4: null }).y4; // no error diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js index ec0cae158fc..2bac381b603 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js @@ -2,4 +2,4 @@ var { while } = { while: 1 } //// [objectBindingPatternKeywordIdentifiers01.js] -var = { "while": 1 }["while"]; +var = ({ "while": 1 })["while"]; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js index 6c9a539bb69..d1fb037dfbe 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js @@ -2,4 +2,4 @@ var { "while" } = { while: 1 } //// [objectBindingPatternKeywordIdentifiers03.js] -var = { "while": 1 }["while"]; +var = ({ "while": 1 })["while"]; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.js index 08f8e632f29..146ac4b2077 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.js @@ -2,4 +2,4 @@ var { as } = { as: 1 } //// [objectBindingPatternKeywordIdentifiers05.js] -var as = { as: 1 }.as; +var as = ({ as: 1 }).as; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.js index 9f29dfff1f8..d465161f4ce 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.js @@ -2,4 +2,4 @@ var { as: as } = { as: 1 } //// [objectBindingPatternKeywordIdentifiers06.js] -var as = { as: 1 }.as; +var as = ({ as: 1 }).as; diff --git a/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js b/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js index e1cae9c73fe..b3c44600d1d 100644 --- a/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js +++ b/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js @@ -15,9 +15,9 @@ if (true) { var x_1; if (true) { var x = 0; // Error - var _a = { x: 0 }.x, x = _a === void 0 ? 0 : _a; // Error - var _b = { x: 0 }.x, x = _b === void 0 ? 0 : _b; // Error - var x = { x: 0 }.x; // Error - var x = { x: 0 }.x; // Error + var _a = ({ x: 0 }).x, x = _a === void 0 ? 0 : _a; // Error + var _b = ({ x: 0 }).x, x = _b === void 0 ? 0 : _b; // Error + var x = ({ x: 0 }).x; // Error + var x = ({ x: 0 }).x; // Error } } diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js index a92f3b6a63d..7e1c7622cf7 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js @@ -174,22 +174,22 @@ function foo({a = 4, b = { x: 5 }}) { }); (function () { var y; - (_a = { y: 1 }.y, y = _a === void 0 ? 5 : _a); + (_a = ({ y: 1 }).y, y = _a === void 0 ? 5 : _a); var _a; }); (function () { var y; - (_a = { y: 1 }.y, y = _a === void 0 ? 5 : _a); + (_a = ({ y: 1 }).y, y = _a === void 0 ? 5 : _a); var _a; }); (function () { var y0; - (_a = { y0: 1 }.y0, y0 = _a === void 0 ? 5 : _a); + (_a = ({ y0: 1 }).y0, y0 = _a === void 0 ? 5 : _a); var _a; }); (function () { var y0; - (_a = { y0: 1 }.y0, y0 = _a === void 0 ? 5 : _a); + (_a = ({ y0: 1 }).y0, y0 = _a === void 0 ? 5 : _a); var _a; }); (function () { @@ -224,12 +224,12 @@ function foo({a = 4, b = { x: 5 }}) { }); (function () { var z; - (_a = { z: { x: 1 } }.z, z = _a === void 0 ? { x: 5 } : _a); + (_a = ({ z: { x: 1 } }).z, z = _a === void 0 ? { x: 5 } : _a); var _a; }); (function () { var z; - (_a = { z: { x: 1 } }.z, z = _a === void 0 ? { x: 5 } : _a); + (_a = ({ z: { x: 1 } }).z, z = _a === void 0 ? { x: 5 } : _a); var _a; }); (function () { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js index ca29b2eabd8..46d9e251439 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js @@ -81,7 +81,7 @@ for (var nameA = robot.name, i = 0; i < 1; i++) { for (var nameA = getRobot().name, i = 0; i < 1; i++) { console.log(nameA); } -for (var nameA = { name: "trimmer", skill: "trimming" }.name, i = 0; i < 1; i++) { +for (var nameA = ({ name: "trimmer", skill: "trimming" }).name, i = 0; i < 1; i++) { console.log(nameA); } for (var _a = multiRobot.skills, primaryA = _a.primary, secondaryA = _a.secondary, i = 0; i < 1; i++) { @@ -90,7 +90,7 @@ for (var _a = multiRobot.skills, primaryA = _a.primary, secondaryA = _a.secondar for (var _b = getMultiRobot().skills, primaryA = _b.primary, secondaryA = _b.secondary, i = 0; i < 1; i++) { console.log(primaryA); } -for (var _c = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }.skills, primaryA = _c.primary, secondaryA = _c.secondary, i = 0; i < 1; i++) { +for (var _c = ({ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }).skills, primaryA = _c.primary, secondaryA = _c.secondary, i = 0; i < 1; i++) { console.log(primaryA); } for (var nameA = robot.name, skillA = robot.skill, i = 0; i < 1; i++) { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js.map b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js.map index a0295550f0b..e0fa0db3b1a 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringForObjectBindingPattern.js.map] -{"version":3,"file":"sourceMapValidationDestructuringForObjectBindingPattern.js","sourceRoot":"","sources":["sourceMapValidationDestructuringForObjectBindingPattern.ts"],"names":[],"mappings":"AAgBA,IAAI,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACtD,IAAI,UAAU,GAAe,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACjG;IACI,MAAM,CAAC,KAAK,CAAC;AACjB,CAAC;AACD;IACI,MAAM,CAAC,UAAU,CAAC;AACtB,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,kBAAW,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,uBAAW,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,mDAAW,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACzF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,sBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,2BAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,qFAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAEzD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,kBAAW,EAAE,oBAAa,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,eAA0C,EAAzC,eAAW,EAAE,iBAAa,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,2CAA6E,EAA5E,eAAW,EAAE,iBAAa,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACxG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,uBAAW,EAAE,sBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC5G,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,oBAAsF,EAArF,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjH,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,8EACgF,EAD/E,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAErE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringForObjectBindingPattern.js","sourceRoot":"","sources":["sourceMapValidationDestructuringForObjectBindingPattern.ts"],"names":[],"mappings":"AAgBA,IAAI,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACtD,IAAI,UAAU,GAAe,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACjG;IACI,MAAM,CAAC,KAAK,CAAC;AACjB,CAAC;AACD;IACI,MAAM,CAAC,UAAU,CAAC;AACtB,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,kBAAW,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,uBAAW,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,qDAAW,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACzF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,sBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,2BAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,uFAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAEzD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,kBAAW,EAAE,oBAAa,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,eAA0C,EAAzC,eAAW,EAAE,iBAAa,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,2CAA6E,EAA5E,eAAW,EAAE,iBAAa,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACxG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,uBAAW,EAAE,sBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC5G,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,oBAAsF,EAArF,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjH,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,8EACgF,EAD/E,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAErE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.sourcemap.txt index 5ea0b7e360d..94cab1030c8 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.sourcemap.txt @@ -396,33 +396,33 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPattern.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(14, 1) Source(31, 1) + SourceIndex(0) 2 >Emitted(14, 2) Source(31, 2) + SourceIndex(0) --- ->>>for (var nameA = { name: "trimmer", skill: "trimming" }.name, i = 0; i < 1; i++) { +>>>for (var nameA = ({ name: "trimmer", skill: "trimming" }).name, i = 0; i < 1; i++) { 1-> 2 >^^^ 3 > ^ 4 > ^ 5 > ^^^^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -7 > ^^ -8 > ^ -9 > ^^^ -10> ^ -11> ^^ -12> ^ -13> ^^^ -14> ^ -15> ^^ -16> ^ -17> ^^ -18> ^^ -19> ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^ +8 > ^ +9 > ^^^ +10> ^ +11> ^^ +12> ^ +13> ^^^ +14> ^ +15> ^^ +16> ^ +17> ^^ +18> ^^ +19> ^ 1-> > 2 >for @@ -430,38 +430,38 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPattern.ts 4 > (let { 5 > 6 > name: nameA -7 > } = { name: "trimmer", skill: "trimming" }, -8 > i -9 > = -10> 0 -11> ; -12> i -13> < -14> 1 -15> ; -16> i -17> ++ -18> ) -19> { +7 > } = { name: "trimmer", skill: "trimming" }, +8 > i +9 > = +10> 0 +11> ; +12> i +13> < +14> 1 +15> ; +16> i +17> ++ +18> ) +19> { 1->Emitted(15, 1) Source(32, 1) + SourceIndex(0) 2 >Emitted(15, 4) Source(32, 4) + SourceIndex(0) 3 >Emitted(15, 5) Source(32, 5) + SourceIndex(0) 4 >Emitted(15, 6) Source(32, 11) + SourceIndex(0) 5 >Emitted(15, 10) Source(32, 11) + SourceIndex(0) -6 >Emitted(15, 61) Source(32, 22) + SourceIndex(0) -7 >Emitted(15, 63) Source(32, 74) + SourceIndex(0) -8 >Emitted(15, 64) Source(32, 75) + SourceIndex(0) -9 >Emitted(15, 67) Source(32, 78) + SourceIndex(0) -10>Emitted(15, 68) Source(32, 79) + SourceIndex(0) -11>Emitted(15, 70) Source(32, 81) + SourceIndex(0) -12>Emitted(15, 71) Source(32, 82) + SourceIndex(0) -13>Emitted(15, 74) Source(32, 85) + SourceIndex(0) -14>Emitted(15, 75) Source(32, 86) + SourceIndex(0) -15>Emitted(15, 77) Source(32, 88) + SourceIndex(0) -16>Emitted(15, 78) Source(32, 89) + SourceIndex(0) -17>Emitted(15, 80) Source(32, 91) + SourceIndex(0) -18>Emitted(15, 82) Source(32, 93) + SourceIndex(0) -19>Emitted(15, 83) Source(32, 94) + SourceIndex(0) +6 >Emitted(15, 63) Source(32, 22) + SourceIndex(0) +7 >Emitted(15, 65) Source(32, 74) + SourceIndex(0) +8 >Emitted(15, 66) Source(32, 75) + SourceIndex(0) +9 >Emitted(15, 69) Source(32, 78) + SourceIndex(0) +10>Emitted(15, 70) Source(32, 79) + SourceIndex(0) +11>Emitted(15, 72) Source(32, 81) + SourceIndex(0) +12>Emitted(15, 73) Source(32, 82) + SourceIndex(0) +13>Emitted(15, 76) Source(32, 85) + SourceIndex(0) +14>Emitted(15, 77) Source(32, 86) + SourceIndex(0) +15>Emitted(15, 79) Source(32, 88) + SourceIndex(0) +16>Emitted(15, 80) Source(32, 89) + SourceIndex(0) +17>Emitted(15, 82) Source(32, 91) + SourceIndex(0) +18>Emitted(15, 84) Source(32, 93) + SourceIndex(0) +19>Emitted(15, 85) Source(32, 94) + SourceIndex(0) --- >>> console.log(nameA); 1 >^^^^ @@ -711,37 +711,37 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPattern.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(23, 1) Source(40, 1) + SourceIndex(0) 2 >Emitted(23, 2) Source(40, 2) + SourceIndex(0) --- ->>>for (var _c = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }.skills, primaryA = _c.primary, secondaryA = _c.secondary, i = 0; i < 1; i++) { +>>>for (var _c = ({ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }).skills, primaryA = _c.primary, secondaryA = _c.secondary, i = 0; i < 1; i++) { 1-> 2 >^^^ 3 > ^ 4 > ^ 5 > ^^^^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -7 > ^^ -8 > ^^^^^^^^^^^^^^^^^^^^^ -9 > ^^ -10> ^^^^^^^^^^^^^^^^^^^^^^^^^ -11> ^^ -12> ^ -13> ^^^ -14> ^ -15> ^^ -16> ^ -17> ^^^ -18> ^ -19> ^^ -20> ^ -21> ^^ -22> ^^ -23> ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^ +8 > ^^^^^^^^^^^^^^^^^^^^^ +9 > ^^ +10> ^^^^^^^^^^^^^^^^^^^^^^^^^ +11> ^^ +12> ^ +13> ^^^ +14> ^ +15> ^^ +16> ^ +17> ^^^ +18> ^ +19> ^^ +20> ^ +21> ^^ +22> ^^ +23> ^ 1-> > 2 >for @@ -749,48 +749,48 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPattern.ts 4 > (let { 5 > 6 > skills: { primary: primaryA, secondary: secondaryA } -7 > -8 > primary: primaryA -9 > , -10> secondary: secondaryA -11> } } = - > { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, - > -12> i -13> = -14> 0 -15> ; -16> i -17> < -18> 1 -19> ; -20> i -21> ++ -22> ) -23> { +7 > +8 > primary: primaryA +9 > , +10> secondary: secondaryA +11> } } = + > { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, + > +12> i +13> = +14> 0 +15> ; +16> i +17> < +18> 1 +19> ; +20> i +21> ++ +22> ) +23> { 1->Emitted(24, 1) Source(41, 1) + SourceIndex(0) 2 >Emitted(24, 4) Source(41, 4) + SourceIndex(0) 3 >Emitted(24, 5) Source(41, 5) + SourceIndex(0) 4 >Emitted(24, 6) Source(41, 12) + SourceIndex(0) 5 >Emitted(24, 10) Source(41, 12) + SourceIndex(0) -6 >Emitted(24, 95) Source(41, 64) + SourceIndex(0) -7 >Emitted(24, 97) Source(41, 22) + SourceIndex(0) -8 >Emitted(24, 118) Source(41, 39) + SourceIndex(0) -9 >Emitted(24, 120) Source(41, 41) + SourceIndex(0) -10>Emitted(24, 145) Source(41, 62) + SourceIndex(0) -11>Emitted(24, 147) Source(43, 5) + SourceIndex(0) -12>Emitted(24, 148) Source(43, 6) + SourceIndex(0) -13>Emitted(24, 151) Source(43, 9) + SourceIndex(0) -14>Emitted(24, 152) Source(43, 10) + SourceIndex(0) -15>Emitted(24, 154) Source(43, 12) + SourceIndex(0) -16>Emitted(24, 155) Source(43, 13) + SourceIndex(0) -17>Emitted(24, 158) Source(43, 16) + SourceIndex(0) -18>Emitted(24, 159) Source(43, 17) + SourceIndex(0) -19>Emitted(24, 161) Source(43, 19) + SourceIndex(0) -20>Emitted(24, 162) Source(43, 20) + SourceIndex(0) -21>Emitted(24, 164) Source(43, 22) + SourceIndex(0) -22>Emitted(24, 166) Source(43, 24) + SourceIndex(0) -23>Emitted(24, 167) Source(43, 25) + SourceIndex(0) +6 >Emitted(24, 97) Source(41, 64) + SourceIndex(0) +7 >Emitted(24, 99) Source(41, 22) + SourceIndex(0) +8 >Emitted(24, 120) Source(41, 39) + SourceIndex(0) +9 >Emitted(24, 122) Source(41, 41) + SourceIndex(0) +10>Emitted(24, 147) Source(41, 62) + SourceIndex(0) +11>Emitted(24, 149) Source(43, 5) + SourceIndex(0) +12>Emitted(24, 150) Source(43, 6) + SourceIndex(0) +13>Emitted(24, 153) Source(43, 9) + SourceIndex(0) +14>Emitted(24, 154) Source(43, 10) + SourceIndex(0) +15>Emitted(24, 156) Source(43, 12) + SourceIndex(0) +16>Emitted(24, 157) Source(43, 13) + SourceIndex(0) +17>Emitted(24, 160) Source(43, 16) + SourceIndex(0) +18>Emitted(24, 161) Source(43, 17) + SourceIndex(0) +19>Emitted(24, 163) Source(43, 19) + SourceIndex(0) +20>Emitted(24, 164) Source(43, 20) + SourceIndex(0) +21>Emitted(24, 166) Source(43, 22) + SourceIndex(0) +22>Emitted(24, 168) Source(43, 24) + SourceIndex(0) +23>Emitted(24, 169) Source(43, 25) + SourceIndex(0) --- >>> console.log(primaryA); 1 >^^^^ diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js index 785148ba652..3a3ffc6b8d4 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js @@ -112,7 +112,7 @@ for (var _a = robot.name, nameA = _a === void 0 ? "noName" : _a, i = 0; i < 1; i for (var _b = getRobot().name, nameA = _b === void 0 ? "noName" : _b, i = 0; i < 1; i++) { console.log(nameA); } -for (var _c = { name: "trimmer", skill: "trimming" }.name, nameA = _c === void 0 ? "noName" : _c, i = 0; i < 1; i++) { +for (var _c = ({ name: "trimmer", skill: "trimming" }).name, nameA = _c === void 0 ? "noName" : _c, i = 0; i < 1; i++) { console.log(nameA); } for (var _d = multiRobot.skills, _e = _d === void 0 ? { primary: "none", secondary: "none" } : _d, _f = _e.primary, primaryA = _f === void 0 ? "primary" : _f, _g = _e.secondary, secondaryA = _g === void 0 ? "secondary" : _g, i = 0; i < 1; i++) { @@ -121,7 +121,7 @@ for (var _d = multiRobot.skills, _e = _d === void 0 ? { primary: "none", seconda for (var _h = getMultiRobot().skills, _j = _h === void 0 ? { primary: "none", secondary: "none" } : _h, _k = _j.primary, primaryA = _k === void 0 ? "primary" : _k, _l = _j.secondary, secondaryA = _l === void 0 ? "secondary" : _l, i = 0; i < 1; i++) { console.log(primaryA); } -for (var _m = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }.skills, _o = _m === void 0 ? { primary: "none", secondary: "none" } : _m, _p = _o.primary, primaryA = _p === void 0 ? "primary" : _p, _q = _o.secondary, secondaryA = _q === void 0 ? "secondary" : _q, i = 0; i < 1; i++) { +for (var _m = ({ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }).skills, _o = _m === void 0 ? { primary: "none", secondary: "none" } : _m, _p = _o.primary, primaryA = _p === void 0 ? "primary" : _p, _q = _o.secondary, secondaryA = _q === void 0 ? "secondary" : _q, i = 0; i < 1; i++) { console.log(primaryA); } for (var _r = robot.name, nameA = _r === void 0 ? "noName" : _r, _s = robot.skill, skillA = _s === void 0 ? "skill" : _s, i = 0; i < 1; i++) { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map index 0e96b80e749..ac5719ded6a 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map] -{"version":3,"file":"sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.ts"],"names":[],"mappings":"AAgBA,IAAI,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACtD,IAAI,UAAU,GAAe,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACjG;IACI,MAAM,CAAC,KAAK,CAAC;AACjB,CAAC;AACD;IACI,MAAM,CAAC,UAAU,CAAC;AACtB,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,eAAqB,EAArB,qCAAqB,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,oBAAsB,EAAtB,qCAAsB,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,gDAAsB,EAAtB,qCAAsB,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CACA,IAAA,sBAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAE3B,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CACA,IAAA,2BAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAEtB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CACA,IAAA,qFAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAGvC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,eAAsB,EAAtB,qCAAsB,EAAE,gBAAuB,EAAvB,qCAAuB,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,eAA+D,EAA9D,YAAsB,EAAtB,qCAAsB,EAAE,aAAuB,EAAvB,qCAAuB,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC1F,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,2CAAkG,EAAjG,YAAsB,EAAtB,qCAAsB,EAAE,aAAuB,EAAvB,qCAAuB,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC7H,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CACA,IAAA,oBAAsB,EAAtB,qCAAsB,EACtB,sBAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAE3B,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,oBAMU,EALf,YAAsB,EAAtB,qCAAsB,EACtB,cAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAEtB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,+EAMgF,EALrF,cAAsB,EAAtB,uCAAsB,EACtB,gBAG0C,EAH1C,mEAG0C,EAFtC,iBAA6B,EAA7B,2CAA6B,EAC7B,mBAAmC,EAAnC,+CAAmC,EAGvC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.ts"],"names":[],"mappings":"AAgBA,IAAI,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACtD,IAAI,UAAU,GAAe,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACjG;IACI,MAAM,CAAC,KAAK,CAAC;AACjB,CAAC;AACD;IACI,MAAM,CAAC,UAAU,CAAC;AACtB,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,eAAqB,EAArB,qCAAqB,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,oBAAsB,EAAtB,qCAAsB,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,kDAAsB,EAAtB,qCAAsB,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CACA,IAAA,sBAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAE3B,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CACA,IAAA,2BAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAEtB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CACA,IAAA,uFAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAGvC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,eAAsB,EAAtB,qCAAsB,EAAE,gBAAuB,EAAvB,qCAAuB,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,eAA+D,EAA9D,YAAsB,EAAtB,qCAAsB,EAAE,aAAuB,EAAvB,qCAAuB,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC1F,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,2CAAkG,EAAjG,YAAsB,EAAtB,qCAAsB,EAAE,aAAuB,EAAvB,qCAAuB,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC7H,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CACA,IAAA,oBAAsB,EAAtB,qCAAsB,EACtB,sBAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAE3B,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,oBAMU,EALf,YAAsB,EAAtB,qCAAsB,EACtB,cAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAEtB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,+EAMgF,EALrF,cAAsB,EAAtB,uCAAsB,EACtB,gBAG0C,EAH1C,mEAG0C,EAFtC,iBAA6B,EAA7B,2CAA6B,EAC7B,mBAAmC,EAAnC,+CAAmC,EAGvC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.sourcemap.txt index ebe3dccdad7..61eeccd186f 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.sourcemap.txt @@ -408,35 +408,35 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPatternDefaultValues. >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(14, 1) Source(31, 1) + SourceIndex(0) 2 >Emitted(14, 2) Source(31, 2) + SourceIndex(0) --- ->>>for (var _c = { name: "trimmer", skill: "trimming" }.name, nameA = _c === void 0 ? "noName" : _c, i = 0; i < 1; i++) { +>>>for (var _c = ({ name: "trimmer", skill: "trimming" }).name, nameA = _c === void 0 ? "noName" : _c, i = 0; i < 1; i++) { 1-> 2 >^^^ 3 > ^ 4 > ^ 5 > ^^^^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -7 > ^^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -9 > ^^ -10> ^ -11> ^^^ -12> ^ -13> ^^ -14> ^ -15> ^^^ -16> ^ -17> ^^ -18> ^ -19> ^^ -20> ^^ -21> ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +9 > ^^ +10> ^ +11> ^^^ +12> ^ +13> ^^ +14> ^ +15> ^^^ +16> ^ +17> ^^ +18> ^ +19> ^^ +20> ^^ +21> ^ 1-> > 2 >for @@ -444,42 +444,42 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPatternDefaultValues. 4 > (let { 5 > 6 > name: nameA = "noName" -7 > -8 > name: nameA = "noName" -9 > } = { name: "trimmer", skill: "trimming" }, -10> i -11> = -12> 0 -13> ; -14> i -15> < -16> 1 -17> ; -18> i -19> ++ -20> ) -21> { +7 > +8 > name: nameA = "noName" +9 > } = { name: "trimmer", skill: "trimming" }, +10> i +11> = +12> 0 +13> ; +14> i +15> < +16> 1 +17> ; +18> i +19> ++ +20> ) +21> { 1->Emitted(15, 1) Source(32, 1) + SourceIndex(0) 2 >Emitted(15, 4) Source(32, 4) + SourceIndex(0) 3 >Emitted(15, 5) Source(32, 5) + SourceIndex(0) 4 >Emitted(15, 6) Source(32, 11) + SourceIndex(0) 5 >Emitted(15, 10) Source(32, 11) + SourceIndex(0) -6 >Emitted(15, 58) Source(32, 33) + SourceIndex(0) -7 >Emitted(15, 60) Source(32, 11) + SourceIndex(0) -8 >Emitted(15, 97) Source(32, 33) + SourceIndex(0) -9 >Emitted(15, 99) Source(32, 85) + SourceIndex(0) -10>Emitted(15, 100) Source(32, 86) + SourceIndex(0) -11>Emitted(15, 103) Source(32, 89) + SourceIndex(0) -12>Emitted(15, 104) Source(32, 90) + SourceIndex(0) -13>Emitted(15, 106) Source(32, 92) + SourceIndex(0) -14>Emitted(15, 107) Source(32, 93) + SourceIndex(0) -15>Emitted(15, 110) Source(32, 96) + SourceIndex(0) -16>Emitted(15, 111) Source(32, 97) + SourceIndex(0) -17>Emitted(15, 113) Source(32, 99) + SourceIndex(0) -18>Emitted(15, 114) Source(32, 100) + SourceIndex(0) -19>Emitted(15, 116) Source(32, 102) + SourceIndex(0) -20>Emitted(15, 118) Source(32, 104) + SourceIndex(0) -21>Emitted(15, 119) Source(32, 105) + SourceIndex(0) +6 >Emitted(15, 60) Source(32, 33) + SourceIndex(0) +7 >Emitted(15, 62) Source(32, 11) + SourceIndex(0) +8 >Emitted(15, 99) Source(32, 33) + SourceIndex(0) +9 >Emitted(15, 101) Source(32, 85) + SourceIndex(0) +10>Emitted(15, 102) Source(32, 86) + SourceIndex(0) +11>Emitted(15, 105) Source(32, 89) + SourceIndex(0) +12>Emitted(15, 106) Source(32, 90) + SourceIndex(0) +13>Emitted(15, 108) Source(32, 92) + SourceIndex(0) +14>Emitted(15, 109) Source(32, 93) + SourceIndex(0) +15>Emitted(15, 112) Source(32, 96) + SourceIndex(0) +16>Emitted(15, 113) Source(32, 97) + SourceIndex(0) +17>Emitted(15, 115) Source(32, 99) + SourceIndex(0) +18>Emitted(15, 116) Source(32, 100) + SourceIndex(0) +19>Emitted(15, 118) Source(32, 102) + SourceIndex(0) +20>Emitted(15, 120) Source(32, 104) + SourceIndex(0) +21>Emitted(15, 121) Source(32, 105) + SourceIndex(0) --- >>> console.log(nameA); 1 >^^^^ @@ -785,43 +785,43 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPatternDefaultValues. >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(23, 1) Source(50, 1) + SourceIndex(0) 2 >Emitted(23, 2) Source(50, 2) + SourceIndex(0) --- ->>>for (var _m = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }.skills, _o = _m === void 0 ? { primary: "none", secondary: "none" } : _m, _p = _o.primary, primaryA = _p === void 0 ? "primary" : _p, _q = _o.secondary, secondaryA = _q === void 0 ? "secondary" : _q, i = 0; i < 1; i++) { +>>>for (var _m = ({ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }).skills, _o = _m === void 0 ? { primary: "none", secondary: "none" } : _m, _p = _o.primary, primaryA = _p === void 0 ? "primary" : _p, _q = _o.secondary, secondaryA = _q === void 0 ? "secondary" : _q, i = 0; i < 1; i++) { 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> ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +9 > ^^ +10> ^^^^^^^^^^^^^^^ +11> ^^ +12> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13> ^^ +14> ^^^^^^^^^^^^^^^^^ +15> ^^ +16> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +17> ^^ +18> ^ +19> ^^^ +20> ^ +21> ^^ +22> ^ +23> ^^^ +24> ^ +25> ^^ +26> ^ +27> ^^ +28> ^^ +29> ^ 1-> > 2 >for @@ -833,65 +833,65 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPatternDefaultValues. > primary: primaryA = "primary", > secondary: secondaryA = "secondary" > } = { primary: "none", secondary: "none" } -7 > -8 > skills: { - > primary: primaryA = "primary", - > secondary: secondaryA = "secondary" - > } = { primary: "none", secondary: "none" } -9 > -10> primary: primaryA = "primary" -11> -12> primary: primaryA = "primary" -13> , - > -14> secondary: secondaryA = "secondary" -15> -16> secondary: secondaryA = "secondary" -17> - > } = { primary: "none", secondary: "none" } - > } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, - > -18> i -19> = -20> 0 -21> ; -22> i -23> < -24> 1 -25> ; -26> i -27> ++ -28> ) -29> { +7 > +8 > skills: { + > primary: primaryA = "primary", + > secondary: secondaryA = "secondary" + > } = { primary: "none", secondary: "none" } +9 > +10> primary: primaryA = "primary" +11> +12> primary: primaryA = "primary" +13> , + > +14> secondary: secondaryA = "secondary" +15> +16> secondary: secondaryA = "secondary" +17> + > } = { primary: "none", secondary: "none" } + > } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, + > +18> i +19> = +20> 0 +21> ; +22> i +23> < +24> 1 +25> ; +26> i +27> ++ +28> ) +29> { 1->Emitted(24, 1) Source(51, 1) + SourceIndex(0) 2 >Emitted(24, 4) Source(51, 4) + SourceIndex(0) 3 >Emitted(24, 5) Source(51, 5) + SourceIndex(0) 4 >Emitted(24, 6) Source(52, 5) + SourceIndex(0) 5 >Emitted(24, 10) Source(52, 5) + SourceIndex(0) -6 >Emitted(24, 95) Source(55, 47) + SourceIndex(0) -7 >Emitted(24, 97) Source(52, 5) + SourceIndex(0) -8 >Emitted(24, 161) Source(55, 47) + SourceIndex(0) -9 >Emitted(24, 163) Source(53, 9) + SourceIndex(0) -10>Emitted(24, 178) Source(53, 38) + SourceIndex(0) -11>Emitted(24, 180) Source(53, 9) + SourceIndex(0) -12>Emitted(24, 221) Source(53, 38) + SourceIndex(0) -13>Emitted(24, 223) Source(54, 9) + SourceIndex(0) -14>Emitted(24, 240) Source(54, 44) + SourceIndex(0) -15>Emitted(24, 242) Source(54, 9) + SourceIndex(0) -16>Emitted(24, 287) Source(54, 44) + SourceIndex(0) -17>Emitted(24, 289) Source(57, 5) + SourceIndex(0) -18>Emitted(24, 290) Source(57, 6) + SourceIndex(0) -19>Emitted(24, 293) Source(57, 9) + SourceIndex(0) -20>Emitted(24, 294) Source(57, 10) + SourceIndex(0) -21>Emitted(24, 296) Source(57, 12) + SourceIndex(0) -22>Emitted(24, 297) Source(57, 13) + SourceIndex(0) -23>Emitted(24, 300) Source(57, 16) + SourceIndex(0) -24>Emitted(24, 301) Source(57, 17) + SourceIndex(0) -25>Emitted(24, 303) Source(57, 19) + SourceIndex(0) -26>Emitted(24, 304) Source(57, 20) + SourceIndex(0) -27>Emitted(24, 306) Source(57, 22) + SourceIndex(0) -28>Emitted(24, 308) Source(57, 24) + SourceIndex(0) -29>Emitted(24, 309) Source(57, 25) + SourceIndex(0) +6 >Emitted(24, 97) Source(55, 47) + SourceIndex(0) +7 >Emitted(24, 99) Source(52, 5) + SourceIndex(0) +8 >Emitted(24, 163) Source(55, 47) + SourceIndex(0) +9 >Emitted(24, 165) Source(53, 9) + SourceIndex(0) +10>Emitted(24, 180) Source(53, 38) + SourceIndex(0) +11>Emitted(24, 182) Source(53, 9) + SourceIndex(0) +12>Emitted(24, 223) Source(53, 38) + SourceIndex(0) +13>Emitted(24, 225) Source(54, 9) + SourceIndex(0) +14>Emitted(24, 242) Source(54, 44) + SourceIndex(0) +15>Emitted(24, 244) Source(54, 9) + SourceIndex(0) +16>Emitted(24, 289) Source(54, 44) + SourceIndex(0) +17>Emitted(24, 291) Source(57, 5) + SourceIndex(0) +18>Emitted(24, 292) Source(57, 6) + SourceIndex(0) +19>Emitted(24, 295) Source(57, 9) + SourceIndex(0) +20>Emitted(24, 296) Source(57, 10) + SourceIndex(0) +21>Emitted(24, 298) Source(57, 12) + SourceIndex(0) +22>Emitted(24, 299) Source(57, 13) + SourceIndex(0) +23>Emitted(24, 302) Source(57, 16) + SourceIndex(0) +24>Emitted(24, 303) Source(57, 17) + SourceIndex(0) +25>Emitted(24, 305) Source(57, 19) + SourceIndex(0) +26>Emitted(24, 306) Source(57, 20) + SourceIndex(0) +27>Emitted(24, 308) Source(57, 22) + SourceIndex(0) +28>Emitted(24, 310) Source(57, 24) + SourceIndex(0) +29>Emitted(24, 311) Source(57, 25) + SourceIndex(0) --- >>> console.log(primaryA); 1 >^^^^ diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js index a20e7578d93..164159655b2 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js @@ -2,5 +2,5 @@ var {x} = { x: 20 }; //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js] -var x = { x: 20 }.x; +var x = ({ x: 20 }).x; //# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map index b0a552391c9..b1104fa4eab 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts"],"names":[],"mappings":"AAAK,IAAA,eAAC,CAAc"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts"],"names":[],"mappings":"AAAK,IAAA,iBAAC,CAAc"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt index 0c554c986a4..fb41dc6233f 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt @@ -8,19 +8,19 @@ sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern1. emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts ------------------------------------------------------------------- ->>>var x = { x: 20 }.x; +>>>var x = ({ x: 20 }).x; 1 > 2 >^^^^ -3 > ^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >var { 2 > 3 > x -4 > } = { x: 20 }; +4 > } = { x: 20 }; 1 >Emitted(1, 1) Source(1, 6) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 6) + SourceIndex(0) -3 >Emitted(1, 20) Source(1, 7) + SourceIndex(0) -4 >Emitted(1, 21) Source(1, 21) + SourceIndex(0) +3 >Emitted(1, 22) Source(1, 7) + SourceIndex(0) +4 >Emitted(1, 23) Source(1, 21) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js index 44295762d6d..771bda92ef4 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js @@ -3,6 +3,6 @@ var {x} = { x: 20 }; var { a, b } = { a: 30, b: 40 }; //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js] -var x = { x: 20 }.x; +var x = ({ x: 20 }).x; var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; //# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map index eb36a3b9022..5acc1fea7fa 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts"],"names":[],"mappings":"AAAK,IAAA,eAAC,CAAc;AAChB,IAAA,qBAA2B,EAAzB,QAAC,EAAE,QAAC,CAAsB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts"],"names":[],"mappings":"AAAK,IAAA,iBAAC,CAAc;AAChB,IAAA,qBAA2B,EAAzB,QAAC,EAAE,QAAC,CAAsB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt index 2390f91a8b1..51c431c5da5 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt @@ -8,20 +8,20 @@ sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern2. emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts ------------------------------------------------------------------- ->>>var x = { x: 20 }.x; +>>>var x = ({ x: 20 }).x; 1 > 2 >^^^^ -3 > ^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >var { 2 > 3 > x -4 > } = { x: 20 }; +4 > } = { x: 20 }; 1 >Emitted(1, 1) Source(1, 6) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 6) + SourceIndex(0) -3 >Emitted(1, 20) Source(1, 7) + SourceIndex(0) -4 >Emitted(1, 21) Source(1, 21) + SourceIndex(0) +3 >Emitted(1, 22) Source(1, 7) + SourceIndex(0) +4 >Emitted(1, 23) Source(1, 21) + SourceIndex(0) --- >>>var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; 1-> diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js index 88a5bce4dcc..3ef30f1a8aa 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js @@ -2,5 +2,5 @@ var {x = 500} = { x: 20 }; //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js] -var _a = { x: 20 }.x, x = _a === void 0 ? 500 : _a; +var _a = ({ x: 20 }).x, x = _a === void 0 ? 500 : _a; //# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map index 1faa8f8e71a..d974f0b7c78 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts"],"names":[],"mappings":"AAAK,IAAA,gBAAO,EAAP,4BAAO,CAAc"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts"],"names":[],"mappings":"AAAK,IAAA,kBAAO,EAAP,4BAAO,CAAc"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt index d58e756de42..7c06d77cf83 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt @@ -8,25 +8,25 @@ sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern3. emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts ------------------------------------------------------------------- ->>>var _a = { x: 20 }.x, x = _a === void 0 ? 500 : _a; +>>>var _a = ({ x: 20 }).x, x = _a === void 0 ? 500 : _a; 1 > 2 >^^^^ -3 > ^^^^^^^^^^^^^^^^ -4 > ^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +6 > ^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >var { 2 > 3 > x = 500 -4 > -5 > x = 500 -6 > } = { x: 20 }; +4 > +5 > x = 500 +6 > } = { x: 20 }; 1 >Emitted(1, 1) Source(1, 6) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 6) + SourceIndex(0) -3 >Emitted(1, 21) Source(1, 13) + SourceIndex(0) -4 >Emitted(1, 23) Source(1, 6) + SourceIndex(0) -5 >Emitted(1, 51) Source(1, 13) + SourceIndex(0) -6 >Emitted(1, 52) Source(1, 27) + SourceIndex(0) +3 >Emitted(1, 23) Source(1, 13) + SourceIndex(0) +4 >Emitted(1, 25) Source(1, 6) + SourceIndex(0) +5 >Emitted(1, 53) Source(1, 13) + SourceIndex(0) +6 >Emitted(1, 54) Source(1, 27) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map \ No newline at end of file diff --git a/tests/baselines/reference/strictModeReservedWordInDestructuring.js b/tests/baselines/reference/strictModeReservedWordInDestructuring.js index 78c8ab788ca..7186683bdff 100644 --- a/tests/baselines/reference/strictModeReservedWordInDestructuring.js +++ b/tests/baselines/reference/strictModeReservedWordInDestructuring.js @@ -11,7 +11,7 @@ var { public: a, protected: b } = { public: 1, protected: 2 }; //// [strictModeReservedWordInDestructuring.js] "use strict"; var public = [1][0]; -var public = { x: 1 }.x; +var public = ({ x: 1 }).x; var private = [["hello"]][0][0]; var _a = { y: { s: 1 }, z: { o: { p: 'h' } } }, static = _a.y.s, package = _a.z.o.p; var _b = { public: 1, protected: 2 }, public = _b.public, protected = _b.protected; diff --git a/tests/baselines/reference/strictModeUseContextualKeyword.js b/tests/baselines/reference/strictModeUseContextualKeyword.js index 6d5d3dfd5e0..0e28f5828fd 100644 --- a/tests/baselines/reference/strictModeUseContextualKeyword.js +++ b/tests/baselines/reference/strictModeUseContextualKeyword.js @@ -27,5 +27,5 @@ function F() { function as() { } } function H() { - var as = { as: 1 }.as; + var as = ({ as: 1 }).as; } diff --git a/tests/baselines/reference/templateStringInObjectLiteral.js b/tests/baselines/reference/templateStringInObjectLiteral.js index 0381e9a95e7..5a096b0adfa 100644 --- a/tests/baselines/reference/templateStringInObjectLiteral.js +++ b/tests/baselines/reference/templateStringInObjectLiteral.js @@ -5,8 +5,8 @@ var x = { } //// [templateStringInObjectLiteral.js] -var x = (_a = ["b"], _a.raw = ["b"], { +var x = (_a = ["b"], _a.raw = ["b"], ({ a: "abc" + 123 + "def" -}(_a)); +})(_a)); 321; var _a; From 01657e20362147aa94c66829a1dd531612319ad8 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Mon, 28 Aug 2017 23:43:29 +0100 Subject: [PATCH 022/216] Fix typo in comment --- src/compiler/factory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 0c863b38ca3..5fe5fa03225 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3817,7 +3817,7 @@ namespace ts { // new C.x -> not the same as (new C).x // // ObjectLiteral: - // {a:1}.toString() -> is incorrect syntax, should be ({a:3}).toString() + // {a:1}.toString() -> is incorrect syntax, should be ({a:1}).toString() // const emittedExpression = skipPartiallyEmittedExpressions(expression); if (isLeftHandSideExpression(emittedExpression) From 16ccb6637785724c2b215cb26ac2f7d727591130 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 28 Aug 2017 16:09:09 -0700 Subject: [PATCH 023/216] Provide jsdoc type code fixes for all variable-like decls This includes 3 SyntaxKinds I missed earlier: Parameter, PropertyDeclaration and PropertyAssignment. --- src/services/codefixes/fixJSDocTypes.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/services/codefixes/fixJSDocTypes.ts b/src/services/codefixes/fixJSDocTypes.ts index 249bc32dbf7..27c0edac628 100644 --- a/src/services/codefixes/fixJSDocTypes.ts +++ b/src/services/codefixes/fixJSDocTypes.ts @@ -8,11 +8,16 @@ namespace ts.codefix { function getActionsForJSDocTypes(context: CodeFixContext): CodeAction[] | undefined { const sourceFile = context.sourceFile; const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); - const decl = ts.findAncestor(node, n => n.kind === SyntaxKind.VariableDeclaration); + const decl = ts.findAncestor(node, + n => n.kind === SyntaxKind.VariableDeclaration || + n.kind === SyntaxKind.Parameter || + n.kind === SyntaxKind.PropertyDeclaration || + n.kind === SyntaxKind.PropertyAssignment); if (!decl) return; const checker = context.program.getTypeChecker(); const jsdocType = (decl as VariableDeclaration).type; + if (!jsdocType) return; const original = getTextOfNode(jsdocType); const type = checker.getTypeFromTypeNode(jsdocType); const actions = [createAction(jsdocType, sourceFile.fileName, original, checker.typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.NoTruncation))]; From b082c27fbeb1b46b5a27838aba82edd64a50705e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 28 Aug 2017 16:10:03 -0700 Subject: [PATCH 024/216] Test:jsdoc codefix for variable-like declarations --- tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts | 5 +++++ tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts | 5 +++++ tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts | 6 ++++++ tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts | 6 ++++++ 4 files changed, 22 insertions(+) create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts new file mode 100644 index 00000000000..3e6754588fd --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax10.ts @@ -0,0 +1,5 @@ +// @strict: true +/// +//// function f(x: [|number?|]) { +//// } +verify.rangeAfterCodeFix("number | null", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts new file mode 100644 index 00000000000..7ac80125775 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax11.ts @@ -0,0 +1,5 @@ +// @strict: true +/// +//// var f = function f(x: [|string?|]) { +//// } +verify.rangeAfterCodeFix("string | null | undefined", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 1); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts new file mode 100644 index 00000000000..37eb5df41ee --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax12.ts @@ -0,0 +1,6 @@ +// @strict: true +/// +////class C { +//// p: [|*|] +////} +verify.rangeAfterCodeFix("any", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts new file mode 100644 index 00000000000..5b374b508f1 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax13.ts @@ -0,0 +1,6 @@ +// @strict: true +/// +////class C { +//// p: [|*|] = 12 +////} +verify.rangeAfterCodeFix("any", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); From 63cb84f3d1e09fc62229945556b022432d0ccbc9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 29 Aug 2017 10:38:16 -0700 Subject: [PATCH 025/216] Codefix jsdoc types for anything with a .type That means type parameters and type arguments are still not handled. --- src/services/codefixes/fixJSDocTypes.ts | 20 +++++++++++++++++-- .../fourslash/codeFixChangeJSDocSyntax14.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax15.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax16.ts | 4 ++++ .../fourslash/codeFixChangeJSDocSyntax17.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax18.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax19.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax20.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax21.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax22.ts | 3 +++ .../fourslash/codeFixChangeJSDocSyntax23.ts | 6 ++++++ .../fourslash/codeFixChangeJSDocSyntax24.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax25.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax26.ts | 5 +++++ .../fourslash/codeFixChangeJSDocSyntax27.ts | 4 ++++ 15 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax17.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax23.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax26.ts create mode 100644 tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts diff --git a/src/services/codefixes/fixJSDocTypes.ts b/src/services/codefixes/fixJSDocTypes.ts index 27c0edac628..8d5cd562497 100644 --- a/src/services/codefixes/fixJSDocTypes.ts +++ b/src/services/codefixes/fixJSDocTypes.ts @@ -8,11 +8,27 @@ namespace ts.codefix { function getActionsForJSDocTypes(context: CodeFixContext): CodeAction[] | undefined { const sourceFile = context.sourceFile; const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); + + // NOTE: Some locations are not handled yet: + // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments const decl = ts.findAncestor(node, - n => n.kind === SyntaxKind.VariableDeclaration || + n => + n.kind === SyntaxKind.AsExpression || + n.kind === SyntaxKind.CallSignature || + n.kind === SyntaxKind.ConstructSignature || + n.kind === SyntaxKind.FunctionDeclaration || + n.kind === SyntaxKind.GetAccessor || + n.kind === SyntaxKind.IndexSignature || + n.kind === SyntaxKind.MappedType || + n.kind === SyntaxKind.MethodDeclaration || + n.kind === SyntaxKind.MethodSignature || n.kind === SyntaxKind.Parameter || n.kind === SyntaxKind.PropertyDeclaration || - n.kind === SyntaxKind.PropertyAssignment); + n.kind === SyntaxKind.PropertySignature || + n.kind === SyntaxKind.SetAccessor || + n.kind === SyntaxKind.TypeAliasDeclaration || + n.kind === SyntaxKind.TypeAssertionExpression || + n.kind === SyntaxKind.VariableDeclaration); if (!decl) return; const checker = context.program.getTypeChecker(); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts new file mode 100644 index 00000000000..69478fc3abc --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax14.ts @@ -0,0 +1,5 @@ +// @strict: true +/// +//// var x = 12 as [|number?|]; + +verify.rangeAfterCodeFix("number | null", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts new file mode 100644 index 00000000000..9482830c19d --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax15.ts @@ -0,0 +1,5 @@ +/// +//// var f = <[|function(number?): number|]>(x => x); + +// note: without --strict, number? --> number, not number | null +verify.rangeAfterCodeFix("(arg0: number) => number", /*includeWhiteSpace*/ false, /*errorCode*/ 8020, 0); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts new file mode 100644 index 00000000000..111aec1dce7 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax16.ts @@ -0,0 +1,4 @@ +/// +//// var f: { [K in keyof number]: [|*|] }; + +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax17.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax17.ts new file mode 100644 index 00000000000..6a3ce2ed3df --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax17.ts @@ -0,0 +1,3 @@ +/// +//// declare function index(ix: number): [|*|]; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts new file mode 100644 index 00000000000..30a3815516a --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax18.ts @@ -0,0 +1,3 @@ +/// +//// var index: { (ix: number): [|?|] }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts new file mode 100644 index 00000000000..e6344881227 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax19.ts @@ -0,0 +1,3 @@ +/// +//// var index: { new (ix: number): [|?|] }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts new file mode 100644 index 00000000000..dc153730841 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax20.ts @@ -0,0 +1,3 @@ +/// +//// var index = { get p(): [|*|] { return 12 } }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts new file mode 100644 index 00000000000..442414e4577 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax21.ts @@ -0,0 +1,3 @@ +/// +//// var index = { set p(x: [|*|]) { } }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts new file mode 100644 index 00000000000..c575f1ca7ce --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax22.ts @@ -0,0 +1,3 @@ +/// +//// var index: { [s: string]: [|*|] }; +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax23.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax23.ts new file mode 100644 index 00000000000..7ab70e18ee7 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax23.ts @@ -0,0 +1,6 @@ +/// +////class C { +//// m(): [|*|] { +//// } +////} +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts new file mode 100644 index 00000000000..7ea2d1f6faf --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax24.ts @@ -0,0 +1,5 @@ +/// +////declare class C { +//// m(): [|*|]; +////} +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts new file mode 100644 index 00000000000..6486a70417e --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax25.ts @@ -0,0 +1,5 @@ +/// +////declare class C { +//// p: [|*|]; +////} +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax26.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax26.ts new file mode 100644 index 00000000000..dc31f1dfffd --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax26.ts @@ -0,0 +1,5 @@ +/// +////class C { +//// p: [|*|] = 12; +////} +verify.rangeAfterCodeFix("any"); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts new file mode 100644 index 00000000000..255976c7767 --- /dev/null +++ b/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts @@ -0,0 +1,4 @@ +// @strict: true +/// +////type T = [|...number?|]; +verify.rangeAfterCodeFix("(number | null)[]"); From 3f090114fff2473e9b2ec8e340e7b3dba93266bd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 30 Aug 2017 09:44:51 -0700 Subject: [PATCH 026/216] Optimize array operations to reduce memory footprint --- src/compiler/binder.ts | 6 ++- src/compiler/parser.ts | 114 +++++++++++++++++------------------------ 2 files changed, 51 insertions(+), 69 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a7e94da09d9..67782ece962 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -203,9 +203,11 @@ namespace ts { node.symbol = symbol; if (!symbol.declarations) { - symbol.declarations = []; + symbol.declarations = [node]; + } + else { + symbol.declarations.push(node); } - symbol.declarations.push(node); if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) { symbol.exports = createSymbolTable(); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7486c7541be..bf066b6143e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -940,10 +940,6 @@ namespace ts { return scanner.getStartPos(); } - function getNodeEnd(): number { - return scanner.getStartPos(); - } - // Use this function to access the current token instead of reading the currentToken // variable. Since function results aren't narrowed in control flow analysis, this ensures // that the type checker doesn't make wrong assumptions about the type of the current @@ -1135,13 +1131,14 @@ namespace ts { new TokenConstructor(kind, pos, pos); } - function createNodeArray(elements?: T[], pos?: number): MutableNodeArray { - const array = >(elements || []); - if (!(pos >= 0)) { - pos = getNodePos(); - } + function createNodeArray(elements: T[], pos: number, end?: number): NodeArray { + // Since the element list of a node array is typically created by starting with an empty array and + // repeatedly calling push(), the list may not have the optimal memory layout. We invoke slice() for + // small arrays (1 to 4 elements) to give the VM a chance to allocate an optimal representation. + const length = elements.length; + const array = >(length >= 1 && length <= 4 ? elements.slice() : elements); array.pos = pos; - array.end = pos; + array.end = end === undefined ? scanner.getStartPos() : end; return array; } @@ -1527,12 +1524,13 @@ namespace ts { function parseList(kind: ParsingContext, parseElement: () => T): NodeArray { const saveParsingContext = parsingContext; parsingContext |= 1 << kind; - const result = createNodeArray(); + const list = []; + const listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { const element = parseListElement(kind, parseElement); - result.push(element); + list.push(element); continue; } @@ -1542,9 +1540,8 @@ namespace ts { } } - result.end = getNodeEnd(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { @@ -1874,13 +1871,14 @@ namespace ts { function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray { const saveParsingContext = parsingContext; parsingContext |= 1 << kind; - const result = createNodeArray(); + const list = []; + const listPos = getNodePos(); let commaStart = -1; // Meaning the previous token was not a comma while (true) { if (isListElement(kind, /*inErrorRecovery*/ false)) { const startPos = scanner.getStartPos(); - result.push(parseListElement(kind, parseElement)); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(SyntaxKind.CommaToken)) { @@ -1924,6 +1922,8 @@ namespace ts { } } + parsingContext = saveParsingContext; + const result = createNodeArray(list, listPos); // Recording the trailing comma is deliberately done after the previous // loop, and not just if we see a list terminator. This is because the list // may have ended incorrectly, but it is still important to know if there @@ -1933,14 +1933,11 @@ namespace ts { // Always preserve a trailing comma by marking it on the NodeArray result.hasTrailingComma = true; } - - result.end = getNodeEnd(); - parsingContext = saveParsingContext; return result; } function createMissingList(): NodeArray { - return createNodeArray(); + return createNodeArray([], getNodePos()); } function parseBracketedList(kind: ParsingContext, parseElement: () => T, open: SyntaxKind, close: SyntaxKind): NodeArray { @@ -2015,15 +2012,15 @@ namespace ts { template.head = parseTemplateHead(); Debug.assert(template.head.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind"); - const templateSpans = createNodeArray(); + const list = []; + const listPos = getNodePos(); do { - templateSpans.push(parseTemplateSpan()); + list.push(parseTemplateSpan()); } - while (lastOrUndefined(templateSpans).literal.kind === SyntaxKind.TemplateMiddle); + while (lastOrUndefined(list).literal.kind === SyntaxKind.TemplateMiddle); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; + template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } @@ -2802,13 +2799,12 @@ namespace ts { parseOptional(operator); let type = parseConstituentType(); if (token() === operator) { - const types = createNodeArray([type], type.pos); + const types = [type]; while (parseOptional(operator)) { types.push(parseConstituentType()); } - types.end = getNodeEnd(); const node = createNode(kind, type.pos); - node.types = types; + node.types = createNodeArray(types, type.pos); type = finishNode(node); } return type; @@ -3174,8 +3170,7 @@ namespace ts { parameter.name = identifier; finishNode(parameter); - node.parameters = createNodeArray([parameter], parameter.pos); - node.parameters.end = parameter.end; + node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); @@ -4025,7 +4020,8 @@ namespace ts { } function parseJsxChildren(openingTagName: LeftHandSideExpression): NodeArray { - const result = createNodeArray(); + const list = []; + const listPos = getNodePos(); const saveParsingContext = parsingContext; parsingContext |= 1 << ParsingContext.JsxChildren; @@ -4046,15 +4042,13 @@ namespace ts { } const child = parseJsxChild(); if (child) { - result.push(child); + list.push(child); } } - result.end = scanner.getTokenPos(); - parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseJsxAttributes(): JsxAttributes { @@ -5447,27 +5441,19 @@ namespace ts { } function parseDecorators(): NodeArray { - let decorators: NodeArray & Decorator[]; + let list: Decorator[]; + const listPos = getNodePos(); while (true) { const decoratorStart = getNodePos(); if (!parseOptional(SyntaxKind.AtToken)) { break; } - const decorator = createNode(SyntaxKind.Decorator, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); - if (!decorators) { - decorators = createNodeArray([decorator], decoratorStart); - } - else { - decorators.push(decorator); - } + (list || (list = [])).push(decorator); } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; + return list && createNodeArray(list, listPos); } /* @@ -5478,7 +5464,8 @@ namespace ts { * In such situations, 'permitInvalidConstAsModifier' should be set to true. */ function parseModifiers(permitInvalidConstAsModifier?: boolean): NodeArray | undefined { - let modifiers: MutableNodeArray | undefined; + let list: Modifier[]; + const listPos = getNodePos(); while (true) { const modifierStart = scanner.getStartPos(); const modifierKind = token(); @@ -5497,17 +5484,9 @@ namespace ts { } const modifier = finishNode(createNode(modifierKind, modifierStart)); - if (!modifiers) { - modifiers = createNodeArray([modifier], modifierStart); - } - else { - modifiers.push(modifier); - } + (list || (list = [])).push(modifier); } - if (modifiers) { - modifiers.end = scanner.getStartPos(); - } - return modifiers; + return list && createNodeArray(list, listPos); } function parseModifiersForArrowFunction(): NodeArray { @@ -5518,9 +5497,7 @@ namespace ts { nextToken(); const modifier = finishNode(createNode(modifierKind, modifierStart)); modifiers = createNodeArray([modifier], modifierStart); - modifiers.end = scanner.getStartPos(); } - return modifiers; } @@ -6222,7 +6199,9 @@ namespace ts { Debug.assert(start <= end); Debug.assert(end <= content.length); - let tags: MutableNodeArray; + let tags: JSDocTag[]; + let tagsPos: number; + let tagsEnd: number; const comments: string[] = []; let result: JSDoc; @@ -6355,7 +6334,7 @@ namespace ts { function createJSDocComment(): JSDoc { const result = createNode(SyntaxKind.JSDocComment, start); - result.tags = tags; + result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -6495,12 +6474,13 @@ namespace ts { tag.comment = comments.join(""); if (!tags) { - tags = createNodeArray([tag], tag.pos); + tags = [tag]; + tagsPos = tag.pos; } else { tags.push(tag); } - tags.end = tag.end; + tagsEnd = tag.end; } function tryParseTypeExpression(): JSDocTypeExpression | undefined { @@ -6800,7 +6780,8 @@ namespace ts { } // Type parameter list looks like '@template T,U,V' - const typeParameters = createNodeArray(); + const typeParameters = []; + const typeParametersPos = getNodePos(); while (true) { const name = parseJSDocIdentifierName(); @@ -6828,9 +6809,8 @@ namespace ts { const result = createNode(SyntaxKind.JSDocTemplateTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; + result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); - typeParameters.end = result.end; return result; } From c2168cb94a15879c917797b60734891e194ddca9 Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Thu, 31 Aug 2017 14:05:41 -0700 Subject: [PATCH 027/216] Added logic to check for EOF when creating a missing node. --- src/compiler/parser.ts | 5 ++++- .../reference/conflictMarkerTrivia4.errors.txt | 8 ++++---- .../incompleteDottedExpressionAtEOF.errors.txt | 4 ++-- .../baselines/reference/jsxAndTypeAssertion.errors.txt | 10 ++++++++-- ...platesWithIncompleteTemplateExpressions4.errors.txt | 9 ++++++--- ...platesWithIncompleteTemplateExpressions5.errors.txt | 9 ++++++--- 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7486c7541be..3e446ef4cc3 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1208,7 +1208,10 @@ namespace ts { return finishNode(node); } - return createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, diagnosticMessage || Diagnostics.Identifier_expected); + // Only for end of file because the error gets reported incorrectly on embedded script tags. + const reportAtCurrentPosition = token() === SyntaxKind.EndOfFileToken; + + return createMissingNode(SyntaxKind.Identifier, reportAtCurrentPosition, diagnosticMessage || Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage?: DiagnosticMessage): Identifier { diff --git a/tests/baselines/reference/conflictMarkerTrivia4.errors.txt b/tests/baselines/reference/conflictMarkerTrivia4.errors.txt index 476dbbce6ce..5ea1b27f7f0 100644 --- a/tests/baselines/reference/conflictMarkerTrivia4.errors.txt +++ b/tests/baselines/reference/conflictMarkerTrivia4.errors.txt @@ -1,14 +1,14 @@ tests/cases/compiler/conflictMarkerTrivia4.ts(1,12): error TS2304: Cannot find name 'div'. +tests/cases/compiler/conflictMarkerTrivia4.ts(1,16): error TS1109: Expression expected. tests/cases/compiler/conflictMarkerTrivia4.ts(2,1): error TS1185: Merge conflict marker encountered. -tests/cases/compiler/conflictMarkerTrivia4.ts(2,13): error TS1109: Expression expected. ==== tests/cases/compiler/conflictMarkerTrivia4.ts (3 errors) ==== const x =
~~~ !!! error TS2304: Cannot find name 'div'. + +!!! error TS1109: Expression expected. <<<<<<< HEAD ~~~~~~~ -!!! error TS1185: Merge conflict marker encountered. - -!!! error TS1109: Expression expected. \ No newline at end of file +!!! error TS1185: Merge conflict marker encountered. \ No newline at end of file diff --git a/tests/baselines/reference/incompleteDottedExpressionAtEOF.errors.txt b/tests/baselines/reference/incompleteDottedExpressionAtEOF.errors.txt index fe5d93ec6c1..02348777190 100644 --- a/tests/baselines/reference/incompleteDottedExpressionAtEOF.errors.txt +++ b/tests/baselines/reference/incompleteDottedExpressionAtEOF.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,10): error TS2304: Cannot find name 'window'. -tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,18): error TS1003: Identifier expected. +tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,17): error TS1003: Identifier expected. ==== tests/cases/compiler/incompleteDottedExpressionAtEOF.ts (2 errors) ==== @@ -7,5 +7,5 @@ tests/cases/compiler/incompleteDottedExpressionAtEOF.ts(2,18): error TS1003: Ide var p2 = window. ~~~~~~ !!! error TS2304: Cannot find name 'window'. - + !!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt index 5aa92086c37..d5df3915bf6 100644 --- a/tests/baselines/reference/jsxAndTypeAssertion.errors.txt +++ b/tests/baselines/reference/jsxAndTypeAssertion.errors.txt @@ -10,11 +10,13 @@ tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(14,45): error TS1005: '}' ex tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,2): error TS17008: JSX element 'foo' has no corresponding closing tag. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,8): error TS17008: JSX element 'foo' has no corresponding closing tag. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,13): error TS17008: JSX element 'foo' has no corresponding closing tag. +tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(18,83): error TS1109: Expression expected. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: ':' expected. tests/cases/conformance/jsx/jsxAndTypeAssertion.tsx(21,1): error TS1005: ' Date: Fri, 1 Sep 2017 09:55:38 -0700 Subject: [PATCH 028/216] Expand type references recursively in cache key This means that `A>>` will include the keys for `B` and `C` now. --- src/compiler/checker.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 269666d7b94..22abe7cd57e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9782,8 +9782,8 @@ namespace ts { return type.flags & TypeFlags.TypeParameter && !getConstraintFromTypeParameter(type); } - function isTypeReferenceWithGenericArguments(type: Type) { - return getObjectFlags(type) & ObjectFlags.Reference && some((type).typeArguments, isUnconstrainedTypeParameter); + function isTypeReferenceWithGenericArguments(type: Type): type is TypeReference { + return getObjectFlags(type) & ObjectFlags.Reference && some((type).typeArguments, t => isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t)); } /** @@ -9801,6 +9801,9 @@ namespace ts { } result += "=" + index; } + else if (isTypeReferenceWithGenericArguments(t)) { + result += "<" + getTypeReferenceId(t, typeParameters) + ">"; + } else { result += "-" + t.id; } @@ -10050,7 +10053,7 @@ namespace ts { getUnionType(types, /*subtypeReduction*/ true); } - function isArrayType(type: Type): boolean { + function isArrayType(type: Type): type is TypeReference { return getObjectFlags(type) & ObjectFlags.Reference && (type).target === globalArrayType; } From 520d7fff49d96ba71b9b441e25ff00c772070dff Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 1 Sep 2017 14:19:12 -0700 Subject: [PATCH 029/216] Add depth limit to recursive type reference id generation 4 is the limit. --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 22abe7cd57e..764307de7a9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9790,7 +9790,7 @@ namespace ts { * getTypeReferenceId(A) returns "111=0-12=1" * where A.id=111 and number.id=12 */ - function getTypeReferenceId(type: TypeReference, typeParameters: Type[]) { + function getTypeReferenceId(type: TypeReference, typeParameters: Type[], depth = 0) { let result = "" + type.target.id; for (const t of type.typeArguments) { if (isUnconstrainedTypeParameter(t)) { @@ -9801,8 +9801,8 @@ namespace ts { } result += "=" + index; } - else if (isTypeReferenceWithGenericArguments(t)) { - result += "<" + getTypeReferenceId(t, typeParameters) + ">"; + else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) { + result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">"; } else { result += "-" + t.id; From b65ff647c1debc58aa66b20359d644f54048fd56 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 2 Sep 2017 10:27:48 -0700 Subject: [PATCH 030/216] Improved caching scheme for anonymous types --- src/compiler/checker.ts | 281 +++++++++++++--------------------- src/compiler/types.ts | 5 +- src/services/signatureHelp.ts | 2 +- 3 files changed, 107 insertions(+), 181 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 269666d7b94..7a9931f19a4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4794,22 +4794,39 @@ namespace ts { return typeParameters; } - // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function - // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and - // returns the same array. - function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[] { + // Return the outer type parameters of a node or undefined if the node has no outer type parameters. + function getOuterTypeParameters(node: Node, includeThisTypes?: boolean): TypeParameter[] { while (true) { node = node.parent; if (!node) { - return typeParameters; + return undefined; } - if (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || - node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression || - node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.ArrowFunction) { - const declarations = (node).typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.MethodSignature: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + case SyntaxKind.JSDocFunctionType: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.JSDocTemplateTag: + case SyntaxKind.MappedType: + const outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + if (node.kind === SyntaxKind.MappedType) { + return append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode((node).typeParameter))); + } + const outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, getEffectiveTypeParameterDeclarations(node) || emptyArray); + const thisType = includeThisTypes && + (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.InterfaceDeclaration) && + getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; + return thisType ? append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } @@ -4817,7 +4834,7 @@ namespace ts { // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] { const declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); - return appendOuterTypeParameters(/*typeParameters*/ undefined, declaration); + return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -6800,7 +6817,7 @@ namespace ts { const id = getTypeListId(typeArguments); let instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); } return instantiation; } @@ -8024,11 +8041,6 @@ namespace ts { return instantiateList(signatures, mapper, instantiateSignature); } - function instantiateCached(type: T, mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): T { - const instantiations = mapper.instantiations || (mapper.instantiations = []); - return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); - } - function makeUnaryTypeMapper(source: Type, target: Type) { return (t: Type) => t === source ? target : t; } @@ -8050,11 +8062,9 @@ namespace ts { function createTypeMapper(sources: TypeParameter[], targets: Type[]): TypeMapper { Debug.assert(targets === undefined || sources.length === targets.length); - const mapper: TypeMapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - makeArrayTypeMapper(sources, targets); - mapper.mappedTypes = sources; - return mapper; + makeArrayTypeMapper(sources, targets); } function createTypeEraser(sources: TypeParameter[]): TypeMapper { @@ -8065,10 +8075,8 @@ namespace ts { * Maps forward-references to later types parameters to the empty object type. * This is used during inference when instantiating type parameter defaults. */ - function createBackreferenceMapper(typeParameters: TypeParameter[], index: number) { - const mapper: TypeMapper = t => indexOf(typeParameters, t) >= index ? emptyObjectType : t; - mapper.mappedTypes = typeParameters; - return mapper; + function createBackreferenceMapper(typeParameters: TypeParameter[], index: number): TypeMapper { + return t => indexOf(typeParameters, t) >= index ? emptyObjectType : t; } function isInferenceContext(mapper: TypeMapper): mapper is InferenceContext { @@ -8086,15 +8094,11 @@ namespace ts { } function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper { - const mapper: TypeMapper = t => instantiateType(mapper1(t), mapper2); - mapper.mappedTypes = concatenate(mapper1.mappedTypes, mapper2.mappedTypes); - return mapper; + return t => instantiateType(mapper1(t), mapper2); } - function createReplacementMapper(source: Type, target: Type, baseMapper: TypeMapper) { - const mapper: TypeMapper = t => t === source ? target : baseMapper(t); - mapper.mappedTypes = baseMapper.mappedTypes; - return mapper; + function createReplacementMapper(source: Type, target: Type, baseMapper: TypeMapper): TypeMapper { + return t => t === source ? target : baseMapper(t); } function cloneTypeParameter(typeParameter: TypeParameter): TypeParameter { @@ -8174,13 +8178,39 @@ namespace ts { return result; } - function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper): AnonymousType { - const result = createObjectType(ObjectFlags.Anonymous | ObjectFlags.Instantiated, type.symbol); - result.target = type.objectFlags & ObjectFlags.Instantiated ? type.target : type; - result.mapper = type.objectFlags & ObjectFlags.Instantiated ? combineTypeMappers(type.mapper, mapper) : mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); - return result; + function getAnonymousTypeInstantiation(type: AnonymousType, mapper: TypeMapper) { + if (type.objectFlags & ObjectFlags.Instantiated) { + mapper = combineTypeMappers(type.mapper, mapper); + type = type.target; + } + const symbol = type.symbol; + const links = getSymbolLinks(symbol); + if (!links.typeParameters) { + // This first time an anonymous type is instantiated we compute and store a list of the type + // parameters that are in scope (and therefore potentially referenced). + const typeParameters = getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true); + links.typeParameters = typeParameters || emptyArray; + if (typeParameters) { + links.instantiations = createMap(); + links.instantiations.set(getTypeListId(typeParameters), type); + } + } + const typeParameters = links.typeParameters; + if (typeParameters.length) { + // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the + // mapper to the type parameters to produce the effective list of type arguments, and compute the + // instantiation cache key from the type IDs of the type arguments. + const typeArguments = map(typeParameters, mapper); + const id = getTypeListId(typeArguments); + let result = links.instantiations.get(id); + if (!result) { + const newMapper = createTypeMapper(typeParameters, typeArguments); + result = type.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(type, newMapper) : instantiateAnonymousType(type, newMapper); + links.instantiations.set(id, result); + } + return result; + } + return type; } function instantiateMappedType(type: MappedType, mapper: TypeMapper): Type { @@ -8197,164 +8227,64 @@ namespace ts { if (typeVariable !== mappedTypeVariable) { return mapType(mappedTypeVariable, t => { if (isMappableType(t)) { - return instantiateMappedObjectType(type, createReplacementMapper(typeVariable, t, mapper)); + return instantiateAnonymousType(type, createReplacementMapper(typeVariable, t, mapper)); } return t; }); } } } - return instantiateMappedObjectType(type, mapper); + return instantiateAnonymousType(type, mapper); } function isMappableType(type: Type) { return type.flags & (TypeFlags.TypeParameter | TypeFlags.Object | TypeFlags.Intersection | TypeFlags.IndexedAccess); } - function instantiateMappedObjectType(type: MappedType, mapper: TypeMapper): Type { - const result = createObjectType(ObjectFlags.Mapped | ObjectFlags.Instantiated, type.symbol); - result.declaration = type.declaration; - result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper): AnonymousType { + const result = createObjectType(type.objectFlags | ObjectFlags.Instantiated, type.symbol); + if (type.objectFlags & ObjectFlags.Mapped) { + (result).declaration = (type).declaration; + } + result.target = type; + result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function isSymbolInScopeOfMappedTypeParameter(symbol: Symbol, mapper: TypeMapper) { - if (!(symbol.declarations && symbol.declarations.length)) { - return false; - } - const mappedTypes = mapper.mappedTypes; - // Starting with the parent of the symbol's declaration, check if the mapper maps any of - // the type parameters introduced by enclosing declarations. We just pick the first - // declaration since multiple declarations will all have the same parent anyway. - return !!findAncestor(symbol.declarations[0], node => { - if (node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.SourceFile) { - return "quit"; - } - switch (node.kind) { - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.Constructor: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.TypeAliasDeclaration: - const typeParameters = getEffectiveTypeParameterDeclarations(node as DeclarationWithTypeParameters); - if (typeParameters) { - for (const d of typeParameters) { - if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) { - return true; - } - } - } - if (isClassLike(node) || node.kind === SyntaxKind.InterfaceDeclaration) { - const thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; - if (thisType && contains(mappedTypes, thisType)) { - return true; - } - } - break; - case SyntaxKind.MappedType: - if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode((node).typeParameter)))) { - return true; - } - break; - case SyntaxKind.JSDocFunctionType: - const func = node as JSDocFunctionType; - for (const p of func.parameters) { - if (contains(mappedTypes, getTypeOfNode(p))) { - return true; - } - } - break; - } - }); - } - - function isTopLevelTypeAlias(symbol: Symbol) { - if (symbol.declarations && symbol.declarations.length) { - const parentKind = symbol.declarations[0].parent.kind; - return parentKind === SyntaxKind.SourceFile || parentKind === SyntaxKind.ModuleBlock; - } - return false; - } - function instantiateType(type: Type, mapper: TypeMapper): Type { if (type && mapper !== identityMapper) { - // If we are instantiating a type that has a top-level type alias, obtain the instantiation through - // the type alias instead in order to share instantiations for the same type arguments. This can - // dramatically reduce the number of structurally identical types we generate. Note that we can only - // perform this optimization for top-level type aliases. Consider: - // - // function f1(x: T) { - // type Foo = { x: X, t: T }; - // let obj: Foo = { x: x }; - // return obj; - // } - // function f2(x: U) { return f1(x); } - // let z = f2(42); - // - // Above, the declaration of f2 has an inferred return type that is an instantiation of f1's Foo - // equivalent to { x: U, t: U }. When instantiating this return type, we can't go back to Foo's - // cache because all cached instantiations are of the form { x: ???, t: T }, i.e. they have not been - // instantiated for T. Instead, we need to further instantiate the { x: U, t: U } form. - if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { - if (type.aliasTypeArguments) { - return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + if (type.flags & TypeFlags.TypeParameter) { + return mapper(type); + } + if (type.flags & TypeFlags.Object) { + if ((type).objectFlags & ObjectFlags.Anonymous) { + // If the anonymous type originates in a declaration of a function, method, class, or + // interface, in an object type literal, or in an object literal expression, we may need + // to instantiate the type because it might reference a type parameter. + return type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations ? + getAnonymousTypeInstantiation(type, mapper) : type; + } + if ((type).objectFlags & ObjectFlags.Mapped) { + return getAnonymousTypeInstantiation(type, mapper); + } + if ((type).objectFlags & ObjectFlags.Reference) { + return createTypeReference((type).target, instantiateTypes((type).typeArguments, mapper)); } - return type; } - return instantiateTypeNoAlias(type, mapper); - } - return type; - } - - function instantiateTypeNoAlias(type: Type, mapper: TypeMapper): Type { - if (type.flags & TypeFlags.TypeParameter) { - return mapper(type); - } - if (type.flags & TypeFlags.Object) { - if ((type).objectFlags & ObjectFlags.Anonymous) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. We skip instantiation - // if none of the type parameters that are in scope in the type's declaration are mapped by - // the given mapper, however we can only do that analysis if the type isn't itself an - // instantiation. - return type.symbol && - type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && - ((type).objectFlags & ObjectFlags.Instantiated || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateCached(type, mapper, instantiateAnonymousType) : type; + if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) { + return getUnionType(instantiateTypes((type).types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if ((type).objectFlags & ObjectFlags.Mapped) { - return instantiateCached(type, mapper, instantiateMappedType); + if (type.flags & TypeFlags.Intersection) { + return getIntersectionType(instantiateTypes((type).types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if ((type).objectFlags & ObjectFlags.Reference) { - return createTypeReference((type).target, instantiateTypes((type).typeArguments, mapper)); + if (type.flags & TypeFlags.Index) { + return getIndexType(instantiateType((type).type, mapper)); + } + if (type.flags & TypeFlags.IndexedAccess) { + return getIndexedAccessType(instantiateType((type).objectType, mapper), instantiateType((type).indexType, mapper)); } - } - if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) { - return getUnionType(instantiateTypes((type).types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & TypeFlags.Intersection) { - return getIntersectionType(instantiateTypes((type).types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & TypeFlags.Index) { - return getIndexType(instantiateType((type).type, mapper)); - } - if (type.flags & TypeFlags.IndexedAccess) { - return getIndexedAccessType(instantiateType((type).objectType, mapper), instantiateType((type).indexType, mapper)); } return type; } @@ -10368,7 +10298,6 @@ namespace ts { function createInferenceContext(signature: Signature, flags: InferenceFlags, compareTypes?: TypeComparer, baseInferences?: InferenceInfo[]): InferenceContext { const inferences = baseInferences ? map(baseInferences, cloneInferenceInfo) : map(signature.typeParameters, createInferenceInfo); const context = mapper as InferenceContext; - context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 64444693acf..99afe5e6e4e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3331,13 +3331,12 @@ namespace ts { } /* @internal */ - export interface MappedType extends ObjectType { + export interface MappedType extends AnonymousType { declaration: MappedTypeNode; typeParameter?: TypeParameter; constraintType?: Type; templateType?: Type; modifiersType?: Type; - mapper?: TypeMapper; // Instantiation mapper } export interface EvolvingArrayType extends ObjectType { @@ -3469,8 +3468,6 @@ namespace ts { /* @internal */ export interface TypeMapper { (t: TypeParameter): Type; - mappedTypes?: TypeParameter[]; // Types mapped by this mapper - instantiations?: Type[]; // Cache of instantiations created using this type mapper. } export const enum InferencePriority { diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 2976b0d28ee..10d5dda7966 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -373,7 +373,7 @@ namespace ts.SignatureHelp { isVariadic = false; // type parameter lists are not variadic prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken)); // Use `.mapper` to ensure we get the generic type arguments even if this is an instantiated version of the signature. - const typeParameters = candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; + const typeParameters = candidateSignature.typeParameters; // !!! candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken)); const parameterParts = mapToDisplayParts(writer => From 601a21c77b3af323b293cbcb3483936443bc50b7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 2 Sep 2017 15:39:14 -0700 Subject: [PATCH 031/216] Fix signature help --- src/services/signatureHelp.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 10d5dda7966..7e8e748bb17 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -372,8 +372,7 @@ namespace ts.SignatureHelp { if (isTypeParameterList) { isVariadic = false; // type parameter lists are not variadic prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken)); - // Use `.mapper` to ensure we get the generic type arguments even if this is an instantiated version of the signature. - const typeParameters = candidateSignature.typeParameters; // !!! candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; + const typeParameters = (candidateSignature.target || candidateSignature).typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken)); const parameterParts = mapToDisplayParts(writer => From 319617c5d8f7e496402b1ae746d0d9135bf880b4 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 3 Sep 2017 08:53:04 -0700 Subject: [PATCH 032/216] Optimize caching of type literals --- src/compiler/checker.ts | 46 +++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7a9931f19a4..112bbbf1c0a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8179,33 +8179,37 @@ namespace ts { } function getAnonymousTypeInstantiation(type: AnonymousType, mapper: TypeMapper) { - if (type.objectFlags & ObjectFlags.Instantiated) { - mapper = combineTypeMappers(type.mapper, mapper); - type = type.target; - } - const symbol = type.symbol; + const target = type.objectFlags & ObjectFlags.Instantiated ? type.target : type; + const symbol = target.symbol; const links = getSymbolLinks(symbol); - if (!links.typeParameters) { - // This first time an anonymous type is instantiated we compute and store a list of the type - // parameters that are in scope (and therefore potentially referenced). - const typeParameters = getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true); - links.typeParameters = typeParameters || emptyArray; - if (typeParameters) { + let typeParameters = links.typeParameters; + if (!typeParameters) { + // The first time an anonymous type is instantiated we compute and store a list of the type + // parameters that are in scope (and therefore potentially referenced). For type literals that + // aren't the right hand side of a generic type alias declaration we optimize by reducing the + // set of type parameters to those that are actually referenced somewhere in the literal. + const declaration = symbol.declarations[0]; + const outerTypeParameters = getOuterTypeParameters(declaration, /*includeThisTypes*/ true) || emptyArray; + typeParameters = symbol.flags & SymbolFlags.TypeLiteral && !target.aliasTypeArguments ? + filter(outerTypeParameters, tp => isTypeParameterReferencedWithin(tp, declaration)) : + outerTypeParameters; + links.typeParameters = typeParameters; + if (typeParameters.length) { links.instantiations = createMap(); - links.instantiations.set(getTypeListId(typeParameters), type); + links.instantiations.set(getTypeListId(typeParameters), target); } } - const typeParameters = links.typeParameters; if (typeParameters.length) { // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - const typeArguments = map(typeParameters, mapper); + const combinedMapper = type.objectFlags & ObjectFlags.Instantiated ? combineTypeMappers(type.mapper, mapper) : mapper; + const typeArguments = map(typeParameters, combinedMapper); const id = getTypeListId(typeArguments); let result = links.instantiations.get(id); if (!result) { const newMapper = createTypeMapper(typeParameters, typeArguments); - result = type.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(type, newMapper) : instantiateAnonymousType(type, newMapper); + result = target.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -8213,6 +8217,16 @@ namespace ts { return type; } + function isTypeParameterReferencedWithin(tp: TypeParameter, node: Node) { + return tp.isThisType ? forEachChild(node, checkThis) : forEachChild(node, checkIdentifier); + function checkThis(node: Node): boolean { + return node.kind === SyntaxKind.ThisType || forEachChild(node, checkThis); + } + function checkIdentifier(node: Node): boolean { + return node.kind === SyntaxKind.Identifier && isPartOfTypeNode(node) && getTypeFromTypeNode(node) === tp || forEachChild(node, checkIdentifier); + } + } + function instantiateMappedType(type: MappedType, mapper: TypeMapper): Type { // Check if we have a homomorphic mapped type, i.e. a type of the form { [P in keyof T]: X } for some // type variable T. If so, the mapped type is distributive over a union type and when T is instantiated @@ -10420,6 +10434,7 @@ namespace ts { function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0) { let symbolStack: Symbol[]; let visited: Map; + //sys.write(typeToString(originalSource) + " ==> " + typeToString(originalTarget) + "\n"); inferFromTypes(originalSource, originalTarget); function inferFromTypes(source: Type, target: Type) { @@ -10487,6 +10502,7 @@ namespace ts { const inference = getInferenceInfoForType(target); if (inference) { if (!inference.isFixed) { + //sys.write(" " + typeToString(source) + "\n"); if (!inference.candidates || priority < inference.priority) { inference.candidates = [source]; inference.priority = priority; From a0c40943feaa4afb1fbbe038d2cf5daf9d642f48 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 3 Sep 2017 08:53:19 -0700 Subject: [PATCH 033/216] Accept new baselines --- .../reference/functionConstraintSatisfaction2.errors.txt | 4 ---- tests/baselines/reference/limitDeepInstantiations.errors.txt | 4 ++-- tests/baselines/reference/promisePermutations.errors.txt | 2 -- tests/baselines/reference/promisePermutations2.errors.txt | 2 -- tests/baselines/reference/promisePermutations3.errors.txt | 2 -- 5 files changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt index f87312634f8..7558a97511f 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt +++ b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt @@ -22,8 +22,6 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain Type 'void' is not assignable to type 'string'. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(38,10): error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'. Type 'T' is not assignable to type '(x: string) => string'. - Type '() => void' is not assignable to type '(x: string) => string'. - Type 'void' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts (13 errors) ==== @@ -102,7 +100,5 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain ~ !!! error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'. !!! error TS2345: Type 'T' is not assignable to type '(x: string) => string'. -!!! error TS2345: Type '() => void' is not assignable to type '(x: string) => string'. -!!! error TS2345: Type 'void' is not assignable to type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/limitDeepInstantiations.errors.txt b/tests/baselines/reference/limitDeepInstantiations.errors.txt index 330e5fbc8e4..70718199d2b 100644 --- a/tests/baselines/reference/limitDeepInstantiations.errors.txt +++ b/tests/baselines/reference/limitDeepInstantiations.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/limitDeepInstantiations.ts(3,35): error TS2550: Generic type instantiation is excessively deep and possibly infinite. +tests/cases/compiler/limitDeepInstantiations.ts(3,35): error TS2502: '"true"' is referenced directly or indirectly in its own type annotation. tests/cases/compiler/limitDeepInstantiations.ts(5,13): error TS2344: Type '"false"' does not satisfy the constraint '"true"'. @@ -7,7 +7,7 @@ tests/cases/compiler/limitDeepInstantiations.ts(5,13): error TS2344: Type '"fals type Foo = { "true": Foo> }[T]; ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2550: Generic type instantiation is excessively deep and possibly infinite. +!!! error TS2502: '"true"' is referenced directly or indirectly in its own type annotation. let f1: Foo<"true", {}>; let f2: Foo<"false", {}>; ~~~~~~~ diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index a876345ffa1..c5527d5aa67 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -45,7 +45,6 @@ tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of t tests/cases/compiler/promisePermutations.ts(137,33): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations.ts(144,35): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. - Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations.ts(152,36): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. Types of property 'then' are incompatible. @@ -290,7 +289,6 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t var r10d = r10.then(testFunction, sIPromise, nIPromise); // ok ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. -!!! error TS2345: Type 'IPromise' is not assignable to type 'IPromise'. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index 871ee2ae2c3..955063797c0 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -45,7 +45,6 @@ tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of tests/cases/compiler/promisePermutations2.ts(136,33): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations2.ts(143,35): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. - Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations2.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. Types of property 'then' are incompatible. @@ -289,7 +288,6 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of var r10d = r10.then(testFunction, sIPromise, nIPromise); // error ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. -!!! error TS2345: Type 'IPromise' is not assignable to type 'IPromise'. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index 9d09559c5d3..89a4cffe688 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -48,7 +48,6 @@ tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of tests/cases/compiler/promisePermutations3.ts(136,33): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations3.ts(143,35): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. - Type 'IPromise' is not assignable to type 'IPromise'. tests/cases/compiler/promisePermutations3.ts(151,36): error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. Types of property 'then' are incompatible. @@ -301,7 +300,6 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of var r10d = r10.then(testFunction, sIPromise, nIPromise); // error ~~~~~~~~~ !!! error TS2345: Argument of type '(x: any) => IPromise' is not assignable to parameter of type '(error: any) => IPromise'. -!!! error TS2345: Type 'IPromise' is not assignable to type 'IPromise'. var r10e = r10.then(testFunction, nIPromise, sIPromise).then(sIPromise, sIPromise, sIPromise); // ok var s10 = testFunction10P(x => x); var s10a = s10.then(testFunction10, testFunction10, testFunction10); // ok From 82281d9910e9d5dd3289368dad63b18fb87dbc29 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 3 Sep 2017 11:00:03 -0700 Subject: [PATCH 034/216] Fix linting errors --- src/compiler/checker.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 112bbbf1c0a..42b15d1a0ac 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10434,7 +10434,6 @@ namespace ts { function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0) { let symbolStack: Symbol[]; let visited: Map; - //sys.write(typeToString(originalSource) + " ==> " + typeToString(originalTarget) + "\n"); inferFromTypes(originalSource, originalTarget); function inferFromTypes(source: Type, target: Type) { @@ -10502,7 +10501,6 @@ namespace ts { const inference = getInferenceInfoForType(target); if (inference) { if (!inference.isFixed) { - //sys.write(" " + typeToString(source) + "\n"); if (!inference.candidates || priority < inference.priority) { inference.candidates = [source]; inference.priority = priority; From 3f5986f747b581c000481812d68d62cd6bfbda3a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 4 Sep 2017 16:37:51 -0700 Subject: [PATCH 035/216] Disable control flow analysis in excessively large statement blocks --- src/compiler/checker.ts | 83 ++++++++++++++++++---------- src/compiler/diagnosticMessages.json | 4 ++ 2 files changed, 57 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9174aa3c023..c3e3473e3f8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -334,6 +334,7 @@ namespace ts { let flowLoopStart = 0; let flowLoopCount = 0; let visitedFlowCount = 0; + let flowAnalysisDisabled = false; const emptyStringType = getLiteralType(""); const zeroType = getLiteralType(0); @@ -11487,6 +11488,10 @@ namespace ts { function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; + let flowLength = 0; + if (flowAnalysisDisabled) { + return unknownType; + } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; } @@ -11504,60 +11509,72 @@ namespace ts { return resultType; function getTypeAtFlowNode(flow: FlowNode): FlowType { + const saveFlowLength = flowLength; while (true) { - if (flow.flags & FlowFlags.Shared) { + flowLength++; + if (flowLength === 5000) { + // The length of this particular control flow path is 5000 nodes or more. Rather than spending an + // excessive amount of time and possibly overflowing the call stack, we report an error and disable + // further control flow analysis in the containing function or module body. + flowAnalysisDisabled = true; + error(reference, Diagnostics.The_body_of_the_containing_function_or_module_is_too_large_for_control_flow_analysis); + return unknownType; + } + const flags = flow.flags; + if (flags & FlowFlags.Shared) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. for (let i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { + flowLength = saveFlowLength; return visitedFlowTypes[i]; } } } let type: FlowType; - if (flow.flags & FlowFlags.AfterFinally) { + if (flags & FlowFlags.AfterFinally) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement (flow).locked = true; type = getTypeAtFlowNode((flow).antecedent); (flow).locked = false; } - else if (flow.flags & FlowFlags.PreFinally) { + else if (flags & FlowFlags.PreFinally) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = (flow).antecedent; continue; } - else if (flow.flags & FlowFlags.Assignment) { + else if (flags & FlowFlags.Assignment) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = (flow).antecedent; continue; } } - else if (flow.flags & FlowFlags.Condition) { + else if (flags & FlowFlags.Condition) { type = getTypeAtFlowCondition(flow); } - else if (flow.flags & FlowFlags.SwitchClause) { + else if (flags & FlowFlags.SwitchClause) { type = getTypeAtSwitchClause(flow); } - else if (flow.flags & FlowFlags.Label) { + else if (flags & FlowFlags.Label) { if ((flow).antecedents.length === 1) { flow = (flow).antecedents[0]; continue; } - type = flow.flags & FlowFlags.BranchLabel ? + type = flags & FlowFlags.BranchLabel ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flow.flags & FlowFlags.ArrayMutation) { + else if (flags & FlowFlags.ArrayMutation) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = (flow).antecedent; continue; } } - else if (flow.flags & FlowFlags.Start) { + else if (flags & FlowFlags.Start) { // Check if we should continue with the control flow of the containing function. const container = (flow).container; if (container && container !== flowContainer && reference.kind !== SyntaxKind.PropertyAccessExpression && reference.kind !== SyntaxKind.ThisKeyword) { @@ -11572,12 +11589,13 @@ namespace ts { // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flow.flags & FlowFlags.Shared) { + if (flags & FlowFlags.Shared) { // Record visited node and the associated type in the cache. visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; } + flowLength = saveFlowLength; return type; } } @@ -11615,29 +11633,31 @@ namespace ts { } function getTypeAtFlowArrayMutation(flow: FlowArrayMutation): FlowType { - const node = flow.node; - const expr = node.kind === SyntaxKind.CallExpression ? - ((node).expression).expression : - ((node).left).expression; - if (isMatchingReference(reference, getReferenceCandidate(expr))) { - const flowType = getTypeAtFlowNode(flow.antecedent); - const type = getTypeFromFlowType(flowType); - if (getObjectFlags(type) & ObjectFlags.EvolvingArray) { - let evolvedType = type; - if (node.kind === SyntaxKind.CallExpression) { - for (const arg of (node).arguments) { - evolvedType = addEvolvingArrayElementType(evolvedType, arg); + if (declaredType === autoType || declaredType === autoArrayType) { + const node = flow.node; + const expr = node.kind === SyntaxKind.CallExpression ? + ((node).expression).expression : + ((node).left).expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + const flowType = getTypeAtFlowNode(flow.antecedent); + const type = getTypeFromFlowType(flowType); + if (getObjectFlags(type) & ObjectFlags.EvolvingArray) { + let evolvedType = type; + if (node.kind === SyntaxKind.CallExpression) { + for (const arg of (node).arguments) { + evolvedType = addEvolvingArrayElementType(evolvedType, arg); + } } - } - else { - const indexType = getTypeOfExpression(((node).left).argumentExpression); - if (isTypeAssignableToKind(indexType, TypeFlags.NumberLike)) { - evolvedType = addEvolvingArrayElementType(evolvedType, (node).right); + else { + const indexType = getTypeOfExpression(((node).left).argumentExpression); + if (isTypeAssignableToKind(indexType, TypeFlags.NumberLike)) { + evolvedType = addEvolvingArrayElementType(evolvedType, (node).right); + } } + return evolvedType === type ? flowType : createFlowType(evolvedType, isIncomplete(flowType)); } - return evolvedType === type ? flowType : createFlowType(evolvedType, isIncomplete(flowType)); + return flowType; } - return flowType; } return undefined; } @@ -19951,7 +19971,9 @@ namespace ts { if (node.kind === SyntaxKind.Block) { checkGrammarStatementInAmbientContext(node); } + const saveFlowAnalysisDisabled = flowAnalysisDisabled; forEach(node.statements, checkSourceElement); + flowAnalysisDisabled = saveFlowAnalysisDisabled; if (node.locals) { registerForUnusedIdentifiersCheck(node); } @@ -22541,6 +22563,7 @@ namespace ts { deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; + flowAnalysisDisabled = false; forEach(node.statements, checkSourceElement); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9a3492e5c37..b3668cc5acf 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1920,6 +1920,10 @@ "category": "Error", "code": 2562 }, + "The body of the containing function or module is too large for control flow analysis.": { + "category": "Error", + "code": 2563 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 From 4f43ae207afe655f1dbda7fa0a732890fdf78313 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 4 Sep 2017 16:57:36 -0700 Subject: [PATCH 036/216] Add test --- .../largeControlFlowGraph.errors.txt | 10010 ++++++++ .../reference/largeControlFlowGraph.js | 20010 ++++++++++++++++ tests/cases/compiler/largeControlFlowGraph.ts | 10003 ++++++++ 3 files changed, 40023 insertions(+) create mode 100644 tests/baselines/reference/largeControlFlowGraph.errors.txt create mode 100644 tests/baselines/reference/largeControlFlowGraph.js create mode 100644 tests/cases/compiler/largeControlFlowGraph.ts diff --git a/tests/baselines/reference/largeControlFlowGraph.errors.txt b/tests/baselines/reference/largeControlFlowGraph.errors.txt new file mode 100644 index 00000000000..f9dad52c79f --- /dev/null +++ b/tests/baselines/reference/largeControlFlowGraph.errors.txt @@ -0,0 +1,10010 @@ +tests/cases/compiler/largeControlFlowGraph.ts(5003,1): error TS2563: The body of the containing function or module is too large for control flow analysis. + + +==== tests/cases/compiler/largeControlFlowGraph.ts (1 errors) ==== + // The control flow graph for the following statement block is 10000 nodes deep. Check that + // we gracefully handle this, possibly by issuing an error. + const data = []; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + ~~~~ +!!! error TS2563: The body of the containing function or module is too large for control flow analysis. + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + data[0] = 0; + \ No newline at end of file diff --git a/tests/baselines/reference/largeControlFlowGraph.js b/tests/baselines/reference/largeControlFlowGraph.js new file mode 100644 index 00000000000..ee1edbe8984 --- /dev/null +++ b/tests/baselines/reference/largeControlFlowGraph.js @@ -0,0 +1,20010 @@ +//// [largeControlFlowGraph.ts] +// The control flow graph for the following statement block is 10000 nodes deep. Check that +// we gracefully handle this, possibly by issuing an error. +const data = []; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; + + +//// [largeControlFlowGraph.js] +// The control flow graph for the following statement block is 10000 nodes deep. Check that +// we gracefully handle this, possibly by issuing an error. +var data = []; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; diff --git a/tests/cases/compiler/largeControlFlowGraph.ts b/tests/cases/compiler/largeControlFlowGraph.ts new file mode 100644 index 00000000000..0503c80095b --- /dev/null +++ b/tests/cases/compiler/largeControlFlowGraph.ts @@ -0,0 +1,10003 @@ +// The control flow graph for the following statement block is 10000 nodes deep. Check that +// we gracefully handle this, possibly by issuing an error. +const data = []; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; +data[0] = 0; From 2fc14d8ae81ceee5046f1be05c6d5536183d8ef9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 5 Sep 2017 10:39:32 -0700 Subject: [PATCH 037/216] Remove added type predicates I forgot that 'f(x): x is T' implies that x is *not* T if f returns false. --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 85ac20b4114..8f1f4808741 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9781,7 +9781,7 @@ namespace ts { return type.flags & TypeFlags.TypeParameter && !getConstraintFromTypeParameter(type); } - function isTypeReferenceWithGenericArguments(type: Type): type is TypeReference { + function isTypeReferenceWithGenericArguments(type: Type): boolean { return getObjectFlags(type) & ObjectFlags.Reference && some((type).typeArguments, t => isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t)); } @@ -9801,7 +9801,7 @@ namespace ts { result += "=" + index; } else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) { - result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">"; + result += "<" + getTypeReferenceId(t as TypeReference, typeParameters, depth + 1) + ">"; } else { result += "-" + t.id; @@ -10052,7 +10052,7 @@ namespace ts { getUnionType(types, /*subtypeReduction*/ true); } - function isArrayType(type: Type): type is TypeReference { + function isArrayType(type: Type): boolean { return getObjectFlags(type) & ObjectFlags.Reference && (type).target === globalArrayType; } From 3a164b955b11fb82025a8636d57d8a94740381f8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 5 Sep 2017 12:55:18 -0700 Subject: [PATCH 038/216] Improve baseline of complexRecursiveCollections By adding @lib:es6, which gets rid of tons of bogus errors. The point of the test is compile time, but it's more confidence-inspiring to know that basic ES6 collections are getting resolved and typechecked too. --- .../complexRecursiveCollections.errors.txt | 287 +----------------- .../compiler/complexRecursiveCollections.ts | 1 + 2 files changed, 2 insertions(+), 286 deletions(-) diff --git a/tests/baselines/reference/complexRecursiveCollections.errors.txt b/tests/baselines/reference/complexRecursiveCollections.errors.txt index 38f66b7456a..495fca2e651 100644 --- a/tests/baselines/reference/complexRecursiveCollections.errors.txt +++ b/tests/baselines/reference/complexRecursiveCollections.errors.txt @@ -1,110 +1,15 @@ -tests/cases/compiler/immutable.d.ts(25,39): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(46,20): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(47,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(48,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(49,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(50,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(51,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(52,26): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(58,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(60,63): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(68,41): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(69,38): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(69,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(78,21): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(79,21): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(89,20): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(90,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(91,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(92,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(93,23): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(94,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(95,26): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(101,42): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(106,58): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(113,48): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(114,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(114,54): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(120,42): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(125,58): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(134,33): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(134,42): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(135,29): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(135,38): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(139,38): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(155,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(157,62): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(169,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(172,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(174,62): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(188,40): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(195,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(198,19): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(205,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(207,63): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(217,30): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(218,34): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(226,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(227,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(234,48): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(235,52): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(236,109): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(237,109): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(242,22): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(243,25): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(244,24): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(245,28): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(246,25): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(247,25): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(258,8): error TS2304: Cannot find name 'Symbol'. -tests/cases/compiler/immutable.d.ts(258,28): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(266,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(274,44): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(279,60): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(288,44): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(293,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(295,65): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(304,40): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(309,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(311,64): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(320,38): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(329,58): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(339,45): error TS2304: Cannot find name 'Iterable'. tests/cases/compiler/immutable.d.ts(341,22): error TS2430: Interface 'Keyed' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Keyed' is not assignable to type '() => this'. Type 'Keyed' is not assignable to type 'this'. -tests/cases/compiler/immutable.d.ts(347,44): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(352,60): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(355,8): error TS2304: Cannot find name 'Symbol'. -tests/cases/compiler/immutable.d.ts(355,28): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(358,44): error TS2304: Cannot find name 'Iterable'. tests/cases/compiler/immutable.d.ts(359,22): error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Indexed' is not assignable to type '() => this'. Type 'Indexed' is not assignable to type 'this'. -tests/cases/compiler/immutable.d.ts(382,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(384,65): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(387,8): error TS2304: Cannot find name 'Symbol'. -tests/cases/compiler/immutable.d.ts(387,28): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(390,40): error TS2304: Cannot find name 'Iterable'. tests/cases/compiler/immutable.d.ts(391,22): error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. Types of property 'toSeq' are incompatible. Type '() => Set' is not assignable to type '() => this'. Type 'Set' is not assignable to type 'this'. -tests/cases/compiler/immutable.d.ts(396,47): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(398,64): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(401,8): error TS2304: Cannot find name 'Symbol'. -tests/cases/compiler/immutable.d.ts(401,28): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(405,45): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(420,26): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(421,26): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(442,13): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(443,15): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(444,16): error TS2304: Cannot find name 'IterableIterator'. -tests/cases/compiler/immutable.d.ts(476,58): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(503,20): error TS2304: Cannot find name 'Iterable'. -tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Iterable'. ==== tests/cases/compiler/complex.d.ts (0 errors) ==== @@ -128,7 +33,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite flatMap(mapper: (value: T, key: void, iter: this) => Ara, context?: any): N2; toSeq(): N2; } -==== tests/cases/compiler/immutable.d.ts (98 errors) ==== +==== tests/cases/compiler/immutable.d.ts (3 errors) ==== // Test that complex recursive collections can pass the `extends` assignability check without // running out of memory. This bug was exposed in Typescript 2.4 when more generic signatures // started being checked. @@ -154,8 +59,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function List(): List; export function List(): List; export function List(collection: Iterable): List; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface List extends Collection.Indexed { // Persistent changes set(index: number, value: T): List; @@ -177,38 +80,20 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite setSize(size: number): List; // Deep persistent changes setIn(keyPath: Iterable, value: any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. deleteIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. removeIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeepIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Transient changes withMutations(mutator: (mutable: this) => any): this; asMutable(): this; asImmutable(): this; // Sequence algorithms concat(...valuesOrCollections: Array | C>): List; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: number, iter: this) => M, context?: any): List; flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): List; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): List; filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; } @@ -217,13 +102,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function of(...keyValues: Array): Map; } export function Map(collection: Iterable<[K, V]>): Map; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Map(collection: Iterable>): Map; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Map(obj: {[key: string]: V}): Map; export function Map(): Map; export function Map(): Map; @@ -233,11 +112,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite delete(key: K): this; remove(key: K): this; deleteAll(keys: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. removeAll(keys: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. clear(): this; update(key: K, notSetValue: V, updater: (value: V) => V): this; update(key: K, updater: (value: V) => V): this; @@ -248,41 +123,23 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite mergeDeepWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array | {[key: string]: V}>): this; // Deep persistent changes setIn(keyPath: Iterable, value: any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. deleteIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. removeIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeepIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Transient changes withMutations(mutator: (mutable: this) => any): this; asMutable(): this; asImmutable(): this; // Sequence algorithms concat(...collections: Array>): Map; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. concat(...collections: Array<{[key: string]: C}>): Map; map(mapper: (value: V, key: K, iter: this) => M, context?: any): Map; mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Map; mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Map; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Map; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Map; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; } @@ -290,28 +147,18 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap; } export function OrderedMap(collection: Iterable<[K, V]>): OrderedMap; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function OrderedMap(collection: Iterable>): OrderedMap; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function OrderedMap(obj: {[key: string]: V}): OrderedMap; export function OrderedMap(): OrderedMap; export function OrderedMap(): OrderedMap; export interface OrderedMap extends Map { // Sequence algorithms concat(...collections: Array>): OrderedMap; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. concat(...collections: Array<{[key: string]: C}>): OrderedMap; map(mapper: (value: V, key: K, iter: this) => M, context?: any): OrderedMap; mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): OrderedMap; mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): OrderedMap; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): OrderedMap; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): OrderedMap; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; } @@ -321,21 +168,11 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function fromKeys(iter: Collection): Set; function fromKeys(obj: {[key: string]: any}): Set; function intersect(sets: Iterable>): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. function union(sets: Iterable>): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. } export function Set(): Set; export function Set(): Set; export function Set(collection: Iterable): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Set extends Collection.Set { // Persistent changes add(value: T): this; @@ -352,12 +189,8 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite asImmutable(): this; // Sequence algorithms concat(...valuesOrCollections: Array | C>): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: never, iter: this) => M, context?: any): Set; flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Set; filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; } @@ -370,17 +203,11 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function OrderedSet(): OrderedSet; export function OrderedSet(): OrderedSet; export function OrderedSet(collection: Iterable): OrderedSet; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface OrderedSet extends Set { // Sequence algorithms concat(...valuesOrCollections: Array | C>): OrderedSet; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: never, iter: this) => M, context?: any): OrderedSet; flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): OrderedSet; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): OrderedSet; filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; zip(...collections: Array>): OrderedSet; @@ -395,8 +222,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function Stack(): Stack; export function Stack(): Stack; export function Stack(collection: Iterable): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Stack extends Collection.Indexed { // Reading values peek(): T | undefined; @@ -404,13 +229,9 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite clear(): Stack; unshift(...values: Array): Stack; unshiftAll(iter: Iterable): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. shift(): Stack; push(...values: Array): Stack; pushAll(iter: Iterable): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. pop(): Stack; // Transient changes withMutations(mutator: (mutable: this) => any): this; @@ -418,12 +239,8 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite asImmutable(): this; // Sequence algorithms concat(...valuesOrCollections: Array | C>): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: number, iter: this) => M, context?: any): Stack; flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Stack; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Set; filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; } @@ -434,11 +251,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function getDescriptiveName(record: Instance): string; export interface Class { (values?: Partial | Iterable<[string, any]>): Instance & Readonly; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. new (values?: Partial | Iterable<[string, any]>): Instance & Readonly; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. } export interface Instance { readonly size: number; @@ -447,11 +260,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite get(key: K): T[K]; // Reading deep values hasIn(keyPath: Iterable): boolean; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. getIn(keyPath: Iterable): any; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Value equality equals(other: any): boolean; hashCode(): number; @@ -459,39 +268,19 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite set(key: K, value: T[K]): this; update(key: K, updater: (value: T[K]) => T[K]): this; merge(...collections: Array | Iterable<[string, any]>>): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeep(...collections: Array | Iterable<[string, any]>>): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeWith(merger: (oldVal: any, newVal: any, key: keyof T) => any, ...collections: Array | Iterable<[string, any]>>): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeepWith(merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array | Iterable<[string, any]>>): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. delete(key: K): this; remove(key: K): this; clear(): this; // Deep persistent changes setIn(keyPath: Iterable, value: any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. updateIn(keyPath: Iterable, updater: (value: any) => any): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. mergeDeepIn(keyPath: Iterable, ...collections: Array): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. deleteIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. removeIn(keyPath: Iterable): this; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Conversion to JavaScript types toJS(): { [K in keyof T]: any }; toJSON(): T; @@ -503,10 +292,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite // Sequence algorithms toSeq(): Seq.Keyed; [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>; - ~~~~~~ -!!! error TS2304: Cannot find name 'Symbol'. - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. } } export function Record(defaultValues: T, name?: string): Record.Class; @@ -515,8 +300,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function of(...values: Array): Seq.Indexed; export module Keyed {} export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Keyed(obj: {[key: string]: V}): Seq.Keyed; export function Keyed(): Seq.Keyed; export function Keyed(): Seq.Keyed; @@ -525,15 +308,11 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite toJSON(): { [key: string]: V }; toSeq(): this; concat(...collections: Array>): Seq.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. concat(...collections: Array<{[key: string]: C}>): Seq.Keyed; map(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq.Keyed; mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Seq.Keyed; mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Seq.Keyed; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Seq.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq.Keyed; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; } @@ -543,19 +322,13 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function Indexed(): Seq.Indexed; export function Indexed(): Seq.Indexed; export function Indexed(collection: Iterable): Seq.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Indexed extends Seq, Collection.Indexed { toJS(): Array; toJSON(): Array; toSeq(): this; concat(...valuesOrCollections: Array | C>): Seq.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: number, iter: this) => M, context?: any): Seq.Indexed; flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Seq.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Seq.Indexed; filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; } @@ -565,19 +338,13 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function Set(): Seq.Set; export function Set(): Seq.Set; export function Set(collection: Iterable): Seq.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Set extends Seq, Collection.Set { toJS(): Array; toJSON(): Array; toSeq(): this; concat(...valuesOrCollections: Array | C>): Seq.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: never, iter: this) => M, context?: any): Seq.Set; flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Seq.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Seq.Set; filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; } @@ -587,8 +354,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite export function Seq(collection: Collection.Indexed): Seq.Indexed; export function Seq(collection: Collection.Set): Seq.Set; export function Seq(collection: Iterable): Seq.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Seq(obj: {[key: string]: V}): Seq.Keyed; export function Seq(): Seq; export interface Seq extends Collection { @@ -598,8 +363,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite // Sequence algorithms map(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Seq; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; } @@ -610,8 +373,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite function isOrdered(maybeOrdered: any): boolean; export module Keyed {} export function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Keyed(obj: {[key: string]: V}): Collection.Keyed; export interface Keyed extends Collection { ~~~~~ @@ -625,27 +386,17 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite // Sequence functions flip(): this; concat(...collections: Array>): Collection.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. concat(...collections: Array<{[key: string]: C}>): Collection.Keyed; map(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection.Keyed; mapKeys(mapper: (key: K, value: V, iter: this) => M, context?: any): Collection.Keyed; mapEntries(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Collection.Keyed; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Collection.Keyed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection.Keyed; filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this; [Symbol.iterator](): IterableIterator<[K, V]>; - ~~~~~~ -!!! error TS2304: Cannot find name 'Symbol'. - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. } export module Indexed {} export function Indexed(collection: Iterable): Collection.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Indexed extends Collection { ~~~~~~~ !!! error TS2430: Interface 'Indexed' incorrectly extends interface 'Collection'. @@ -675,24 +426,14 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite findLastIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number; // Sequence algorithms concat(...valuesOrCollections: Array | C>): Collection.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: number, iter: this) => M, context?: any): Collection.Indexed; flatMap(mapper: (value: T, key: number, iter: this) => Iterable, context?: any): Collection.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Collection.Indexed; filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this; [Symbol.iterator](): IterableIterator; - ~~~~~~ -!!! error TS2304: Cannot find name 'Symbol'. - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. } export module Set {} export function Set(collection: Iterable): Collection.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export interface Set extends Collection { ~~~ !!! error TS2430: Interface 'Set' incorrectly extends interface 'Collection'. @@ -704,25 +445,15 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite toSeq(): Seq.Set; // Sequence algorithms concat(...valuesOrCollections: Array | C>): Collection.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. map(mapper: (value: T, key: never, iter: this) => M, context?: any): Collection.Set; flatMap(mapper: (value: T, key: never, iter: this) => Iterable, context?: any): Collection.Set; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. filter(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Collection.Set; filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this; [Symbol.iterator](): IterableIterator; - ~~~~~~ -!!! error TS2304: Cannot find name 'Symbol'. - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. } } export function Collection>(collection: I): I; export function Collection(collection: Iterable): Collection.Indexed; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. export function Collection(obj: {[key: string]: V}): Collection.Keyed; export interface Collection extends ValueObject { // Value equality @@ -738,11 +469,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite last(): V | undefined; // Reading deep values getIn(searchKeyPath: Iterable, notSetValue?: any): any; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. hasIn(searchKeyPath: Iterable): boolean; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Persistent changes update(updater: (value: this) => R): R; // Conversion to JavaScript types @@ -764,14 +491,8 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite toSetSeq(): Seq.Set; // Iterators keys(): IterableIterator; - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. values(): IterableIterator; - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. entries(): IterableIterator<[K, V]>; - ~~~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'IterableIterator'. // Collections (Seq) keySeq(): Seq.Indexed; valueSeq(): Seq.Indexed; @@ -804,8 +525,6 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite flatten(depth?: number): Collection; flatten(shallow?: boolean): Collection; flatMap(mapper: (value: V, key: K, iter: this) => Iterable, context?: any): Collection; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. // Reducing a value reduce(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R; reduce(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; @@ -833,11 +552,7 @@ tests/cases/compiler/immutable.d.ts(504,22): error TS2304: Cannot find name 'Ite minBy(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined; // Comparison isSubset(iter: Iterable): boolean; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. isSuperset(iter: Iterable): boolean; - ~~~~~~~~ -!!! error TS2304: Cannot find name 'Iterable'. readonly size: number; } } diff --git a/tests/cases/compiler/complexRecursiveCollections.ts b/tests/cases/compiler/complexRecursiveCollections.ts index a79b429f204..68054aac0f9 100644 --- a/tests/cases/compiler/complexRecursiveCollections.ts +++ b/tests/cases/compiler/complexRecursiveCollections.ts @@ -1,3 +1,4 @@ +// @lib: es6 // @Filename: complex.d.ts interface Ara { t: T } interface Collection { From 6ae761720e7c532185940166f0b9ea5afba89599 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 5 Sep 2017 13:37:51 -0700 Subject: [PATCH 039/216] Add test for #14574 (#18024) --- tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts diff --git a/tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts b/tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts new file mode 100644 index 00000000000..147483cfe58 --- /dev/null +++ b/tests/cases/fourslash/quickInfoForSyntaxErrorNoError.ts @@ -0,0 +1,9 @@ +/// + +//// namespace X { +//// export = +//// } +//// X.add/*1*/ + +// verify there is no crash +verify.quickInfoAt("1", "any"); From 56f646eaff42446f435bd46777e27948fc8a62c8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 5 Sep 2017 15:09:06 -0700 Subject: [PATCH 040/216] Make top-level getJSDoc* functions public * getJSDocParameterTags * getJSDocAugmentsTag * getJSDocClassTag * getJSDocClassTag * getJSDocTemplateTag * getJSDocReturnTag * getJSDocType * getJSDocReturnType --- src/compiler/utilities.ts | 142 ++++++++++++++++++++++++-------------- 1 file changed, 91 insertions(+), 51 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2a07d2b6560..fe242190262 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1495,15 +1495,6 @@ namespace ts { ((node as JSDocFunctionType).parameters[0].name as Identifier).escapedText === "new"; } - export function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean { - return !!getFirstJSDocTag(node, SyntaxKind.JSDocParameterTag); - } - - function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag | undefined { - const tags = getJSDocTags(node); - return find(tags, doc => doc.kind === kind); - } - export function getAllJSDocs(node: Node): (JSDoc | JSDocTag)[] { if (isJSDocTypedefTag(node)) { return [node.parent]; @@ -1577,15 +1568,6 @@ namespace ts { } } - export function getJSDocParameterTags(param: ParameterDeclaration): JSDocParameterTag[] | undefined { - if (param.name && isIdentifier(param.name)) { - const name = param.name.escapedText; - return getJSDocTags(param.parent).filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name) as JSDocParameterTag[]; - } - // a binding pattern doesn't have a name, so it's not possible to match it a jsdoc parameter, which is identified by name - return undefined; - } - /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ export function getParameterSymbolFromJSDoc(node: JSDocParameterTag): Symbol | undefined { if (node.symbol) { @@ -1611,39 +1593,6 @@ namespace ts { return find(typeParameters, p => p.name.escapedText === name); } - export function getJSDocType(node: Node): TypeNode { - let tag: JSDocTypeTag | JSDocParameterTag = getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag; - if (!tag && node.kind === SyntaxKind.Parameter) { - const paramTags = getJSDocParameterTags(node as ParameterDeclaration); - if (paramTags) { - tag = find(paramTags, tag => !!tag.typeExpression); - } - } - - return tag && tag.typeExpression && tag.typeExpression.type; - } - - export function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocAugmentsTag) as JSDocAugmentsTag; - } - - export function getJSDocClassTag(node: Node): JSDocClassTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocClassTag) as JSDocClassTag; - } - - export function getJSDocReturnTag(node: Node): JSDocReturnTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; - } - - export function getJSDocReturnType(node: Node): TypeNode { - const returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; - } - - export function getJSDocTemplateTag(node: Node): JSDocTemplateTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocTemplateTag) as JSDocTemplateTag; - } - export function hasRestParameter(s: SignatureDeclaration): boolean { return isRestParameter(lastOrUndefined(s.parameters)); } @@ -3983,6 +3932,97 @@ namespace ts { return (declaration as NamedDeclaration).name; } } + + /** + * Gets the JSDoc parameter tags for the node if present. + * + * @remarks Returns any JSDoc param tag that matches the provided + * parameter, whether a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the param + * tag on the containing function expression would be first. + * + * Does not return tags for binding patterns, because JSDoc matches + * parameters by name and binding patterns do not have a name. + */ + export function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray | undefined { + if (param.name && isIdentifier(param.name)) { + const name = param.name.escapedText; + return getJSDocTags(param.parent).filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name) as JSDocParameterTag[]; + } + // a binding pattern doesn't have a name, so it's not possible to match it a JSDoc parameter, which is identified by name + return undefined; + } + + /** + * Return true if the node has JSDoc parameter tags. + * + * @remarks Includes parameter tags that are not directly on the node, + * for example on a variable declaration whose initializer is a function expression. + */ + export function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean { + return !!getFirstJSDocTag(node, SyntaxKind.JSDocParameterTag); + } + + /** Gets the JSDoc augments tag for the node if present */ + export function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocAugmentsTag) as JSDocAugmentsTag; + } + + /** Gets the JSDoc class tag for the node if present */ + export function getJSDocClassTag(node: Node): JSDocClassTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocClassTag) as JSDocClassTag; + } + + /** Gets the JSDoc template tag for the node if present */ + export function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocTemplateTag) as JSDocTemplateTag; + } + + /** Gets the JSDoc return tag for the node if present */ + export function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; + } + + /** + * Gets the type node for the node if provided via JSDoc. + * + * @remarks The search includes any JSDoc param tag that relates + * to the provided parameter, for example a type tag on the + * parameter itself, or a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are examined first, so in the previous example, the type + * tag directly on the node would be returned. + */ + export function getJSDocType(node: Node): TypeNode | undefined { + let tag: JSDocTypeTag | JSDocParameterTag = getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag; + if (!tag && node.kind === SyntaxKind.Parameter) { + const paramTags = getJSDocParameterTags(node as ParameterDeclaration); + if (paramTags) { + tag = find(paramTags, tag => !!tag.typeExpression); + } + } + + return tag && tag.typeExpression && tag.typeExpression.type; + } + + /** + * Gets the return type node for the node if provided via JSDoc's return tag. + * + * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function + * gets the type from inside the braces. */ + export function getJSDocReturnType(node: Node): TypeNode | undefined { + const returnTag = getJSDocReturnTag(node); + return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + } + + /* Get the first JSDoc tag of a specified kind, or undefined if not present. */ + function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag | undefined { + const tags = getJSDocTags(node); + return find(tags, doc => doc.kind === kind); + } } // Simple node tests of the form `node.kind === SyntaxKind.Foo`. From 058d355caeab3b4058e1166974ecd8444383fce4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 5 Sep 2017 15:22:17 -0700 Subject: [PATCH 041/216] Add getJSDocTypeTag to get `@type` tag --- src/compiler/utilities.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fe242190262..78eacee7d22 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3975,14 +3975,19 @@ namespace ts { return getFirstJSDocTag(node, SyntaxKind.JSDocClassTag) as JSDocClassTag; } + /** Gets the JSDoc return tag for the node if present */ + export function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; + } + /** Gets the JSDoc template tag for the node if present */ export function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined { return getFirstJSDocTag(node, SyntaxKind.JSDocTemplateTag) as JSDocTemplateTag; } - /** Gets the JSDoc return tag for the node if present */ - export function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined { - return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; + /** Gets the JSDoc type tag for the node if present */ + export function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag; } /** From 9c6765d5cf697b5cb2fcda3d21bb2c2985ecdaf9 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 5 Sep 2017 15:47:54 -0700 Subject: [PATCH 042/216] Document ThrottledOperations.schedule --- src/server/utilities.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 700a1e12fee..cde6329bf07 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -179,6 +179,12 @@ namespace ts.server { constructor(private readonly host: ServerHost) { } + /** + * Wait `number` milliseconds and then invoke `cb`. If, while waiting, schedule + * is called again with the same `operationId`, cancel this operation in favor + * of the new one. (Note that the amount of time the canceled operation had been + * waiting does not affect the amount of time that the new operation waits.) + */ public schedule(operationId: string, delay: number, cb: () => void) { const pendingTimeout = this.pendingTimeouts.get(operationId); if (pendingTimeout) { From 95bf71f08c114dc22979cfbeed5f1bcddfc6bbbd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 5 Sep 2017 17:17:04 -0700 Subject: [PATCH 043/216] Use canonicalized forms when comparing signatures --- src/compiler/checker.ts | 31 ++++++++++++++++++++++++++----- src/compiler/types.ts | 2 ++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fa5441f6841..bf0d7655309 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6632,11 +6632,31 @@ namespace ts { } function getErasedSignature(signature: Signature): Signature { - if (!signature.typeParameters) return signature; - if (!signature.erasedSignatureCache) { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), /*eraseTypeParameters*/ true); - } - return signature.erasedSignatureCache; + return signature.typeParameters ? + signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : + signature; + } + + function createErasedSignature(signature: Signature) { + // Create an instantiation of the signature where all type arguments are the any type. + return instantiateSignature(signature, createTypeEraser(signature.typeParameters), /*eraseTypeParameters*/ true); + } + + function getCanonicalSignature(signature: Signature): Signature { + return signature.typeParameters ? + signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) : + signature; + } + + function createCanonicalSignature(signature: Signature) { + // Create an instantiation of the signature where each unconstrained type parameter is replaced with + // its original. When a generic class or interface is instantiated, each generic method in the class or + // interface is instantiated with a fresh set of cloned type parameters (which we need to handle scenarios + // where different generations of the same type parameter are in scope). This leads to a lot of new type + // identities, and potentially a lot of work comparing those identities, so here we create an instantiation + // that reverts back to the original type identities for all unconstrained type parameters. + const canonicalTypeArguments = map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp); + return instantiateSignature(signature, createTypeMapper(signature.typeParameters, canonicalTypeArguments), /*eraseTypeParameters*/ true); } function getOrCreateTypeFromSignature(signature: Signature): ObjectType { @@ -8473,6 +8493,7 @@ namespace ts { return Ternary.False; } + target = getCanonicalSignature(target); if (source.typeParameters) { source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e2d9977f302..9d5bbf5b08e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3447,6 +3447,8 @@ namespace ts { /* @internal */ erasedSignatureCache?: Signature; // Erased version of signature (deferred) /* @internal */ + canonicalSignatureCache?: Signature; // Canonical version of signature (deferred) + /* @internal */ isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison /* @internal */ typePredicate?: TypePredicate; From 482e802e83598da9bb3c02adb7af71cffa2331aa Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 5 Sep 2017 16:00:19 -0700 Subject: [PATCH 044/216] Limit the number of unanswered typings installer requests If we send them all at once, we (apparently) hit a buffer limit in the node IPC channel and both TS Server and the typings installer become unresponsive. --- src/server/server.ts | 62 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index f70e2d0faf7..7f6daa92d5e 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -236,25 +236,35 @@ namespace ts.server { return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${d.getMilliseconds()}`; } + interface QueuedOperation { + operationId: string; + operation: () => void; + } + class NodeTypingsInstaller implements ITypingsInstaller { private installer: NodeChildProcess; private installerPidReported = false; private socket: NodeSocket; private projectService: ProjectService; - private throttledOperations: ThrottledOperations; private eventSender: EventSender; + private activeRequestCount = 0; + private requestQueue: QueuedOperation[] = []; + private requestMap = createMap(); // Maps operation ID to newest requestQueue entry with that ID + + private static readonly maxActiveRequestCount = 10; + private static readonly requestDelayMillis = 100; + constructor( private readonly telemetryEnabled: boolean, private readonly logger: server.Logger, - host: ServerHost, + private readonly host: ServerHost, eventPort: number, readonly globalTypingsCacheLocation: string, readonly typingSafeListLocation: string, readonly typesMapLocation: string, private readonly npmLocation: string | undefined, private newLine: string) { - this.throttledOperations = new ThrottledOperations(host); if (eventPort) { const s = net.connect({ port: eventPort }, () => { this.socket = s; @@ -338,12 +348,26 @@ namespace ts.server { this.logger.info(`Scheduling throttled operation: ${JSON.stringify(request)}`); } } - this.throttledOperations.schedule(project.getProjectName(), /*ms*/ 250, () => { + + const operationId = project.getProjectName(); + const operation = () => { if (this.logger.hasLevel(LogLevel.verbose)) { this.logger.info(`Sending request: ${JSON.stringify(request)}`); } this.installer.send(request); - }); + }; + const queuedRequest: QueuedOperation = { operationId, operation }; + + if (this.activeRequestCount < NodeTypingsInstaller.maxActiveRequestCount) { + this.scheduleRequest(queuedRequest); + } + else { + if (this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Deferring request for: ${operationId}`); + } + this.requestQueue.push(queuedRequest); + this.requestMap.set(operationId, queuedRequest); + } } private handleMessage(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | InitializationFailedResponse) { @@ -404,11 +428,39 @@ namespace ts.server { return; } + if (this.activeRequestCount > 0) { + this.activeRequestCount--; + } + else { + Debug.fail("Received too many responses"); + } + + while (this.requestQueue.length > 0) { + const queuedRequest = this.requestQueue.shift(); + if (this.requestMap.get(queuedRequest.operationId) == queuedRequest) { + this.requestMap.delete(queuedRequest.operationId); + this.scheduleRequest(queuedRequest); + break; + } + + if (this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); + } + } + this.projectService.updateTypingsForProject(response); if (response.kind === ActionSet && this.socket) { this.sendEvent(0, "setTypings", response); } } + + private scheduleRequest(request: QueuedOperation) { + if(this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Scheduling request for: ${request.operationId}`); + } + this.activeRequestCount++; + this.host.setTimeout(request.operation, NodeTypingsInstaller.requestDelayMillis); + } } class IOSession extends Session { From be7be5955bcafc9b27359dca0083d46fd58b6bd7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 09:41:05 -0700 Subject: [PATCH 045/216] Make getJSDocTags public too --- src/compiler/utilities.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 78eacee7d22..1b19fc738e8 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1502,16 +1502,7 @@ namespace ts { return getJSDocCommentsAndTags(node); } - export function getJSDocTags(node: Node): ReadonlyArray | undefined { - let tags = node.jsDocCache; - // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. - if (tags === undefined) { - node.jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); - } - return tags; - } - - function getJSDocCommentsAndTags(node: Node): (JSDoc | JSDocTag)[] { + export function getJSDocCommentsAndTags(node: Node): (JSDoc | JSDocTag)[] { let result: Array | undefined; getJSDocCommentsAndTagsWorker(node); return result || emptyArray; @@ -4023,11 +4014,22 @@ namespace ts { return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; } - /* Get the first JSDoc tag of a specified kind, or undefined if not present. */ + /** Get all JSDoc tags related to a node, including those on parent nodes. */ + export function getJSDocTags(node: Node): ReadonlyArray | undefined { + let tags = node.jsDocCache; + // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. + if (tags === undefined) { + node.jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); + } + return tags; + } + + /** Get the first JSDoc tag of a specified kind, or undefined if not present. */ function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag | undefined { const tags = getJSDocTags(node); return find(tags, doc => doc.kind === kind); } + } // Simple node tests of the form `node.kind === SyntaxKind.Foo`. From fc163300435e4dce17312fe5b7a74ade4d621afb Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 6 Sep 2017 09:48:00 -0700 Subject: [PATCH 046/216] Minor changes --- src/compiler/checker.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bf0d7655309..1bbd710e327 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6654,9 +6654,8 @@ namespace ts { // interface is instantiated with a fresh set of cloned type parameters (which we need to handle scenarios // where different generations of the same type parameter are in scope). This leads to a lot of new type // identities, and potentially a lot of work comparing those identities, so here we create an instantiation - // that reverts back to the original type identities for all unconstrained type parameters. - const canonicalTypeArguments = map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp); - return instantiateSignature(signature, createTypeMapper(signature.typeParameters, canonicalTypeArguments), /*eraseTypeParameters*/ true); + // that uses the original type identities for all unconstrained type parameters. + return getSignatureInstantiation(signature, map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp)); } function getOrCreateTypeFromSignature(signature: Signature): ObjectType { @@ -8493,8 +8492,8 @@ namespace ts { return Ternary.False; } - target = getCanonicalSignature(target); - if (source.typeParameters) { + if (source.typeParameters && source.typeParameters !== target.typeParameters) { + target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } From 0f73a0a2443573d7677aeb85145f317c2e8be9ca Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 09:50:25 -0700 Subject: [PATCH 047/216] Fix jsdoc lint --- src/compiler/utilities.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 1b19fc738e8..a6ae7925a53 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4008,7 +4008,8 @@ namespace ts { * Gets the return type node for the node if provided via JSDoc's return tag. * * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function - * gets the type from inside the braces. */ + * gets the type from inside the braces. + */ export function getJSDocReturnType(node: Node): TypeNode | undefined { const returnTag = getJSDocReturnTag(node); return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; From 8055e7f40b80edee4b66f73fa990bf5ba0aa5f4c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 10:13:34 -0700 Subject: [PATCH 048/216] Test new JSDoc surface area --- tests/baselines/reference/APISample_jsdoc.js | 212 +++++++++++++++++++ tests/cases/compiler/APISample_jsdoc.ts | 116 ++++++++++ 2 files changed, 328 insertions(+) create mode 100644 tests/baselines/reference/APISample_jsdoc.js create mode 100644 tests/cases/compiler/APISample_jsdoc.ts diff --git a/tests/baselines/reference/APISample_jsdoc.js b/tests/baselines/reference/APISample_jsdoc.js new file mode 100644 index 00000000000..c74e188f38b --- /dev/null +++ b/tests/baselines/reference/APISample_jsdoc.js @@ -0,0 +1,212 @@ +//// [APISample_jsdoc.ts] +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + +declare var console: any; + +import * as ts from "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(this: any, + symbol: ts.Symbol, + definition: {description?: string, [s: string]: string | undefined}, + otherAnnotations: { [s: string]: true}): void { + if (!symbol) { + return; + } + + // the comments for a symbol + let comments = symbol.getDocumentationComment(); + + if (comments.length) { + definition.description = comments.map(comment => comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n")).join(""); + } + + // jsdocs are separate from comments + const jsdocs = symbol.getJsDocTags(); + jsdocs.forEach(doc => { + // if we have @TJS-... annotations, we have to parse them + const { name, text } = doc; + if (this.userValidationKeywords[name]) { + definition[name] = this.parseValue(text); + } else { + // special annotations + otherAnnotations[doc.name] = true; + } + }); +} + + +// excerpted from https://github.com/vega/ts-json-schema-generator +export interface Annotations { + [name: string]: any; +} +function getAnnotations(this: any, node: ts.Node): Annotations | undefined { + const symbol: ts.Symbol = (node as any).symbol; + if (!symbol) { + return undefined; + } + + const jsDocTags: ts.JSDocTagInfo[] = symbol.getJsDocTags(); + if (!jsDocTags || !jsDocTags.length) { + return undefined; + } + + const annotations: Annotations = jsDocTags.reduce((result: Annotations, jsDocTag: ts.JSDocTagInfo) => { + const 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: ts.Node) { + if (node.kind === ts.SyntaxKind.Parameter) { + return ts.getJSDocParameterTags(node as ts.ParameterDeclaration); + } + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + const func = node as ts.FunctionDeclaration; + if (ts.hasJSDocParameterTags(func)) { + const flat: ts.JSDocTag[] = []; + for (const tags of func.parameters.map(ts.getJSDocParameterTags)) { + if (tags) flat.push(...tags); + } + return flat; + } + } +} + +function getReturnTypeFromJSDoc(node: ts.Node) { + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + return ts.getJSDocReturnType(node); + } + let type = ts.getJSDocType(node); + if (type && type.kind === ts.SyntaxKind.FunctionType) { + return (type as ts.FunctionTypeNode).type; + } +} + +function getAllTags(node: ts.Node) { + ts.getJSDocTags(node); +} + +function getSomeOtherTags(node: ts.Node) { + const tags: (ts.JSDocTag | undefined)[] = []; + tags.push(ts.getJSDocAugmentsTag(node)); + tags.push(ts.getJSDocClassTag(node)); + tags.push(ts.getJSDocReturnTag(node)); + const type = ts.getJSDocTypeTag(node); + if (type) { + tags.push(type); + } + tags.push(ts.getJSDocTemplateTag(node)); + return tags; +} + + +//// [APISample_jsdoc.js] +"use strict"; +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * 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) { + var _this = this; + if (!symbol) { + return; + } + // the comments for a symbol + var comments = symbol.getDocumentationComment(); + 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) { + // if we have @TJS-... annotations, we have to parse them + var name = doc.name, text = doc.text; + if (_this.userValidationKeywords[name]) { + definition[name] = _this.parseValue(text); + } + else { + // special annotations + otherAnnotations[doc.name] = true; + } + }); +} +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) { + return ts.getJSDocParameterTags(node); + } + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + var func = node; + if (ts.hasJSDocParameterTags(func)) { + var flat = []; + for (var _i = 0, _a = func.parameters.map(ts.getJSDocParameterTags); _i < _a.length; _i++) { + var tags = _a[_i]; + if (tags) + flat.push.apply(flat, tags); + } + return flat; + } + } +} +function getReturnTypeFromJSDoc(node) { + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + return ts.getJSDocReturnType(node); + } + var type = ts.getJSDocType(node); + if (type && type.kind === ts.SyntaxKind.FunctionType) { + return type.type; + } +} +function getAllTags(node) { + ts.getJSDocTags(node); +} +function getSomeOtherTags(node) { + var tags = []; + tags.push(ts.getJSDocAugmentsTag(node)); + tags.push(ts.getJSDocClassTag(node)); + tags.push(ts.getJSDocReturnTag(node)); + var type = ts.getJSDocTypeTag(node); + if (type) { + tags.push(type); + } + tags.push(ts.getJSDocTemplateTag(node)); + return tags; +} diff --git a/tests/cases/compiler/APISample_jsdoc.ts b/tests/cases/compiler/APISample_jsdoc.ts new file mode 100644 index 00000000000..70b814ffff4 --- /dev/null +++ b/tests/cases/compiler/APISample_jsdoc.ts @@ -0,0 +1,116 @@ +// @module: commonjs +// @includebuiltfile: typescript_standalone.d.ts +// @strict:true + +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + +declare var console: any; + +import * as ts from "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(this: any, + symbol: ts.Symbol, + definition: {description?: string, [s: string]: string | undefined}, + otherAnnotations: { [s: string]: true}): void { + if (!symbol) { + return; + } + + // the comments for a symbol + let comments = symbol.getDocumentationComment(); + + if (comments.length) { + definition.description = comments.map(comment => comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n")).join(""); + } + + // jsdocs are separate from comments + const jsdocs = symbol.getJsDocTags(); + jsdocs.forEach(doc => { + // if we have @TJS-... annotations, we have to parse them + const { name, text } = doc; + if (this.userValidationKeywords[name]) { + definition[name] = this.parseValue(text); + } else { + // special annotations + otherAnnotations[doc.name] = true; + } + }); +} + + +// excerpted from https://github.com/vega/ts-json-schema-generator +export interface Annotations { + [name: string]: any; +} +function getAnnotations(this: any, node: ts.Node): Annotations | undefined { + const symbol: ts.Symbol = (node as any).symbol; + if (!symbol) { + return undefined; + } + + const jsDocTags: ts.JSDocTagInfo[] = symbol.getJsDocTags(); + if (!jsDocTags || !jsDocTags.length) { + return undefined; + } + + const annotations: Annotations = jsDocTags.reduce((result: Annotations, jsDocTag: ts.JSDocTagInfo) => { + const 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: ts.Node) { + if (node.kind === ts.SyntaxKind.Parameter) { + return ts.getJSDocParameterTags(node as ts.ParameterDeclaration); + } + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + const func = node as ts.FunctionDeclaration; + if (ts.hasJSDocParameterTags(func)) { + const flat: ts.JSDocTag[] = []; + for (const tags of func.parameters.map(ts.getJSDocParameterTags)) { + if (tags) flat.push(...tags); + } + return flat; + } + } +} + +function getReturnTypeFromJSDoc(node: ts.Node) { + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + return ts.getJSDocReturnType(node); + } + let type = ts.getJSDocType(node); + if (type && type.kind === ts.SyntaxKind.FunctionType) { + return (type as ts.FunctionTypeNode).type; + } +} + +function getAllTags(node: ts.Node) { + ts.getJSDocTags(node); +} + +function getSomeOtherTags(node: ts.Node) { + const tags: (ts.JSDocTag | undefined)[] = []; + tags.push(ts.getJSDocAugmentsTag(node)); + tags.push(ts.getJSDocClassTag(node)); + tags.push(ts.getJSDocReturnTag(node)); + const type = ts.getJSDocTypeTag(node); + if (type) { + tags.push(type); + } + tags.push(ts.getJSDocTemplateTag(node)); + return tags; +} From 7c69dd84b9996d631cd0ad47bf97a496dec18b17 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 13:11:35 -0700 Subject: [PATCH 049/216] Disable lookahead in isStartOfParameter/isStartOfType --- src/compiler/core.ts | 2 +- src/compiler/parser.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 20f757c3df8..a9138e0ab5c 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1283,7 +1283,7 @@ namespace ts { args[i] = arguments[i]; } - return t => reduceLeft<(t: T) => T, T>(args, (u, f) => f(u), t); + return t => reduceLeft(args, (u, f) => f(u), t); } else if (d) { return t => d(c(b(a(t)))); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 71c7d3aac49..e4847517252 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2237,7 +2237,14 @@ namespace ts { return token() === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifierKind(token()) || - token() === SyntaxKind.AtToken || isStartOfType(); + token() === SyntaxKind.AtToken || + // a jsdoc parameter can start directly with a type, but shouldn't look ahead + // in order to avoid confusion between parenthesized types and arrow functions + // eg + // declare function f(cb: function(number): void): void; + // vs + // f((n) => console.log(n)); + isStartOfType(/*disableLookahead*/ true); } function parseParameter(): ParameterDeclaration { @@ -2698,7 +2705,7 @@ namespace ts { } } - function isStartOfType(): boolean { + function isStartOfType(disableLookahead?: boolean): boolean { switch (token()) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -2728,11 +2735,11 @@ namespace ts { case SyntaxKind.DotDotDotToken: return true; case SyntaxKind.MinusToken: - return lookAhead(nextTokenIsNumericLiteral); + return !disableLookahead && lookAhead(nextTokenIsNumericLiteral); case SyntaxKind.OpenParenToken: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. - return lookAhead(isStartOfParenthesizedOrFunctionType); + return !disableLookahead && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } From 36607e1bde77ba57bb09023ded321f18516abaf5 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 6 Sep 2017 14:39:53 -0700 Subject: [PATCH 050/216] Allow quoted names in completions (#18162) * Allow quoted names in completions * Don't allow string literal completions if not in an object literal; and use string literals for number keys * Add TODO --- src/harness/fourslash.ts | 14 ++++-- src/services/completions.ts | 46 +++++++++++-------- ...nForQuotedPropertyInPropertyAssignment1.ts | 11 +---- ...nForQuotedPropertyInPropertyAssignment2.ts | 11 +---- ...nForQuotedPropertyInPropertyAssignment3.ts | 15 ++---- .../completionListInvalidMemberNames.ts | 15 ++---- .../completionListInvalidMemberNames2.ts | 9 ++-- ...entifiers-should-not-show-in-completion.ts | 10 +--- tests/cases/fourslash/fourslash.ts | 2 +- 9 files changed, 57 insertions(+), 76 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 3010fc53533..c224fd210ea 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -762,7 +762,7 @@ namespace FourSlash { } } - public verifyCompletionsAt(markerName: string, expected: string[]) { + public verifyCompletionsAt(markerName: string, expected: string[], options?: FourSlashInterface.CompletionsAtOptions) { this.goToMarker(markerName); const actualCompletions = this.getCompletionListAtCaret(); @@ -770,6 +770,10 @@ namespace FourSlash { this.raiseError(`No completions at position '${this.currentCaretPosition}'.`); } + if (options && options.isNewIdentifierLocation !== undefined && actualCompletions.isNewIdentifierLocation !== options.isNewIdentifierLocation) { + this.raiseError(`Expected 'isNewIdentifierLocation' to be ${options.isNewIdentifierLocation}, got ${actualCompletions.isNewIdentifierLocation}`); + } + const actual = actualCompletions.entries; if (actual.length !== expected.length) { @@ -3705,8 +3709,8 @@ namespace FourSlashInterface { super(state); } - public completionsAt(markerName: string, completions: string[]) { - this.state.verifyCompletionsAt(markerName, completions); + public completionsAt(markerName: string, completions: string[], options?: CompletionsAtOptions) { + this.state.verifyCompletionsAt(markerName, completions, options); } public quickInfoIs(expectedText: string, expectedDocumentation?: string) { @@ -4314,4 +4318,8 @@ namespace FourSlashInterface { actionName: string; actionDescription: string; } + + export interface CompletionsAtOptions { + isNewIdentifierLocation?: boolean; + } } diff --git a/src/services/completions.ts b/src/services/completions.ts index fde07aa78f6..300ade2da48 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -24,7 +24,7 @@ namespace ts.Completions { return undefined; } - const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, request, keywordFilters } = completionData; + const { symbols, isGlobalCompletion, isMemberCompletion, allowStringLiteral, isNewIdentifierLocation, location, request, keywordFilters } = completionData; if (sourceFile.languageVariant === LanguageVariant.JSX && location && location.parent && location.parent.kind === SyntaxKind.JsxClosingElement) { @@ -56,7 +56,7 @@ namespace ts.Completions { const entries: CompletionEntry[] = []; if (isSourceFileJavaScript(sourceFile)) { - const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log, allowStringLiteral); getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); } else { @@ -64,7 +64,7 @@ namespace ts.Completions { return undefined; } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log, allowStringLiteral); } // TODO add filter for keyword based on type/value/namespace and also location @@ -97,7 +97,7 @@ namespace ts.Completions { } uniqueNames.set(realName, true); - const displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true); + const displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true, /*allowStringLiteral*/ false); if (displayName) { entries.push({ name: displayName, @@ -109,11 +109,11 @@ namespace ts.Completions { }); } - function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget): CompletionEntry { + function createCompletionEntry(symbol: Symbol, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget, allowStringLiteral: boolean): CompletionEntry { // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - const displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks); + const displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral); if (!displayName) { return undefined; } @@ -134,12 +134,12 @@ namespace ts.Completions { }; } - function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: Push, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget, log: Log): Map { + function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: Push, location: Node, performCharacterChecks: boolean, typeChecker: TypeChecker, target: ScriptTarget, log: Log, allowStringLiteral: boolean): Map { const start = timestamp(); const uniqueNames = createMap(); if (symbols) { for (const symbol of symbols) { - const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral); if (entry) { const id = entry.name; if (!uniqueNames.has(id)) { @@ -224,7 +224,7 @@ namespace ts.Completions { const type = typeChecker.getContextualType((element.parent)); const entries: CompletionEntry[] = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log, /*allowStringLiteral*/ true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; } @@ -253,7 +253,7 @@ namespace ts.Completions { const type = typeChecker.getTypeAtLocation(node.expression); const entries: CompletionEntry[] = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log, /*allowStringLiteral*/ true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries }; } @@ -302,13 +302,13 @@ namespace ts.Completions { // Compute all the completion symbols again. const completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - const { symbols, location } = completionData; + const { symbols, location, allowStringLiteral } = completionData; // Find the symbol with the matching entry name. // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - const symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false) === entryName ? s : undefined); + const symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral) === entryName ? s : undefined); if (symbol) { const { displayParts, documentation, symbolKind, tags } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, SemanticMeaning.All); @@ -345,17 +345,22 @@ namespace ts.Completions { export function getCompletionEntrySymbol(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): Symbol | undefined { // Compute all the completion symbols again. const completionData = getCompletionData(typeChecker, log, sourceFile, position); + if (!completionData) { + return undefined; + } + const { symbols, allowStringLiteral } = completionData; // Find the symbol with the matching entry name. // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - return completionData && forEach(completionData.symbols, s => getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false) === entryName ? s : undefined); + return forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral) === entryName ? s : undefined); } interface CompletionData { symbols: Symbol[]; isGlobalCompletion: boolean; isMemberCompletion: boolean; + allowStringLiteral: boolean; isNewIdentifierLocation: boolean; location: Node; isRightOfDot: boolean; @@ -436,7 +441,7 @@ namespace ts.Completions { } if (request) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request, keywordFilters: KeywordCompletionFilters.None }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, allowStringLiteral: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request, keywordFilters: KeywordCompletionFilters.None }; } if (!insideJsDocTagTypeExpression) { @@ -534,6 +539,7 @@ namespace ts.Completions { const semanticStart = timestamp(); let isGlobalCompletion = false; let isMemberCompletion: boolean; + let allowStringLiteral = false; let isNewIdentifierLocation: boolean; let keywordFilters = KeywordCompletionFilters.None; let symbols: Symbol[] = []; @@ -573,7 +579,7 @@ namespace ts.Completions { log("getCompletionData: Semantic work: " + (timestamp() - semanticStart)); - return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request, keywordFilters }; + return { symbols, isGlobalCompletion, isMemberCompletion, allowStringLiteral, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request, keywordFilters }; type JSDocTagWithTypeExpression = JSDocAugmentsTag | JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag; @@ -961,6 +967,7 @@ namespace ts.Completions { function tryGetObjectLikeCompletionSymbols(objectLikeContainer: ObjectLiteralExpression | ObjectBindingPattern): boolean { // We're looking up possible property names from contextual/inferred/declared type. isMemberCompletion = true; + allowStringLiteral = true; let typeMembers: Symbol[]; let existingMembers: ReadonlyArray; @@ -1609,7 +1616,7 @@ namespace ts.Completions { * * @return undefined if the name is of external module */ - function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string | undefined { + function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean, allowStringLiteral: boolean): string | undefined { const name = symbol.name; if (!name) return undefined; @@ -1623,20 +1630,21 @@ namespace ts.Completions { } } - return getCompletionEntryDisplayName(name, target, performCharacterChecks); + return getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral); } /** * Get a displayName from a given for completion list, performing any necessary quotes stripping * and checking whether the name is valid identifier name. */ - function getCompletionEntryDisplayName(name: string, target: ScriptTarget, performCharacterChecks: boolean): string { + function getCompletionEntryDisplayName(name: string, target: ScriptTarget, performCharacterChecks: boolean, allowStringLiteral: boolean): string { // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. if (performCharacterChecks && !isIdentifierText(name, target)) { - return undefined; + // TODO: GH#18169 + return allowStringLiteral ? JSON.stringify(name) : undefined; } return name; diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts index 15f5901113b..ab218cea93d 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment1.ts @@ -13,12 +13,5 @@ //// '/*1*/': '' //// } -goTo.marker('0'); -verify.completionListContains("jspm"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(1); - -goTo.marker('1'); -verify.completionListContains("jspm:dev"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(4); +verify.completionsAt("0", ["jspm", '"jspm:browser"', '"jspm:dev"', '"jspm:node"'], { isNewIdentifierLocation: true }); +verify.completionsAt("1", ["jspm", "jspm:browser", "jspm:dev", "jspm:node"], { isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts index 1d20b57e2a1..66ba4ada241 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment2.ts @@ -19,12 +19,5 @@ //// } //// } -goTo.marker('0'); -verify.completionListContains("jspm"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(1); - -goTo.marker('1'); -verify.completionListContains("jspm:dev"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(4); +verify.completionsAt("0", ["jspm", '"jspm:browser"', '"jspm:dev"', '"jspm:node"'], { isNewIdentifierLocation: true }); +verify.completionsAt("1", ["jspm", "jspm:browser", "jspm:dev", "jspm:node"], { isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts index 764011d90c1..1ab9aa4a8cf 100644 --- a/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts +++ b/tests/cases/fourslash/completionForQuotedPropertyInPropertyAssignment3.ts @@ -4,7 +4,7 @@ //// jspm: string; //// 'jspm:browser': string; //// } = { -//// /*0*/: "", +//// /*0*/: "", //// } //// let configFiles2: { @@ -12,15 +12,8 @@ //// 'jspm:browser': string; //// } = { //// jspm: "", -//// '/*1*/': "" +//// '/*1*/': "" //// } -goTo.marker('0'); -verify.completionListContains("jspm"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(1); - -goTo.marker('1'); -verify.completionListContains("jspm:browser"); -verify.completionListAllowsNewIdentifier(); -verify.completionListCount(2); +verify.completionsAt("0", ["jspm", '"jspm:browser"'], { isNewIdentifierLocation: true }); +verify.completionsAt("1", ["jspm", "jspm:browser"], { isNewIdentifierLocation: true }); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames.ts b/tests/cases/fourslash/completionListInvalidMemberNames.ts index e0a65bfca4d..8e62ba2fb67 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames.ts @@ -11,15 +11,8 @@ //// "\u0031\u0062": "invalid unicode identifer name (1b)" ////}; //// -////x./**/ +////x./*a*/; +////x["/*b*/"]; -goTo.marker(); - -verify.completionListContains("bar"); -verify.completionListContains("break"); -verify.completionListContains("any"); -verify.completionListContains("$"); -verify.completionListContains("b"); - -// Nothing else should show up -verify.completionListCount(5); +verify.completionsAt("a", ["bar", "break", "any", "$", "b"]); +verify.completionsAt("b", ["foo ", "bar", "break", "any", "#", "$", "b", "\u0031\u0062"]); diff --git a/tests/cases/fourslash/completionListInvalidMemberNames2.ts b/tests/cases/fourslash/completionListInvalidMemberNames2.ts index 6b25cf1f5d9..753f9bbcb30 100644 --- a/tests/cases/fourslash/completionListInvalidMemberNames2.ts +++ b/tests/cases/fourslash/completionListInvalidMemberNames2.ts @@ -3,9 +3,8 @@ ////enum Foo { //// X, Y, '☆' ////} -////var x = Foo./**/ +////Foo./*a*/; +////Foo["/*b*/"]; -goTo.marker(); -verify.completionListContains("X"); -verify.completionListContains("Y"); -verify.completionListCount(2); \ No newline at end of file +verify.completionsAt("a", ["X", "Y"]); +verify.completionsAt("b", ["X", "Y", "☆"]); diff --git a/tests/cases/fourslash/completion_enum-members-with-invalid-identifiers-should-not-show-in-completion.ts b/tests/cases/fourslash/completion_enum-members-with-invalid-identifiers-should-not-show-in-completion.ts index d01856a54fb..6d5b3167198 100644 --- a/tests/cases/fourslash/completion_enum-members-with-invalid-identifiers-should-not-show-in-completion.ts +++ b/tests/cases/fourslash/completion_enum-members-with-invalid-identifiers-should-not-show-in-completion.ts @@ -7,13 +7,7 @@ //// a, //// b //// } -//// +//// //// e./**/ -goTo.marker(); -verify.not.completionListContains('1'); -verify.not.completionListContains('"1"'); -verify.not.completionListContains('2'); -verify.not.completionListContains('3'); -verify.completionListContains('a'); -verify.completionListContains('b'); \ No newline at end of file +verify.completionsAt("", ["a", "b"]); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 652ed4812c0..5150fa16ae9 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -164,7 +164,7 @@ declare namespace FourSlashInterface { class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; caretAtMarker(markerName?: string): void; - completionsAt(markerName: string, completions: string[]): void; + completionsAt(markerName: string, completions: string[], options?: { isNewIdentifierLocation?: boolean }): void; indentationIs(numberOfSpaces: number): void; indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle, baseIndentSize?: number): void; textAtCaretIs(text: string): void; From 73eff819b589c9a8fdf0e9e866221fa15fe3f885 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 14:44:29 -0700 Subject: [PATCH 051/216] Fix 18224 (#18259) * Probably fix 18224 * Corrected test --- src/compiler/checker.ts | 2 +- tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js | 8 ++++++++ .../reference/jsdocTypecastNoTypeNoCrash.symbols | 8 ++++++++ .../baselines/reference/jsdocTypecastNoTypeNoCrash.types | 9 +++++++++ tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts | 5 +++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js create mode 100644 tests/baselines/reference/jsdocTypecastNoTypeNoCrash.symbols create mode 100644 tests/baselines/reference/jsdocTypecastNoTypeNoCrash.types create mode 100644 tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1bbd710e327..9fcd0b593f8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18017,7 +18017,7 @@ namespace ts { function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type { if (isInJavaScriptFile(node) && node.jsDoc) { - const typecasts = flatMap(node.jsDoc, doc => filter(doc.tags, tag => tag.kind === SyntaxKind.JSDocTypeTag)); + const typecasts = flatMap(node.jsDoc, doc => filter(doc.tags, tag => tag.kind === SyntaxKind.JSDocTypeTag && !!(tag as JSDocTypeTag).typeExpression && !!(tag as JSDocTypeTag).typeExpression.type)); if (typecasts && typecasts.length) { // We should have already issued an error if there were multiple type jsdocs const cast = typecasts[0] as JSDocTypeTag; diff --git a/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js new file mode 100644 index 00000000000..06c7924440b --- /dev/null +++ b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js @@ -0,0 +1,8 @@ +//// [index.js] +function Foo() {} +const a = /* @type string */(Foo); + + +//// [index.js] +function Foo() { } +var a = (Foo); diff --git a/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.symbols b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.symbols new file mode 100644 index 00000000000..7a9d98e39ec --- /dev/null +++ b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/index.js === +function Foo() {} +>Foo : Symbol(Foo, Decl(index.js, 0, 0)) + +const a = /* @type string */(Foo); +>a : Symbol(a, Decl(index.js, 1, 5)) +>Foo : Symbol(Foo, Decl(index.js, 0, 0)) + diff --git a/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.types b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.types new file mode 100644 index 00000000000..590940b51ff --- /dev/null +++ b/tests/baselines/reference/jsdocTypecastNoTypeNoCrash.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/index.js === +function Foo() {} +>Foo : () => void + +const a = /* @type string */(Foo); +>a : () => void +>(Foo) : () => void +>Foo : () => void + diff --git a/tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts b/tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts new file mode 100644 index 00000000000..8c5e52d34f0 --- /dev/null +++ b/tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts @@ -0,0 +1,5 @@ +// @allowJS: true +// @outDir: ./out +// @filename: index.js +function Foo() {} +const a = /* @type string */(Foo); From 697c4d33530646440dd8c22d75523761da23549b Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 6 Sep 2017 14:46:47 -0700 Subject: [PATCH 052/216] Add `debugName` property to `Rule` (#18289) --- src/services/formatting/rule.ts | 14 +++++--------- src/services/formatting/rules.ts | 22 ++++++++++------------ src/services/formatting/rulesProvider.ts | 10 +--------- 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/services/formatting/rule.ts b/src/services/formatting/rule.ts index 543295f364f..10987c745c2 100644 --- a/src/services/formatting/rule.ts +++ b/src/services/formatting/rule.ts @@ -3,16 +3,12 @@ /* @internal */ namespace ts.formatting { export class Rule { + // Used for debugging to identify each rule based on the property name it's assigned to. + public debugName?: string; constructor( - public Descriptor: RuleDescriptor, - public Operation: RuleOperation, - public Flag: RuleFlags = RuleFlags.None) { - } - - public toString() { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; + readonly Descriptor: RuleDescriptor, + readonly Operation: RuleOperation, + readonly Flag: RuleFlags = RuleFlags.None) { } } } \ No newline at end of file diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 2daf8d9d284..07c2804ee83 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -3,18 +3,6 @@ /* @internal */ namespace ts.formatting { export class Rules { - public getRuleName(rule: Rule) { - const o: ts.MapLike = this; - for (const name in o) { - if (o[name] === rule) { - return name; - } - } - throw new Error("Unknown rule"); - } - - [name: string]: any; - public IgnoreBeforeComment: Rule; public IgnoreAfterLineComment: Rule; @@ -569,6 +557,16 @@ namespace ts.formatting { this.SpaceAfterSemicolon, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; + + if (Debug.isDebugging) { + const o: ts.MapLike = this; + for (const name in o) { + const rule = o[name]; + if (rule instanceof Rule) { + rule.debugName = name; + } + } + } } /// diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index 790bce054b0..1dd7acbdc64 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -9,18 +9,10 @@ namespace ts.formatting { constructor() { this.globalRules = new Rules(); - const activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); + const activeRules = this.globalRules.HighPriorityCommonRules.concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); this.rulesMap = RulesMap.create(activeRules); } - public getRuleName(rule: Rule): string { - return this.globalRules.getRuleName(rule); - } - - public getRuleByName(name: string): Rule { - return this.globalRules[name]; - } - public getRulesMap() { return this.rulesMap; } From 0b1bad8421c2a252e89731d056649fe7673414e3 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 6 Sep 2017 15:44:00 -0700 Subject: [PATCH 053/216] Fix lint issues --- src/server/server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index 7f6daa92d5e..96368fb9e54 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -437,7 +437,7 @@ namespace ts.server { while (this.requestQueue.length > 0) { const queuedRequest = this.requestQueue.shift(); - if (this.requestMap.get(queuedRequest.operationId) == queuedRequest) { + if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { this.requestMap.delete(queuedRequest.operationId); this.scheduleRequest(queuedRequest); break; @@ -455,7 +455,7 @@ namespace ts.server { } private scheduleRequest(request: QueuedOperation) { - if(this.logger.hasLevel(LogLevel.verbose)) { + if (this.logger.hasLevel(LogLevel.verbose)) { this.logger.info(`Scheduling request for: ${request.operationId}`); } this.activeRequestCount++; From 9692ce86db3fb81c31c64c7716b9afe2c6cd4128 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 6 Sep 2017 15:46:59 -0700 Subject: [PATCH 054/216] Add explanatory comment --- src/server/server.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/server/server.ts b/src/server/server.ts index 96368fb9e54..6b6535c8cac 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -251,6 +251,11 @@ namespace ts.server { private requestQueue: QueuedOperation[] = []; private requestMap = createMap(); // Maps operation ID to newest requestQueue entry with that ID + // This number is essentially arbitrary. Processing more than one typings request + // at a time makes sense, but having too many in the pipe results in a hang + // (see https://github.com/nodejs/node/issues/7657). + // It would be preferable to base our limit on the amount of space left in the + // buffer, but we have yet to find a way to retrieve that value. private static readonly maxActiveRequestCount = 10; private static readonly requestDelayMillis = 100; From a5c2eac2ee533fa3e71a6be3e5d320107e2614e8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 6 Sep 2017 15:54:14 -0700 Subject: [PATCH 055/216] Test:disable lookahead in isStartOfParameter --- src/compiler/parser.ts | 6 ------ ...arrowfunctionsOptionalArgsErrors2.errors.txt | 17 +++++++++++++---- .../fatarrowfunctionsOptionalArgsErrors2.js | 6 ++---- .../baselines/reference/parser512325.errors.txt | 17 +++++++++++++---- tests/baselines/reference/parser512325.js | 6 ++---- .../parserArrowFunctionExpression5.errors.txt | 15 +++++++++++++++ .../reference/parserArrowFunctionExpression5.js | 10 ++++++++++ .../parserArrowFunctionExpression5.ts | 5 +++++ 8 files changed, 60 insertions(+), 22 deletions(-) create mode 100644 tests/baselines/reference/parserArrowFunctionExpression5.errors.txt create mode 100644 tests/baselines/reference/parserArrowFunctionExpression5.js create mode 100644 tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e4847517252..1740bad2d34 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2238,12 +2238,6 @@ namespace ts { isIdentifierOrPattern() || isModifierKind(token()) || token() === SyntaxKind.AtToken || - // a jsdoc parameter can start directly with a type, but shouldn't look ahead - // in order to avoid confusion between parenthesized types and arrow functions - // eg - // declare function f(cb: function(number): void): void; - // vs - // f((n) => console.log(n)); isStartOfType(/*disableLookahead*/ true); } diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt index 51db9c7391e..b435e7773f5 100644 --- a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.errors.txt @@ -1,7 +1,10 @@ -tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,15): error TS1003: Identifier expected. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,12): error TS2304: Cannot find name 'a'. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,12): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,16): error TS2304: Cannot find name 'b'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,16): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,19): error TS2304: Cannot find name 'c'. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,23): error TS1005: ';' expected. +tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,26): error TS2304: Cannot find name 'a'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,28): error TS2304: Cannot find name 'b'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(1,30): error TS2304: Cannot find name 'c'. tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(2,12): error TS2695: Left side of comma operator is unused and has no side effects. @@ -18,16 +21,22 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(4,17): error TS1005 tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts(4,20): error TS2304: Cannot find name 'a'. -==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts (18 errors) ==== +==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors2.ts (21 errors) ==== var tt1 = (a, (b, c)) => a+b+c; - ~ -!!! error TS1003: Identifier expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. ~ !!! error TS2304: Cannot find name 'b'. ~ !!! error TS2695: Left side of comma operator is unused and has no side effects. ~ !!! error TS2304: Cannot find name 'c'. + ~~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'b'. ~ diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js index a1c68ea4476..b51003b62df 100644 --- a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors2.js @@ -5,10 +5,8 @@ var tt2 = ((a), b, c) => a+b+c; var tt3 = ((a)) => a; //// [fatarrowfunctionsOptionalArgsErrors2.js] -var tt1 = function (a, ) { - if ( === void 0) { = (b, c); } - return a + b + c; -}; +var tt1 = (a, (b, c)); +a + b + c; var tt2 = ((a), b, c); a + b + c; var tt3 = ((a)); diff --git a/tests/baselines/reference/parser512325.errors.txt b/tests/baselines/reference/parser512325.errors.txt index f54d9f2110a..e6a47fbf226 100644 --- a/tests/baselines/reference/parser512325.errors.txt +++ b/tests/baselines/reference/parser512325.errors.txt @@ -1,21 +1,30 @@ -tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,14): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,11): error TS2304: Cannot find name 'a'. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,11): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,15): error TS2304: Cannot find name 'b'. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,15): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,18): error TS2304: Cannot find name 'c'. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,22): error TS1005: ';' expected. +tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,25): error TS2304: Cannot find name 'a'. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,27): error TS2304: Cannot find name 'b'. tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts(1,29): error TS2304: Cannot find name 'c'. -==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts (6 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser512325.ts (9 errors) ==== var tt = (a, (b, c)) => a+b+c; - ~ -!!! error TS1003: Identifier expected. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. ~ !!! error TS2304: Cannot find name 'b'. ~ !!! error TS2695: Left side of comma operator is unused and has no side effects. ~ !!! error TS2304: Cannot find name 'c'. + ~~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'a'. ~ !!! error TS2304: Cannot find name 'b'. ~ diff --git a/tests/baselines/reference/parser512325.js b/tests/baselines/reference/parser512325.js index 75af6b9f39a..14cbcddd86b 100644 --- a/tests/baselines/reference/parser512325.js +++ b/tests/baselines/reference/parser512325.js @@ -2,7 +2,5 @@ var tt = (a, (b, c)) => a+b+c; //// [parser512325.js] -var tt = function (a, ) { - if ( === void 0) { = (b, c); } - return a + b + c; -}; +var tt = (a, (b, c)); +a + b + c; diff --git a/tests/baselines/reference/parserArrowFunctionExpression5.errors.txt b/tests/baselines/reference/parserArrowFunctionExpression5.errors.txt new file mode 100644 index 00000000000..220c4d42279 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression5.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts(1,2): error TS2304: Cannot find name 'bar'. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts(1,6): error TS2304: Cannot find name 'x'. + + +==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts (2 errors) ==== + (bar(x, + ~~~ +!!! error TS2304: Cannot find name 'bar'. + ~ +!!! error TS2304: Cannot find name 'x'. + () => {}, + () => {} + ) + ) + \ No newline at end of file diff --git a/tests/baselines/reference/parserArrowFunctionExpression5.js b/tests/baselines/reference/parserArrowFunctionExpression5.js new file mode 100644 index 00000000000..b25d77a4b02 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression5.js @@ -0,0 +1,10 @@ +//// [parserArrowFunctionExpression5.ts] +(bar(x, + () => {}, + () => {} + ) +) + + +//// [parserArrowFunctionExpression5.js] +(bar(x, function () { }, function () { })); diff --git a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts new file mode 100644 index 00000000000..d4ab2adefba --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts @@ -0,0 +1,5 @@ +(bar(x, + () => {}, + () => {} + ) +) From 5c779b1edbc17d03491fee4e73b9c4d9a45cd2eb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 21:56:16 -0700 Subject: [PATCH 056/216] Allow singleline string writer to be recursively used (#18297) * Allow singleline string writer to be recursively used * Add unit test exposing issue * Fix lints --- Jakefile.js | 1 + src/compiler/utilities.ts | 6 +-- src/harness/tsconfig.json | 1 + src/harness/unittests/languageService.ts | 49 ++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 src/harness/unittests/languageService.ts diff --git a/Jakefile.js b/Jakefile.js index b3e18e8cb1a..ad853238111 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -143,6 +143,7 @@ var harnessSources = harnessCoreSources.concat([ "customTransforms.ts", "programMissingFiles.ts", "symbolWalker.ts", + "languageService.ts", ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2a07d2b6560..725070c02bf 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -32,7 +32,6 @@ namespace ts { } const stringWriter = createSingleLineStringWriter(); - let stringWriterAcquired = false; function createSingleLineStringWriter(): StringSymbolWriter { let str = ""; @@ -62,15 +61,14 @@ namespace ts { } export function usingSingleLineStringWriter(action: (writer: StringSymbolWriter) => void): string { + const oldString = stringWriter.string(); try { - Debug.assert(!stringWriterAcquired); - stringWriterAcquired = true; action(stringWriter); return stringWriter.string(); } finally { stringWriter.clear(); - stringWriterAcquired = false; + stringWriter.writeKeyword(oldString); } } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 1469079bcaa..bd7c9bc2ffa 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -128,6 +128,7 @@ "./unittests/extractMethods.ts", "./unittests/textChanges.ts", "./unittests/telemetry.ts", + "./unittests/languageService.ts", "./unittests/programMissingFiles.ts" ] } diff --git a/src/harness/unittests/languageService.ts b/src/harness/unittests/languageService.ts new file mode 100644 index 00000000000..9c838845c20 --- /dev/null +++ b/src/harness/unittests/languageService.ts @@ -0,0 +1,49 @@ +/// + +namespace ts { + describe("languageService", () => { + const files: {[index: string]: string} = { + "foo.ts": `import Vue from "./vue"; +import Component from "./vue-class-component"; +import { vueTemplateHtml } from "./variables"; + +@Component({ + template: vueTemplateHtml, +}) +class Carousel extends Vue { +}`, + "variables.ts": `export const vueTemplateHtml = \`
\`;`, + "vue.d.ts": `export namespace Vue { export type Config = { template: string }; }`, + "vue-class-component.d.ts": `import Vue from "./vue"; +export function Component(x: Config): any;` +}; + it("should be able to create a language service which can respond to deinition requests without throwing", () => { + const languageService = ts.createLanguageService({ + getCompilationSettings() { + return {}; + }, + getScriptFileNames() { + return ["foo.ts", "variables.ts", "vue.d.ts", "vue-class-component.d.ts"]; + }, + getScriptVersion(_fileName) { + return ""; + }, + getScriptSnapshot(fileName) { + if (fileName === ".ts") { + return ts.ScriptSnapshot.fromString(""); + } + return ts.ScriptSnapshot.fromString(files[fileName] || ""); + }, + getCurrentDirectory: () => ".", + getDefaultLibFileName(options) { + return ts.getDefaultLibFilePath(options); + }, + fileExists: noop as any, + readFile: noop as any, + readDirectory: noop as any, + }); + const definitions = languageService.getDefinitionAtPosition("foo.ts", 160); // 160 is the latter `vueTemplateHtml` position + expect(definitions).to.exist; + }); + }); +} \ No newline at end of file From ed61d2d803a99e8891fa306face099a6a4290b29 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 21:58:04 -0700 Subject: [PATCH 057/216] Emit updated export declarations when transformed from export * (#18017) * Failing test for missing transform output * dont elide all export stars * Remove comment from test * Refuse to perform ellision on transformed nodes --- src/compiler/transformers/ts.ts | 20 +++++++- src/harness/unittests/transform.ts | 49 +++++++++++++++---- ...sformsCorrectly.transformAwayExportStar.js | 1 + 3 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/transformApi/transformsCorrectly.transformAwayExportStar.js diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 692c758bc75..42c25ca34a5 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -208,6 +208,24 @@ namespace ts { * @param node The node to visit. */ function sourceElementVisitorWorker(node: Node): VisitResult { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ExportAssignment: + case SyntaxKind.ExportDeclaration: + return visitEllidableStatement(node); + default: + return visitorWorker(node); + } + } + + function visitEllidableStatement(node: ImportDeclaration | ImportEqualsDeclaration | ExportAssignment | ExportDeclaration): VisitResult { + const parsed = getParseTreeNode(node); + if (parsed !== node) { + // If the node has been transformed by a `before` transformer, perform no ellision on it + // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes + return node; + } switch (node.kind) { case SyntaxKind.ImportDeclaration: return visitImportDeclaration(node); @@ -218,7 +236,7 @@ namespace ts { case SyntaxKind.ExportDeclaration: return visitExportDeclaration(node); default: - return visitorWorker(node); + Debug.fail("Unhandled ellided statement"); } } diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index 27e41a96dfc..bcdca3e3b60 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -57,7 +57,7 @@ namespace ts { testBaseline("types", () => { return transformSourceFile(`let a: () => void`, [ - context => file => visitNode(file, function visitor(node: Node): VisitResult { + context => file => visitNode(file, function visitor(node: Node): VisitResult { return visitEachChild(node, visitor, context); }) ]); @@ -91,14 +91,14 @@ namespace ts { class C { foo = 10; static bar = 20 } namespace C { export let x = 10; } `, { - transformers: { - before: [forceNamespaceRewrite], - }, - compilerOptions: { - target: ts.ScriptTarget.ESNext, - newLine: NewLineKind.CarriageReturnLineFeed, - } - }).outputText; + transformers: { + before: [forceNamespaceRewrite], + }, + compilerOptions: { + target: ts.ScriptTarget.ESNext, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; }); testBaseline("synthesizedClassAndNamespaceCombination", () => { @@ -138,6 +138,37 @@ namespace ts { } }; } + + testBaseline("transformAwayExportStar", () => { + return ts.transpileModule("export * from './helper';", { + transformers: { + before: [expandExportStar], + }, + compilerOptions: { + target: ts.ScriptTarget.ESNext, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + + function expandExportStar(context: ts.TransformationContext) { + return (sourceFile: ts.SourceFile): ts.SourceFile => { + return visitNode(sourceFile); + + function visitNode(node: T): T { + if (node.kind === ts.SyntaxKind.ExportDeclaration) { + const ed = node as ts.Node as ts.ExportDeclaration; + const exports = [{ name: "x" }]; + const exportSpecifiers = exports.map(e => ts.createExportSpecifier(e.name, e.name)); + const exportClause = ts.createNamedExports(exportSpecifiers); + const newEd = ts.updateExportDeclaration(ed, ed.decorators, ed.modifiers, exportClause, ed.moduleSpecifier); + + return newEd as ts.Node as T; + } + return ts.visitEachChild(node, visitNode, context); + } + }; + } + }); }); } diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.transformAwayExportStar.js b/tests/baselines/reference/transformApi/transformsCorrectly.transformAwayExportStar.js new file mode 100644 index 00000000000..7a05a90c1f8 --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.transformAwayExportStar.js @@ -0,0 +1 @@ +export { x as x } from './helper'; From 72884b8f27abb8bfe8d8ec0f4368d09f1a4c80bf Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 21:59:06 -0700 Subject: [PATCH 058/216] Emit comments on system export default expressions on the surrounding export call epxression instead (#17970) --- src/compiler/emitter.ts | 2 +- src/compiler/transformers/module/system.ts | 3 ++- .../systemDefaultExportCommentValidity.js | 20 +++++++++++++++++++ ...systemDefaultExportCommentValidity.symbols | 8 ++++++++ .../systemDefaultExportCommentValidity.types | 9 +++++++++ .../systemDefaultExportCommentValidity.ts | 5 +++++ 6 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/systemDefaultExportCommentValidity.js create mode 100644 tests/baselines/reference/systemDefaultExportCommentValidity.symbols create mode 100644 tests/baselines/reference/systemDefaultExportCommentValidity.types create mode 100644 tests/cases/compiler/systemDefaultExportCommentValidity.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5444c618353..166e4751983 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2519,7 +2519,7 @@ namespace ts { // 2 // /* end of element 2 */ // ]; - if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + if (previousSibling && delimiter && previousSibling.end !== parentNode.end && !(getEmitFlags(previousSibling) & EmitFlags.NoTrailingComments)) { emitLeadingCommentsOfPosition(previousSibling.end); } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index e1c239736d5..8c47ec82f70 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1132,7 +1132,8 @@ namespace ts { */ function createExportExpression(name: Identifier | StringLiteral, value: Expression) { const exportName = isIdentifier(name) ? createLiteral(name) : name; - return createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]); + setEmitFlags(value, getEmitFlags(value) | EmitFlags.NoComments); + return setCommentRange(createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // diff --git a/tests/baselines/reference/systemDefaultExportCommentValidity.js b/tests/baselines/reference/systemDefaultExportCommentValidity.js new file mode 100644 index 00000000000..a56110b0de9 --- /dev/null +++ b/tests/baselines/reference/systemDefaultExportCommentValidity.js @@ -0,0 +1,20 @@ +//// [systemDefaultExportCommentValidity.ts] +const Home = {} + +export default Home +// There is intentionally no semicolon on the prior line, this comment should not break emit + +//// [systemDefaultExportCommentValidity.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var Home; + return { + setters: [], + execute: function () { + Home = {}; + exports_1("default", Home); + // There is intentionally no semicolon on the prior line, this comment should not break emit + } + }; +}); diff --git a/tests/baselines/reference/systemDefaultExportCommentValidity.symbols b/tests/baselines/reference/systemDefaultExportCommentValidity.symbols new file mode 100644 index 00000000000..39abe3a6685 --- /dev/null +++ b/tests/baselines/reference/systemDefaultExportCommentValidity.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/systemDefaultExportCommentValidity.ts === +const Home = {} +>Home : Symbol(Home, Decl(systemDefaultExportCommentValidity.ts, 0, 5)) + +export default Home +>Home : Symbol(Home, Decl(systemDefaultExportCommentValidity.ts, 0, 5)) + +// There is intentionally no semicolon on the prior line, this comment should not break emit diff --git a/tests/baselines/reference/systemDefaultExportCommentValidity.types b/tests/baselines/reference/systemDefaultExportCommentValidity.types new file mode 100644 index 00000000000..d8b89394ed6 --- /dev/null +++ b/tests/baselines/reference/systemDefaultExportCommentValidity.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/systemDefaultExportCommentValidity.ts === +const Home = {} +>Home : {} +>{} : {} + +export default Home +>Home : {} + +// There is intentionally no semicolon on the prior line, this comment should not break emit diff --git a/tests/cases/compiler/systemDefaultExportCommentValidity.ts b/tests/cases/compiler/systemDefaultExportCommentValidity.ts new file mode 100644 index 00000000000..df1d0283978 --- /dev/null +++ b/tests/cases/compiler/systemDefaultExportCommentValidity.ts @@ -0,0 +1,5 @@ +// @module: system +const Home = {} + +export default Home +// There is intentionally no semicolon on the prior line, this comment should not break emit \ No newline at end of file From c3e090695ec59cd79536ea892f4351fbb3674489 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 22:07:30 -0700 Subject: [PATCH 059/216] Do not consider UMD alias symbols as visible within external modules (#18049) * Do not consider UMD alias symbols as visible within external modules in the symbol writer * Minimal repro --- src/compiler/checker.ts | 5 ++++ .../reference/exportAsNamespace.d.types | 2 +- ...mportShouldNotBeElidedInDeclarationEmit.js | 26 +++++++++++++++++++ ...ShouldNotBeElidedInDeclarationEmit.symbols | 23 ++++++++++++++++ ...rtShouldNotBeElidedInDeclarationEmit.types | 24 +++++++++++++++++ .../reference/umd-augmentation-1.types | 2 +- .../reference/umd-augmentation-2.types | 2 +- .../reference/umd-augmentation-3.symbols | 2 +- .../reference/umd-augmentation-3.types | 4 +-- .../reference/umd-augmentation-4.symbols | 2 +- .../reference/umd-augmentation-4.types | 4 +-- tests/baselines/reference/umd1.types | 2 +- tests/baselines/reference/umd3.types | 2 +- tests/baselines/reference/umd4.types | 2 +- .../reference/umdGlobalConflict.types | 2 +- ...mportShouldNotBeElidedInDeclarationEmit.ts | 12 +++++++++ 16 files changed, 103 insertions(+), 13 deletions(-) create mode 100644 tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js create mode 100644 tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.symbols create mode 100644 tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types create mode 100644 tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9fcd0b593f8..e7e66ed5f2d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2095,6 +2095,10 @@ namespace ts { canQualifySymbol(symbolFromSymbolTable, meaning); } + function isUMDExportSymbol(symbol: Symbol) { + return symbol && symbol.declarations && symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]); + } + function trySymbolTable(symbols: SymbolTable) { // If symbol is directly available by its name in the symbol table if (isAccessible(symbols.get(symbol.escapedName))) { @@ -2106,6 +2110,7 @@ namespace ts { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.escapedName !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier) + && !(isUMDExportSymbol(symbolFromSymbolTable) && isExternalModule(getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration))) { diff --git a/tests/baselines/reference/exportAsNamespace.d.types b/tests/baselines/reference/exportAsNamespace.d.types index 706857bf8ed..4952cb8863b 100644 --- a/tests/baselines/reference/exportAsNamespace.d.types +++ b/tests/baselines/reference/exportAsNamespace.d.types @@ -5,5 +5,5 @@ export var X; >X : any export as namespace N ->N : typeof N +>N : typeof "tests/cases/compiler/exportAsNamespace" diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js new file mode 100644 index 00000000000..a1316dbdd46 --- /dev/null +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts] //// + +//// [umd.d.ts] +export as namespace UMD; + +export type Thing = { + a: number; +} + +export declare function makeThing(): Thing; +//// [index.ts] +import { makeThing } from "umd"; +export const thing = makeThing(); + + +//// [index.js] +"use strict"; +exports.__esModule = true; +var umd_1 = require("umd"); +exports.thing = umd_1.makeThing(); + + +//// [index.d.ts] +export declare const thing: { + a: number; +}; diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.symbols b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.symbols new file mode 100644 index 00000000000..4ac0f4928b0 --- /dev/null +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/node_modules/umd.d.ts === +export as namespace UMD; +>UMD : Symbol(UMD, Decl(umd.d.ts, 0, 0)) + +export type Thing = { +>Thing : Symbol(Thing, Decl(umd.d.ts, 0, 24)) + + a: number; +>a : Symbol(a, Decl(umd.d.ts, 2, 21)) +} + +export declare function makeThing(): Thing; +>makeThing : Symbol(makeThing, Decl(umd.d.ts, 4, 1)) +>Thing : Symbol(Thing, Decl(umd.d.ts, 0, 24)) + +=== tests/cases/compiler/index.ts === +import { makeThing } from "umd"; +>makeThing : Symbol(makeThing, Decl(index.ts, 0, 8)) + +export const thing = makeThing(); +>thing : Symbol(thing, Decl(index.ts, 1, 12)) +>makeThing : Symbol(makeThing, Decl(index.ts, 0, 8)) + diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types new file mode 100644 index 00000000000..2531654f80b --- /dev/null +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/node_modules/umd.d.ts === +export as namespace UMD; +>UMD : typeof "tests/cases/compiler/node_modules/umd" + +export type Thing = { +>Thing : Thing + + a: number; +>a : number +} + +export declare function makeThing(): Thing; +>makeThing : () => Thing +>Thing : Thing + +=== tests/cases/compiler/index.ts === +import { makeThing } from "umd"; +>makeThing : () => { a: number; } + +export const thing = makeThing(); +>thing : { a: number; } +>makeThing() : { a: number; } +>makeThing : () => { a: number; } + diff --git a/tests/baselines/reference/umd-augmentation-1.types b/tests/baselines/reference/umd-augmentation-1.types index 5324e58f68e..9d89e0c4537 100644 --- a/tests/baselines/reference/umd-augmentation-1.types +++ b/tests/baselines/reference/umd-augmentation-1.types @@ -47,7 +47,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof Math2d +>Math2d : typeof "tests/cases/conformance/externalModules/node_modules/math2d/index" export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-2.types b/tests/baselines/reference/umd-augmentation-2.types index 4ead8d611ca..b8d04ecd643 100644 --- a/tests/baselines/reference/umd-augmentation-2.types +++ b/tests/baselines/reference/umd-augmentation-2.types @@ -45,7 +45,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof Math2d +>Math2d : typeof "tests/cases/conformance/externalModules/node_modules/math2d/index" export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-3.symbols b/tests/baselines/reference/umd-augmentation-3.symbols index acb2f471faf..7cbe3ac803b 100644 --- a/tests/baselines/reference/umd-augmentation-3.symbols +++ b/tests/baselines/reference/umd-augmentation-3.symbols @@ -44,7 +44,7 @@ export = M2D; >M2D : Symbol(M2D, Decl(index.d.ts, 2, 13)) declare namespace M2D { ->M2D : Symbol(Math2d, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) +>M2D : Symbol(M2D, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) interface Point { >Point : Symbol(Point, Decl(index.d.ts, 4, 23)) diff --git a/tests/baselines/reference/umd-augmentation-3.types b/tests/baselines/reference/umd-augmentation-3.types index 4802d159e18..5efafd780a0 100644 --- a/tests/baselines/reference/umd-augmentation-3.types +++ b/tests/baselines/reference/umd-augmentation-3.types @@ -47,13 +47,13 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof Math2d +>Math2d : typeof M2D export = M2D; >M2D : typeof M2D declare namespace M2D { ->M2D : typeof Math2d +>M2D : typeof M2D interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-4.symbols b/tests/baselines/reference/umd-augmentation-4.symbols index 12696ab51f7..eabb2e15898 100644 --- a/tests/baselines/reference/umd-augmentation-4.symbols +++ b/tests/baselines/reference/umd-augmentation-4.symbols @@ -42,7 +42,7 @@ export = M2D; >M2D : Symbol(M2D, Decl(index.d.ts, 2, 13)) declare namespace M2D { ->M2D : Symbol(Math2d, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) +>M2D : Symbol(M2D, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) interface Point { >Point : Symbol(Point, Decl(index.d.ts, 4, 23)) diff --git a/tests/baselines/reference/umd-augmentation-4.types b/tests/baselines/reference/umd-augmentation-4.types index 324de384183..f71928f5afc 100644 --- a/tests/baselines/reference/umd-augmentation-4.types +++ b/tests/baselines/reference/umd-augmentation-4.types @@ -45,13 +45,13 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : typeof Math2d +>Math2d : typeof M2D export = M2D; >M2D : typeof M2D declare namespace M2D { ->M2D : typeof Math2d +>M2D : typeof M2D interface Point { >Point : Point diff --git a/tests/baselines/reference/umd1.types b/tests/baselines/reference/umd1.types index 9ccc0d2cd8e..b84aaf3ad70 100644 --- a/tests/baselines/reference/umd1.types +++ b/tests/baselines/reference/umd1.types @@ -30,5 +30,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof Foo +>Foo : typeof "tests/cases/conformance/externalModules/foo" diff --git a/tests/baselines/reference/umd3.types b/tests/baselines/reference/umd3.types index ab7978545ba..ef54806a174 100644 --- a/tests/baselines/reference/umd3.types +++ b/tests/baselines/reference/umd3.types @@ -32,5 +32,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof Foo +>Foo : typeof "tests/cases/conformance/externalModules/foo" diff --git a/tests/baselines/reference/umd4.types b/tests/baselines/reference/umd4.types index c9144af7a18..3b6ebfa6ca7 100644 --- a/tests/baselines/reference/umd4.types +++ b/tests/baselines/reference/umd4.types @@ -32,5 +32,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : typeof Foo +>Foo : typeof "tests/cases/conformance/externalModules/foo" diff --git a/tests/baselines/reference/umdGlobalConflict.types b/tests/baselines/reference/umdGlobalConflict.types index d23d42e702a..0bb26b47918 100644 --- a/tests/baselines/reference/umdGlobalConflict.types +++ b/tests/baselines/reference/umdGlobalConflict.types @@ -1,6 +1,6 @@ === tests/cases/compiler/v1/index.d.ts === export as namespace Alpha; ->Alpha : typeof Alpha +>Alpha : typeof "tests/cases/compiler/v1/index" export var x: string; >x : string diff --git a/tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts b/tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts new file mode 100644 index 00000000000..a6d77a51567 --- /dev/null +++ b/tests/cases/compiler/importShouldNotBeElidedInDeclarationEmit.ts @@ -0,0 +1,12 @@ +// @declaration: true +// @filename: node_modules/umd.d.ts +export as namespace UMD; + +export type Thing = { + a: number; +} + +export declare function makeThing(): Thing; +// @filename: index.ts +import { makeThing } from "umd"; +export const thing = makeThing(); From 72cbc12c9a5cb49ff331f3a3828a83c4ae4c5991 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 6 Sep 2017 22:08:42 -0700 Subject: [PATCH 060/216] Allow undefined/null to override all parameters (#18058) --- src/compiler/commandLineParser.ts | 32 ++++++++++------ src/compiler/types.ts | 2 +- .../unittests/configurationExtension.ts | 37 ++++++++++++++++++- 3 files changed, 58 insertions(+), 13 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index c92d147f9a9..dc9c2ad35ed 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1057,7 +1057,7 @@ namespace ts { errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText)); } const value = convertPropertyValueToJson(element.initializer, option); - if (typeof keyText !== "undefined" && typeof value !== "undefined") { + if (typeof keyText !== "undefined") { result[keyText] = value; // Notify key value set, if user asked for it if (jsonConversionNotifier && @@ -1104,7 +1104,7 @@ namespace ts { return false; case SyntaxKind.NullKeyword: - reportInvalidOptionValue(!!option); + reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return null; // tslint:disable-line:no-null-keyword case SyntaxKind.StringLiteral: @@ -1189,6 +1189,7 @@ namespace ts { function isCompilerOptionsValue(option: CommandLineOption, value: any): value is CompilerOptionsValue { if (option) { + if (isNullOrUndefined(value)) return true; // All options are undefinable/nullable if (option.type === "list") { return isArray(value); } @@ -1379,6 +1380,11 @@ namespace ts { } } + function isNullOrUndefined(x: any): x is null | undefined { + // tslint:disable-next-line:no-null-keyword + return x === undefined || x === null; + } + /** * Parse the contents of a config file from json or json source file (tsconfig.json). * @param json The contents of the config file to parse @@ -1419,7 +1425,7 @@ namespace ts { function getFileNames(): ExpandResult { let fileNames: ReadonlyArray; - if (hasProperty(raw, "files")) { + if (hasProperty(raw, "files") && !isNullOrUndefined(raw["files"])) { if (isArray(raw["files"])) { fileNames = >raw["files"]; if (fileNames.length === 0) { @@ -1432,7 +1438,7 @@ namespace ts { } let includeSpecs: ReadonlyArray; - if (hasProperty(raw, "include")) { + if (hasProperty(raw, "include") && !isNullOrUndefined(raw["include"])) { if (isArray(raw["include"])) { includeSpecs = >raw["include"]; } @@ -1442,7 +1448,7 @@ namespace ts { } let excludeSpecs: ReadonlyArray; - if (hasProperty(raw, "exclude")) { + if (hasProperty(raw, "exclude") && !isNullOrUndefined(raw["exclude"])) { if (isArray(raw["exclude"])) { excludeSpecs = >raw["exclude"]; } @@ -1461,7 +1467,7 @@ namespace ts { includeSpecs = ["**/*"]; } - const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, sourceFile); + const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? getDirectoryPath(toPath(configFileName, basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames))) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push( @@ -1552,7 +1558,7 @@ namespace ts { host: ParseConfigHost, basePath: string, getCanonicalFileName: (fileName: string) => string, - configFileName: string, + configFileName: string | undefined, errors: Push ): ParsedTsconfig { if (hasProperty(json, "excludes")) { @@ -1571,7 +1577,8 @@ namespace ts { errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - extendedConfigPath = getExtendsConfigPath(json.extends, host, basePath, getCanonicalFileName, errors, createCompilerDiagnostic); + const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath; + extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, createCompilerDiagnostic); } } return { raw: json, options, typeAcquisition, extendedConfigPath }; @@ -1582,7 +1589,7 @@ namespace ts { host: ParseConfigHost, basePath: string, getCanonicalFileName: (fileName: string) => string, - configFileName: string, + configFileName: string | undefined, errors: Push ): ParsedTsconfig { const options = getDefaultCompilerOptions(configFileName); @@ -1603,10 +1610,11 @@ namespace ts { onSetValidOptionKeyValueInRoot(key: string, _keyNode: PropertyName, value: CompilerOptionsValue, valueNode: Expression) { switch (key) { case "extends": + const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath; extendedConfigPath = getExtendsConfigPath( value, host, - basePath, + newBase, getCanonicalFileName, errors, (message, arg0) => @@ -1803,6 +1811,7 @@ namespace ts { } function normalizeOptionValue(option: CommandLineOption, basePath: string, value: any): CompilerOptionsValue { + if (isNullOrUndefined(value)) return undefined; if (option.type === "list") { const listOption = option; if (listOption.element.isFilePath || typeof listOption.element.type !== "string") { @@ -1827,6 +1836,7 @@ namespace ts { } function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Push) { + if (isNullOrUndefined(value)) return undefined; const key = value.toLowerCase(); const val = opt.type.get(key); if (val !== undefined) { @@ -1977,7 +1987,7 @@ namespace ts { // remove a literal file. if (fileNames) { for (const fileName of fileNames) { - const file = combinePaths(basePath, fileName); + const file = getNormalizedAbsolutePath(fileName, basePath); literalFileMap.set(keyMapper(file), file); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9d5bbf5b08e..b9d8d7a6319 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3583,7 +3583,7 @@ namespace ts { name: string; } - export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | null | undefined; export interface CompilerOptions { /*@internal*/ all?: boolean; diff --git a/src/harness/unittests/configurationExtension.ts b/src/harness/unittests/configurationExtension.ts index 2d50d2cb2af..b46d98f1524 100644 --- a/src/harness/unittests/configurationExtension.ts +++ b/src/harness/unittests/configurationExtension.ts @@ -78,6 +78,23 @@ namespace ts { }, include: ["../supplemental.*"] }, + "/dev/configs/third.json": { + extends: "./second", + compilerOptions: { + // tslint:disable-next-line:no-null-keyword + module: null + }, + include: ["../supplemental.*"] + }, + "/dev/configs/fourth.json": { + extends: "./third", + compilerOptions: { + module: "system" + }, + // tslint:disable-next-line:no-null-keyword + include: null, + files: ["../main.ts"] + }, "/dev/extends.json": { extends: 42 }, "/dev/extends2.json": { extends: "configs/base" }, "/dev/main.ts": "", @@ -106,7 +123,7 @@ namespace ts { } } - describe("Configuration Extension", () => { + describe("configurationExtension", () => { forEach<[string, string, Utils.MockParseConfigHost], void>([ ["under a case insensitive host", caseInsensitiveBasePath, caseInsensitiveHost], ["under a case sensitive host", caseSensitiveBasePath, caseSensitiveHost] @@ -206,6 +223,24 @@ namespace ts { category: DiagnosticCategory.Error, messageText: `A path in an 'extends' option must be relative or rooted, but 'configs/base' is not.` }]); + + testSuccess("can overwrite compiler options using extended 'null'", "configs/third.json", { + allowJs: true, + noImplicitAny: true, + strictNullChecks: true, + module: undefined // Technically, this is distinct from the key never being set; but within the compiler we don't make the distinction + }, [ + combinePaths(basePath, "supplemental.ts") + ]); + + testSuccess("can overwrite top-level options using extended 'null'", "configs/fourth.json", { + allowJs: true, + noImplicitAny: true, + strictNullChecks: true, + module: ModuleKind.System + }, [ + combinePaths(basePath, "main.ts") + ]); }); }); }); From 53b5abe5bbb88edaaa6634999e7f1c6480262b63 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:19:00 -0700 Subject: [PATCH 061/216] Update `fromCodeFixContext` (#18290) --- .../correctQualifiedNameToIndexedAccessType.ts | 2 +- src/services/codefixes/fixAddMissingMember.ts | 10 +++++----- .../codefixes/fixClassSuperMustPrecedeThisAccess.ts | 2 +- .../codefixes/fixConstructorForDerivedNeedSuperCall.ts | 2 +- .../codefixes/fixExtendsInterfaceBecomesImplements.ts | 2 +- .../codefixes/fixForgottenThisPropertyAccess.ts | 2 +- src/services/codefixes/fixUnusedIdentifier.ts | 10 +++++----- src/services/codefixes/helpers.ts | 2 +- src/services/codefixes/importFixes.ts | 2 +- src/services/refactors/convertFunctionToEs6Class.ts | 2 +- src/services/refactors/extractMethod.ts | 2 +- src/services/textChanges.ts | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts index 3087d73276d..e18190d6f6a 100644 --- a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts +++ b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts @@ -15,7 +15,7 @@ namespace ts.codefix { const replacement = createIndexedAccessTypeNode( createTypeReferenceNode(qualifiedName.left, /*typeArguments*/ undefined), createLiteralTypeNode(createLiteral(rightText))); - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, qualifiedName, replacement); return [{ diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 1587b47c01b..97e209fe89a 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -87,7 +87,7 @@ namespace ts.codefix { createPropertyAccess(createIdentifier(className), tokenName), createIdentifier("undefined"))); - const staticInitializationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const staticInitializationChangeTracker = textChanges.ChangeTracker.fromContext(context); staticInitializationChangeTracker.insertNodeAfter( classDeclarationSourceFile, classDeclaration, @@ -111,7 +111,7 @@ namespace ts.codefix { createPropertyAccess(createThis(), tokenName), createIdentifier("undefined"))); - const propertyInitializationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const propertyInitializationChangeTracker = textChanges.ChangeTracker.fromContext(context); propertyInitializationChangeTracker.insertNodeAt( classDeclarationSourceFile, classConstructor.body.getEnd() - 1, @@ -153,7 +153,7 @@ namespace ts.codefix { /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); - const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const propertyChangeTracker = textChanges.ChangeTracker.fromContext(context); propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter }); (actions || (actions = [])).push({ @@ -178,7 +178,7 @@ namespace ts.codefix { [indexingParameter], typeNode); - const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const indexSignatureChangeTracker = textChanges.ChangeTracker.fromContext(context); indexSignatureChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, indexSignature, { suffix: context.newLineCharacter }); actions.push({ @@ -195,7 +195,7 @@ namespace ts.codefix { const callExpression = token.parent.parent; const methodDeclaration = createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic); - const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromContext(context); methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter }); return { description: formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 937afee340e..bc92cd8e0d1 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -26,7 +26,7 @@ namespace ts.codefix { } } } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.insertNodeAfter(sourceFile, getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); changeTracker.deleteNode(sourceFile, superCall); diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts index 517a79e39bd..24f44a877b3 100644 --- a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -10,7 +10,7 @@ namespace ts.codefix { return undefined; } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); const superCall = createStatement(createCall(createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ emptyArray)); changeTracker.insertNodeAfter(sourceFile, getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); diff --git a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts index d23f61d0f92..57bf2dd2795 100644 --- a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts +++ b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts @@ -21,7 +21,7 @@ namespace ts.codefix { return undefined; } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, extendsToken, createToken(SyntaxKind.ImplementsKeyword)); // We replace existing keywords with commas. diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts index 6925b557755..5ac4f035f73 100644 --- a/src/services/codefixes/fixForgottenThisPropertyAccess.ts +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -8,7 +8,7 @@ namespace ts.codefix { if (token.kind !== SyntaxKind.Identifier) { return undefined; } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, token, createPropertyAccess(createThis(), token)); return [{ diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 18491aaba26..530a4543ec4 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -175,23 +175,23 @@ namespace ts.codefix { } function deleteNode(n: Node) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); + return makeChange(textChanges.ChangeTracker.fromContext(context).deleteNode(sourceFile, n)); } function deleteRange(range: TextRange) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); + return makeChange(textChanges.ChangeTracker.fromContext(context).deleteRange(sourceFile, range)); } function deleteNodeInList(n: Node) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); + return makeChange(textChanges.ChangeTracker.fromContext(context).deleteNodeInList(sourceFile, n)); } function deleteNodeRange(start: Node, end: Node) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + return makeChange(textChanges.ChangeTracker.fromContext(context).deleteNodeRange(sourceFile, start, end)); } function replaceNode(n: Node, newNode: Node) { - return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + return makeChange(textChanges.ChangeTracker.fromContext(context).replaceNode(sourceFile, n, newNode)); } function makeChange(changeTracker: textChanges.ChangeTracker): CodeAction { diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 7b69e12a19a..685c6832f13 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -4,7 +4,7 @@ namespace ts.codefix { export function newNodesToChanges(newNodes: Node[], insertAfter: Node, context: CodeFixContext) { const sourceFile = context.sourceFile; - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); for (const newNode of newNodes) { changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index d0b52184031..99b677ebd3d 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -692,7 +692,7 @@ namespace ts.codefix { } function createChangeTracker() { - return textChanges.ChangeTracker.fromCodeFixContext(context); + return textChanges.ChangeTracker.fromContext(context); } function createCodeAction( diff --git a/src/services/refactors/convertFunctionToEs6Class.ts b/src/services/refactors/convertFunctionToEs6Class.ts index bf0e4e22658..40ef4ed2a2e 100644 --- a/src/services/refactors/convertFunctionToEs6Class.ts +++ b/src/services/refactors/convertFunctionToEs6Class.ts @@ -63,7 +63,7 @@ namespace ts.refactor.convertFunctionToES6Class { } const ctorDeclaration = ctorSymbol.valueDeclaration; - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context as { newLineCharacter: string, rulesProvider: formatting.RulesProvider }); + const changeTracker = textChanges.ChangeTracker.fromContext(context); let precedingNode: Node; let newClassDeclaration: ClassDeclaration; diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 1a96857b73e..6fe664e6c81 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -708,7 +708,7 @@ namespace ts.refactor.extractMethod { ); } - const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(context); // insert function at the end of the scope changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 6462b64e226..7909d2d3adb 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -186,7 +186,7 @@ namespace ts.textChanges { private changes: Change[] = []; private readonly newLineCharacter: string; - public static fromCodeFixContext(context: { newLineCharacter: string, rulesProvider?: formatting.RulesProvider }) { + public static fromContext(context: RefactorContext | CodeFixContext) { return new ChangeTracker(getNewlineKind(context), context.rulesProvider); } From 8c714c3651c7c3b7a2a0ba37f59835bf3b68e439 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:21:47 -0700 Subject: [PATCH 062/216] Support special JS property assignments in doc comment templates (#18193) --- src/harness/fourslash.ts | 12 +- src/services/jsDoc.ts | 111 ++++++++++-------- .../docCommentTemplateClassDecl01.ts | 22 +--- .../docCommentTemplateClassDeclMethods01.ts | 32 ++--- .../docCommentTemplateClassDeclMethods02.ts | 25 +--- .../docCommentTemplateConstructor01.ts | 22 +--- .../fourslash/docCommentTemplateEmptyFile.ts | 3 +- ...ocCommentTemplateFunctionWithParameters.ts | 6 +- .../docCommentTemplateInMultiLineComment.ts | 3 +- .../docCommentTemplateInSingleLineComment.ts | 4 +- .../docCommentTemplateIndentation.ts | 11 +- ...ommentTemplateInsideFunctionDeclaration.ts | 4 +- ...mentTemplateJsSpecialPropertyAssignment.ts | 20 ++++ ...ocCommentTemplateNamespacesAndModules01.ts | 30 +---- ...ocCommentTemplateNamespacesAndModules02.ts | 28 +---- ...ocCommentTemplateObjectLiteralMethods01.ts | 23 +--- .../fourslash/docCommentTemplateRegex.ts | 4 +- .../docCommentTemplateVariableStatements01.ts | 32 ++--- .../docCommentTemplateVariableStatements02.ts | 24 +--- .../docCommentTemplateVariableStatements03.ts | 46 +++----- tests/cases/fourslash/fourslash.ts | 4 +- 21 files changed, 157 insertions(+), 309 deletions(-) create mode 100644 tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c224fd210ea..598cfc2fd7e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2414,7 +2414,7 @@ namespace FourSlash { } } - public verifyDocCommentTemplate(expected?: ts.TextInsertion) { + public verifyDocCommentTemplate(expected: ts.TextInsertion | undefined) { const name = "verifyDocCommentTemplate"; const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition); @@ -3908,12 +3908,14 @@ namespace FourSlashInterface { this.state.verifyNoMatchingBracePosition(bracePosition); } - public DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean) { - this.state.verifyDocCommentTemplate(empty ? undefined : { newText: expectedText, caretOffset: expectedOffset }); + public docCommentTemplateAt(marker: string | FourSlash.Marker, expectedOffset: number, expectedText: string) { + this.state.goToMarker(marker); + this.state.verifyDocCommentTemplate({ newText: expectedText.replace(/\r?\n/g, "\r\n"), caretOffset: expectedOffset }); } - public noDocCommentTemplate() { - this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); + public noDocCommentTemplateAt(marker: string | FourSlash.Marker) { + this.state.goToMarker(marker); + this.state.verifyDocCommentTemplate(/*expected*/ undefined); } public rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void { diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index ee3ae7c868f..a135a9e8eef 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -173,38 +173,15 @@ namespace ts.JsDoc { return undefined; } - // TODO: add support for: - // - enums/enum members - // - interfaces - // - property declarations - // - potentially property assignments - let commentOwner: Node; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.Constructor: - case SyntaxKind.ClassDeclaration: - case SyntaxKind.VariableStatement: - break findOwner; - case SyntaxKind.SourceFile: - return undefined; - case SyntaxKind.ModuleDeclaration: - // If in walking up the tree, we hit a a nested namespace declaration, - // then we must be somewhere within a dotted namespace name; however we don't - // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === SyntaxKind.ModuleDeclaration) { - return undefined; - } - break findOwner; - } + const commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + if (!commentOwnerInfo) { + return undefined; } - - if (!commentOwner || commentOwner.getStart() < position) { + const { commentOwner, parameters } = commentOwnerInfo; + if (commentOwner.getStart() < position) { return undefined; } - const parameters = getParametersForJsDocOwningNode(commentOwner); const posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); const lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; @@ -213,16 +190,18 @@ namespace ts.JsDoc { const isJavaScriptFile = hasJavaScriptFileExtension(sourceFile.fileName); let docParams = ""; - for (let i = 0; i < parameters.length; i++) { - const currentName = parameters[i].name; - const paramName = currentName.kind === SyntaxKind.Identifier ? - (currentName).escapedText : - "param" + i; - if (isJavaScriptFile) { - docParams += `${indentationStr} * @param {any} ${paramName}${newLine}`; - } - else { - docParams += `${indentationStr} * @param ${paramName}${newLine}`; + if (parameters) { + for (let i = 0; i < parameters.length; i++) { + const currentName = parameters[i].name; + const paramName = currentName.kind === SyntaxKind.Identifier ? + (currentName).escapedText : + "param" + i; + if (isJavaScriptFile) { + docParams += `${indentationStr} * @param {any} ${paramName}${newLine}`; + } + else { + docParams += `${indentationStr} * @param ${paramName}${newLine}`; + } } } @@ -244,21 +223,55 @@ namespace ts.JsDoc { return { newText: result, caretOffset: preamble.length }; } - function getParametersForJsDocOwningNode(commentOwner: Node): ReadonlyArray { - if (isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } + interface CommentOwnerInfo { + readonly commentOwner: Node; + readonly parameters?: ReadonlyArray; + } + function getCommentOwnerInfo(tokenAtPos: Node): CommentOwnerInfo | undefined { + // TODO: add support for: + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + for (let commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.Constructor: + const { parameters } = commentOwner as FunctionDeclaration | MethodDeclaration | ConstructorDeclaration; + return { commentOwner, parameters }; - if (commentOwner.kind === SyntaxKind.VariableStatement) { - const varStatement = commentOwner; - const varDeclarations = varStatement.declarationList.declarations; + case SyntaxKind.ClassDeclaration: + return { commentOwner }; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + case SyntaxKind.VariableStatement: { + const varStatement = commentOwner; + const varDeclarations = varStatement.declarationList.declarations; + const parameters = varDeclarations.length === 1 && varDeclarations[0].initializer + ? getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer) + : undefined; + return { commentOwner, parameters }; + } + + case SyntaxKind.SourceFile: + return undefined; + + case SyntaxKind.ModuleDeclaration: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + return commentOwner.parent.kind === SyntaxKind.ModuleDeclaration ? undefined : { commentOwner }; + + case SyntaxKind.BinaryExpression: { + const be = commentOwner as BinaryExpression; + if (getSpecialPropertyAssignmentKind(be) === ts.SpecialPropertyAssignmentKind.None) { + return undefined; + } + const parameters = isFunctionLike(be.right) ? be.right.parameters : emptyArray; + return { commentOwner, parameters }; + } } } - - return emptyArray; } /** diff --git a/tests/cases/fourslash/docCommentTemplateClassDecl01.ts b/tests/cases/fourslash/docCommentTemplateClassDecl01.ts index 958a8c60fa4..5a96f20d2e2 100644 --- a/tests/cases/fourslash/docCommentTemplateClassDecl01.ts +++ b/tests/cases/fourslash/docCommentTemplateClassDecl01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - /////*decl*/class C { //// private p; //// constructor(a, b, c, d); @@ -29,8 +11,8 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ //// } ////} -confirmNormalizedJsDoc("decl", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("decl", /*newTextOffset*/ 8, +`/** * */ `); diff --git a/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts b/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts index da407b632ef..ef4c82e7df7 100644 --- a/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts +++ b/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, indentation); -} - const enum Indentation { Standard = 8, Indented = 12, @@ -34,26 +16,26 @@ const enum Indentation { //// } ////} -confirmNormalizedJsDoc("0", Indentation.Standard, ` -/** +verify.docCommentTemplateAt("0", Indentation.Standard, +`/** * */`); -confirmNormalizedJsDoc("1", Indentation.Indented, +verify.docCommentTemplateAt("1", Indentation.Indented, `/** * */`); -confirmNormalizedJsDoc("2", Indentation.Indented, +verify.docCommentTemplateAt("2", Indentation.Indented, `/** * * @param a */ `); -confirmNormalizedJsDoc("3", Indentation.Indented, +verify.docCommentTemplateAt("3", Indentation.Indented, `/** * * @param a @@ -61,7 +43,7 @@ confirmNormalizedJsDoc("3", Indentation.Indented, */ `); -confirmNormalizedJsDoc("4", Indentation.Indented, +verify.docCommentTemplateAt("4", Indentation.Indented, `/** * * @param a @@ -69,7 +51,7 @@ confirmNormalizedJsDoc("4", Indentation.Indented, * @param param2 */`); -confirmNormalizedJsDoc("5", Indentation.Indented, +verify.docCommentTemplateAt("5", Indentation.Indented, `/** * * @param a diff --git a/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts b/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts index 99392cf3855..28da24d381a 100644 --- a/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts +++ b/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts @@ -1,28 +1,9 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, indentation); -} - const enum Indentation { Indented = 12, } - ////class C { //// /*0*/ //// [Symbol.iterator]() { @@ -32,15 +13,15 @@ const enum Indentation { //// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { } ////} -confirmNormalizedJsDoc("0", Indentation.Indented, +verify.docCommentTemplateAt("0", Indentation.Indented, `/** * */`); -confirmNormalizedJsDoc("1", Indentation.Indented, +verify.docCommentTemplateAt("1", Indentation.Indented, `/** * * @param x * @param y * @param z - */`); \ No newline at end of file + */`); diff --git a/tests/cases/fourslash/docCommentTemplateConstructor01.ts b/tests/cases/fourslash/docCommentTemplateConstructor01.ts index b26ece7a5e6..6c9eedb773d 100644 --- a/tests/cases/fourslash/docCommentTemplateConstructor01.ts +++ b/tests/cases/fourslash/docCommentTemplateConstructor01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - ////class C { //// private p; //// /*0*/ @@ -32,7 +14,7 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ ////} const newTextOffset = 12; -confirmNormalizedJsDoc("0", /*newTextOffset*/ newTextOffset, +verify.docCommentTemplateAt("0", /*newTextOffset*/ newTextOffset, `/** * * @param a @@ -41,7 +23,7 @@ confirmNormalizedJsDoc("0", /*newTextOffset*/ newTextOffset, * @param d */`); -confirmNormalizedJsDoc("1", /*newTextOffset*/ newTextOffset, +verify.docCommentTemplateAt("1", /*newTextOffset*/ newTextOffset, `/** * * @param a diff --git a/tests/cases/fourslash/docCommentTemplateEmptyFile.ts b/tests/cases/fourslash/docCommentTemplateEmptyFile.ts index 76e888ea2cb..f04653dc328 100644 --- a/tests/cases/fourslash/docCommentTemplateEmptyFile.ts +++ b/tests/cases/fourslash/docCommentTemplateEmptyFile.ts @@ -3,5 +3,4 @@ // @Filename: emptyFile.ts /////*0*/ -goTo.marker("0"); -verify.noDocCommentTemplate(); \ No newline at end of file +verify.noDocCommentTemplateAt("0"); diff --git a/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts b/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts index f4410d5d454..b1955d98417 100644 --- a/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts +++ b/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts @@ -11,7 +11,5 @@ const noIndentOffset = 8; const oneIndentOffset = noIndentOffset + 4; goTo.marker("0"); -verify.DocCommentTemplate(noIndentScaffolding, noIndentOffset); - -goTo.marker("1"); -verify.DocCommentTemplate(oneIndentScaffolding, oneIndentOffset); \ No newline at end of file +verify.docCommentTemplateAt("0", noIndentOffset, noIndentScaffolding); +verify.docCommentTemplateAt("1", oneIndentOffset, oneIndentScaffolding); diff --git a/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts b/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts index 131f722a9af..6e749782c7d 100644 --- a/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts +++ b/tests/cases/fourslash/docCommentTemplateInMultiLineComment.ts @@ -3,5 +3,4 @@ // @Filename: justAComment.ts //// /* /*0*/ */ -goTo.marker("0"); -verify.noDocCommentTemplate(); \ No newline at end of file +verify.noDocCommentTemplateAt("0"); diff --git a/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts b/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts index 65e9c17014e..b60fff2d590 100644 --- a/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts +++ b/tests/cases/fourslash/docCommentTemplateInSingleLineComment.ts @@ -8,4 +8,6 @@ //// // We also want to check EOF handling at the end of a comment //// // /*2*/ -goTo.eachMarker(() => verify.noDocCommentTemplate()); +for (const marker of test.markers()) { + verify.noDocCommentTemplateAt(marker); +} diff --git a/tests/cases/fourslash/docCommentTemplateIndentation.ts b/tests/cases/fourslash/docCommentTemplateIndentation.ts index 3f84a73b81f..c3015a6d9dd 100644 --- a/tests/cases/fourslash/docCommentTemplateIndentation.ts +++ b/tests/cases/fourslash/docCommentTemplateIndentation.ts @@ -12,11 +12,6 @@ const noIndentOffset = 8; const oneIndentOffset = noIndentOffset + 4; const twoIndentOffset = oneIndentOffset + 4; -goTo.marker("0"); -verify.DocCommentTemplate(noIndentEmptyScaffolding, noIndentOffset); - -goTo.marker("1"); -verify.DocCommentTemplate(oneIndentEmptyScaffolding, oneIndentOffset); - -goTo.marker("2"); -verify.DocCommentTemplate(twoIndentEmptyScaffolding, twoIndentOffset); +verify.docCommentTemplateAt("0", noIndentOffset, noIndentEmptyScaffolding); +verify.docCommentTemplateAt("1", oneIndentOffset, oneIndentEmptyScaffolding); +verify.docCommentTemplateAt("2", twoIndentOffset, twoIndentEmptyScaffolding); diff --git a/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts b/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts index dd58a1bfd5f..e0ebc00dc39 100644 --- a/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts +++ b/tests/cases/fourslash/docCommentTemplateInsideFunctionDeclaration.ts @@ -3,4 +3,6 @@ // @Filename: functionDecl.ts ////f/*0*/unction /*1*/foo/*2*/(/*3*/) /*4*/{ /*5*/} -goTo.eachMarker(() => verify.noDocCommentTemplate()); +for (const marker of test.markers()) { + verify.noDocCommentTemplateAt(marker); +} diff --git a/tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts b/tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts new file mode 100644 index 00000000000..6a15ce133e4 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateJsSpecialPropertyAssignment.ts @@ -0,0 +1,20 @@ +/// + +// @Filename: /a.js +/////*0*/module.exports = function(a) {}; +////const myNamespace = {}; +/////*1*/myNamespace.myExport = function(x) {}; + +verify.docCommentTemplateAt("0", 8, +`/** + * + * @param {any} a + */ +`); + +verify.docCommentTemplateAt("1", 8, +`/** + * + * @param {any} x + */ +`); diff --git a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts index 4d9fb987be5..e7e52fd5e94 100644 --- a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts +++ b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, charOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, charOffset); -} - /////*namespaceN*/ ////namespace n { ////} @@ -30,17 +12,17 @@ function confirmNormalizedJsDoc(markerName: string, charOffset: number, template ////module "ambientModule" { ////} -confirmNormalizedJsDoc("namespaceN", /*indentation*/ 8, ` -/** +verify.docCommentTemplateAt("namespaceN", /*indentation*/ 8, +`/** * */`); -confirmNormalizedJsDoc("namespaceM", /*indentation*/ 8, ` -/** +verify.docCommentTemplateAt("namespaceM", /*indentation*/ 8, +`/** * */`); -confirmNormalizedJsDoc("namespaceM", /*indentation*/ 8, ` -/** +verify.docCommentTemplateAt("namespaceM", /*indentation*/ 8, +`/** * */`); diff --git a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts index e59b16d6163..dad2e9745a9 100644 --- a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts +++ b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts @@ -1,36 +1,16 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, charOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, charOffset); -} - /////*top*/ ////namespace n1. //// /*n2*/ n2. //// /*n3*/ n3 { ////} -confirmNormalizedJsDoc("top", /*indentation*/ 8, ` -/** +verify.docCommentTemplateAt("top", /*indentation*/ 8, +`/** * */`); -goTo.marker("n2"); -verify.noDocCommentTemplate(); +verify.noDocCommentTemplateAt("n2"); -goTo.marker("n3"); -verify.noDocCommentTemplate(); \ No newline at end of file +verify.noDocCommentTemplateAt("n3"); diff --git a/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts b/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts index 4af1b60c698..2ae77d4afac 100644 --- a/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts +++ b/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts @@ -1,28 +1,9 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, indentation); -} - const enum Indentation { Indented = 12, } - ////var x = { //// /*0*/ //// foo() { @@ -32,12 +13,12 @@ const enum Indentation { //// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { } ////} -confirmNormalizedJsDoc("0", Indentation.Indented, +verify.docCommentTemplateAt("0", Indentation.Indented, `/** * */`); -confirmNormalizedJsDoc("1", Indentation.Indented, +verify.docCommentTemplateAt("1", Indentation.Indented, `/** * * @param x diff --git a/tests/cases/fourslash/docCommentTemplateRegex.ts b/tests/cases/fourslash/docCommentTemplateRegex.ts index 62d200dee10..685c1ca5aef 100644 --- a/tests/cases/fourslash/docCommentTemplateRegex.ts +++ b/tests/cases/fourslash/docCommentTemplateRegex.ts @@ -3,4 +3,6 @@ // @Filename: regex.ts ////var regex = /*0*///*1*/asdf/*2*/ /*3*///*4*/; -goTo.eachMarker(() => verify.noDocCommentTemplate()); +for (const marker of test.markers()) { + verify.noDocCommentTemplateAt(marker); +} diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts index b901919fa1f..b6243652167 100644 --- a/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - /////*a*/ ////var a = 10; //// @@ -46,23 +28,23 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ //// } ////} -for (const varName of "abcd".split("")) { - confirmNormalizedJsDoc(varName, /*newTextOffset*/ 8, ` -/** +for (const varName of ["a", "b", "c", "d"]) { + verify.docCommentTemplateAt(varName, /*newTextOffset*/ 8, +`/** * */`); } -confirmNormalizedJsDoc("e", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("e", /*newTextOffset*/ 8, +`/** * * @param x * @param y * @param z */`); -confirmNormalizedJsDoc("f", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("f", /*newTextOffset*/ 8, +`/** * * @param a * @param b diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts index 9339e703570..f22e361f63f 100644 --- a/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements02.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - /////*a*/ ////var a1 = 10, a2 = 20; //// @@ -46,9 +28,9 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ //// bar: "20" ////}, f2 = null; -for (const varName of "abcdef".split("")) { - confirmNormalizedJsDoc(varName, /*newTextOffset*/ 8, ` -/** +for (const varName of ["a", "b", "c", "d", "e", "f"]) { + verify.docCommentTemplateAt(varName, /*newTextOffset*/ 8, +`/** * */`); } diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts index e473cb798b7..195553098f0 100644 --- a/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts @@ -1,23 +1,5 @@ /// -const CRLF = "\r\n"; -/** - * @returns the given value with '\n' normalized to '\r\n' and with no leading newline - */ -function useCRLFAndStripLeadingNewline(str: string): string { - str = str.replace(/\r?\n/g, CRLF); - if (str.indexOf(CRLF) === 0) { - str = str.slice(CRLF.length); - } - return str; -} - -function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { - goTo.marker(markerName); - const normalized = useCRLFAndStripLeadingNewline(template); - verify.DocCommentTemplate(normalized, newTextOffset); -} - /////*a*/ ////var a = x => x //// @@ -47,44 +29,44 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ //// } ////})) -confirmNormalizedJsDoc("a", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("a", /*newTextOffset*/ 8, +`/** * * @param x */`); -confirmNormalizedJsDoc("b", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("b", /*newTextOffset*/ 8, +`/** * * @param x * @param y * @param z */`); -confirmNormalizedJsDoc("c", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("c", /*newTextOffset*/ 8, +`/** * * @param x */`); -confirmNormalizedJsDoc("d", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("d", /*newTextOffset*/ 8, +`/** * */`); -confirmNormalizedJsDoc("e", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("e", /*newTextOffset*/ 8, +`/** * * @param param0 */`); -confirmNormalizedJsDoc("f", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("f", /*newTextOffset*/ 8, +`/** * */`); -confirmNormalizedJsDoc("g", /*newTextOffset*/ 8, ` -/** +verify.docCommentTemplateAt("g", /*newTextOffset*/ 8, +`/** * * @param x */`); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 5150fa16ae9..119780872e9 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -242,8 +242,8 @@ declare namespace FourSlashInterface { todoCommentsInCurrentFile(descriptors: string[]): void; matchingBracePositionInCurrentFile(bracePosition: number, expectedMatchPosition: number): void; noMatchingBracePositionInCurrentFile(bracePosition: number): void; - DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; - noDocCommentTemplate(): void; + docCommentTemplateAt(markerName: string | FourSlashInterface.Marker, expectedOffset: number, expectedText: string): void; + noDocCommentTemplateAt(markerName: string | FourSlashInterface.Marker): void; rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void; fileAfterApplyingRefactorAtMarker(markerName: string, expectedContent: string, refactorNameToApply: string, actionName: string, formattingOptions?: FormatCodeOptions): void; rangeIs(expectedText: string, includeWhiteSpace?: boolean): void; From 0434fe797a0fe0b63f117dc811912e8312e62365 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:22:39 -0700 Subject: [PATCH 063/216] Get quickInfo from a contextual type if possible (#18119) --- src/compiler/types.ts | 3 ++ src/services/services.ts | 17 ++++++++++- tests/cases/fourslash/contextualTyping.ts | 28 +++++++++---------- .../fourslash/quickInfoFromContextualType.ts | 10 +++++++ .../quickInfoOnClassMergedWithFunction.ts | 22 +++++++-------- tests/cases/fourslash/quickInfoTypeError.ts | 4 +-- 6 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 tests/cases/fourslash/quickInfoFromContextualType.ts diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b9d8d7a6319..83fc699c844 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -744,6 +744,7 @@ namespace ts { ; export interface PropertyAssignment extends ObjectLiteralElement { + parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; @@ -751,6 +752,7 @@ namespace ts { } export interface ShorthandPropertyAssignment extends ObjectLiteralElement { + parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; @@ -761,6 +763,7 @@ namespace ts { } export interface SpreadAssignment extends ObjectLiteralElement { + parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } diff --git a/src/services/services.ts b/src/services/services.ts index bada7ff021d..c22229fd089 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1398,7 +1398,7 @@ namespace ts { } const typeChecker = program.getTypeChecker(); - const symbol = typeChecker.getSymbolAtLocation(node); + const symbol = getSymbolAtLocationForQuickInfo(node, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show @@ -1437,6 +1437,21 @@ namespace ts { }; } + function getSymbolAtLocationForQuickInfo(node: Node, checker: TypeChecker): Symbol | undefined { + if ((isIdentifier(node) || isStringLiteral(node)) + && isPropertyAssignment(node.parent) + && node.parent.name === node) { + const type = checker.getContextualType(node.parent.parent); + if (type) { + const property = checker.getPropertyOfType(type, getTextOfIdentifierOrLiteral(node)); + if (property) { + return property; + } + } + } + return checker.getSymbolAtLocation(node); + } + /// Goto definition function getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] { synchronizeHostData(); diff --git a/tests/cases/fourslash/contextualTyping.ts b/tests/cases/fourslash/contextualTyping.ts index 7819db20d92..9e9bce6dfaa 100644 --- a/tests/cases/fourslash/contextualTyping.ts +++ b/tests/cases/fourslash/contextualTyping.ts @@ -32,7 +32,7 @@ ////var /*13*/c3t5: (n: number) => IFoo = function(/*14*/n) { return ({}) }; ////var /*15*/c3t6: (n: number, s: string) => IFoo = function(/*16*/n, /*17*/s) { return ({}) }; ////var /*18*/c3t7: { -//// (n: number): number; +//// (n: number): number; //// (s1: string): number; ////}; ////var /*20*/c3t8: (n: number, s: string) => number = function(/*21*/n) { return n; }; @@ -79,7 +79,7 @@ //// t5: (n: number) => IFoo; //// t6: (n: number, s: string) => IFoo; //// t7: { -//// (n: number, s: string): number; +//// (n: number, s: string): number; //// //(s1: string, s2: string): number; //// }; //// t8: (n: number, s: string) => number; @@ -98,7 +98,7 @@ //// t5: (n: number) => IFoo; //// t6: (n: number, s: string) => IFoo; //// t7: { -//// (n: number, s: string): number; +//// (n: number, s: string): number; //// //(s1: string, s2: string): number; //// }; //// t8: (n: number, s: string) => number; @@ -152,7 +152,7 @@ ////var /*80*/c12t5 = <(n: number) => IFoo> function(/*81*/n) { return ({}) }; ////var /*82*/c12t6 = <(n: number, s: string) => IFoo> function(/*83*/n, /*84*/s) { return ({}) }; ////var /*85*/c12t7 = <{ -//// (n: number, s: string): number; +//// (n: number, s: string): number; //// //(s1: string, s2: string): number; ////}> function(n:number) { return n }; ////var /*86*/c12t8 = <(n: number, s: string) => number> function (/*87*/n) { return n; }; @@ -221,13 +221,13 @@ verify.quickInfos({ 25: "(parameter) n: number", 26: "(parameter) s: string", 27: "var c3t12: IBar", - 28: "(property) foo: IFoo", + 28: "(property) IBar.foo: IFoo", 29: "var c3t13: IFoo", - 30: "(property) f: (i: number, s: string) => string", + 30: "(method) IFoo.f(i: number, s: string): string", 31: "(parameter) i: number", 32: "(parameter) s: string", 33: "var c3t14: IFoo", - 34: "(property) a: undefined[]", + 34: "(property) IFoo.a: number[]", 35: "(property) C4T5.foo: (i: number, s: string) => string", 36: "(parameter) i: number", 37: "(parameter) s: string", @@ -257,13 +257,13 @@ verify.quickInfos({ 61: "(parameter) n: number", 62: "(parameter) s: string", 63: "(property) t12: IBar", - 64: "(property) foo: IFoo", + 64: "(property) IBar.foo: IFoo", 65: "(property) t13: IFoo", - 66: "(property) f: (i: number, s: string) => string", + 66: "(method) IFoo.f(i: number, s: string): string", 67: "(parameter) i: number", 68: "(parameter) s: string", 69: "(property) t14: IFoo", - 70: "(property) a: undefined[]", + 70: "(property) IFoo.a: number[]", 71: "(parameter) n: number", 72: "var c10t5: () => (n: number) => IFoo", 73: "(parameter) n: number", @@ -287,13 +287,13 @@ verify.quickInfos({ 91: "(parameter) n: number", 92: "(parameter) s: string", 93: "var c12t12: IBar", - 94: "(property) foo: IFoo", + 94: "(property) IBar.foo: IFoo", 95: "var c12t13: IFoo", - 96: "(property) f: (i: number, s: string) => string", + 96: "(method) IFoo.f(i: number, s: string): string", 97: "(parameter) i: number", 98: "(parameter) s: string", 99: "var c12t14: IFoo", - 100: "(property) a: undefined[]", + 100: "(property) IFoo.a: number[]", 101: "function EF1(a: number, b: number): number", 102: "(parameter) a: any", 103: "(parameter) b: any", @@ -302,7 +302,7 @@ verify.quickInfos({ 112: "(method) Point.add(dx: number, dy: number): Point", 113: "(parameter) dx: number", 114: "(parameter) dy: number", - 115: "(property) add: (dx: number, dy: number) => Point", + 115: "(method) Point.add(dx: number, dy: number): Point", 116: "(parameter) dx: number", 117: "(parameter) dy: number" }); diff --git a/tests/cases/fourslash/quickInfoFromContextualType.ts b/tests/cases/fourslash/quickInfoFromContextualType.ts new file mode 100644 index 00000000000..020681cd022 --- /dev/null +++ b/tests/cases/fourslash/quickInfoFromContextualType.ts @@ -0,0 +1,10 @@ +/// + +// @Filename: quickInfoExportAssignmentOfGenericInterface_0.ts +////interface I { +//// /** Documentation */ +//// x: number; +////} +////const i: I = { /**/x: 0 }; + +verify.quickInfoAt("", "(property) I.x: number", "Documentation "); diff --git a/tests/cases/fourslash/quickInfoOnClassMergedWithFunction.ts b/tests/cases/fourslash/quickInfoOnClassMergedWithFunction.ts index ef735fdfe3f..4a4f4e5fc17 100644 --- a/tests/cases/fourslash/quickInfoOnClassMergedWithFunction.ts +++ b/tests/cases/fourslash/quickInfoOnClassMergedWithFunction.ts @@ -1,16 +1,16 @@ /// ////module Test { -//// class Mocked { -//// myProp: string; -//// } -//// class Tester { -//// willThrowError() { -//// Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression. -//// return { /**/myProp: "test" }; -//// }; -//// } -//// } +//// class Mocked { +//// myProp: string; +//// } +//// class Tester { +//// willThrowError() { +//// Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression. +//// return { /**/myProp: "test" }; +//// }; +//// } +//// } ////} -verify.quickInfoAt("", "(property) myProp: string"); \ No newline at end of file +verify.quickInfoAt("", "(property) myProp: string"); diff --git a/tests/cases/fourslash/quickInfoTypeError.ts b/tests/cases/fourslash/quickInfoTypeError.ts index 7e0c9b20303..a4fa64e49d6 100644 --- a/tests/cases/fourslash/quickInfoTypeError.ts +++ b/tests/cases/fourslash/quickInfoTypeError.ts @@ -5,6 +5,6 @@ //// f() {} ////}); -// The symbol indicates that this is a funciton, but the type is `any`. +// The symbol indicates that this is a function, but the type is `any`. // Regression test that we don't crash (by trying to get signatures from `any`). -verify.quickInfoAt("", "(method) f"); +verify.quickInfoAt("", "(method) f(): void"); From 23f793fc3e804b43c2c6f6781913f025fe396221 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:23:06 -0700 Subject: [PATCH 064/216] findAllReferences: Handle root symbols of binding element property symbol (#17738) --- src/services/findAllReferences.ts | 78 +++++++++++-------- .../findAllRefsDestructureGeneric.ts | 15 ++++ ...OccurrencesIsDefinitionOfBindingPattern.ts | 11 ++- 3 files changed, 67 insertions(+), 37 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsDestructureGeneric.ts diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 04d383748c8..2de7eeb0210 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1435,22 +1435,27 @@ namespace ts.FindAllReferences.Core { const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); if (bindingElementPropertySymbol) { result.push(bindingElementPropertySymbol); + addRootSymbols(bindingElementPropertySymbol); } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - for (const rootSymbol of checker.getRootSymbols(symbol)) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), checker); - } - } + addRootSymbols(symbol); return result; + + function addRootSymbols(sym: Symbol): void { + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + for (const rootSymbol of checker.getRootSymbols(sym)) { + if (rootSymbol !== sym) { + result.push(rootSymbol); + } + + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), checker); + } + } + } } /** @@ -1542,34 +1547,39 @@ namespace ts.FindAllReferences.Core { // then include the binding element in the related symbols // let { a } : { a }; const bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); - if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; + if (bindingElementPropertySymbol) { + const fromBindingElement = findRootSymbol(bindingElementPropertySymbol); + if (fromBindingElement) return fromBindingElement; } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return forEach(state.checker.getRootSymbols(referenceSymbol), rootSymbol => { - // if it is in the list, then we are done - if (search.includes(rootSymbol)) { - return rootSymbol; - } + return findRootSymbol(referenceSymbol); - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - // Parents will only be defined if implementations is true - if (search.parents && !some(search.parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker))) { - return undefined; + function findRootSymbol(sym: Symbol): Symbol | undefined { + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return forEach(state.checker.getRootSymbols(sym), rootSymbol => { + // if it is in the list, then we are done + if (search.includes(rootSymbol)) { + return rootSymbol; } - const result: Symbol[] = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), state.checker); - return find(result, search.includes); - } + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + // Parents will only be defined if implementations is true + if (search.parents && !some(search.parents, parent => explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker))) { + return undefined; + } - return undefined; - }); + const result: Symbol[] = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ createSymbolTable(), state.checker); + return find(result, search.includes); + } + + return undefined; + }); + } } function getNameFromObjectLiteralElement(node: ObjectLiteralElement): string { diff --git a/tests/cases/fourslash/findAllRefsDestructureGeneric.ts b/tests/cases/fourslash/findAllRefsDestructureGeneric.ts new file mode 100644 index 00000000000..f3d4635cebd --- /dev/null +++ b/tests/cases/fourslash/findAllRefsDestructureGeneric.ts @@ -0,0 +1,15 @@ +/// + +////interface I { +//// [|{| "isWriteAccess": true, "isDefinition": true |}x|]: boolean; +////} +////declare const i: I; +////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } = i; + +const [r0, r1] = test.ranges(); + +verify.referenceGroups(r0, [{ definition: "(property) I.x: boolean", ranges: [r0, r1] }]); +verify.referenceGroups(r1, [ + { definition: "(property) I.x: boolean", ranges: [r0] }, + { definition: "const x: boolean", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts index 7725b2e94f8..58814b45e99 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts @@ -1,5 +1,10 @@ /// -////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|], y } = { x: 1, y: 2 }; -////const z = [|{| "isDefinition": false |}x|]; +////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|], y } = { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: 1, y: 2 }; +////const z = [|x|]; -verify.singleReferenceGroup("const x: number"); +const [r0, r1, r2] = test.ranges(); +verify.referenceGroups([r0, r2], [ + { definition: "const x: number", ranges: [r0, r2] }, + { definition: "(property) x: number", ranges: [r1] }, +]); +verify.referenceGroups(r1, [{ definition: "(property) x: number", ranges: [r0, r1, r2] }]); From 817c329667947afd780a69551b93fb4224e331dc Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:23:53 -0700 Subject: [PATCH 065/216] getFormattingScanner: Ensure scanner is closed, and avoid global variables (#18293) --- src/services/formatting/formatting.ts | 14 +++++------ src/services/formatting/formattingScanner.ts | 25 +++++++------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 83f87483194..443ce13d6a4 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -339,17 +339,17 @@ namespace ts.formatting { /* @internal */ export function formatNodeGivenIndentation(node: Node, sourceFileLike: SourceFileLike, languageVariant: LanguageVariant, initialIndentation: number, delta: number, rulesProvider: RulesProvider): TextChange[] { const range = { pos: 0, end: sourceFileLike.text.length }; - return formatSpanWorker( + return getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, scanner => formatSpanWorker( range, node, initialIndentation, delta, - getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), + scanner, rulesProvider.getFormatOptions(), rulesProvider, FormattingRequestKind.FormatSelection, _ => false, // assume that node does not have any errors - sourceFileLike); + sourceFileLike)); } function formatNodeLines(node: Node, sourceFile: SourceFile, options: FormatCodeSettings, rulesProvider: RulesProvider, requestKind: FormattingRequestKind): TextChange[] { @@ -372,17 +372,17 @@ namespace ts.formatting { requestKind: FormattingRequestKind): TextChange[] { // find the smallest node that fully wraps the range and compute the initial indentation for the node const enclosingNode = findEnclosingNode(originalRange, sourceFile); - return formatSpanWorker( + return getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, scanner => formatSpanWorker( originalRange, enclosingNode, SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), - getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), + scanner, options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), - sourceFile); + sourceFile)); } function formatSpanWorker(originalRange: TextRange, @@ -427,8 +427,6 @@ namespace ts.formatting { } } - formattingScanner.close(); - return edits; // local functions diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 52df6477ed0..9b4e1be323b 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -6,11 +6,6 @@ namespace ts.formatting { const standardScanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false, LanguageVariant.Standard); const jsxScanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false, LanguageVariant.JSX); - /** - * Scanner that is currently used for formatting - */ - let scanner: Scanner; - export interface FormattingScanner { advance(): void; isOnToken(): boolean; @@ -18,7 +13,6 @@ namespace ts.formatting { getCurrentLeadingTrivia(): TextRangeWithKind[]; lastTrailingTriviaWasNewLine(): boolean; skipToEndOf(node: Node): void; - close(): void; } const enum ScanAction { @@ -30,9 +24,8 @@ namespace ts.formatting { RescanJsxText, } - export function getFormattingScanner(text: string, languageVariant: LanguageVariant, startPos: number, endPos: number): FormattingScanner { - Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; + export function getFormattingScanner(text: string, languageVariant: LanguageVariant, startPos: number, endPos: number, cb: (scanner: FormattingScanner) => T): T { + const scanner = languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); @@ -45,21 +38,19 @@ namespace ts.formatting { let lastScanAction: ScanAction | undefined; let lastTokenInfo: TokenInfo | undefined; - return { + const res = cb({ advance, readTokenInfo, isOnToken, getCurrentLeadingTrivia: () => leadingTrivia, lastTrailingTriviaWasNewLine: () => wasNewLine, skipToEndOf, - close: () => { - Debug.assert(scanner !== undefined); + }); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } - }; + lastTokenInfo = undefined; + scanner.setText(undefined); + + return res; function advance(): void { Debug.assert(scanner !== undefined, "Scanner should be present"); From b3c87aa919a24196e95ab1f5552ca19fcf3be247 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:26:22 -0700 Subject: [PATCH 066/216] Support find-all-references for `default` keyword (#17992) * Support find-all-references for anonymous default exports * Also handle re-exported default exports * Add test for using `export =` with `--allowSyntheticDefaultExports` --- src/compiler/checker.ts | 3 + src/services/findAllReferences.ts | 11 ++- src/services/importTracker.ts | 69 +++++++++++-------- .../findAllRefsForDefaultExport04.ts | 21 ++++-- .../findAllRefsForDefaultExportAnonymous.ts | 22 ++++++ .../findAllRefsForDefaultExport_reExport.ts | 30 ++++++++ ...t_reExport_allowSyntheticDefaultImports.ts | 32 +++++++++ tests/cases/fourslash/findAllRefsReExports.ts | 15 ++-- 8 files changed, 159 insertions(+), 44 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts create mode 100644 tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e7e66ed5f2d..1c8bc7846d0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22987,6 +22987,9 @@ namespace ts { : undefined; return objectType && getPropertyOfType(objectType, escapeLeadingUnderscores((node as StringLiteral | NumericLiteral).text)); + case SyntaxKind.DefaultKeyword: + return getSymbolOfNode(node.parent); + default: return undefined; } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 2de7eeb0210..b12b0f85fda 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -176,7 +176,9 @@ namespace ts.FindAllReferences { fileName: node.getSourceFile().fileName, textSpan: getTextSpan(node), isWriteAccess: isWriteAccess(node), - isDefinition: isAnyDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node), + isDefinition: node.kind === SyntaxKind.DefaultKeyword + || isAnyDeclarationName(node) + || isLiteralComputedPropertyDeclarationName(node), isInString }; } @@ -243,7 +245,7 @@ namespace ts.FindAllReferences { /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node: Node): boolean { - if (isAnyDeclarationName(node)) { + if (node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node)) { return true; } @@ -743,7 +745,7 @@ namespace ts.FindAllReferences.Core { function isValidReferencePosition(node: Node, searchSymbolName: string): boolean { // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node && node.kind) { + switch (node.kind) { case SyntaxKind.Identifier: return (node as Identifier).text.length === searchSymbolName.length; @@ -754,6 +756,9 @@ namespace ts.FindAllReferences.Core { case SyntaxKind.NumericLiteral: return isLiteralNameOfPropertyDeclarationOrIndexAccess(node as NumericLiteral) && (node as NumericLiteral).text.length === searchSymbolName.length; + case SyntaxKind.DefaultKeyword: + return "default".length === searchSymbolName.length; + default: return false; } diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index d4301db2f83..65b504e7bd8 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -180,7 +180,6 @@ namespace ts.FindAllReferences { * But re-exports will be placed in 'singleReferences' since they cannot be locally referenced. */ function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker, isForRename: boolean): Pick { - const exportName = exportSymbol.escapedName; const importSearches: Array<[Identifier, Symbol]> = []; const singleReferences: Identifier[] = []; function addSearch(location: Identifier, symbol: Symbol): void { @@ -218,12 +217,11 @@ namespace ts.FindAllReferences { return; } - if (!decl.importClause) { + const { importClause } = decl; + if (!importClause) { return; } - const { importClause } = decl; - const { namedBindings } = importClause; if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) { handleNamespaceImportLike(namedBindings.name); @@ -245,7 +243,6 @@ namespace ts.FindAllReferences { // 'default' might be accessed as a named import `{ default as foo }`. if (!isForRename && exportKind === ExportKind.Default) { - Debug.assert(exportName === "default"); searchForNamedImport(namedBindings as NamedImports | undefined); } } @@ -258,36 +255,43 @@ namespace ts.FindAllReferences { */ function handleNamespaceImportLike(importName: Identifier): void { // Don't rename an import that already has a different name than the export. - if (exportKind === ExportKind.ExportEquals && (!isForRename || importName.escapedText === exportName)) { + if (exportKind === ExportKind.ExportEquals && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } function searchForNamedImport(namedBindings: NamedImportsOrExports | undefined): void { - if (namedBindings) { - for (const element of namedBindings.elements) { - const { name, propertyName } = element; - if ((propertyName || name).escapedText !== exportName) { - continue; - } + if (!namedBindings) { + return; + } - if (propertyName) { - // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. - singleReferences.push(propertyName); - if (!isForRename) { // If renaming `foo`, don't touch `bar`, just `foo`. - // Search locally for `bar`. - addSearch(name, checker.getSymbolAtLocation(name)); - } - } - else { - const localSymbol = element.kind === SyntaxKind.ExportSpecifier && element.propertyName - ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. - : checker.getSymbolAtLocation(name); - addSearch(name, localSymbol); + for (const element of namedBindings.elements) { + const { name, propertyName } = element; + if (!isNameMatch((propertyName || name).escapedText)) { + continue; + } + + if (propertyName) { + // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. + singleReferences.push(propertyName); + if (!isForRename) { // If renaming `foo`, don't touch `bar`, just `foo`. + // Search locally for `bar`. + addSearch(name, checker.getSymbolAtLocation(name)); } } + else { + const localSymbol = element.kind === SyntaxKind.ExportSpecifier && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. + : checker.getSymbolAtLocation(name); + addSearch(name, localSymbol); + } } } + + function isNameMatch(name: __String): boolean { + // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports + return name === exportSymbol.escapedName || exportKind !== ExportKind.Named && name === "default"; + } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -413,7 +417,7 @@ namespace ts.FindAllReferences { case SyntaxKind.ExternalModuleReference: return (decl as ExternalModuleReference).parent; default: - Debug.fail(`Unexpected module specifier parent: ${decl.kind}`); + Debug.fail("Unexpected module specifier parent: " + decl.kind); } } @@ -468,11 +472,11 @@ namespace ts.FindAllReferences { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } - // If we are in `export = a;`, `parent` is the export assignment. + // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (isExportAssignment(parent)) { return getExportAssignmentExport(parent); } - // If we are in `export = class A {};` at `A`, `parent.parent` is the export assignment. + // If we are in `export = class A {};` (or `export = class A {};`) at `A`, `parent.parent` is the export assignment. else if (isExportAssignment(parent.parent)) { return getExportAssignmentExport(parent.parent); } @@ -489,7 +493,8 @@ namespace ts.FindAllReferences { // Get the symbol for the `export =` node; its parent is the module it's the export of. const exportingModuleSymbol = ex.symbol.parent; Debug.assert(!!exportingModuleSymbol); - return { kind: ImportExport.Export, symbol, exportInfo: { exportingModuleSymbol, exportKind: ExportKind.ExportEquals } }; + const exportKind = ex.isExportEquals ? ExportKind.ExportEquals : ExportKind.Default; + return { kind: ImportExport.Export, symbol, exportInfo: { exportingModuleSymbol, exportKind } }; } function getSpecialPropertyExport(node: ts.BinaryExpression, useLhsSymbol: boolean): ExportedSymbol | undefined { @@ -525,7 +530,11 @@ namespace ts.FindAllReferences { importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker); } - if (symbolName(importedSymbol) === symbol.escapedName) { // If this is a rename import, do not continue searching. + // If the import has a different name than the export, do not continue searching. + // If `importedName` is undefined, do continue searching as the export is anonymous. + // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) + const importedName = symbolName(importedSymbol); + if (importedName === undefined || importedName === "default" || importedName === symbol.escapedName) { return { kind: ImportExport.Import, symbol: importedSymbol, ...isImport }; } } diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts index c8fdb0a6149..1b5eb7a282d 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts @@ -2,15 +2,24 @@ // @Filename: /a.ts ////const [|{| "isWriteAccess": true, "isDefinition": true |}a|] = 0; -////export default [|a|]; +////export [|{| "isWriteAccess": true, "isDefinition": true |}default|] [|a|]; // @Filename: /b.ts ////import [|{| "isWriteAccess": true, "isDefinition": true |}a|] from "./a"; ////[|a|]; -const [r0, r1, r2, r3] = test.ranges(); -verify.referenceGroups([r0, r1], [ - { definition: "const a: 0", ranges: [r0, r1] }, - { definition: "import a", ranges: [r2, r3] } +const [r0, r1, r2, r3, r4] = test.ranges(); +verify.referenceGroups([r0, r2], [ + { definition: "const a: 0", ranges: [r0, r2] }, + { definition: "import a", ranges: [r3, r4] } +]); +verify.referenceGroups(r1, [ + // TODO:GH#17990 + { definition: "import default", ranges: [r1] }, + { definition: "import a", ranges: [r3, r4] }, +]); +verify.referenceGroups([r3, r4], [ + { definition: "import a", ranges: [r3, r4] }, + // TODO:GH#17990 + { definition: "import default", ranges: [r1] }, ]); -verify.singleReferenceGroup("import a", [r2, r3]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts b/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts new file mode 100644 index 00000000000..3beb5b59424 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: /a.ts +////export [|{| "isWriteAccess": true, "isDefinition": true |}default|] function() {} + +// @Filename: /b.ts +////import [|{| "isWriteAccess": true, "isDefinition": true |}f|] from "./a"; + +const [r0, r1] = test.ranges(); +verify.referenceGroups(r0, [ + { definition: "function default(): void", ranges: [r0] }, + { definition: "import f", ranges: [r1] }, +]); +verify.referenceGroups(r1, [ + { definition: "import f", ranges: [r1] }, + { definition: "function default(): void", ranges: [r0] }, +]); + +// Verify that it doesn't try to rename "default" +goTo.rangeStart(r0); +verify.renameInfoFailed(); +verify.renameLocations(r1, [r1]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts new file mode 100644 index 00000000000..401db1a8033 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts @@ -0,0 +1,30 @@ +/// + +// @Filename: /export.ts +////const [|{| "isWriteAccess": true, "isDefinition": true |}foo|] = 1; +////export default [|foo|]; + +// @Filename: /re-export.ts +////export { [|{| "isWriteAccess": true, "isDefinition": true |}default|] } from "./export"; + +// @Filename: /re-export-dep.ts +////import [|{| "isWriteAccess": true, "isDefinition": true |}fooDefault|] from "./re-export"; + +verify.noErrors(); + +const [r0, r1, r2, r3] = test.ranges(); +verify.referenceGroups([r0, r1], [ + { definition: "const foo: 1", ranges: [r0, r1] }, + { definition: "import default", ranges: [r2], }, + { definition: "import fooDefault", ranges: [r3] }, +]); +verify.referenceGroups(r2, [ + { definition: "import default", ranges: [r2] }, + { definition: "import fooDefault", ranges: [r3] }, + { definition: "const foo: 1", ranges: [r0, r1] }, +]); +verify.referenceGroups(r3, [ + { definition: "import fooDefault", ranges: [r3] }, + { definition: "import default", ranges: [r2] }, + { definition: "const foo: 1", ranges: [r0, r1] }, +]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts new file mode 100644 index 00000000000..26a05f2e12e --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts @@ -0,0 +1,32 @@ +/// + +// @allowSyntheticDefaultImports: true + +// @Filename: /export.ts +////const [|{| "isWriteAccess": true, "isDefinition": true |}foo|] = 1; +////export = [|foo|]; + +// @Filename: /re-export.ts +////export { [|{| "isWriteAccess": true, "isDefinition": true |}default|] } from "./export"; + +// @Filename: /re-export-dep.ts +////import [|{| "isWriteAccess": true, "isDefinition": true |}fooDefault|] from "./re-export"; + +verify.noErrors(); + +const [r0, r1, r2, r3] = test.ranges(); +verify.referenceGroups([r0, r1], [ + { definition: "const foo: 1", ranges: [r0, r1] }, + { definition: "import default", ranges: [r2], }, + { definition: "import fooDefault", ranges: [r3] }, +]); +verify.referenceGroups(r2, [ + { definition: "import default", ranges: [r2] }, + { definition: "import fooDefault", ranges: [r3] }, + { definition: "const foo: 1", ranges: [r0, r1] }, +]); +verify.referenceGroups(r3, [ + { definition: "import fooDefault", ranges: [r3] }, + { definition: "import default", ranges: [r2] }, + { definition: "const foo: 1", ranges: [r0, r1] }, +]); diff --git a/tests/cases/fourslash/findAllRefsReExports.ts b/tests/cases/fourslash/findAllRefsReExports.ts index a4cced049b9..e9936867604 100644 --- a/tests/cases/fourslash/findAllRefsReExports.ts +++ b/tests/cases/fourslash/findAllRefsReExports.ts @@ -39,14 +39,19 @@ verify.referenceGroups(bar2, [{ ...eBar, definition: "(alias) bar(): void\nimpor verify.referenceGroups([defaultC], [c, d, eBoom, eBaz, eBang]); verify.referenceGroups(defaultD, [d, eBoom, a, b, eBar,c, eBaz, eBang]); verify.referenceGroups(defaultE, [c, d, eBoom, eBaz, eBang]); -verify.referenceGroups(baz0, [eBaz]); -verify.referenceGroups(baz1, [{ ...eBaz, definition: "(alias) baz(): void\nimport baz" }]); +verify.referenceGroups(baz0, [eBaz, c, d, eBoom, eBang]); +verify.referenceGroups(baz1, [ + { ...eBaz, definition: "(alias) baz(): void\nimport baz" }, + c, d, eBoom, eBang, +]); verify.referenceGroups(bang0, [eBang]); verify.referenceGroups(bang1, [{ ...eBang, definition: "(alias) bang(): void\nimport bang" }]); - -verify.referenceGroups(boom0, [eBoom]); -verify.referenceGroups(boom1, [{ ...eBoom, definition: "(alias) boom(): void\nimport boom" }]); +verify.referenceGroups(boom0, [eBoom, d, a, b, eBar, c, eBaz, eBang]); +verify.referenceGroups(boom1, [ + { ...eBoom, definition: "(alias) boom(): void\nimport boom" }, + d, a, b, eBar, c, eBaz, eBang, +]); test.rangesByText().forEach((ranges, text) => { if (text === "default") { From b533b24686d5f2c799e2c5edf6283243b6a8d2df Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:28:12 -0700 Subject: [PATCH 067/216] extractMethod: Don't try to extract a single token (#18090) * extractMethod: Don't try to extract a single token * Update tests --- src/services/refactors/extractMethod.ts | 4 ++-- tests/cases/fourslash/extract-method-not-for-token.ts | 6 ++++++ tests/cases/fourslash/extract-method13.ts | 8 ++++---- tests/cases/fourslash/extract-method5.ts | 5 +++-- tests/cases/fourslash/extract-method7.ts | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 tests/cases/fourslash/extract-method-not-for-token.ts diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 6fe664e6c81..b76ab9376dc 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -95,7 +95,7 @@ namespace ts.refactor.extractMethod { export const CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators: DiagnosticMessage = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); export const TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); export const FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); - export const InsufficientSelection = createMessage("Select more than a single identifier."); + export const InsufficientSelection = createMessage("Select more than a single token."); export const CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); export const CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); export const CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); @@ -239,7 +239,7 @@ namespace ts.refactor.extractMethod { } function checkRootNode(node: Node): Diagnostic[] | undefined { - if (isIdentifier(node)) { + if (isToken(node)) { return [createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; diff --git a/tests/cases/fourslash/extract-method-not-for-token.ts b/tests/cases/fourslash/extract-method-not-for-token.ts new file mode 100644 index 00000000000..756716441cd --- /dev/null +++ b/tests/cases/fourslash/extract-method-not-for-token.ts @@ -0,0 +1,6 @@ +/// + +////"/**/foo"; + +goTo.marker(""); +verify.not.refactorAvailable('Extract Method'); diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index 14a146a80c5..94ad86e4399 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -4,8 +4,8 @@ // Also checks that we correctly find non-conflicting names in static contexts. //// class C { -//// static j = /*c*/100/*d*/; -//// constructor(q: string = /*a*/"hello"/*b*/) { +//// static j = /*c*/1 + 1/*d*/; +//// constructor(q: string = /*a*/"a" + "b"/*b*/) { //// } //// } @@ -29,10 +29,10 @@ verify.currentFileContentIs(`class C { } private static newFunction(): string { - return "hello"; + return "a" + "b"; } private static newFunction_1() { - return 100; + return 1 + 1; } }`); \ No newline at end of file diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index 10294298b08..d1e70d10716 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -5,7 +5,7 @@ // annotation in the extracted function //// function f() { -//// var x: 1 | 2 | 3 = /*start*/2/*end*/; +//// var x: 1 | 2 | 3 = /*start*/1 + 1 === 2 ? 1 : 2/*end*/; //// } goTo.select('start', 'end'); @@ -14,11 +14,12 @@ edit.applyRefactor({ actionName: "scope_0", actionDescription: "Extract function into function 'f'", }); +// TODO: GH#18091 (fix formatting to use `2 ? 1 :` and not `2?1:`) verify.currentFileContentIs( `function f() { var x: 1 | 2 | 3 = newFunction(); function newFunction(): 1 | 2 | 3 { - return 2; + return 1 + 1 === 2?1: 2; } }`); \ No newline at end of file diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index 95c9cbe9897..d10c7c3136e 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -3,7 +3,7 @@ // You cannot extract a function initializer into the function's body. // The innermost scope (scope_0) is the sibling of the function, not the function itself. -//// function fn(x = /*a*/3/*b*/) { +//// function fn(x = /*a*/1 + 1/*b*/) { //// } goTo.select('a', 'b'); @@ -15,6 +15,6 @@ edit.applyRefactor({ verify.currentFileContentIs(`function fn(x = newFunction()) { } function newFunction() { - return 3; + return 1 + 1; } `); From 7541c705bfe9fd3247f5a3471b45c727d5484bca Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 07:45:11 -0700 Subject: [PATCH 068/216] Support navTo for special assignment kinds (#18154) * Support navTo for special assignment kinds * Return ScriptElementKind.unknown --- src/compiler/core.ts | 2 ++ src/services/services.ts | 6 +++++ src/services/utilities.ts | 22 +++++++++++++++++++ ...avigationItemsSpecialPropertyAssignment.ts | 20 +++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 20f757c3df8..f7ff8c27bf7 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2628,4 +2628,6 @@ namespace ts { export function and(f: (arg: T) => boolean, g: (arg: T) => boolean) { return (arg: T) => f(arg) && g(arg); } + + export function assertTypeIsNever(_: never): void {} } diff --git a/src/services/services.ts b/src/services/services.ts index c22229fd089..e0e3bea79ff 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -722,6 +722,12 @@ namespace ts { } break; + case SyntaxKind.BinaryExpression: + if (getSpecialPropertyAssignmentKind(node as BinaryExpression) !== SpecialPropertyAssignmentKind.None) { + addDeclaration(node as BinaryExpression); + } + // falls through + default: forEachChild(node, visit); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index c7f5b5909f0..c3a1d5d571d 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -343,6 +343,28 @@ namespace ts { return ScriptElementKind.alias; case SyntaxKind.JSDocTypedefTag: return ScriptElementKind.typeElement; + case SyntaxKind.BinaryExpression: + const kind = getSpecialPropertyAssignmentKind(node as BinaryExpression); + const { right } = node as BinaryExpression; + switch (kind) { + case SpecialPropertyAssignmentKind.None: + return ScriptElementKind.unknown; + case SpecialPropertyAssignmentKind.ExportsProperty: + case SpecialPropertyAssignmentKind.ModuleExports: + const rightKind = getNodeKind(right); + return rightKind === ScriptElementKind.unknown ? ScriptElementKind.constElement : rightKind; + case SpecialPropertyAssignmentKind.PrototypeProperty: + return ScriptElementKind.memberFunctionElement; // instance method + case SpecialPropertyAssignmentKind.ThisProperty: + return ScriptElementKind.memberVariableElement; // property + case SpecialPropertyAssignmentKind.Property: + // static method / property + return isFunctionExpression(right) ? ScriptElementKind.memberFunctionElement : ScriptElementKind.memberVariableElement; + default: { + assertTypeIsNever(kind); + return ScriptElementKind.unknown; + } + } default: return ScriptElementKind.unknown; } diff --git a/tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts b/tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts new file mode 100644 index 00000000000..4618d34b954 --- /dev/null +++ b/tests/cases/fourslash/navigationItemsSpecialPropertyAssignment.ts @@ -0,0 +1,20 @@ +/// + +// @allowJs: true +// @Filename: /a.js +////exports.{| "name": "x", "kind": "const" |}x = 0; +////exports.{| "name": "y", "kind": "function" |}y = function() {}; +////function Cls() { +//// this.{| "name": "prop", "kind": "property" |}prop = 0; +////} +////Cls.{| "name": "staticMethod", "kind": "method" |}staticMethod = function() {}; +////Cls.{| "name": "staticProperty", "kind": "property" |}staticProperty = 0; +////Cls.prototype.{| "name": "instance", "kind": "method" |}instance = function() {}; + +for (const marker of test.markers()) { + verify.navigationItemsListContains( + marker.data.name, + marker.data.kind, + marker.data.name, + "exact"); +} From 90d9f3d4ba2b45c28fa3361725002f31c75d8403 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 09:07:59 -0700 Subject: [PATCH 069/216] Rename isStartOfType parameter used by isStartOfParameter --- src/compiler/parser.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 1740bad2d34..d25bb3efd50 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2238,7 +2238,7 @@ namespace ts { isIdentifierOrPattern() || isModifierKind(token()) || token() === SyntaxKind.AtToken || - isStartOfType(/*disableLookahead*/ true); + isStartOfType(/*inStartOfParameter*/ true); } function parseParameter(): ParameterDeclaration { @@ -2699,7 +2699,7 @@ namespace ts { } } - function isStartOfType(disableLookahead?: boolean): boolean { + function isStartOfType(inStartOfParameter?: boolean): boolean { switch (token()) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -2729,11 +2729,11 @@ namespace ts { case SyntaxKind.DotDotDotToken: return true; case SyntaxKind.MinusToken: - return !disableLookahead && lookAhead(nextTokenIsNumericLiteral); + return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); case SyntaxKind.OpenParenToken: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. - return !disableLookahead && lookAhead(isStartOfParenthesizedOrFunctionType); + return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } From be0633825cd4c82c279dd8f6ee8d432e0b757521 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 09:13:46 -0700 Subject: [PATCH 070/216] Don't provide string literal completions for string enums (#18288) * Don't provide string literal completions for string enums * Rename test --- src/services/completions.ts | 2 +- ...tringLiteralCompletionsForStringEnumContextualType.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 300ade2da48..97998ec724b 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -284,7 +284,7 @@ namespace ts.Completions { addStringLiteralCompletionsFromType(t, result, typeChecker, uniques); } } - else if (type.flags & TypeFlags.StringLiteral) { + else if (type.flags & TypeFlags.StringLiteral && !(type.flags & TypeFlags.EnumLiteral)) { const name = (type).value; if (!uniques.has(name)) { uniques.set(name, true); diff --git a/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts b/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts new file mode 100644 index 00000000000..664bfbac369 --- /dev/null +++ b/tests/cases/fourslash/stringLiteralCompletionsForStringEnumContextualType.ts @@ -0,0 +1,9 @@ +/// + +////const enum E { +//// A = "A", +////} +////const e: E = "/**/"; + +goTo.marker(""); +verify.completionListIsEmpty(); From 193f4be355168145ede3a8186b9b7ff13339c3ca Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 09:14:59 -0700 Subject: [PATCH 071/216] Enable interface-over-type-literal lint rule (#17733) --- src/compiler/checker.ts | 2 +- src/harness/unittests/convertTypeAcquisitionFromJson.ts | 2 +- src/server/protocol.ts | 8 ++++---- src/server/typingsInstaller/typingsInstaller.ts | 4 ++-- src/services/navigateTo.ts | 8 +++++++- src/services/types.ts | 9 ++++----- tslint.json | 1 + 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1c8bc7846d0..b7f0894d284 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21516,7 +21516,7 @@ namespace ts { return true; } - type InheritanceInfoMap = { prop: Symbol; containingType: Type }; + interface InheritanceInfoMap { prop: Symbol; containingType: Type; } const seen = createUnderscoreEscapedMap(); forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.escapedName, { prop: p, containingType: type }); }); let ok = true; diff --git a/src/harness/unittests/convertTypeAcquisitionFromJson.ts b/src/harness/unittests/convertTypeAcquisitionFromJson.ts index aae4ee38382..67646de3680 100644 --- a/src/harness/unittests/convertTypeAcquisitionFromJson.ts +++ b/src/harness/unittests/convertTypeAcquisitionFromJson.ts @@ -2,7 +2,7 @@ /// namespace ts { - type ExpectedResult = { typeAcquisition: TypeAcquisition, errors: Diagnostic[] }; + interface ExpectedResult { typeAcquisition: TypeAcquisition; errors: Diagnostic[]; } describe("convertTypeAcquisitionFromJson", () => { function assertTypeAcquisition(json: any, configFileName: string, expectedResult: ExpectedResult) { assertTypeAcquisitionWithJson(json, configFileName, expectedResult); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 37bf79837c9..3fdbd8fd7f7 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -466,7 +466,7 @@ namespace ts.server.protocol { * Represents a single refactoring action - for example, the "Extract Method..." refactor might * offer several actions, each corresponding to a surround class or closure to extract into. */ - export type RefactorActionInfo = { + export interface RefactorActionInfo { /** * The programmatic name of the refactoring action */ @@ -478,7 +478,7 @@ namespace ts.server.protocol { * so this description should make sense by itself if the parent is inlineable=true */ description: string; - }; + } export interface GetEditsForRefactorRequest extends Request { command: CommandTypes.GetEditsForRefactor; @@ -501,7 +501,7 @@ namespace ts.server.protocol { body?: RefactorEditInfo; } - export type RefactorEditInfo = { + export interface RefactorEditInfo { edits: FileCodeEdits[]; /** @@ -510,7 +510,7 @@ namespace ts.server.protocol { */ renameLocation?: Location; renameFilename?: string; - }; + } /** * Request for the available codefixes at a specific position. diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index c6423bc3c7b..3eae0755747 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -73,12 +73,12 @@ namespace ts.server.typingsInstaller { } export type RequestCompletedAction = (success: boolean) => void; - type PendingRequest = { + interface PendingRequest { requestId: number; args: string[]; cwd: string; onRequestCompleted: RequestCompletedAction; - }; + } export abstract class TypingsInstaller { private readonly packageNameToTypingLocation: Map = createMap(); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 6d84769082d..ec7b011456f 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -1,6 +1,12 @@ /* @internal */ namespace ts.NavigateTo { - type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; + interface RawNavigateToItem { + name: string; + fileName: string; + matchKind: PatternMatchKind; + isCaseSensitive: boolean; + declaration: Declaration; + } export function getNavigateToItems(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[] { const patternMatcher = createPatternMatcher(searchValue); diff --git a/src/services/types.ts b/src/services/types.ts index 609eaf11de5..8a23bfec1c5 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -394,7 +394,7 @@ namespace ts { * Represents a single refactoring action - for example, the "Extract Method..." refactor might * offer several actions, each corresponding to a surround class or closure to extract into. */ - export type RefactorActionInfo = { + export interface RefactorActionInfo { /** * The programmatic name of the refactoring action */ @@ -406,18 +406,17 @@ namespace ts { * so this description should make sense by itself if the parent is inlineable=true */ description: string; - }; + } /** * A set of edits to make in response to a refactor action, plus an optional * location where renaming should be invoked from */ - export type RefactorEditInfo = { + export interface RefactorEditInfo { edits: FileTextChanges[]; renameFilename?: string; renameLocation?: number; - }; - + } export interface TextInsertion { newText: string; diff --git a/tslint.json b/tslint.json index de60ad7683a..30e71eb5e0d 100644 --- a/tslint.json +++ b/tslint.json @@ -11,6 +11,7 @@ "indent": [true, "spaces" ], + "interface-over-type-literal": true, "jsdoc-format": true, "linebreak-style": [true, "CRLF"], "next-line": [true, From 59aa29b85470809af10616aa92a2df460ac3b4c6 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Thu, 7 Sep 2017 21:45:07 +0530 Subject: [PATCH 072/216] Added only the source file (#18175) --- src/lib/es2017.object.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/es2017.object.d.ts b/src/lib/es2017.object.d.ts index 1f090a8fef2..1d8a52da758 100644 --- a/src/lib/es2017.object.d.ts +++ b/src/lib/es2017.object.d.ts @@ -22,4 +22,10 @@ interface ObjectConstructor { * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ entries(o: any): [string, any][]; + + /** + * Returns an object containing all own property descriptors of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + getOwnPropertyDescriptors(o: T): {[P in keyof T]: TypedPropertyDescriptor} & { [x: string]: PropertyDescriptor }; } From 7b12b7955873fb0a937e3538b8fee2460fd63c64 Mon Sep 17 00:00:00 2001 From: Adrian Leonhard Date: Thu, 7 Sep 2017 18:17:47 +0200 Subject: [PATCH 073/216] ts.server.ProjectService.closeConfiguredProject returns true on success. (#18180) Fixes #17892 The if condition around the return value of that method in closeExternalProject indicates that this was the expected behavior. --- src/server/editorServices.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index d849226a35b..3f5b76ae39d 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1686,11 +1686,13 @@ namespace ts.server { } } - private closeConfiguredProject(configFile: NormalizedPath): void { + private closeConfiguredProject(configFile: NormalizedPath): boolean { const configuredProject = this.findConfiguredProjectByProjectName(configFile); if (configuredProject && configuredProject.deleteOpenRef() === 0) { this.removeProject(configuredProject); + return true; } + return false; } closeExternalProject(uncheckedFileName: string, suppressRefresh = false): void { From a8dfdf2fa111c709cb4d1262ad559e70efaec6c5 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 7 Sep 2017 18:22:26 +0200 Subject: [PATCH 074/216] Add and fix some AST Node parent types (#18200) --- src/compiler/types.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 83fc699c844..6c48fc90f0e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -636,6 +636,7 @@ namespace ts { export interface Decorator extends Node { kind: SyntaxKind.Decorator; + parent?: NamedDeclaration; expression: LeftHandSideExpression; } @@ -765,6 +766,7 @@ namespace ts { export interface SpreadAssignment extends ObjectLiteralElement { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; + parent?: ObjectLiteralExpression; expression: Expression; } @@ -781,7 +783,7 @@ namespace ts { export interface VariableLikeDeclaration extends NamedDeclaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; - name?: DeclarationName; // May be missing for ParameterDeclaration, see comment there + name: DeclarationName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; @@ -945,6 +947,7 @@ namespace ts { export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; + parent?: SignatureDeclaration; parameterName: Identifier | ThisTypeNode; type: TypeNode; } @@ -1001,7 +1004,6 @@ namespace ts { export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; - parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; @@ -1453,6 +1455,7 @@ namespace ts { export interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; + parent?: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; } From c82881f36ef412cacfe62e3394284e34cd9c4388 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 7 Sep 2017 09:36:31 -0700 Subject: [PATCH 075/216] Fix build break --- src/compiler/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6c48fc90f0e..75e1cb05bc9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -766,7 +766,6 @@ namespace ts { export interface SpreadAssignment extends ObjectLiteralElement { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; - parent?: ObjectLiteralExpression; expression: Expression; } From 69933bd4d134250247175b00acc8e1e371331a7e Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 7 Sep 2017 18:46:58 +0200 Subject: [PATCH 076/216] expose isExternalModuleNameRelative and moduleHasNonRelativeName (#17971) * expose isExternalModuleNameRelative and moduleHasNonRelativeName Fixes: #17890 * only expose isExternalModuleNameRelative --- src/compiler/core.ts | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f7ff8c27bf7..c76cd24f1b0 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -9,6 +9,15 @@ namespace ts { export const version = `${versionMajorMinor}.0`; } +namespace ts { + export function isExternalModuleNameRelative(moduleName: string): boolean { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + // Update: We also consider a path like `C:\foo.ts` "relative" because we do not search for it in `node_modules` or treat it as an ambient module. + return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); + } +} + /* @internal */ namespace ts { @@ -40,7 +49,6 @@ namespace ts { return new MapCtr() as UnderscoreEscapedMap; } - /* @internal */ export function createSymbolTable(symbols?: ReadonlyArray): SymbolTable { const result = createMap() as SymbolTable; if (symbols) { @@ -1604,18 +1612,10 @@ namespace ts { return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; } - /* @internal */ export function pathIsRelative(path: string): boolean { return /^\.\.?($|[\\/])/.test(path); } - export function isExternalModuleNameRelative(moduleName: string): boolean { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - // Update: We also consider a path like `C:\foo.ts` "relative" because we do not search for it in `node_modules` or treat it as an ambient module. - return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); - } - /** @deprecated Use `!isExternalModuleNameRelative(moduleName)` instead. */ export function moduleHasNonRelativeName(moduleName: string): boolean { return !isExternalModuleNameRelative(moduleName); @@ -1639,7 +1639,6 @@ namespace ts { return moduleResolution; } - /* @internal */ export function hasZeroOrOneAsteriskCharacter(str: string): boolean { let seenAsterisk = false; for (let i = 0; i < str.length; i++) { @@ -1864,17 +1863,14 @@ namespace ts { return true; } - /* @internal */ export function startsWith(str: string, prefix: string): boolean { return str.lastIndexOf(prefix, 0) === 0; } - /* @internal */ export function removePrefix(str: string, prefix: string): string { return startsWith(str, prefix) ? str.substr(prefix.length) : str; } - /* @internal */ export function endsWith(str: string, suffix: string): boolean { const expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -1888,7 +1884,6 @@ namespace ts { return path.length > extension.length && endsWith(path, extension); } - /* @internal */ export function fileExtensionIsOneOf(path: string, extensions: ReadonlyArray): boolean { for (const extension of extensions) { if (fileExtensionIs(path, extension)) { @@ -1905,7 +1900,6 @@ namespace ts { const reservedCharacterPattern = /[^\w\s\/]/g; const wildcardCharCodes = [CharacterCodes.asterisk, CharacterCodes.question]; - /* @internal */ export const commonPackageFolders: ReadonlyArray = ["node_modules", "bower_components", "jspm_packages"]; const implicitExcludePathRegexPattern = `(?!(${commonPackageFolders.join("|")})(/|$))`; @@ -2523,7 +2517,6 @@ namespace ts { * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - /* @internal */ export function matchPatternOrExact(patternStrings: ReadonlyArray, candidate: string): string | Pattern | undefined { const patterns: Pattern[] = []; for (const patternString of patternStrings) { @@ -2540,7 +2533,6 @@ namespace ts { return findBestPatternMatch(patterns, _ => _, candidate); } - /* @internal */ export function patternText({prefix, suffix}: Pattern): string { return `${prefix}*${suffix}`; } @@ -2549,14 +2541,12 @@ namespace ts { * Given that candidate matches pattern, returns the text matching the '*'. * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" */ - /* @internal */ export function matchedText(pattern: Pattern, candidate: string): string { Debug.assert(isPatternMatch(pattern, candidate)); return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); } /** Return the object corresponding to the best pattern to match `candidate`. */ - /* @internal */ export function findBestPatternMatch(values: ReadonlyArray, getPattern: (value: T) => Pattern, candidate: string): T | undefined { let matchedValue: T | undefined = undefined; // use length of prefix as betterness criteria @@ -2579,7 +2569,6 @@ namespace ts { endsWith(candidate, suffix); } - /* @internal */ export function tryParsePattern(pattern: string): Pattern | undefined { // This should be verified outside of here and a proper error thrown. Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); From 39d0590869de4d94a16f9aa06334698d76fef5f9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 09:54:50 -0700 Subject: [PATCH 077/216] Adds comment --- src/harness/unittests/languageService.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/harness/unittests/languageService.ts b/src/harness/unittests/languageService.ts index 9c838845c20..fd0a95c167f 100644 --- a/src/harness/unittests/languageService.ts +++ b/src/harness/unittests/languageService.ts @@ -17,6 +17,8 @@ class Carousel extends Vue { "vue-class-component.d.ts": `import Vue from "./vue"; export function Component(x: Config): any;` }; + // Regression test for GH #18245 - bug in single line comment writer caused a debug assertion when attempting + // to write an alias to a module's default export was referrenced across files and had no default export it("should be able to create a language service which can respond to deinition requests without throwing", () => { const languageService = ts.createLanguageService({ getCompilationSettings() { From c1f2afd64587042dc8094bb12ecdbde9d1731523 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 10:28:58 -0700 Subject: [PATCH 078/216] Add typedef declaration space, unify typedef name gathering (#18172) * Add typedef declaration space, unify typedef name gathering, strengthen errorUnusedLocal * Bonus round: make jsdoc presence way mroe typesafe * Be exhaustive in nameForNamelessJSDocTypedef * Remove nonrequired casts * Replace more casts with guards * Cannot be internal * Debug.fail returns never, assert never no longer needs unreachable throw to satisfy checker * Rename type * Add replacement message as in 18287 --- src/compiler/binder.ts | 17 +-- src/compiler/checker.ts | 9 +- src/compiler/core.ts | 6 +- src/compiler/parser.ts | 16 +- src/compiler/types.ts | 143 +++++++++++------- src/compiler/utilities.ts | 82 +++++++++- src/services/classifier.ts | 3 +- src/services/completions.ts | 2 +- src/services/navigationBar.ts | 14 +- src/services/services.ts | 2 +- .../reference/jsdocTypedefNoCrash.js | 13 ++ .../reference/jsdocTypedefNoCrash.symbols | 8 + .../reference/jsdocTypedefNoCrash.types | 9 ++ .../reference/jsdocTypedefNoCrash2.errors.txt | 12 ++ .../reference/jsdocTypedefNoCrash2.js | 14 ++ tests/cases/compiler/jsdocTypedefNoCrash.ts | 9 ++ tests/cases/compiler/jsdocTypedefNoCrash2.ts | 11 ++ 17 files changed, 279 insertions(+), 91 deletions(-) create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash.js create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash.symbols create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash.types create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash2.errors.txt create mode 100644 tests/baselines/reference/jsdocTypedefNoCrash2.js create mode 100644 tests/cases/compiler/jsdocTypedefNoCrash.ts create mode 100644 tests/cases/compiler/jsdocTypedefNoCrash2.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a7e94da09d9..d6d253e1d77 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -282,17 +282,8 @@ namespace ts { const index = indexOf(functionType.parameters, node); return "arg" + index as __String; case SyntaxKind.JSDocTypedefTag: - const parentNode = node.parent && node.parent.parent; - let nameFromParentNode: __String; - if (parentNode && parentNode.kind === SyntaxKind.VariableStatement) { - if ((parentNode).declarationList.declarations.length > 0) { - const nameIdentifier = (parentNode).declarationList.declarations[0].name; - if (isIdentifier(nameIdentifier)) { - nameFromParentNode = nameIdentifier.escapedText; - } - } - } - return nameFromParentNode; + const name = getNameOfJSDocTypedef(node as JSDocTypedefTag); + return typeof name !== "undefined" ? name.escapedText : undefined; } } @@ -598,7 +589,7 @@ namespace ts { // Binding of JsDocComment should be done before the current block scope container changes. // because the scope of JsDocComment should not be affected by whether the current node is a // container or not. - if (node.jsDoc) { + if (hasJSDocNodes(node)) { if (isInJavaScriptFile(node)) { for (const j of node.jsDoc) { bind(j); @@ -1931,7 +1922,7 @@ namespace ts { } function bindJSDocTypedefTagIfAny(node: Node) { - if (!node.jsDoc) { + if (!hasJSDocNodes(node)) { return; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b7f0894d284..91653c140c8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19158,6 +19158,8 @@ namespace ts { switch (d.kind) { case SyntaxKind.InterfaceDeclaration: case SyntaxKind.TypeAliasDeclaration: + // A jsdoc typedef is, by definition, a type alias + case SyntaxKind.JSDocTypedefTag: return DeclarationSpaces.ExportType; case SyntaxKind.ModuleDeclaration: return isAmbientModule(d) || getModuleInstanceState(d) !== ModuleInstanceState.NonInstantiated @@ -19827,7 +19829,7 @@ namespace ts { } } else if (compilerOptions.noUnusedLocals) { - forEach(local.declarations, d => errorUnusedLocal(getNameOfDeclaration(d) || d, unescapeLeadingUnderscores(local.escapedName))); + forEach(local.declarations, d => errorUnusedLocal(d, unescapeLeadingUnderscores(local.escapedName))); } } }); @@ -19842,7 +19844,8 @@ namespace ts { return false; } - function errorUnusedLocal(node: Node, name: string) { + function errorUnusedLocal(declaration: Declaration, name: string) { + const node = getNameOfDeclaration(declaration) || declaration; if (isIdentifierThatStartsWithUnderScore(node)) { const declaration = getRootDeclaration(node.parent); if (declaration.kind === SyntaxKind.VariableDeclaration && isForInOrOfStatement(declaration.parent.parent)) { @@ -19909,7 +19912,7 @@ namespace ts { if (!local.isReferenced && !local.exportSymbol) { for (const declaration of local.declarations) { if (!isAmbientModule(declaration)) { - errorUnusedLocal(getNameOfDeclaration(declaration), unescapeLeadingUnderscores(local.escapedName)); + errorUnusedLocal(declaration, unescapeLeadingUnderscores(local.escapedName)); } } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c76cd24f1b0..2c0416c0711 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2441,7 +2441,7 @@ namespace ts { } } - export function fail(message?: string, stackCrawlMark?: Function): void { + export function fail(message?: string, stackCrawlMark?: Function): never { debugger; const e = new Error(message ? `Debug Failure. ${message}` : "Debug Failure."); if ((Error).captureStackTrace) { @@ -2450,6 +2450,10 @@ namespace ts { throw e; } + export function assertNever(member: never, message?: string, stackCrawlMark?: Function): never { + return fail(message || `Illegal value: ${member}`, stackCrawlMark || assertNever); + } + export function getFunctionName(func: Function) { if (typeof func !== "function") { return ""; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 71c7d3aac49..e30d5dbe1e4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -729,7 +729,7 @@ namespace ts { } - function addJSDocComment(node: T): T { + function addJSDocComment(node: T): T { const comments = getJSDocCommentRanges(node, sourceFile.text); if (comments) { for (const comment of comments) { @@ -768,7 +768,7 @@ namespace ts { const saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDoc) { + if (hasJSDocNodes(n)) { for (const jsDoc of n.jsDoc) { jsDoc.parent = n; parent = jsDoc; @@ -2158,7 +2158,7 @@ namespace ts { const result = createNode(SyntaxKind.JSDocFunctionType); nextToken(); fillSignature(SyntaxKind.ColonToken, SignatureFlags.Type | SignatureFlags.JSDoc, result); - return finishNode(result); + return addJSDocComment(finishNode(result)); } const node = createNode(SyntaxKind.TypeReference); node.typeName = parseIdentifierName(); @@ -2365,7 +2365,7 @@ namespace ts { parseSemicolon(); } - function parseSignatureMember(kind: SyntaxKind): CallSignatureDeclaration | ConstructSignatureDeclaration { + function parseSignatureMember(kind: SyntaxKind.CallSignature | SyntaxKind.ConstructSignature): CallSignatureDeclaration | ConstructSignatureDeclaration { const node = createNode(kind); if (kind === SyntaxKind.ConstructSignature) { parseExpected(SyntaxKind.NewKeyword); @@ -2445,7 +2445,7 @@ namespace ts { node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parsePropertyOrMethodSignature(fullStart: number, modifiers: NodeArray): PropertySignature | MethodSignature { @@ -2605,7 +2605,7 @@ namespace ts { parseExpected(SyntaxKind.NewKeyword); } fillSignature(SyntaxKind.EqualsGreaterThanToken, SignatureFlags.Type, node); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseKeywordAndNoDot(): TypeNode | undefined { @@ -6182,7 +6182,7 @@ namespace ts { return jsDoc ? { jsDoc, diagnostics } : undefined; } - export function parseJSDocComment(parent: Node, start: number, length: number): JSDoc { + export function parseJSDocComment(parent: HasJSDoc, start: number, length: number): JSDoc { const saveToken = currentToken; const saveParseDiagnosticsLength = parseDiagnostics.length; const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; @@ -6997,7 +6997,7 @@ namespace ts { } forEachChild(node, visitNode, visitArray); - if (node.jsDoc) { + if (hasJSDocNodes(node)) { for (const jsDocComment of node.jsDoc) { forEachChild(jsDocComment, visitNode, visitArray); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 75e1cb05bc9..55baf9763c2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -516,8 +516,6 @@ namespace ts { parent?: Node; // Parent node (initialized by binding) /* @internal */ original?: Node; // The original node if this is an updated node. /* @internal */ startsOnNewLine?: boolean; // Whether a synthesized node should start on a new line (used by transforms). - /* @internal */ jsDoc?: JSDoc[]; // JSDoc that directly precedes this node - /* @internal */ jsDocCache?: ReadonlyArray; // Cache for getJSDocTags /* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding) /* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding) /* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding) @@ -528,6 +526,44 @@ namespace ts { /* @internal */ contextualMapper?: TypeMapper; // Mapper for contextual type } + export interface JSDocContainer { + /* @internal */ jsDoc?: JSDoc[]; // JSDoc that directly precedes this node + /* @internal */ jsDocCache?: ReadonlyArray; // Cache for getJSDocTags + } + + export type HasJSDoc = + | ParameterDeclaration + | CallSignatureDeclaration + | ConstructSignatureDeclaration + | MethodSignature + | PropertySignature + | ArrowFunction + | ParenthesizedExpression + | SpreadAssignment + | ShorthandPropertyAssignment + | PropertyAssignment + | FunctionExpression + | LabeledStatement + | ExpressionStatement + | VariableStatement + | FunctionDeclaration + | ConstructorDeclaration + | MethodDeclaration + | PropertyDeclaration + | AccessorDeclaration + | ClassLikeDeclaration + | InterfaceDeclaration + | TypeAliasDeclaration + | EnumMember + | EnumDeclaration + | ModuleDeclaration + | ImportEqualsDeclaration + | IndexSignatureDeclaration + | FunctionTypeNode + | ConstructorTypeNode + | JSDocFunctionType + | EndOfFileToken; + /* @internal */ export type MutableNodeArray = NodeArray & T[]; @@ -546,7 +582,7 @@ namespace ts { export type EqualsToken = Token; export type AsteriskToken = Token; export type EqualsGreaterThanToken = Token; - export type EndOfFileToken = Token; + export type EndOfFileToken = Token & JSDocContainer; export type AtToken = Token; export type ReadonlyToken = Token; export type AwaitKeywordToken = Token; @@ -651,32 +687,34 @@ namespace ts { expression?: Expression; } - export interface SignatureDeclaration extends NamedDeclaration { - kind: SyntaxKind.CallSignature - | SyntaxKind.ConstructSignature - | SyntaxKind.MethodSignature - | SyntaxKind.IndexSignature - | SyntaxKind.FunctionType - | SyntaxKind.ConstructorType - | SyntaxKind.JSDocFunctionType - | SyntaxKind.FunctionDeclaration - | SyntaxKind.MethodDeclaration - | SyntaxKind.Constructor - | SyntaxKind.GetAccessor - | SyntaxKind.SetAccessor - | SyntaxKind.FunctionExpression - | SyntaxKind.ArrowFunction; + export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; type: TypeNode | undefined; } - export interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { + export type SignatureDeclaration = + | CallSignatureDeclaration + | ConstructSignatureDeclaration + | MethodSignature + | IndexSignatureDeclaration + | FunctionTypeNode + | ConstructorTypeNode + | JSDocFunctionType + | FunctionDeclaration + | MethodDeclaration + | ConstructorDeclaration + | AccessorDeclaration + | FunctionExpression + | ArrowFunction; + + export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - export interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { + export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } @@ -696,7 +734,7 @@ namespace ts { declarations: NodeArray; } - export interface ParameterDeclaration extends NamedDeclaration { + export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; // Present on rest parameter @@ -715,7 +753,7 @@ namespace ts { initializer?: Expression; // Optional initializer } - export interface PropertySignature extends TypeElement { + export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; // Declared property name questionToken?: QuestionToken; // Present on optional property @@ -723,7 +761,7 @@ namespace ts { initializer?: Expression; // Optional initializer } - export interface PropertyDeclaration extends ClassElement { + export interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; questionToken?: QuestionToken; // Present for use with reporting a grammar error name: PropertyName; @@ -744,7 +782,7 @@ namespace ts { | AccessorDeclaration ; - export interface PropertyAssignment extends ObjectLiteralElement { + export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; @@ -752,7 +790,7 @@ namespace ts { initializer: Expression; } - export interface ShorthandPropertyAssignment extends ObjectLiteralElement { + export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; @@ -763,7 +801,7 @@ namespace ts { objectAssignmentInitializer?: Expression; } - export interface SpreadAssignment extends ObjectLiteralElement { + export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; @@ -816,7 +854,7 @@ namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - export interface FunctionLikeDeclarationBase extends SignatureDeclaration { + export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; @@ -847,7 +885,7 @@ namespace ts { body?: FunctionBody; } - export interface MethodSignature extends SignatureDeclaration, TypeElement { + export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; name: PropertyName; } @@ -861,13 +899,13 @@ namespace ts { // Because of this, it may be necessary to determine what sort of MethodDeclaration you have // at later stages of the compiler pipeline. In that case, you can either check the parent kind // of the method, or use helpers like isObjectLiteralMethodDeclaration - export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; name: PropertyName; body?: FunctionBody; } - export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement { + export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; @@ -881,7 +919,7 @@ namespace ts { // See the comment on MethodDeclaration for the intuition behind GetAccessorDeclaration being a // ClassElement and an ObjectLiteralElement. - export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; @@ -890,7 +928,7 @@ namespace ts { // See the comment on MethodDeclaration for the intuition behind SetAccessorDeclaration being a // ClassElement and an ObjectLiteralElement. - export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; @@ -899,7 +937,7 @@ namespace ts { export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - export interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { + export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } @@ -928,11 +966,11 @@ namespace ts { export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - export interface FunctionTypeNode extends TypeNode, SignatureDeclaration { + export interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType; } - export interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { + export interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.ConstructorType; } @@ -1355,13 +1393,13 @@ namespace ts { export type FunctionBody = Block; export type ConciseBody = FunctionBody | Expression; - export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase { + export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; // Required, whereas the member inherited from FunctionDeclaration is optional } - export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase { + export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; @@ -1440,7 +1478,7 @@ namespace ts { literal: TemplateMiddle | TemplateTail; } - export interface ParenthesizedExpression extends PrimaryExpression { + export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } @@ -1696,12 +1734,12 @@ namespace ts { /*@internal*/ multiLine?: boolean; } - export interface VariableStatement extends Statement { + export interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - export interface ExpressionStatement extends Statement { + export interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } @@ -1807,7 +1845,7 @@ namespace ts { export type CaseOrDefaultClause = CaseClause | DefaultClause; - export interface LabeledStatement extends Statement { + export interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; @@ -1834,7 +1872,7 @@ namespace ts { export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - export interface ClassLikeDeclaration extends NamedDeclaration { + export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; @@ -1842,15 +1880,17 @@ namespace ts { members: NodeArray; } - export interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { + export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; name?: Identifier; } - export interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } + export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; + export interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; @@ -1862,7 +1902,7 @@ namespace ts { questionToken?: QuestionToken; } - export interface InterfaceDeclaration extends DeclarationStatement { + export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; @@ -1877,14 +1917,14 @@ namespace ts { types: NodeArray; } - export interface TypeAliasDeclaration extends DeclarationStatement { + export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - export interface EnumMember extends NamedDeclaration { + export interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent?: EnumDeclaration; // This does include ComputedPropertyName, but the parser will give an error @@ -1893,7 +1933,7 @@ namespace ts { initializer?: Expression; } - export interface EnumDeclaration extends DeclarationStatement { + export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; @@ -1903,7 +1943,7 @@ namespace ts { export type ModuleBody = NamespaceBody | JSDocNamespaceBody; - export interface ModuleDeclaration extends DeclarationStatement { + export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent?: ModuleBody | SourceFile; name: ModuleName; @@ -1937,7 +1977,7 @@ namespace ts { * - import x = require("mod"); * - import x = M.x; */ - export interface ImportEqualsDeclaration extends DeclarationStatement { + export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent?: SourceFile | ModuleBlock; name: Identifier; @@ -2090,7 +2130,7 @@ namespace ts { type: TypeNode; } - export interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } @@ -2103,6 +2143,7 @@ namespace ts { export interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; + parent?: HasJSDoc; tags: NodeArray | undefined; comment: string | undefined; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 725070c02bf..11c30a2d8ab 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -277,7 +277,7 @@ namespace ts { return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + if (includeJsDoc && hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } @@ -1510,10 +1510,10 @@ namespace ts { } export function getJSDocTags(node: Node): ReadonlyArray | undefined { - let tags = node.jsDocCache; + let tags = (node as JSDocContainer).jsDocCache; // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. if (tags === undefined) { - node.jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); + (node as JSDocContainer).jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); } return tags; } @@ -1567,11 +1567,13 @@ namespace ts { result = addRange(result, getJSDocParameterTags(node as ParameterDeclaration)); } - if (isVariableLike(node) && node.initializer) { + if (isVariableLike(node) && node.initializer && hasJSDocNodes(node.initializer)) { result = addRange(result, node.initializer.jsDoc); } - result = addRange(result, node.jsDoc); + if (hasJSDocNodes(node)) { + result = addRange(result, node.jsDoc); + } } } @@ -3958,7 +3960,66 @@ namespace ts { return id; } - export function getNameOfDeclaration(declaration: Declaration): DeclarationName | undefined { + /** + * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should + * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol + * will be merged with) + */ + function nameForNamelessJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined { + const hostNode = declaration.parent.parent; + if (!hostNode) { + return undefined; + } + // Covers classes, functions - any named declaration host node + if (isDeclaration(hostNode)) { + return getDeclarationIdentifier(hostNode); + } + // Covers remaining cases + switch (hostNode.kind) { + case SyntaxKind.VariableStatement: + if ((hostNode as VariableStatement).declarationList && + (hostNode as VariableStatement).declarationList.declarations[0]) { + return getDeclarationIdentifier((hostNode as VariableStatement).declarationList.declarations[0]); + } + return undefined; + case SyntaxKind.ExpressionStatement: + const expr = (hostNode as ExpressionStatement).expression; + switch (expr.kind) { + case SyntaxKind.PropertyAccessExpression: + return (expr as PropertyAccessExpression).name; + case SyntaxKind.ElementAccessExpression: + const arg = (expr as ElementAccessExpression).argumentExpression; + if (isIdentifier(arg)) { + return arg; + } + } + return undefined; + case SyntaxKind.EndOfFileToken: + return undefined; + case SyntaxKind.ParenthesizedExpression: { + return getDeclarationIdentifier(hostNode.expression); + } + case SyntaxKind.LabeledStatement: { + if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { + return getDeclarationIdentifier(hostNode.statement); + } + return undefined; + } + default: + Debug.assertNever(hostNode, "Found typedef tag attached to node which it should not be!"); + } + } + + function getDeclarationIdentifier(node: Declaration | Expression) { + const name = getNameOfDeclaration(node); + return isIdentifier(name) ? name : undefined; + } + + export function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined { + return declaration.name || nameForNamelessJSDocTypedef(declaration as JSDocTypedefTag); + } + + export function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined { if (!declaration) { return undefined; } @@ -3977,6 +4038,9 @@ namespace ts { return undefined; } } + else if (declaration.kind === SyntaxKind.JSDocTypedefTag) { + return getNameOfJSDocTypedef(declaration as JSDocTypedefTag); + } else { return (declaration as NamedDeclaration).name; } @@ -5365,4 +5429,10 @@ namespace ts { export function isJSDocTag(node: Node): boolean { return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; } + + /** True if has jsdoc nodes attached to it. */ + /* @internal */ + export function hasJSDocNodes(node: Node): node is HasJSDoc { + return !!(node as JSDocContainer).jsDoc && (node as JSDocContainer).jsDoc.length > 0; + } } diff --git a/src/services/classifier.ts b/src/services/classifier.ts index 4552d8bf985..18eec066ea2 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -699,7 +699,8 @@ namespace ts { // specially. const docCommentAndDiagnostics = parseIsolatedJSDocComment(sourceFile.text, start, width); if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDoc) { - docCommentAndDiagnostics.jsDoc.parent = token; + // TODO: This should be predicated on `token["kind"]` being compatible with `HasJSDoc["kind"]` + docCommentAndDiagnostics.jsDoc.parent = token as HasJSDoc; classifyJSDocComment(docCommentAndDiagnostics.jsDoc); return; } diff --git a/src/services/completions.ts b/src/services/completions.ts index 97998ec724b..15a20798508 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1739,7 +1739,7 @@ namespace ts.Completions { /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */ function getJsDocTagAtPosition(node: Node, position: number): JSDocTag | undefined { - const { jsDoc } = getJsDocHavingNode(node); + const { jsDoc } = getJsDocHavingNode(node) as JSDocContainer; if (!jsDoc) return undefined; for (const { pos, end, tags } of jsDoc) { diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 35357b9331a..f7ed515a18f 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -263,13 +263,15 @@ namespace ts.NavigationBar { break; default: - forEach(node.jsDoc, jsDoc => { - forEach(jsDoc.tags, tag => { - if (tag.kind === SyntaxKind.JSDocTypedefTag) { - addLeafNode(tag); - } + if (hasJSDocNodes(node)) { + forEach(node.jsDoc, jsDoc => { + forEach(jsDoc.tags, tag => { + if (tag.kind === SyntaxKind.JSDocTypedefTag) { + addLeafNode(tag); + } + }); }); - }); + } forEachChild(node, addChildrenRecursively); } diff --git a/src/services/services.ts b/src/services/services.ts index e0e3bea79ff..1feafdd55f5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2111,7 +2111,7 @@ namespace ts { } forEachChild(node, walk); - if (node.jsDoc) { + if (hasJSDocNodes(node)) { for (const jsDoc of node.jsDoc) { forEachChild(jsDoc, walk); } diff --git a/tests/baselines/reference/jsdocTypedefNoCrash.js b/tests/baselines/reference/jsdocTypedefNoCrash.js new file mode 100644 index 00000000000..803f6b1bb85 --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash.js @@ -0,0 +1,13 @@ +//// [export.js] +/** + * @typedef {{ + * }} + */ +export const foo = 5; + +//// [export.js] +/** + * @typedef {{ + * }} + */ +export const foo = 5; diff --git a/tests/baselines/reference/jsdocTypedefNoCrash.symbols b/tests/baselines/reference/jsdocTypedefNoCrash.symbols new file mode 100644 index 00000000000..8724c9da8d1 --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/export.js === +/** + * @typedef {{ + * }} + */ +export const foo = 5; +>foo : Symbol(foo, Decl(export.js, 4, 12)) + diff --git a/tests/baselines/reference/jsdocTypedefNoCrash.types b/tests/baselines/reference/jsdocTypedefNoCrash.types new file mode 100644 index 00000000000..e05c4421a79 --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/export.js === +/** + * @typedef {{ + * }} + */ +export const foo = 5; +>foo : 5 +>5 : 5 + diff --git a/tests/baselines/reference/jsdocTypedefNoCrash2.errors.txt b/tests/baselines/reference/jsdocTypedefNoCrash2.errors.txt new file mode 100644 index 00000000000..6c4a15e5947 --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash2.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/export.js(1,13): error TS8008: 'type aliases' can only be used in a .ts file. + + +==== tests/cases/compiler/export.js (1 errors) ==== + export type foo = 5; + ~~~ +!!! error TS8008: 'type aliases' can only be used in a .ts file. + /** + * @typedef {{ + * }} + */ + export const foo = 5; \ No newline at end of file diff --git a/tests/baselines/reference/jsdocTypedefNoCrash2.js b/tests/baselines/reference/jsdocTypedefNoCrash2.js new file mode 100644 index 00000000000..397ca973d1e --- /dev/null +++ b/tests/baselines/reference/jsdocTypedefNoCrash2.js @@ -0,0 +1,14 @@ +//// [export.js] +export type foo = 5; +/** + * @typedef {{ + * }} + */ +export const foo = 5; + +//// [export.js] +/** + * @typedef {{ + * }} + */ +export const foo = 5; diff --git a/tests/cases/compiler/jsdocTypedefNoCrash.ts b/tests/cases/compiler/jsdocTypedefNoCrash.ts new file mode 100644 index 00000000000..cb8f5df09ef --- /dev/null +++ b/tests/cases/compiler/jsdocTypedefNoCrash.ts @@ -0,0 +1,9 @@ +// @target: es6 +// @allowJs: true +// @outDir: ./dist +// @filename: export.js +/** + * @typedef {{ + * }} + */ +export const foo = 5; \ No newline at end of file diff --git a/tests/cases/compiler/jsdocTypedefNoCrash2.ts b/tests/cases/compiler/jsdocTypedefNoCrash2.ts new file mode 100644 index 00000000000..d41fb62e446 --- /dev/null +++ b/tests/cases/compiler/jsdocTypedefNoCrash2.ts @@ -0,0 +1,11 @@ +// @target: es6 +// @allowJs: true +// @outDir: ./dist +// @filename: export.js + +export type foo = 5; +/** + * @typedef {{ + * }} + */ +export const foo = 5; \ No newline at end of file From de313ff1bd11daf484aa421a5d9fde954b8e6fc7 Mon Sep 17 00:00:00 2001 From: Alex Chugaev Date: Thu, 7 Sep 2017 20:58:05 +0300 Subject: [PATCH 079/216] Object.getOwnPropertyDescriptor() returns 'undefined' if property descriptor not found. (#18148) --- src/lib/es2015.core.d.ts | 2 +- src/lib/es2015.reflect.d.ts | 2 +- src/lib/es5.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 0deef59a47d..42d3d1543a0 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -327,7 +327,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor | undefined; /** * Adds a property to an object, or modifies attributes of an existing property. diff --git a/src/lib/es2015.reflect.d.ts b/src/lib/es2015.reflect.d.ts index 83755e4c791..aab3da993dc 100644 --- a/src/lib/es2015.reflect.d.ts +++ b/src/lib/es2015.reflect.d.ts @@ -4,7 +4,7 @@ declare namespace Reflect { function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: object, propertyKey: PropertyKey): boolean; function get(target: object, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined; function getPrototypeOf(target: object): object; function has(target: object, propertyKey: PropertyKey): boolean; function isExtensible(target: object): boolean; diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 4dae997ffb4..6033a8fd989 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -127,7 +127,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor | undefined; /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly From 097b094082827c2055a401686a4b5aec30afbfe6 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 7 Sep 2017 10:58:50 -0700 Subject: [PATCH 080/216] Don't get typings for projects with disabled language services --- src/server/project.ts | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/server/project.ts b/src/server/project.ts index 623c43e8d3a..c8e9e1b4833 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -547,33 +547,32 @@ namespace ts.server { this.cachedUnresolvedImportsPerFile.remove(file); } - // 1. no changes in structure, no changes in unresolved imports - do nothing - // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files - // (can reuse cached imports for files that were not changed) - // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files - // (can reuse cached imports for files that were not changed) - // 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch - let unresolvedImports: SortedReadonlyArray; - if (hasChanges || changedFiles.length) { - const result: string[] = []; - for (const sourceFile of this.program.getSourceFiles()) { - this.extractUnresolvedImportsFromSourceFile(sourceFile, result); - } - this.lastCachedUnresolvedImportsList = toDeduplicatedSortedArray(result); - } - unresolvedImports = this.lastCachedUnresolvedImportsList; - - const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); - if (this.setTypings(cachedTypings)) { - hasChanges = this.updateGraphWorker() || hasChanges; - } - // update builder only if language service is enabled // otherwise tell it to drop its internal state if (this.languageServiceEnabled) { + // 1. no changes in structure, no changes in unresolved imports - do nothing + // 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files + // (can reuse cached imports for files that were not changed) + // 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files + // (can reuse cached imports for files that were not changed) + // 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch + if (hasChanges || changedFiles.length) { + const result: string[] = []; + for (const sourceFile of this.program.getSourceFiles()) { + this.extractUnresolvedImportsFromSourceFile(sourceFile, result); + } + this.lastCachedUnresolvedImportsList = toDeduplicatedSortedArray(result); + } + + const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, this.lastCachedUnresolvedImportsList, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } + this.builder.onProjectUpdateGraph(); } else { + this.lastCachedUnresolvedImportsList = undefined; this.builder.clear(); } From ac58751b6239aeb2c4a980644c4db48ee4bf3c27 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 11:30:38 -0700 Subject: [PATCH 081/216] Object literals computed property names allow literal-typed expressions --- src/compiler/checker.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b7f0894d284..d33fc9ced56 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13526,6 +13526,7 @@ namespace ts { for (let i = 0; i < node.properties.length; i++) { const memberDecl = node.properties[i]; let member = memberDecl.symbol; + let literalName: __String | undefined; if (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment || isObjectLiteralMethod(memberDecl)) { @@ -13536,6 +13537,12 @@ namespace ts { let type: Type; if (memberDecl.kind === SyntaxKind.PropertyAssignment) { + if (memberDecl.name.kind === SyntaxKind.ComputedPropertyName) { + const t = checkComputedPropertyName(memberDecl.name); + if (t.flags & TypeFlags.Literal) { + literalName = escapeLeadingUnderscores("" + (t as LiteralType).value); + } + } type = checkPropertyAssignment(memberDecl, checkMode); } else if (memberDecl.kind === SyntaxKind.MethodDeclaration) { @@ -13552,7 +13559,7 @@ namespace ts { } typeFlags |= type.flags; - const prop = createSymbol(SymbolFlags.Property | member.flags, member.escapedName); + const prop = createSymbol(SymbolFlags.Property | member.flags, literalName || member.escapedName); if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. @@ -13562,7 +13569,7 @@ namespace ts { if (isOptional) { prop.flags |= SymbolFlags.Optional; } - if (hasDynamicName(memberDecl)) { + if (!literalName && hasDynamicName(memberDecl)) { patternWithComputedProperties = true; } } @@ -13620,7 +13627,7 @@ namespace ts { checkNodeDeferred(memberDecl); } - if (hasDynamicName(memberDecl)) { + if (!literalName && hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } From 3c5b2a5e9d43c3f8b0f92e61208775ad9ffb5c05 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 11:41:13 -0700 Subject: [PATCH 082/216] Test Literal-typed computed property names in obj literals --- .../computedPropertyNames46_ES5.types | 4 +- .../computedPropertyNames46_ES6.types | 4 +- .../computedPropertyNames47_ES5.types | 4 +- .../computedPropertyNames47_ES6.types | 4 +- .../computedPropertyNames48_ES5.types | 4 +- .../computedPropertyNames48_ES6.types | 4 +- .../computedPropertyNames4_ES5.types | 4 +- .../computedPropertyNames4_ES6.types | 4 +- .../computedPropertyNames7_ES5.types | 4 +- .../computedPropertyNames7_ES6.types | 4 +- .../objectLiteralEnumPropertyNames.js | 108 +++++++++++ .../objectLiteralEnumPropertyNames.symbols | 144 ++++++++++++++ .../objectLiteralEnumPropertyNames.types | 177 ++++++++++++++++++ .../objectLiteralEnumPropertyNames.ts | 52 +++++ 14 files changed, 501 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/objectLiteralEnumPropertyNames.js create mode 100644 tests/baselines/reference/objectLiteralEnumPropertyNames.symbols create mode 100644 tests/baselines/reference/objectLiteralEnumPropertyNames.types create mode 100644 tests/cases/compiler/objectLiteralEnumPropertyNames.ts diff --git a/tests/baselines/reference/computedPropertyNames46_ES5.types b/tests/baselines/reference/computedPropertyNames46_ES5.types index 7ea3ffda244..e90d1a6c498 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES5.types +++ b/tests/baselines/reference/computedPropertyNames46_ES5.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames46_ES5.ts === var o = { ->o : { [x: number]: number; } ->{ ["" || 0]: 0} : { [x: number]: number; } +>o : { ["" || 0]: number; } +>{ ["" || 0]: 0} : { ["" || 0]: number; } ["" || 0]: 0 >"" || 0 : 0 diff --git a/tests/baselines/reference/computedPropertyNames46_ES6.types b/tests/baselines/reference/computedPropertyNames46_ES6.types index 3914f6facef..34aac7489c9 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES6.types +++ b/tests/baselines/reference/computedPropertyNames46_ES6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames46_ES6.ts === var o = { ->o : { [x: number]: number; } ->{ ["" || 0]: 0} : { [x: number]: number; } +>o : { ["" || 0]: number; } +>{ ["" || 0]: 0} : { ["" || 0]: number; } ["" || 0]: 0 >"" || 0 : 0 diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.types b/tests/baselines/reference/computedPropertyNames47_ES5.types index 137f3d63d38..9c01db09846 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.types +++ b/tests/baselines/reference/computedPropertyNames47_ES5.types @@ -8,8 +8,8 @@ enum E2 { x } >x : E2 var o = { ->o : { [x: number]: number; } ->{ [E1.x || E2.x]: 0} : { [x: number]: number; } +>o : { [E1.x || E2.x]: number; } +>{ [E1.x || E2.x]: 0} : { [E1.x || E2.x]: number; } [E1.x || E2.x]: 0 >E1.x || E2.x : E2 diff --git a/tests/baselines/reference/computedPropertyNames47_ES6.types b/tests/baselines/reference/computedPropertyNames47_ES6.types index 04c18df83a7..c2e65523e46 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES6.types +++ b/tests/baselines/reference/computedPropertyNames47_ES6.types @@ -8,8 +8,8 @@ enum E2 { x } >x : E2 var o = { ->o : { [x: number]: number; } ->{ [E1.x || E2.x]: 0} : { [x: number]: number; } +>o : { [E1.x || E2.x]: number; } +>{ [E1.x || E2.x]: 0} : { [E1.x || E2.x]: number; } [E1.x || E2.x]: 0 >E1.x || E2.x : E2 diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.types b/tests/baselines/reference/computedPropertyNames48_ES5.types index 545dc641434..25818fff967 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.types +++ b/tests/baselines/reference/computedPropertyNames48_ES5.types @@ -28,7 +28,7 @@ extractIndexer({ extractIndexer({ >extractIndexer({ [E.x]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ [E.x]: ""} : { [x: number]: string; } +>{ [E.x]: ""} : { [E.x]: string; } [E.x]: "" >E.x : E @@ -41,7 +41,7 @@ extractIndexer({ extractIndexer({ >extractIndexer({ ["" || 0]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ ["" || 0]: ""} : { [x: number]: string; } +>{ ["" || 0]: ""} : { ["" || 0]: string; } ["" || 0]: "" >"" || 0 : 0 diff --git a/tests/baselines/reference/computedPropertyNames48_ES6.types b/tests/baselines/reference/computedPropertyNames48_ES6.types index 0f352b57d24..65f93239f30 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES6.types +++ b/tests/baselines/reference/computedPropertyNames48_ES6.types @@ -28,7 +28,7 @@ extractIndexer({ extractIndexer({ >extractIndexer({ [E.x]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ [E.x]: ""} : { [x: number]: string; } +>{ [E.x]: ""} : { [E.x]: string; } [E.x]: "" >E.x : E @@ -41,7 +41,7 @@ extractIndexer({ extractIndexer({ >extractIndexer({ ["" || 0]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ ["" || 0]: ""} : { [x: number]: string; } +>{ ["" || 0]: ""} : { ["" || 0]: string; } ["" || 0]: "" >"" || 0 : 0 diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.types b/tests/baselines/reference/computedPropertyNames4_ES5.types index fc883aa2833..f0e105be4a7 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.types +++ b/tests/baselines/reference/computedPropertyNames4_ES5.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; [`hello bye`]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; [`hello bye`]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNames4_ES6.types b/tests/baselines/reference/computedPropertyNames4_ES6.types index 5704841b97f..178eca88a72 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES6.types +++ b/tests/baselines/reference/computedPropertyNames4_ES6.types @@ -9,8 +9,8 @@ var a: any; >a : any var v = { ->v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } ->{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; } +>v : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; [`hello bye`]: number; } +>{ [s]: 0, [n]: n, [s + s]: 1, [s + n]: 2, [+s]: s, [""]: 0, [0]: 0, [a]: 1, [true]: 0, [`hello bye`]: 0, [`hello ${a} bye`]: 0} : { [x: string]: string | number; [x: number]: string | number; [""]: number; [0]: number; [`hello bye`]: number; } [s]: 0, >s : string diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.types b/tests/baselines/reference/computedPropertyNames7_ES5.types index fbc070e3951..01c0117bd02 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.types +++ b/tests/baselines/reference/computedPropertyNames7_ES5.types @@ -6,8 +6,8 @@ enum E { >member : E } var v = { ->v : { [x: number]: number; } ->{ [E.member]: 0} : { [x: number]: number; } +>v : { [E.member]: number; } +>{ [E.member]: 0} : { [E.member]: number; } [E.member]: 0 >E.member : E diff --git a/tests/baselines/reference/computedPropertyNames7_ES6.types b/tests/baselines/reference/computedPropertyNames7_ES6.types index f8f1dd7f791..80433c94ab3 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES6.types +++ b/tests/baselines/reference/computedPropertyNames7_ES6.types @@ -6,8 +6,8 @@ enum E { >member : E } var v = { ->v : { [x: number]: number; } ->{ [E.member]: 0} : { [x: number]: number; } +>v : { [E.member]: number; } +>{ [E.member]: 0} : { [E.member]: number; } [E.member]: 0 >E.member : E diff --git a/tests/baselines/reference/objectLiteralEnumPropertyNames.js b/tests/baselines/reference/objectLiteralEnumPropertyNames.js new file mode 100644 index 00000000000..4a6f7128159 --- /dev/null +++ b/tests/baselines/reference/objectLiteralEnumPropertyNames.js @@ -0,0 +1,108 @@ +//// [objectLiteralEnumPropertyNames.ts] +// Fixes #16887 +enum Strs { + A = 'a', + B = 'b' +} +type TestStrs = { [key in Strs]: string } +const x: TestStrs = { + [Strs.A]: 'xo', + [Strs.B]: 'xe' +} +const ux = { + [Strs.A]: 'xo', + [Strs.B]: 'xe' +} +const y: TestStrs = { + ['a']: 'yo', + ['b']: 'ye' +} +const a = 'a'; +const b = 'b'; +const z: TestStrs = { + [a]: 'zo', + [b]: 'ze' +} +const uz = { + [a]: 'zo', + [b]: 'ze' +} + +enum Nums { + A, + B +} +type TestNums = { 0: number, 1: number } +const n: TestNums = { + [Nums.A]: 1, + [Nums.B]: 2 +} +const un = { + [Nums.A]: 3, + [Nums.B]: 4 +} +const an = 0; +const bn = 1; +const m: TestNums = { + [an]: 5, + [bn]: 6 +} +const um = { + [an]: 7, + [bn]: 8 +} + + +//// [objectLiteralEnumPropertyNames.js] +// Fixes #16887 +var Strs; +(function (Strs) { + Strs["A"] = "a"; + Strs["B"] = "b"; +})(Strs || (Strs = {})); +var x = (_a = {}, + _a[Strs.A] = 'xo', + _a[Strs.B] = 'xe', + _a); +var ux = (_b = {}, + _b[Strs.A] = 'xo', + _b[Strs.B] = 'xe', + _b); +var y = (_c = {}, + _c['a'] = 'yo', + _c['b'] = 'ye', + _c); +var a = 'a'; +var b = 'b'; +var z = (_d = {}, + _d[a] = 'zo', + _d[b] = 'ze', + _d); +var uz = (_e = {}, + _e[a] = 'zo', + _e[b] = 'ze', + _e); +var Nums; +(function (Nums) { + Nums[Nums["A"] = 0] = "A"; + Nums[Nums["B"] = 1] = "B"; +})(Nums || (Nums = {})); +var n = (_f = {}, + _f[Nums.A] = 1, + _f[Nums.B] = 2, + _f); +var un = (_g = {}, + _g[Nums.A] = 3, + _g[Nums.B] = 4, + _g); +var an = 0; +var bn = 1; +var m = (_h = {}, + _h[an] = 5, + _h[bn] = 6, + _h); +var um = (_j = {}, + _j[an] = 7, + _j[bn] = 8, + _j); +var _a, _b, _c, _d, _e, _f, _g, _h, _j; diff --git a/tests/baselines/reference/objectLiteralEnumPropertyNames.symbols b/tests/baselines/reference/objectLiteralEnumPropertyNames.symbols new file mode 100644 index 00000000000..594af3c3f99 --- /dev/null +++ b/tests/baselines/reference/objectLiteralEnumPropertyNames.symbols @@ -0,0 +1,144 @@ +=== tests/cases/compiler/objectLiteralEnumPropertyNames.ts === +// Fixes #16887 +enum Strs { +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) + + A = 'a', +>A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) + + B = 'b' +>B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +} +type TestStrs = { [key in Strs]: string } +>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) +>key : Symbol(key, Decl(objectLiteralEnumPropertyNames.ts, 5, 19)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) + +const x: TestStrs = { +>x : Symbol(x, Decl(objectLiteralEnumPropertyNames.ts, 6, 5)) +>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) + + [Strs.A]: 'xo', +>Strs.A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) +>A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) + + [Strs.B]: 'xe' +>Strs.B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) +>B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +} +const ux = { +>ux : Symbol(ux, Decl(objectLiteralEnumPropertyNames.ts, 10, 5)) + + [Strs.A]: 'xo', +>Strs.A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) +>A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) + + [Strs.B]: 'xe' +>Strs.B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) +>B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) +} +const y: TestStrs = { +>y : Symbol(y, Decl(objectLiteralEnumPropertyNames.ts, 14, 5)) +>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) + + ['a']: 'yo', +>'a' : Symbol(['a'], Decl(objectLiteralEnumPropertyNames.ts, 14, 21)) + + ['b']: 'ye' +>'b' : Symbol(['b'], Decl(objectLiteralEnumPropertyNames.ts, 15, 16)) +} +const a = 'a'; +>a : Symbol(a, Decl(objectLiteralEnumPropertyNames.ts, 18, 5)) + +const b = 'b'; +>b : Symbol(b, Decl(objectLiteralEnumPropertyNames.ts, 19, 5)) + +const z: TestStrs = { +>z : Symbol(z, Decl(objectLiteralEnumPropertyNames.ts, 20, 5)) +>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) + + [a]: 'zo', +>a : Symbol(a, Decl(objectLiteralEnumPropertyNames.ts, 18, 5)) + + [b]: 'ze' +>b : Symbol(b, Decl(objectLiteralEnumPropertyNames.ts, 19, 5)) +} +const uz = { +>uz : Symbol(uz, Decl(objectLiteralEnumPropertyNames.ts, 24, 5)) + + [a]: 'zo', +>a : Symbol(a, Decl(objectLiteralEnumPropertyNames.ts, 18, 5)) + + [b]: 'ze' +>b : Symbol(b, Decl(objectLiteralEnumPropertyNames.ts, 19, 5)) +} + +enum Nums { +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) + + A, +>A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) + + B +>B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +} +type TestNums = { 0: number, 1: number } +>TestNums : Symbol(TestNums, Decl(objectLiteralEnumPropertyNames.ts, 32, 1)) + +const n: TestNums = { +>n : Symbol(n, Decl(objectLiteralEnumPropertyNames.ts, 34, 5)) +>TestNums : Symbol(TestNums, Decl(objectLiteralEnumPropertyNames.ts, 32, 1)) + + [Nums.A]: 1, +>Nums.A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) +>A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) + + [Nums.B]: 2 +>Nums.B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) +>B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +} +const un = { +>un : Symbol(un, Decl(objectLiteralEnumPropertyNames.ts, 38, 5)) + + [Nums.A]: 3, +>Nums.A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) +>A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) + + [Nums.B]: 4 +>Nums.B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) +>B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) +} +const an = 0; +>an : Symbol(an, Decl(objectLiteralEnumPropertyNames.ts, 42, 5)) + +const bn = 1; +>bn : Symbol(bn, Decl(objectLiteralEnumPropertyNames.ts, 43, 5)) + +const m: TestNums = { +>m : Symbol(m, Decl(objectLiteralEnumPropertyNames.ts, 44, 5)) +>TestNums : Symbol(TestNums, Decl(objectLiteralEnumPropertyNames.ts, 32, 1)) + + [an]: 5, +>an : Symbol(an, Decl(objectLiteralEnumPropertyNames.ts, 42, 5)) + + [bn]: 6 +>bn : Symbol(bn, Decl(objectLiteralEnumPropertyNames.ts, 43, 5)) +} +const um = { +>um : Symbol(um, Decl(objectLiteralEnumPropertyNames.ts, 48, 5)) + + [an]: 7, +>an : Symbol(an, Decl(objectLiteralEnumPropertyNames.ts, 42, 5)) + + [bn]: 8 +>bn : Symbol(bn, Decl(objectLiteralEnumPropertyNames.ts, 43, 5)) +} + diff --git a/tests/baselines/reference/objectLiteralEnumPropertyNames.types b/tests/baselines/reference/objectLiteralEnumPropertyNames.types new file mode 100644 index 00000000000..460d96bc56d --- /dev/null +++ b/tests/baselines/reference/objectLiteralEnumPropertyNames.types @@ -0,0 +1,177 @@ +=== tests/cases/compiler/objectLiteralEnumPropertyNames.ts === +// Fixes #16887 +enum Strs { +>Strs : Strs + + A = 'a', +>A : Strs.A +>'a' : "a" + + B = 'b' +>B : Strs.B +>'b' : "b" +} +type TestStrs = { [key in Strs]: string } +>TestStrs : TestStrs +>key : key +>Strs : Strs + +const x: TestStrs = { +>x : TestStrs +>TestStrs : TestStrs +>{ [Strs.A]: 'xo', [Strs.B]: 'xe'} : { [Strs.A]: string; [Strs.B]: string; } + + [Strs.A]: 'xo', +>Strs.A : Strs.A +>Strs : typeof Strs +>A : Strs.A +>'xo' : "xo" + + [Strs.B]: 'xe' +>Strs.B : Strs.B +>Strs : typeof Strs +>B : Strs.B +>'xe' : "xe" +} +const ux = { +>ux : { [Strs.A]: string; [Strs.B]: string; } +>{ [Strs.A]: 'xo', [Strs.B]: 'xe'} : { [Strs.A]: string; [Strs.B]: string; } + + [Strs.A]: 'xo', +>Strs.A : Strs.A +>Strs : typeof Strs +>A : Strs.A +>'xo' : "xo" + + [Strs.B]: 'xe' +>Strs.B : Strs.B +>Strs : typeof Strs +>B : Strs.B +>'xe' : "xe" +} +const y: TestStrs = { +>y : TestStrs +>TestStrs : TestStrs +>{ ['a']: 'yo', ['b']: 'ye'} : { ['a']: string; ['b']: string; } + + ['a']: 'yo', +>'a' : "a" +>'yo' : "yo" + + ['b']: 'ye' +>'b' : "b" +>'ye' : "ye" +} +const a = 'a'; +>a : "a" +>'a' : "a" + +const b = 'b'; +>b : "b" +>'b' : "b" + +const z: TestStrs = { +>z : TestStrs +>TestStrs : TestStrs +>{ [a]: 'zo', [b]: 'ze'} : { [a]: string; [b]: string; } + + [a]: 'zo', +>a : "a" +>'zo' : "zo" + + [b]: 'ze' +>b : "b" +>'ze' : "ze" +} +const uz = { +>uz : { [a]: string; [b]: string; } +>{ [a]: 'zo', [b]: 'ze'} : { [a]: string; [b]: string; } + + [a]: 'zo', +>a : "a" +>'zo' : "zo" + + [b]: 'ze' +>b : "b" +>'ze' : "ze" +} + +enum Nums { +>Nums : Nums + + A, +>A : Nums.A + + B +>B : Nums.B +} +type TestNums = { 0: number, 1: number } +>TestNums : TestNums + +const n: TestNums = { +>n : TestNums +>TestNums : TestNums +>{ [Nums.A]: 1, [Nums.B]: 2} : { [Nums.A]: number; [Nums.B]: number; } + + [Nums.A]: 1, +>Nums.A : Nums.A +>Nums : typeof Nums +>A : Nums.A +>1 : 1 + + [Nums.B]: 2 +>Nums.B : Nums.B +>Nums : typeof Nums +>B : Nums.B +>2 : 2 +} +const un = { +>un : { [Nums.A]: number; [Nums.B]: number; } +>{ [Nums.A]: 3, [Nums.B]: 4} : { [Nums.A]: number; [Nums.B]: number; } + + [Nums.A]: 3, +>Nums.A : Nums.A +>Nums : typeof Nums +>A : Nums.A +>3 : 3 + + [Nums.B]: 4 +>Nums.B : Nums.B +>Nums : typeof Nums +>B : Nums.B +>4 : 4 +} +const an = 0; +>an : 0 +>0 : 0 + +const bn = 1; +>bn : 1 +>1 : 1 + +const m: TestNums = { +>m : TestNums +>TestNums : TestNums +>{ [an]: 5, [bn]: 6} : { [an]: number; [bn]: number; } + + [an]: 5, +>an : 0 +>5 : 5 + + [bn]: 6 +>bn : 1 +>6 : 6 +} +const um = { +>um : { [an]: number; [bn]: number; } +>{ [an]: 7, [bn]: 8} : { [an]: number; [bn]: number; } + + [an]: 7, +>an : 0 +>7 : 7 + + [bn]: 8 +>bn : 1 +>8 : 8 +} + diff --git a/tests/cases/compiler/objectLiteralEnumPropertyNames.ts b/tests/cases/compiler/objectLiteralEnumPropertyNames.ts new file mode 100644 index 00000000000..0f698d9c51d --- /dev/null +++ b/tests/cases/compiler/objectLiteralEnumPropertyNames.ts @@ -0,0 +1,52 @@ +// Fixes #16887 +enum Strs { + A = 'a', + B = 'b' +} +type TestStrs = { [key in Strs]: string } +const x: TestStrs = { + [Strs.A]: 'xo', + [Strs.B]: 'xe' +} +const ux = { + [Strs.A]: 'xo', + [Strs.B]: 'xe' +} +const y: TestStrs = { + ['a']: 'yo', + ['b']: 'ye' +} +const a = 'a'; +const b = 'b'; +const z: TestStrs = { + [a]: 'zo', + [b]: 'ze' +} +const uz = { + [a]: 'zo', + [b]: 'ze' +} + +enum Nums { + A, + B +} +type TestNums = { 0: number, 1: number } +const n: TestNums = { + [Nums.A]: 1, + [Nums.B]: 2 +} +const un = { + [Nums.A]: 3, + [Nums.B]: 4 +} +const an = 0; +const bn = 1; +const m: TestNums = { + [an]: 5, + [bn]: 6 +} +const um = { + [an]: 7, + [bn]: 8 +} From 727facb55c9dc2f5e924d1303d82fb3e63264dd3 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 7 Sep 2017 21:15:28 +0200 Subject: [PATCH 083/216] fix initialization of shouldCreateNewSourceFiles (#17686) --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 1feafdd55f5..197f76b607f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1143,7 +1143,7 @@ namespace ts { oldSettings.noResolve !== newSettings.noResolve || oldSettings.jsx !== newSettings.jsx || oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.disableSizeLimit !== newSettings.disableSizeLimit || oldSettings.baseUrl !== newSettings.baseUrl || !equalOwnProperties(oldSettings.paths, newSettings.paths)); From de940af23bdf88893cad7eb3e163335d03ae44d9 Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmed Date: Thu, 7 Sep 2017 12:20:56 -0700 Subject: [PATCH 084/216] Update README.md (#17714) --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 23829a74d39..4cd1efe2fb0 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ For the latest stable version: -``` +```bash npm install -g typescript ``` For our nightly builds: -``` +```bash npm install -g typescript@next ``` @@ -50,26 +50,26 @@ In order to build the TypeScript compiler, ensure that you have [Git](https://gi Clone a copy of the repo: -``` +```bash git clone https://github.com/Microsoft/TypeScript.git ``` Change to the TypeScript directory: -``` +```bash cd TypeScript ``` Install Gulp tools and dev dependencies: -``` +```bash npm install -g gulp npm install ``` Use one of the following to build and test: -``` +```bash gulp local # Build the compiler into built/local gulp clean # Delete the built compiler gulp LKG # Replace the last known good with the built one. @@ -88,7 +88,7 @@ gulp help # List the above commands. ## Usage -```shell +```bash node built/local/tsc.js hello.ts ``` From b29e0c9e3ab247199eed6b69674a2c992c3a05a6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 7 Sep 2017 12:21:33 -0700 Subject: [PATCH 085/216] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4cd1efe2fb0..fd9926d2dfa 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ npm install Use one of the following to build and test: -```bash +``` gulp local # Build the compiler into built/local gulp clean # Delete the built compiler gulp LKG # Replace the last known good with the built one. From 6695255d8610a475260cded3535b00fddc2f32eb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 12:26:23 -0700 Subject: [PATCH 086/216] Allow trailing newline to have fake position (#18298) * Actually support baselining pretty in the harness * Test case from 18216 * Use host newline in formatDiagnosticsWithColorAndContext * Merge statements --- src/compiler/program.ts | 16 ++++++++-------- src/compiler/scanner.ts | 2 +- src/harness/compilerRunner.ts | 2 +- src/harness/harness.ts | 13 +++++++------ .../prettyContextNotDebugAssertion.errors.txt | 12 ++++++++++++ .../reference/prettyContextNotDebugAssertion.js | 7 +++++++ .../compiler/prettyContextNotDebugAssertion.ts | 3 +++ 7 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt create mode 100644 tests/baselines/reference/prettyContextNotDebugAssertion.js create mode 100644 tests/cases/compiler/prettyContextNotDebugAssertion.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ec220ad248e..7932c6874d9 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -268,7 +268,7 @@ namespace ts { return s; } - export function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string { + export function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string { let output = ""; for (const diagnostic of diagnostics) { if (diagnostic.file) { @@ -284,12 +284,12 @@ namespace ts { gutterWidth = Math.max(ellipsis.length, gutterWidth); } - output += sys.newLine; + output += host.getNewLine(); for (let i = firstLine; i <= lastLine; i++) { // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, // so we'll skip ahead to the second-to-last line. if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine; + output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); i = lastLine - 1; } @@ -301,7 +301,7 @@ namespace ts { // Output the gutter and the actual contents of the line. output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += lineContent + sys.newLine; + output += lineContent + host.getNewLine(); // Output the gutter and the error span for the line using tildes. output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; @@ -323,17 +323,17 @@ namespace ts { } output += resetEscapeSequence; - output += sys.newLine; + output += host.getNewLine(); } - output += sys.newLine; + output += host.getNewLine(); output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; } const categoryColor = getCategoryFormat(diagnostic.category); const category = DiagnosticCategory[diagnostic.category].toLowerCase(); - output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; - output += sys.newLine; + output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) }`; + output += host.getNewLine(); } return output; } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index a130d8427da..c9c14198279 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -337,7 +337,7 @@ namespace ts { Debug.assert(res < lineStarts[line + 1]); } else if (debugText !== undefined) { - Debug.assert(res < debugText.length); + Debug.assert(res <= debugText.length); // Allow single character overflow for trailing newline } return res; } diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 170a23e34f2..a600c7dd857 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -141,7 +141,7 @@ class CompilerBaselineRunner extends RunnerBase { // check errors it("Correct errors for " + fileName, () => { - Harness.Compiler.doErrorBaseline(justName, tsConfigFiles.concat(toBeCompiled, otherFiles), result.errors); + Harness.Compiler.doErrorBaseline(justName, tsConfigFiles.concat(toBeCompiled, otherFiles), result.errors, !!options.pretty); }); it (`Correct module resolution tracing for ${fileName}`, () => { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 9443844cf9a..2fc1aac2d83 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1284,11 +1284,12 @@ namespace Harness { return normalized; } - export function minimalDiagnosticsToString(diagnostics: ReadonlyArray) { - return ts.formatDiagnostics(diagnostics, { getCanonicalFileName, getCurrentDirectory: () => "", getNewLine: () => Harness.IO.newLine() }); + export function minimalDiagnosticsToString(diagnostics: ReadonlyArray, pretty?: boolean) { + const host = { getCanonicalFileName, getCurrentDirectory: () => "", getNewLine: () => Harness.IO.newLine() }; + return (pretty ? ts.formatDiagnosticsWithColorAndContext : ts.formatDiagnostics)(diagnostics, host); } - export function getErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray) { + export function getErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray, pretty?: boolean) { diagnostics = diagnostics.slice().sort(ts.compareDiagnostics); let outputLines = ""; // Count up all errors that were found in files other than lib.d.ts so we don't miss any @@ -1408,18 +1409,18 @@ namespace Harness { // Verify we didn't miss any errors in total assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); - return minimalDiagnosticsToString(diagnostics) + + return minimalDiagnosticsToString(diagnostics, pretty) + Harness.IO.newLine() + Harness.IO.newLine() + outputLines; } - export function doErrorBaseline(baselinePath: string, inputFiles: TestFile[], errors: ts.Diagnostic[]) { + export function doErrorBaseline(baselinePath: string, inputFiles: TestFile[], errors: ts.Diagnostic[], pretty?: boolean) { Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?$/, ".errors.txt"), (): string => { if (!errors || (errors.length === 0)) { /* tslint:disable:no-null-keyword */ return null; /* tslint:enable:no-null-keyword */ } - return getErrorBaseline(inputFiles, errors); + return getErrorBaseline(inputFiles, errors, pretty); }); } diff --git a/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt b/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt new file mode 100644 index 00000000000..7b7e3fea3e3 --- /dev/null +++ b/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt @@ -0,0 +1,12 @@ + +2 +   + +tests/cases/compiler/index.ts(2,1): error TS1005: '}' expected. + + +==== tests/cases/compiler/index.ts (1 errors) ==== + if (true) { + + +!!! error TS1005: '}' expected. \ No newline at end of file diff --git a/tests/baselines/reference/prettyContextNotDebugAssertion.js b/tests/baselines/reference/prettyContextNotDebugAssertion.js new file mode 100644 index 00000000000..1051f76864c --- /dev/null +++ b/tests/baselines/reference/prettyContextNotDebugAssertion.js @@ -0,0 +1,7 @@ +//// [index.ts] +if (true) { + + +//// [index.js] +if (true) { +} diff --git a/tests/cases/compiler/prettyContextNotDebugAssertion.ts b/tests/cases/compiler/prettyContextNotDebugAssertion.ts new file mode 100644 index 00000000000..d65b02d472f --- /dev/null +++ b/tests/cases/compiler/prettyContextNotDebugAssertion.ts @@ -0,0 +1,3 @@ +// @pretty: true +// @filename: index.ts +if (true) { From 508cde0ea12a86668d8c893a0356cf2c7320619a Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 12:39:13 -0700 Subject: [PATCH 087/216] Document assignment to aliasSymbol in getUnionTypeFromSortedList (#17434) * Document assignment to aliasSymbol in getUnionTypeFromSortedList * Update wording --- src/compiler/checker.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 91653c140c8..8547fc7e176 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7435,6 +7435,12 @@ namespace ts { type = createType(TypeFlags.Union | propagatedFlags); unionTypes.set(id, type); type.types = types; + /* + Note: This is the alias symbol (or lack thereof) that we see when we first encounter this union type. + For aliases of identical unions, eg `type T = A | B; type U = A | B`, the symbol of the first alias encountered is the aliasSymbol. + (In the language service, the order may depend on the order in which a user takes actions, such as hovering over symbols.) + It's important that we create equivalent union types only once, so that's an unfortunate side effect. + */ type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } @@ -7528,7 +7534,7 @@ namespace ts { type = createType(TypeFlags.Intersection | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; - type.aliasSymbol = aliasSymbol; + type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. type.aliasTypeArguments = aliasTypeArguments; } return type; From 1b5a0aed93f617d63627cb6d7c5c104d4f4dfdc9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 12:47:09 -0700 Subject: [PATCH 088/216] Update pretty baseline changed by #17675 (#18320) --- .../reference/prettyContextNotDebugAssertion.errors.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt b/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt index 7b7e3fea3e3..9cac1423f3f 100644 --- a/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt +++ b/tests/baselines/reference/prettyContextNotDebugAssertion.errors.txt @@ -1,6 +1,6 @@ -2 -   +2 +   tests/cases/compiler/index.ts(2,1): error TS1005: '}' expected. From ed4e2e6e3b66e43ce3e4807be342f3b235e0bb73 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 14:30:19 -0700 Subject: [PATCH 089/216] Ensure that emitter calls callbacks (#18284) * Ensure that emitter calls calbacks * Move new parameter to end of parameters * Fix for ConditionalExpression * Make suggested changes to emitter * Fix parameter ordering * Respond to minor comments * Remove potentially expensive assertion * More emitter cleanup --- src/compiler/emitter.ts | 123 ++++++++-------- src/compiler/factory.ts | 60 +++++++- src/compiler/transformers/es2017.ts | 3 +- src/compiler/transformers/esnext.ts | 3 +- src/compiler/transformers/ts.ts | 3 +- src/compiler/types.ts | 9 +- src/compiler/utilities.ts | 3 +- src/compiler/visitor.ts | 3 + src/services/formatting/formatting.ts | 1 + src/services/refactors/extractMethod.ts | 6 +- src/services/textChanges.ts | 28 ++-- .../reference/extractMethod/extractMethod4.ts | 24 ++-- .../sourceMapValidationStatements.js.map | 2 +- ...ourceMapValidationStatements.sourcemap.txt | 132 +++++++++++------- .../ternaryExpressionSourceMap.js.map | 2 +- .../ternaryExpressionSourceMap.sourcemap.txt | 90 ++++++------ ...ypeGuardsInRightOperandOfAndAndOperator.js | 2 + .../typeGuardsInRightOperandOfOrOrOperator.js | 2 + .../fourslash/extract-method-formatting.ts | 24 ++++ tests/cases/fourslash/extract-method5.ts | 2 +- 20 files changed, 325 insertions(+), 197 deletions(-) create mode 100644 tests/cases/fourslash/extract-method-formatting.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 166e4751983..5abeecd4107 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -406,6 +406,14 @@ namespace ts { setWriter(/*output*/ undefined); } + // TODO: Should this just be `emit`? + // See https://github.com/Microsoft/TypeScript/pull/18284#discussion_r137611034 + function emitIfPresent(node: Node | undefined) { + if (node) { + emit(node); + } + } + function emit(node: Node) { pipelineEmitWithNotification(EmitHint.Unspecified, node); } @@ -451,6 +459,7 @@ namespace ts { case EmitHint.SourceFile: return pipelineEmitSourceFile(node); case EmitHint.IdentifierName: return pipelineEmitIdentifierName(node); case EmitHint.Expression: return pipelineEmitExpression(node); + case EmitHint.MappedTypeParameter: return emitMappedTypeParameter(cast(node, isTypeParameterDeclaration)); case EmitHint.Unspecified: return pipelineEmitUnspecified(node); } } @@ -465,6 +474,12 @@ namespace ts { emitIdentifier(node); } + function emitMappedTypeParameter(node: TypeParameterDeclaration): void { + emit(node.name); + write(" in "); + emit(node.constraint); + } + function pipelineEmitUnspecified(node: Node): void { const kind = node.kind; @@ -898,9 +913,9 @@ namespace ts { function emitParameter(node: ParameterDeclaration) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } @@ -918,7 +933,7 @@ namespace ts { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); write(";"); } @@ -927,7 +942,7 @@ namespace ts { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); write(";"); @@ -937,7 +952,7 @@ namespace ts { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); @@ -947,9 +962,9 @@ namespace ts { function emitMethodDeclaration(node: MethodDeclaration) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.asteriskToken, "*"); + emitIfPresent(node.asteriskToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitSignatureAndBody(node, emitSignatureHead); } @@ -1035,10 +1050,8 @@ namespace ts { function emitTypeLiteral(node: TypeLiteralNode) { write("{"); - // If the literal is empty, do not add spaces between braces. - if (node.members.length > 0) { - emitList(node, node.members, getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineTypeLiteralMembers : ListFormat.MultiLineTypeLiteralMembers); - } + const flags = getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineTypeLiteralMembers : ListFormat.MultiLineTypeLiteralMembers; + emitList(node, node.members, flags | ListFormat.NoSpaceIfEmpty); write("}"); } @@ -1094,13 +1107,16 @@ namespace ts { writeLine(); increaseIndent(); } - writeIfPresent(node.readonlyToken, "readonly "); + if (node.readonlyToken) { + emit(node.readonlyToken); + write(" "); + } + write("["); - emit(node.typeParameter.name); - write(" in "); - emit(node.typeParameter.constraint); + pipelineEmitWithNotification(EmitHint.MappedTypeParameter, node.typeParameter); write("]"); - writeIfPresent(node.questionToken, "?"); + + emitIfPresent(node.questionToken); write(": "); emit(node.type); write(";"); @@ -1148,7 +1164,7 @@ namespace ts { function emitBindingElement(node: BindingElement) { emitWithSuffix(node.propertyName, ": "); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); } @@ -1159,33 +1175,22 @@ namespace ts { function emitArrayLiteralExpression(node: ArrayLiteralExpression) { const elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else { - const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; - emitExpressionList(node, elements, ListFormat.ArrayLiteralExpressionElements | preferNewLine); - } + const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; + emitExpressionList(node, elements, ListFormat.ArrayLiteralExpressionElements | preferNewLine); } function emitObjectLiteralExpression(node: ObjectLiteralExpression) { - const properties = node.properties; - if (properties.length === 0) { - write("{}"); + const indentedFlag = getEmitFlags(node) & EmitFlags.Indented; + if (indentedFlag) { + increaseIndent(); } - else { - const indentedFlag = getEmitFlags(node) & EmitFlags.Indented; - if (indentedFlag) { - increaseIndent(); - } - const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; - const allowTrailingComma = currentSourceFile.languageVersion >= ScriptTarget.ES5 ? ListFormat.AllowTrailingComma : ListFormat.None; - emitList(node, properties, ListFormat.ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine); + const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None; + const allowTrailingComma = currentSourceFile.languageVersion >= ScriptTarget.ES5 ? ListFormat.AllowTrailingComma : ListFormat.None; + emitList(node, node.properties, ListFormat.ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine); - if (indentedFlag) { - decreaseIndent(); - } + if (indentedFlag) { + decreaseIndent(); } } @@ -1286,7 +1291,8 @@ namespace ts { emitTypeParameters(node, node.typeParameters); emitParametersForArrow(node, node.parameters); emitWithPrefix(": ", node.type); - write(" =>"); + write(" "); + emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node: DeleteExpression) { @@ -1364,13 +1370,13 @@ namespace ts { emitExpression(node.condition); increaseIndentIf(indentBeforeQuestion, " "); - write("?"); + emit(node.questionToken); increaseIndentIf(indentAfterQuestion, " "); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); increaseIndentIf(indentBeforeColon, " "); - write(":"); + emit(node.colonToken); increaseIndentIf(indentAfterColon, " "); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); @@ -1382,7 +1388,8 @@ namespace ts { } function emitYieldExpression(node: YieldExpression) { - write(node.asteriskToken ? "yield*" : "yield"); + write("yield"); + emit(node.asteriskToken); emitExpressionWithPrefix(" ", node.expression); } @@ -1662,7 +1669,9 @@ namespace ts { function emitFunctionDeclarationOrExpression(node: FunctionDeclaration | FunctionExpression) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.asteriskToken ? "function* " : "function "); + write("function"); + emitIfPresent(node.asteriskToken); + write(" "); emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -2068,9 +2077,7 @@ namespace ts { function emitJsxExpression(node: JsxExpression) { if (node.expression) { write("{"); - if (node.dotDotDotToken) { - write("..."); - } + emitIfPresent(node.dotDotDotToken); emitExpression(node.expression); write("}"); } @@ -2128,13 +2135,12 @@ namespace ts { emitTrailingCommentsOfPosition(statements.pos); } + let format = ListFormat.CaseOrDefaultClauseStatements; if (emitAsSingleStatement) { write(" "); - emit(statements[0]); - } - else { - emitList(parentNode, statements, ListFormat.CaseOrDefaultClauseStatements); + format &= ~(ListFormat.MultiLine | ListFormat.Indented); } + emitList(parentNode, statements, format); } function emitHeritageClause(node: HeritageClause) { @@ -2384,7 +2390,7 @@ namespace ts { function emitParametersForArrow(parentNode: FunctionTypeNode | ArrowFunction, parameters: NodeArray) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emit(parameters[0]); + emitList(parentNode, parameters, ListFormat.Parameters & ~ListFormat.Parenthesis); } else { emitParameters(parentNode, parameters); @@ -2427,7 +2433,7 @@ namespace ts { if (format & ListFormat.MultiLine) { writeLine(); } - else if (format & ListFormat.SpaceBetweenBraces) { + else if (format & ListFormat.SpaceBetweenBraces && !(format & ListFormat.NoSpaceIfEmpty)) { write(" "); } } @@ -2568,12 +2574,6 @@ namespace ts { } } - function writeIfPresent(node: Node, text: string) { - if (node) { - write(text); - } - } - function writeToken(token: SyntaxKind, pos: number, contextNode?: Node) { return onEmitSourceMapOfToken ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) @@ -2584,7 +2584,7 @@ namespace ts { if (onBeforeEmitToken) { onBeforeEmitToken(node); } - writeTokenText(node.kind); + write(tokenToString(node.kind)); if (onAfterEmitToken) { onAfterEmitToken(node); } @@ -3107,6 +3107,9 @@ namespace ts { NoTrailingNewLine = 1 << 16, // Do not emit a trailing NewLine for a MultiLine list. NoInterveningComments = 1 << 17, // Do not emit comments between each node + NoSpaceIfEmpty = 1 << 18, // If the literal is empty, do not add spaces between braces. + SingleElement = 1 << 19, + // Precomputed Formats Modifiers = SingleLine | SpaceBetweenSiblings | NoInterveningComments, HeritageClauses = SingleLine | SpaceBetweenSiblings, @@ -3118,7 +3121,7 @@ namespace ts { IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine, ObjectBindingPatternElements = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings, ArrayBindingPatternElements = SingleLine | AllowTrailingComma | CommaDelimited | SpaceBetweenSiblings, - ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces, + ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces | NoSpaceIfEmpty, ArrayLiteralExpressionElements = PreserveLines | CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | Indented | SquareBrackets, CommaListElements = CommaDelimited | SpaceBetweenSiblings | SingleLine, CallExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis, diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 4492c3ed474..2bf6d6e879d 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -281,7 +281,7 @@ namespace ts { || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer - ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node) : node; } @@ -1016,19 +1016,49 @@ namespace ts { return node; } + /* @deprecated */ export function updateArrowFunction( + node: ArrowFunction, + modifiers: ReadonlyArray | undefined, + typeParameters: ReadonlyArray | undefined, + parameters: ReadonlyArray, + type: TypeNode | undefined, + body: ConciseBody): ArrowFunction; export function updateArrowFunction( node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, - body: ConciseBody) { + equalsGreaterThanToken: Token, + body: ConciseBody): ArrowFunction; + export function updateArrowFunction( + node: ArrowFunction, + modifiers: ReadonlyArray | undefined, + typeParameters: ReadonlyArray | undefined, + parameters: ReadonlyArray, + type: TypeNode | undefined, + equalsGreaterThanTokenOrBody: Token | ConciseBody, + bodyOrUndefined?: ConciseBody, + ): ArrowFunction { + let equalsGreaterThanToken: Token; + let body: ConciseBody; + if (bodyOrUndefined === undefined) { + equalsGreaterThanToken = node.equalsGreaterThanToken; + body = cast(equalsGreaterThanTokenOrBody, isConciseBody); + } + else { + equalsGreaterThanToken = cast(equalsGreaterThanTokenOrBody, (n): n is Token => + n.kind === SyntaxKind.EqualsGreaterThanToken); + body = bodyOrUndefined; + } + return node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type + || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body - ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node; } @@ -1135,11 +1165,31 @@ namespace ts { return node; } - export function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression) { + /* @deprecated */ export function updateConditional( + node: ConditionalExpression, + condition: Expression, + whenTrue: Expression, + whenFalse: Expression): ConditionalExpression; + export function updateConditional( + node: ConditionalExpression, + condition: Expression, + questionToken: Token, + whenTrue: Expression, + colonToken: Token, + whenFalse: Expression): ConditionalExpression; + export function updateConditional(node: ConditionalExpression, condition: Expression, ...args: any[]) { + if (args.length === 2) { + const [whenTrue, whenFalse] = args; + return updateConditional(node, condition, node.questionToken, whenTrue, node.colonToken, whenFalse); + } + Debug.assert(args.length === 4); + const [questionToken, whenTrue, colonToken, whenFalse] = args; return node.condition !== condition + || node.questionToken !== questionToken || node.whenTrue !== whenTrue + || node.colonToken !== colonToken || node.whenFalse !== whenFalse - ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node) : node; } diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 43058358ee5..85a44e35983 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -197,9 +197,10 @@ namespace ts { /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, + node.equalsGreaterThanToken, getFunctionFlags(node) & FunctionFlags.Async ? transformAsyncFunctionBody(node) - : visitFunctionBody(node.body, visitor, context) + : visitFunctionBody(node.body, visitor, context), ); } diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 3bdcc9e9ee7..0fca09b4540 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -595,7 +595,8 @@ namespace ts { /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - transformFunctionBody(node) + node.equalsGreaterThanToken, + transformFunctionBody(node), ); enclosingFunctionFlags = savedEnclosingFunctionFlags; return updated; diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 42c25ca34a5..ebce55aa7e5 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2309,7 +2309,8 @@ namespace ts { /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, - visitFunctionBody(node.body, visitor, context) + node.equalsGreaterThanToken, + visitFunctionBody(node.body, visitor, context), ); return updated; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 55baf9763c2..1b5a0164585 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4299,10 +4299,11 @@ namespace ts { } export const enum EmitHint { - SourceFile, // Emitting a SourceFile - Expression, // Emitting an Expression - IdentifierName, // Emitting an IdentifierName - Unspecified, // Emitting an otherwise unspecified node + SourceFile, // Emitting a SourceFile + Expression, // Emitting an Expression + IdentifierName, // Emitting an IdentifierName + MappedTypeParameter, // Emitting a TypeParameterDeclaration inside of a MappedTypeNode + Unspecified, // Emitting an otherwise unspecified node } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 11c30a2d8ab..160d81d04da 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4728,8 +4728,7 @@ namespace ts { /* @internal */ export function isNodeArray(array: ReadonlyArray): array is NodeArray { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); + return array.hasOwnProperty("pos") && array.hasOwnProperty("end"); } // Literals diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 1ce42199372..7d46630e227 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -488,6 +488,7 @@ namespace ts { nodesVisitor((node).typeParameters, visitor, isTypeParameterDeclaration), visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), + visitNode((node).equalsGreaterThanToken, visitor, isToken), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.DeleteExpression: @@ -523,7 +524,9 @@ namespace ts { case SyntaxKind.ConditionalExpression: return updateConditional(node, visitNode((node).condition, visitor, isExpression), + visitNode((node).questionToken, visitor, isToken), visitNode((node).whenTrue, visitor, isExpression), + visitNode((node).colonToken, visitor, isToken), visitNode((node).whenFalse, visitor, isExpression)); case SyntaxKind.TemplateExpression: diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 443ce13d6a4..5f26990d3a4 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -726,6 +726,7 @@ namespace ts.formatting { parent: Node, parentStartLine: number, parentDynamicIndentation: DynamicIndentation): void { + Debug.assert(isNodeArray(nodes)); const listStartToken = getOpenTokenForList(parent, nodes); const listEndToken = getCloseTokenForOpenToken(listStartToken); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index b76ab9376dc..25a995dc231 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -656,11 +656,13 @@ namespace ts.refactor.extractMethod { const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values()).map(type => ({ type, declaration: getFirstDeclaration(type) })); const sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder); - const typeParameters: ReadonlyArray = sortedTypeParametersAndDeclarations.map(t => t.declaration as TypeParameterDeclaration); + const typeParameters: ReadonlyArray | undefined = sortedTypeParametersAndDeclarations.length === 0 + ? undefined + : sortedTypeParametersAndDeclarations.map(t => t.declaration as TypeParameterDeclaration); // Strictly speaking, we should check whether each name actually binds to the appropriate type // parameter. In cases of shadowing, they may not. - const callTypeArguments: ReadonlyArray | undefined = typeParameters.length > 0 + const callTypeArguments: ReadonlyArray | undefined = typeParameters !== undefined ? typeParameters.map(decl => createTypeReferenceNode(decl.name, /*typeArguments*/ undefined)) : undefined; diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 7909d2d3adb..42c1d1e9a4f 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -5,19 +5,25 @@ namespace ts.textChanges { * Currently for simplicity we store recovered positions on the node itself. * It can be changed to side-table later if we decide that current design is too invasive. */ - function getPos(n: TextRange) { - return (n)["__pos"]; + function getPos(n: TextRange): number { + const result = (n)["__pos"]; + Debug.assert(typeof result === "number"); + return result; } - function setPos(n: TextRange, pos: number) { + function setPos(n: TextRange, pos: number): void { + Debug.assert(typeof pos === "number"); (n)["__pos"] = pos; } - function getEnd(n: TextRange) { - return (n)["__end"]; + function getEnd(n: TextRange): number { + const result = (n)["__end"]; + Debug.assert(typeof result === "number"); + return result; } - function setEnd(n: TextRange, end: number) { + function setEnd(n: TextRange, end: number): void { + Debug.assert(typeof end === "number"); (n)["__end"] = end; } @@ -582,7 +588,7 @@ namespace ts.textChanges { readonly node: Node; } - export function getNonformattedText(node: Node, sourceFile: SourceFile | undefined, newLine: NewLineKind): NonFormattedText { + function getNonformattedText(node: Node, sourceFile: SourceFile | undefined, newLine: NewLineKind): NonFormattedText { const options = { newLine, target: sourceFile && sourceFile.languageVersion }; const writer = new Writer(getNewLineCharacter(options)); const printer = createPrinter(options, writer); @@ -590,7 +596,7 @@ namespace ts.textChanges { return { text: writer.getText(), node: assignPositionsToNode(node) }; } - export function applyFormatting(nonFormattedText: NonFormattedText, sourceFile: SourceFile, initialIndentation: number, delta: number, rulesProvider: formatting.RulesProvider) { + function applyFormatting(nonFormattedText: NonFormattedText, sourceFile: SourceFile, initialIndentation: number, delta: number, rulesProvider: formatting.RulesProvider) { const lineMap = computeLineStarts(nonFormattedText.text); const file: SourceFileLike = { text: nonFormattedText.text, @@ -616,14 +622,10 @@ namespace ts.textChanges { function assignPositionsToNode(node: Node): Node { const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes - const newNode = nodeIsSynthesized(visited) - ? visited - : (Proxy.prototype = visited, new (Proxy)()); + const newNode = nodeIsSynthesized(visited) ? visited : Object.create(visited) as Node; newNode.pos = getPos(node); newNode.end = getEnd(node); return newNode; - - function Proxy() { } } function assignPositionsToNodeArray(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) { diff --git a/tests/baselines/reference/extractMethod/extractMethod4.ts b/tests/baselines/reference/extractMethod/extractMethod4.ts index 107f99e669b..4e9811501f4 100644 --- a/tests/baselines/reference/extractMethod/extractMethod4.ts +++ b/tests/baselines/reference/extractMethod/extractMethod4.ts @@ -24,9 +24,9 @@ namespace A { async function newFunction() { let y = 5; - if(z) { - await z1; - } + if (z) { + await z1; + } return foo(); } } @@ -44,9 +44,9 @@ namespace A { async function newFunction(z: number, z1: any) { let y = 5; - if(z) { - await z1; - } + if (z) { + await z1; + } return foo(); } } @@ -64,9 +64,9 @@ namespace A { async function newFunction(z: number, z1: any) { let y = 5; - if(z) { - await z1; - } + if (z) { + await z1; + } return foo(); } } @@ -83,8 +83,8 @@ namespace A { } async function newFunction(z: number, z1: any, foo: () => void) { let y = 5; - if(z) { - await z1; -} + if (z) { + await z1; + } return foo(); } diff --git a/tests/baselines/reference/sourceMapValidationStatements.js.map b/tests/baselines/reference/sourceMapValidationStatements.js.map index 5841f329e5e..40d65e0106c 100644 --- a/tests/baselines/reference/sourceMapValidationStatements.js.map +++ b/tests/baselines/reference/sourceMapValidationStatements.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationStatements.js.map] -{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":[],"mappings":"AAAA;IACI,IAAI,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1B,CAAC,IAAI,CAAC,CAAC;QACP,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IACD,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACT,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,CAAC,IAAI,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;IACR,CAAC;IACD,IAAI,CAAC,GAAG;QACJ,CAAC;QACD,CAAC;QACD,CAAC;KACJ,CAAC;IACF,IAAI,GAAG,GAAG;QACN,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,OAAO;KACb,CAAC;IACF,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACD,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACnB,CAAC;IAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACT,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACb,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACf,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAClB,CAAC;IACL,CAAC;IACD,IAAI,CAAC;QACD,MAAM,IAAI,KAAK,EAAE,CAAC;IACtB,CAAC;IAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;YAAS,CAAC;QACP,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,GAAG,EAAE,CAAC;QACR,CAAC,GAAG,CAAC,CAAC;QACN,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACZ,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,SAAS,CAAC;YACN,CAAC,IAAI,CAAC,CAAC;YACP,CAAC,GAAG,EAAE,CAAC;YACP,KAAK,CAAC;QAEV,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;QACZ,CAAC,EAAE,CAAC;IACR,CAAC;IACD,GAAG,CAAC;QACA,CAAC,EAAE,CAAC;IACR,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAC;IACf,CAAC,GAAG,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,KAAK,CAAC,CAAC;IACR,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC;AACX,CAAC;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":[],"mappings":"AAAA;IACI,IAAI,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1B,CAAC,IAAI,CAAC,CAAC;QACP,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IACD,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACT,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,CAAC,IAAI,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;IACR,CAAC;IACD,IAAI,CAAC,GAAG;QACJ,CAAC;QACD,CAAC;QACD,CAAC;KACJ,CAAC;IACF,IAAI,GAAG,GAAG;QACN,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,OAAO;KACb,CAAC;IACF,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACD,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACnB,CAAC;IAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACT,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACb,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACf,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAClB,CAAC;IACL,CAAC;IACD,IAAI,CAAC;QACD,MAAM,IAAI,KAAK,EAAE,CAAC;IACtB,CAAC;IAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,EAAE,CAAC;IACf,CAAC;YAAS,CAAC;QACP,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,GAAG,EAAE,CAAC;QACR,CAAC,GAAG,CAAC,CAAC;QACN,CAAC,GAAG,EAAE,CAAC;IACX,CAAC;IACD,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACZ,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,KAAK,CAAC,EAAE,CAAC;YACL,CAAC,EAAE,CAAC;YACJ,KAAK,CAAC;QAEV,CAAC;QACD,SAAS,CAAC;YACN,CAAC,IAAI,CAAC,CAAC;YACP,CAAC,GAAG,EAAE,CAAC;YACP,KAAK,CAAC;QAEV,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;QACZ,CAAC,EAAE,CAAC;IACR,CAAC;IACD,GAAG,CAAC;QACA,CAAC,EAAE,CAAC;IACR,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAC;IACf,CAAC,GAAG,CAAC,CAAC;IACN,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC,KAAK,CAAC,CAAC;IACR,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC;AACX,CAAC;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt b/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt index 7c5c5bfcfeb..aec7eaafc06 100644 --- a/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt @@ -1251,15 +1251,19 @@ sourceFile:sourceMapValidationStatements.ts 7 > ^^^^ 8 > ^ 9 > ^ -10> ^^^ -11> ^ -12> ^^^ -13> ^ -14> ^^^ -15> ^ -16> ^^^ -17> ^ -18> ^ +10> ^ +11> ^ +12> ^ +13> ^ +14> ^^^ +15> ^ +16> ^ +17> ^ +18> ^ +19> ^ +20> ^^^ +21> ^ +22> ^ 1-> > 2 > var @@ -1270,15 +1274,19 @@ sourceFile:sourceMapValidationStatements.ts 7 > == 8 > 1 9 > ) -10> ? -11> x -12> + -13> 1 -14> : -15> x -16> - -17> 1 -18> ; +10> +11> ? +12> +13> x +14> + +15> 1 +16> +17> : +18> +19> x +20> - +21> 1 +22> ; 1->Emitted(74, 5) Source(72, 5) + SourceIndex(0) 2 >Emitted(74, 9) Source(72, 9) + SourceIndex(0) 3 >Emitted(74, 10) Source(72, 10) + SourceIndex(0) @@ -1288,15 +1296,19 @@ sourceFile:sourceMapValidationStatements.ts 7 >Emitted(74, 19) Source(72, 19) + SourceIndex(0) 8 >Emitted(74, 20) Source(72, 20) + SourceIndex(0) 9 >Emitted(74, 21) Source(72, 21) + SourceIndex(0) -10>Emitted(74, 24) Source(72, 24) + SourceIndex(0) -11>Emitted(74, 25) Source(72, 25) + SourceIndex(0) -12>Emitted(74, 28) Source(72, 28) + SourceIndex(0) -13>Emitted(74, 29) Source(72, 29) + SourceIndex(0) -14>Emitted(74, 32) Source(72, 32) + SourceIndex(0) -15>Emitted(74, 33) Source(72, 33) + SourceIndex(0) -16>Emitted(74, 36) Source(72, 36) + SourceIndex(0) -17>Emitted(74, 37) Source(72, 37) + SourceIndex(0) -18>Emitted(74, 38) Source(72, 38) + SourceIndex(0) +10>Emitted(74, 22) Source(72, 22) + SourceIndex(0) +11>Emitted(74, 23) Source(72, 23) + SourceIndex(0) +12>Emitted(74, 24) Source(72, 24) + SourceIndex(0) +13>Emitted(74, 25) Source(72, 25) + SourceIndex(0) +14>Emitted(74, 28) Source(72, 28) + SourceIndex(0) +15>Emitted(74, 29) Source(72, 29) + SourceIndex(0) +16>Emitted(74, 30) Source(72, 30) + SourceIndex(0) +17>Emitted(74, 31) Source(72, 31) + SourceIndex(0) +18>Emitted(74, 32) Source(72, 32) + SourceIndex(0) +19>Emitted(74, 33) Source(72, 33) + SourceIndex(0) +20>Emitted(74, 36) Source(72, 36) + SourceIndex(0) +21>Emitted(74, 37) Source(72, 37) + SourceIndex(0) +22>Emitted(74, 38) Source(72, 38) + SourceIndex(0) --- >>> (x == 1) ? x + 1 : x - 1; 1 >^^^^ @@ -1305,15 +1317,19 @@ sourceFile:sourceMapValidationStatements.ts 4 > ^^^^ 5 > ^ 6 > ^ -7 > ^^^ -8 > ^ -9 > ^^^ -10> ^ -11> ^^^ -12> ^ -13> ^^^ -14> ^ -15> ^ +7 > ^ +8 > ^ +9 > ^ +10> ^ +11> ^^^ +12> ^ +13> ^ +14> ^ +15> ^ +16> ^ +17> ^^^ +18> ^ +19> ^ 1 > > 2 > ( @@ -1321,30 +1337,38 @@ sourceFile:sourceMapValidationStatements.ts 4 > == 5 > 1 6 > ) -7 > ? -8 > x -9 > + -10> 1 -11> : -12> x -13> - -14> 1 -15> ; +7 > +8 > ? +9 > +10> x +11> + +12> 1 +13> +14> : +15> +16> x +17> - +18> 1 +19> ; 1 >Emitted(75, 5) Source(73, 5) + SourceIndex(0) 2 >Emitted(75, 6) Source(73, 6) + SourceIndex(0) 3 >Emitted(75, 7) Source(73, 7) + SourceIndex(0) 4 >Emitted(75, 11) Source(73, 11) + SourceIndex(0) 5 >Emitted(75, 12) Source(73, 12) + SourceIndex(0) 6 >Emitted(75, 13) Source(73, 13) + SourceIndex(0) -7 >Emitted(75, 16) Source(73, 16) + SourceIndex(0) -8 >Emitted(75, 17) Source(73, 17) + SourceIndex(0) -9 >Emitted(75, 20) Source(73, 20) + SourceIndex(0) -10>Emitted(75, 21) Source(73, 21) + SourceIndex(0) -11>Emitted(75, 24) Source(73, 24) + SourceIndex(0) -12>Emitted(75, 25) Source(73, 25) + SourceIndex(0) -13>Emitted(75, 28) Source(73, 28) + SourceIndex(0) -14>Emitted(75, 29) Source(73, 29) + SourceIndex(0) -15>Emitted(75, 30) Source(73, 30) + SourceIndex(0) +7 >Emitted(75, 14) Source(73, 14) + SourceIndex(0) +8 >Emitted(75, 15) Source(73, 15) + SourceIndex(0) +9 >Emitted(75, 16) Source(73, 16) + SourceIndex(0) +10>Emitted(75, 17) Source(73, 17) + SourceIndex(0) +11>Emitted(75, 20) Source(73, 20) + SourceIndex(0) +12>Emitted(75, 21) Source(73, 21) + SourceIndex(0) +13>Emitted(75, 22) Source(73, 22) + SourceIndex(0) +14>Emitted(75, 23) Source(73, 23) + SourceIndex(0) +15>Emitted(75, 24) Source(73, 24) + SourceIndex(0) +16>Emitted(75, 25) Source(73, 25) + SourceIndex(0) +17>Emitted(75, 28) Source(73, 28) + SourceIndex(0) +18>Emitted(75, 29) Source(73, 29) + SourceIndex(0) +19>Emitted(75, 30) Source(73, 30) + SourceIndex(0) --- >>> x === 1; 1 >^^^^ diff --git a/tests/baselines/reference/ternaryExpressionSourceMap.js.map b/tests/baselines/reference/ternaryExpressionSourceMap.js.map index 9340c972274..27160910378 100644 --- a/tests/baselines/reference/ternaryExpressionSourceMap.js.map +++ b/tests/baselines/reference/ternaryExpressionSourceMap.js.map @@ -1,2 +1,2 @@ //// [ternaryExpressionSourceMap.js.map] -{"version":3,"file":"ternaryExpressionSourceMap.js","sourceRoot":"","sources":["ternaryExpressionSourceMap.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC;AACV,IAAI,GAAG,GAAG,CAAC,GAAG,cAAM,OAAA,CAAC,EAAD,CAAC,GAAG,cAAM,OAAA,CAAC,EAAD,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"ternaryExpressionSourceMap.js","sourceRoot":"","sources":["ternaryExpressionSourceMap.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC;AACV,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,cAAM,OAAA,CAAC,EAAD,CAAC,CAAC,CAAC,CAAC,cAAM,OAAA,CAAC,EAAD,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/ternaryExpressionSourceMap.sourcemap.txt b/tests/baselines/reference/ternaryExpressionSourceMap.sourcemap.txt index d46e703e357..87e3ce02304 100644 --- a/tests/baselines/reference/ternaryExpressionSourceMap.sourcemap.txt +++ b/tests/baselines/reference/ternaryExpressionSourceMap.sourcemap.txt @@ -35,55 +35,67 @@ sourceFile:ternaryExpressionSourceMap.ts 3 > ^^^ 4 > ^^^ 5 > ^ -6 > ^^^ -7 > ^^^^^^^^^^^^^^ -8 > ^^^^^^^ -9 > ^ -10> ^^ -11> ^ -12> ^^^ -13> ^^^^^^^^^^^^^^ -14> ^^^^^^^ -15> ^ -16> ^^ -17> ^ -18> ^ +6 > ^ +7 > ^ +8 > ^ +9 > ^^^^^^^^^^^^^^ +10> ^^^^^^^ +11> ^ +12> ^^ +13> ^ +14> ^ +15> ^ +16> ^ +17> ^^^^^^^^^^^^^^ +18> ^^^^^^^ +19> ^ +20> ^^ +21> ^ +22> ^ 1-> > 2 >var 3 > foo 4 > = 5 > x -6 > ? -7 > () => -8 > -9 > 0 -10> -11> 0 -12> : -13> () => -14> -15> 0 -16> -17> 0 -18> ; +6 > +7 > ? +8 > +9 > () => +10> +11> 0 +12> +13> 0 +14> +15> : +16> +17> () => +18> +19> 0 +20> +21> 0 +22> ; 1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) 2 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) 3 >Emitted(2, 8) Source(2, 8) + SourceIndex(0) 4 >Emitted(2, 11) Source(2, 11) + SourceIndex(0) 5 >Emitted(2, 12) Source(2, 12) + SourceIndex(0) -6 >Emitted(2, 15) Source(2, 15) + SourceIndex(0) -7 >Emitted(2, 29) Source(2, 21) + SourceIndex(0) -8 >Emitted(2, 36) Source(2, 21) + SourceIndex(0) -9 >Emitted(2, 37) Source(2, 22) + SourceIndex(0) -10>Emitted(2, 39) Source(2, 21) + SourceIndex(0) -11>Emitted(2, 40) Source(2, 22) + SourceIndex(0) -12>Emitted(2, 43) Source(2, 25) + SourceIndex(0) -13>Emitted(2, 57) Source(2, 31) + SourceIndex(0) -14>Emitted(2, 64) Source(2, 31) + SourceIndex(0) -15>Emitted(2, 65) Source(2, 32) + SourceIndex(0) -16>Emitted(2, 67) Source(2, 31) + SourceIndex(0) -17>Emitted(2, 68) Source(2, 32) + SourceIndex(0) -18>Emitted(2, 69) Source(2, 33) + SourceIndex(0) +6 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +7 >Emitted(2, 14) Source(2, 14) + SourceIndex(0) +8 >Emitted(2, 15) Source(2, 15) + SourceIndex(0) +9 >Emitted(2, 29) Source(2, 21) + SourceIndex(0) +10>Emitted(2, 36) Source(2, 21) + SourceIndex(0) +11>Emitted(2, 37) Source(2, 22) + SourceIndex(0) +12>Emitted(2, 39) Source(2, 21) + SourceIndex(0) +13>Emitted(2, 40) Source(2, 22) + SourceIndex(0) +14>Emitted(2, 41) Source(2, 23) + SourceIndex(0) +15>Emitted(2, 42) Source(2, 24) + SourceIndex(0) +16>Emitted(2, 43) Source(2, 25) + SourceIndex(0) +17>Emitted(2, 57) Source(2, 31) + SourceIndex(0) +18>Emitted(2, 64) Source(2, 31) + SourceIndex(0) +19>Emitted(2, 65) Source(2, 32) + SourceIndex(0) +20>Emitted(2, 67) Source(2, 31) + SourceIndex(0) +21>Emitted(2, 68) Source(2, 32) + SourceIndex(0) +22>Emitted(2, 69) Source(2, 33) + SourceIndex(0) --- >>>//# sourceMappingURL=ternaryExpressionSourceMap.js.map \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.js b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.js index be1c497e3ea..5483f314fb9 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.js +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.js @@ -85,6 +85,8 @@ function foo7(x) { return typeof x !== "string" && ((z = x) // number | boolean && (typeof x === "number" + // change value of x ? ((x = 10) && x.toString()) // x is number + // do not change value : ((y = x) && x.toString()))); // x is boolean } diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.js b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.js index a8d66dc5fa2..c3143999d3a 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.js +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.js @@ -87,6 +87,8 @@ function foo7(x) { return typeof x === "string" || ((z = x) // number | boolean || (typeof x === "number" + // change value of x ? ((x = 10) && x.toString()) // number | boolean | string + // do not change value : ((y = x) && x.toString()))); // number | boolean | string } diff --git a/tests/cases/fourslash/extract-method-formatting.ts b/tests/cases/fourslash/extract-method-formatting.ts new file mode 100644 index 00000000000..1342e5632e8 --- /dev/null +++ b/tests/cases/fourslash/extract-method-formatting.ts @@ -0,0 +1,24 @@ +/// + +////function f(x: number): number { +//// /*start*/switch (x) {case 0: +////return 0;}/*end*/ +////} + +goTo.select('start', 'end') +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_1", + actionDescription: "Extract function into global scope", +}); +verify.currentFileContentIs( +`function f(x: number): number { + return newFunction(x); +} +function newFunction(x: number) { + switch (x) { + case 0: + return 0; + } +} +`); diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index d1e70d10716..8b0bd4fec6d 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -20,6 +20,6 @@ verify.currentFileContentIs( var x: 1 | 2 | 3 = newFunction(); function newFunction(): 1 | 2 | 3 { - return 1 + 1 === 2?1: 2; + return 1 + 1 === 2 ? 1 : 2; } }`); \ No newline at end of file From 2e027789606a7b5bcd015cf1173823ed8f83023b Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 14:31:20 -0700 Subject: [PATCH 090/216] When loading a module from node_modules, get packageId even in the `loadModuleFromFile` case (#18185) * When loading a module from node_modules, get packageId even in the `loadModuleFromFile` case * Support packageId for too --- src/compiler/moduleNameResolver.ts | 103 +++++++++++------- src/compiler/program.ts | 14 +-- src/compiler/types.ts | 6 + src/compiler/utilities.ts | 2 +- src/harness/unittests/moduleResolution.ts | 31 +++--- .../unittests/reuseProgramStructure.ts | 20 ++-- .../unittests/tsserverProjectSystem.ts | 2 +- ...icatePackage_packageIdIncludesSubModule.js | 22 ++++ ...Package_packageIdIncludesSubModule.symbols | 20 ++++ ...tePackage_packageIdIncludesSubModule.types | 20 ++++ .../duplicatePackage_referenceTypes.js | 31 ++++++ .../duplicatePackage_referenceTypes.symbols | 33 ++++++ .../duplicatePackage_referenceTypes.types | 33 ++++++ .../reference/duplicatePackage_subModule.js | 34 ++++++ .../duplicatePackage_subModule.symbols | 38 +++++++ .../duplicatePackage_subModule.types | 38 +++++++ .../reference/library-reference-11.trace.json | 2 +- .../reference/library-reference-12.trace.json | 2 +- .../reference/library-reference-3.trace.json | 2 +- .../reference/library-reference-4.trace.json | 8 +- .../reference/library-reference-5.trace.json | 8 +- .../reference/library-reference-7.trace.json | 2 +- ...brary-reference-scoped-packages.trace.json | 2 +- ...NodeModuleJsDepthDefaultsToZero.trace.json | 4 +- ...lutionWithExtensions_unexpected.trace.json | 4 +- ...utionWithExtensions_unexpected2.trace.json | 4 +- ...thExtensions_withAmbientPresent.trace.json | 4 +- .../moduleResolutionWithSymlinks.trace.json | 2 +- ...onWithSymlinks_preserveSymlinks.trace.json | 10 +- ...tionWithSymlinks_referenceTypes.trace.json | 6 +- ...solutionWithSymlinks_withOutDir.trace.json | 2 +- .../reference/packageJsonMain.trace.json | 12 +- .../packageJsonMain_isNonRecursive.trace.json | 4 +- ...pingBasedModuleResolution3_node.trace.json | 2 +- ...pingBasedModuleResolution4_node.trace.json | 2 +- .../reference/scopedPackages.trace.json | 5 +- .../scopedPackagesClassic.trace.json | 2 +- .../reference/typingsLookup4.trace.json | 8 +- .../reference/typingsLookupAmd.trace.json | 4 +- ...icatePackage_packageIdIncludesSubModule.ts | 17 +++ .../duplicatePackage_referenceTypes.ts | 24 ++++ .../compiler/duplicatePackage_subModule.ts | 27 +++++ 42 files changed, 493 insertions(+), 123 deletions(-) create mode 100644 tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.js create mode 100644 tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.symbols create mode 100644 tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.types create mode 100644 tests/baselines/reference/duplicatePackage_referenceTypes.js create mode 100644 tests/baselines/reference/duplicatePackage_referenceTypes.symbols create mode 100644 tests/baselines/reference/duplicatePackage_referenceTypes.types create mode 100644 tests/baselines/reference/duplicatePackage_subModule.js create mode 100644 tests/baselines/reference/duplicatePackage_subModule.symbols create mode 100644 tests/baselines/reference/duplicatePackage_subModule.types create mode 100644 tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts create mode 100644 tests/cases/compiler/duplicatePackage_referenceTypes.ts create mode 100644 tests/cases/compiler/duplicatePackage_subModule.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 5fdac504896..ddffe876d80 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -51,13 +51,17 @@ namespace ts { DtsOnly /** Only '.d.ts' */ } + interface PathAndPackageId { + readonly fileName: string; + readonly packageId: PackageId; + } /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ - function resolvedTypeScriptOnly(resolved: Resolved | undefined): string | undefined { + function resolvedTypeScriptOnly(resolved: Resolved | undefined): PathAndPackageId | undefined { if (!resolved) { return undefined; } Debug.assert(extensionIsTypeScript(resolved.extension)); - return resolved.path; + return { fileName: resolved.path, packageId: resolved.packageId }; } function createResolvedModuleWithFailedLookupLocations(resolved: Resolved | undefined, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations { @@ -201,18 +205,18 @@ namespace ts { let resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; if (resolved) { if (!options.preserveSymlinks) { - resolved = realPath(resolved, host, traceEnabled); + resolved = { ...resolved, fileName: realPath(resolved.fileName, host, traceEnabled) }; } if (traceEnabled) { - trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); } - resolvedTypeReferenceDirective = { primary, resolvedFileName: resolved }; + resolvedTypeReferenceDirective = { primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; } return { resolvedTypeReferenceDirective, failedLookupLocations }; - function primaryLookup(): string | undefined { + function primaryLookup(): PathAndPackageId | undefined { // Check primary library paths if (typeRoots && typeRoots.length) { if (traceEnabled) { @@ -237,8 +241,8 @@ namespace ts { } } - function secondaryLookup(): string | undefined { - let resolvedFile: string; + function secondaryLookup(): PathAndPackageId | undefined { + let resolvedFile: PathAndPackageId; const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { @@ -675,7 +679,7 @@ namespace ts { if (extension !== undefined) { const path = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); if (path !== undefined) { - return { path, extension, packageId: undefined }; + return noPackageId({ path, ext: extension }); } } @@ -875,38 +879,49 @@ namespace ts { return undefined; } - function loadNodeModuleFromDirectory(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState, considerPackageJson = true): Resolved | undefined { - const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + function loadNodeModuleFromDirectory(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState, considerPackageJson = true) { + const { packageJsonContent, packageId } = considerPackageJson + ? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state) + : { packageJsonContent: undefined, packageId: undefined }; + return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent)); + } - let packageId: PackageId | undefined; - - if (considerPackageJson) { - const packageJsonPath = pathToPackageJson(candidate); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, Diagnostics.Found_package_json_at_0, packageJsonPath); - } - const jsonContent = readJson(packageJsonPath, state.host); - - if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { - packageId = { name: jsonContent.name, version: jsonContent.version }; - } - - const fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); - if (fromPackageJson) { - return withPackageId(packageId, fromPackageJson); - } - } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, Diagnostics.File_0_does_not_exist, packageJsonPath); - } - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocations.push(packageJsonPath); - } + function loadNodeModuleFromDirectoryWorker(extensions: Extensions, candidate: string, failedLookupLocations: Push, onlyRecordFailures: boolean, state: ModuleResolutionState, packageJsonContent: PackageJson | undefined): PathAndExtension | undefined { + const fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; } + const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + return loadModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } - return withPackageId(packageId, loadModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); + function getPackageJsonInfo( + nodeModuleDirectory: string, + subModuleName: string, + failedLookupLocations: Push, + onlyRecordFailures: boolean, + { host, traceEnabled }: ModuleResolutionState, + ): { packageJsonContent: PackageJson | undefined, packageId: PackageId | undefined } { + const directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host); + const packageJsonPath = pathToPackageJson(nodeModuleDirectory); + if (directoryExists && host.fileExists(packageJsonPath)) { + if (traceEnabled) { + trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath); + } + const packageJsonContent = readJson(packageJsonPath, host); + const packageId: PackageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string" + ? { name: packageJsonContent.name, subModuleName, version: packageJsonContent.version } + : undefined; + return { packageJsonContent, packageId }; + } + else { + if (directoryExists && traceEnabled) { + trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath); + } + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocations.push(packageJsonPath); + return { packageJsonContent: undefined, packageId: undefined }; + } } function loadModuleFromPackageJson(jsonContent: PackageJson, extensions: Extensions, candidate: string, failedLookupLocations: Push, state: ModuleResolutionState): PathAndExtension | undefined { @@ -961,10 +976,18 @@ namespace ts { } function loadModuleFromNodeModulesFolder(extensions: Extensions, moduleName: string, nodeModulesFolder: string, nodeModulesFolderExists: boolean, failedLookupLocations: Push, state: ModuleResolutionState): Resolved | undefined { + const { top, rest } = getNameOfTopDirectory(moduleName); + const packageRootPath = combinePaths(nodeModulesFolder, top); + const { packageJsonContent, packageId } = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state); const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); + const pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent); + return withPackageId(packageId, pathAndExtension); + } - return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + function getNameOfTopDirectory(name: string): { top: string, rest: string } { + const idx = name.indexOf(directorySeparator); + return idx === -1 ? { top: name, rest: "" } : { top: name.slice(0, idx), rest: name.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions: Extensions, moduleName: string, directory: string, failedLookupLocations: Push, state: ModuleResolutionState, cache: NonRelativeModuleNameResolutionCache): SearchResult { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 89c23598c58..00e933d680a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1427,7 +1427,7 @@ namespace ts { } function processRootFile(fileName: string, isDefaultLib: boolean) { - processSourceFile(normalizePath(fileName), isDefaultLib); + processSourceFile(normalizePath(fileName), isDefaultLib, /*packageId*/ undefined); } function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean { @@ -1591,9 +1591,9 @@ namespace ts { } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): void { + function processSourceFile(fileName: string, isDefaultLib: boolean, packageId: PackageId | undefined, refFile?: SourceFile, refPos?: number, refEnd?: number): void { getSourceFileFromReferenceWorker(fileName, - fileName => findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, /*packageId*/ undefined), + fileName => findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId), (diagnostic, ...args) => { fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined ? createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...args) @@ -1675,7 +1675,7 @@ namespace ts { }); if (packageId) { - const packageIdKey = `${packageId.name}@${packageId.version}`; + const packageIdKey = `${packageId.name}/${packageId.subModuleName}@${packageId.version}`; const fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. @@ -1735,7 +1735,7 @@ namespace ts { function processReferencedFiles(file: SourceFile, isDefaultLib: boolean) { forEach(file.referencedFiles, ref => { const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, /*packageId*/ undefined, file, ref.pos, ref.end); }); } @@ -1766,7 +1766,7 @@ namespace ts { if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -1789,7 +1789,7 @@ namespace ts { } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1b5a0164585..c9ba56506a4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4055,6 +4055,11 @@ namespace ts { * If accessing a non-index file, this should include its name e.g. "foo/bar". */ name: string; + /** + * Name of a submodule within this package. + * May be "". + */ + subModuleName: string; /** Version of the package, e.g. "1.2.3" */ version: string; } @@ -4078,6 +4083,7 @@ namespace ts { primary: boolean; // The location of the .d.ts file we located, or undefined if resolution failed resolvedFileName?: string; + packageId?: PackageId; } export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 160d81d04da..06b8437f76b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -104,7 +104,7 @@ namespace ts { } function packageIdIsEqual(a: PackageId | undefined, b: PackageId | undefined): boolean { - return a === b || a && b && a.name === b.name && a.version === b.version; + return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } export function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean { diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index ed8dcf0c7b4..0acbe9450bb 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -198,33 +198,34 @@ namespace ts { const moduleFile = { name: "/a/b/node_modules/foo.ts" }; const resolution = nodeModuleNameResolver("foo", containingFile.name, {}, createModuleResolutionHost(hasDirectoryExists, containingFile, moduleFile)); checkResolvedModuleWithFailedLookupLocations(resolution, createResolvedModule(moduleFile.name, /*isExternalLibraryImport*/ true), [ + "/a/b/c/d/node_modules/foo/package.json", "/a/b/c/d/node_modules/foo.ts", "/a/b/c/d/node_modules/foo.tsx", "/a/b/c/d/node_modules/foo.d.ts", - "/a/b/c/d/node_modules/foo/package.json", "/a/b/c/d/node_modules/foo/index.ts", "/a/b/c/d/node_modules/foo/index.tsx", "/a/b/c/d/node_modules/foo/index.d.ts", - "/a/b/c/d/node_modules/@types/foo.d.ts", "/a/b/c/d/node_modules/@types/foo/package.json", + "/a/b/c/d/node_modules/@types/foo.d.ts", "/a/b/c/d/node_modules/@types/foo/index.d.ts", + "/a/b/c/node_modules/foo/package.json", "/a/b/c/node_modules/foo.ts", "/a/b/c/node_modules/foo.tsx", "/a/b/c/node_modules/foo.d.ts", - "/a/b/c/node_modules/foo/package.json", "/a/b/c/node_modules/foo/index.ts", "/a/b/c/node_modules/foo/index.tsx", "/a/b/c/node_modules/foo/index.d.ts", - "/a/b/c/node_modules/@types/foo.d.ts", "/a/b/c/node_modules/@types/foo/package.json", + "/a/b/c/node_modules/@types/foo.d.ts", "/a/b/c/node_modules/@types/foo/index.d.ts", + "/a/b/node_modules/foo/package.json", ]); } }); @@ -250,52 +251,52 @@ namespace ts { const moduleFile: File = { name: "/a/node_modules/foo/index.d.ts" }; const resolution = nodeModuleNameResolver("foo", containingFile.name, {}, createModuleResolutionHost(hasDirectoryExists, containingFile, moduleFile)); checkResolvedModuleWithFailedLookupLocations(resolution, createResolvedModule(moduleFile.name, /*isExternalLibraryImport*/ true), [ + "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/d/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts", - "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts", - "/a/node_modules/b/c/node_modules/d/node_modules/@types/foo.d.ts", "/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/package.json", + "/a/node_modules/b/c/node_modules/d/node_modules/@types/foo.d.ts", "/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/index.d.ts", + "/a/node_modules/b/c/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/foo.ts", "/a/node_modules/b/c/node_modules/foo.tsx", "/a/node_modules/b/c/node_modules/foo.d.ts", - "/a/node_modules/b/c/node_modules/foo/package.json", "/a/node_modules/b/c/node_modules/foo/index.ts", "/a/node_modules/b/c/node_modules/foo/index.tsx", "/a/node_modules/b/c/node_modules/foo/index.d.ts", - "/a/node_modules/b/c/node_modules/@types/foo.d.ts", "/a/node_modules/b/c/node_modules/@types/foo/package.json", + "/a/node_modules/b/c/node_modules/@types/foo.d.ts", "/a/node_modules/b/c/node_modules/@types/foo/index.d.ts", + "/a/node_modules/b/node_modules/foo/package.json", "/a/node_modules/b/node_modules/foo.ts", "/a/node_modules/b/node_modules/foo.tsx", "/a/node_modules/b/node_modules/foo.d.ts", - "/a/node_modules/b/node_modules/foo/package.json", "/a/node_modules/b/node_modules/foo/index.ts", "/a/node_modules/b/node_modules/foo/index.tsx", "/a/node_modules/b/node_modules/foo/index.d.ts", - "/a/node_modules/b/node_modules/@types/foo.d.ts", "/a/node_modules/b/node_modules/@types/foo/package.json", + "/a/node_modules/b/node_modules/@types/foo.d.ts", "/a/node_modules/b/node_modules/@types/foo/index.d.ts", + "/a/node_modules/foo/package.json", "/a/node_modules/foo.ts", "/a/node_modules/foo.tsx", "/a/node_modules/foo.d.ts", - "/a/node_modules/foo/package.json", "/a/node_modules/foo/index.ts", "/a/node_modules/foo/index.tsx" @@ -707,21 +708,23 @@ import b = require("./moduleB"); "/root/generated/file6/index.d.ts", // fallback to standard node behavior + "/root/folder1/node_modules/file6/package.json", + // load from file "/root/folder1/node_modules/file6.ts", "/root/folder1/node_modules/file6.tsx", "/root/folder1/node_modules/file6.d.ts", // load from folder - "/root/folder1/node_modules/file6/package.json", "/root/folder1/node_modules/file6/index.ts", "/root/folder1/node_modules/file6/index.tsx", "/root/folder1/node_modules/file6/index.d.ts", - "/root/folder1/node_modules/@types/file6.d.ts", - "/root/folder1/node_modules/@types/file6/package.json", + "/root/folder1/node_modules/@types/file6.d.ts", "/root/folder1/node_modules/@types/file6/index.d.ts", + + "/root/node_modules/file6/package.json", // success on /root/node_modules/file6.ts ], /*isExternalLibraryImport*/ true); diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 0c2a4a7052b..8c8c1034677 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -441,20 +441,20 @@ namespace ts { "======== Resolving module 'a' from 'file1.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", + "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a.ts' does not exist.", "File 'node_modules/a.tsx' does not exist.", "File 'node_modules/a.d.ts' does not exist.", - "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a/index.ts' does not exist.", "File 'node_modules/a/index.tsx' does not exist.", "File 'node_modules/a/index.d.ts' does not exist.", - "File 'node_modules/@types/a.d.ts' does not exist.", "File 'node_modules/@types/a/package.json' does not exist.", + "File 'node_modules/@types/a.d.ts' does not exist.", "File 'node_modules/@types/a/index.d.ts' does not exist.", "Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.", + "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a.js' does not exist.", "File 'node_modules/a.jsx' does not exist.", - "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a/index.js' does not exist.", "File 'node_modules/a/index.jsx' does not exist.", "======== Module name 'a' was not resolved. ========" @@ -474,10 +474,10 @@ namespace ts { "======== Resolving module 'a' from 'file1.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", + "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a.ts' does not exist.", "File 'node_modules/a.tsx' does not exist.", "File 'node_modules/a.d.ts' does not exist.", - "File 'node_modules/a/package.json' does not exist.", "File 'node_modules/a/index.ts' does not exist.", "File 'node_modules/a/index.tsx' does not exist.", "File 'node_modules/a/index.d.ts' exist - use it as a name resolution result.", @@ -510,14 +510,14 @@ namespace ts { "File '/fs.ts' does not exist.", "File '/fs.tsx' does not exist.", "File '/fs.d.ts' does not exist.", - "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", "File '/a/b/node_modules/@types/fs/package.json' does not exist.", + "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", "File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/a/node_modules/@types/fs.d.ts' does not exist.", "File '/a/node_modules/@types/fs/package.json' does not exist.", + "File '/a/node_modules/@types/fs.d.ts' does not exist.", "File '/a/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/node_modules/@types/fs.d.ts' does not exist.", "File '/node_modules/@types/fs/package.json' does not exist.", + "File '/node_modules/@types/fs.d.ts' does not exist.", "File '/node_modules/@types/fs/index.d.ts' does not exist.", "File '/a/b/fs.js' does not exist.", "File '/a/b/fs.jsx' does not exist.", @@ -552,14 +552,14 @@ namespace ts { "File '/fs.ts' does not exist.", "File '/fs.tsx' does not exist.", "File '/fs.d.ts' does not exist.", - "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", "File '/a/b/node_modules/@types/fs/package.json' does not exist.", + "File '/a/b/node_modules/@types/fs.d.ts' does not exist.", "File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/a/node_modules/@types/fs.d.ts' does not exist.", "File '/a/node_modules/@types/fs/package.json' does not exist.", + "File '/a/node_modules/@types/fs.d.ts' does not exist.", "File '/a/node_modules/@types/fs/index.d.ts' does not exist.", - "File '/node_modules/@types/fs.d.ts' does not exist.", "File '/node_modules/@types/fs/package.json' does not exist.", + "File '/node_modules/@types/fs.d.ts' does not exist.", "File '/node_modules/@types/fs/index.d.ts' does not exist.", "File '/a/b/fs.js' does not exist.", "File '/a/b/fs.jsx' does not exist.", diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index c9a74310977..651dbae7142 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -2510,8 +2510,8 @@ namespace ts.projectSystem { "======== Module name 'lib' was not resolved. ========", `Auto discovery for typings is enabled in project '${proj.getProjectName()}'. Running extra resolution pass for module 'lib' using cache location '/a/cache'.`, "File '/a/cache/node_modules/lib.d.ts' does not exist.", - "File '/a/cache/node_modules/@types/lib.d.ts' does not exist.", "File '/a/cache/node_modules/@types/lib/package.json' does not exist.", + "File '/a/cache/node_modules/@types/lib.d.ts' does not exist.", "File '/a/cache/node_modules/@types/lib/index.d.ts' exist - use it as a name resolution result.", ]); checkProjectActualFiles(proj, [file1.path, lib.path]); diff --git a/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.js b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.js new file mode 100644 index 00000000000..9817641484e --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts] //// + +//// [Foo.d.ts] +export default class Foo { + protected source: boolean; +} + +//// [Bar.d.ts] +// This is *not* the same! +export const x: number; + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [index.ts] +import Foo from "foo/Foo"; +import { x } from "foo/Bar"; + + +//// [index.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.symbols b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.symbols new file mode 100644 index 00000000000..2174580394b --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.symbols @@ -0,0 +1,20 @@ +=== /index.ts === +import Foo from "foo/Foo"; +>Foo : Symbol(Foo, Decl(index.ts, 0, 6)) + +import { x } from "foo/Bar"; +>x : Symbol(x, Decl(index.ts, 1, 8)) + +=== /node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Symbol(Foo, Decl(Foo.d.ts, 0, 0)) + + protected source: boolean; +>source : Symbol(Foo.source, Decl(Foo.d.ts, 0, 26)) +} + +=== /node_modules/foo/Bar.d.ts === +// This is *not* the same! +export const x: number; +>x : Symbol(x, Decl(Bar.d.ts, 1, 12)) + diff --git a/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.types b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.types new file mode 100644 index 00000000000..8b0501d46c3 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_packageIdIncludesSubModule.types @@ -0,0 +1,20 @@ +=== /index.ts === +import Foo from "foo/Foo"; +>Foo : typeof Foo + +import { x } from "foo/Bar"; +>x : number + +=== /node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Foo + + protected source: boolean; +>source : boolean +} + +=== /node_modules/foo/Bar.d.ts === +// This is *not* the same! +export const x: number; +>x : number + diff --git a/tests/baselines/reference/duplicatePackage_referenceTypes.js b/tests/baselines/reference/duplicatePackage_referenceTypes.js new file mode 100644 index 00000000000..2abd8090e07 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_referenceTypes.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/duplicatePackage_referenceTypes.ts] //// + +//// [index.d.ts] +/// +import { Foo } from "foo"; +export const foo: Foo; + +//// [index.d.ts] +export class Foo { private x; } + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [index.d.ts] +export class Foo { private x; } + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [index.ts] +import * as a from "a"; +import { Foo } from "foo"; + +let foo: Foo = a.foo; + + +//// [index.js] +"use strict"; +exports.__esModule = true; +var a = require("a"); +var foo = a.foo; diff --git a/tests/baselines/reference/duplicatePackage_referenceTypes.symbols b/tests/baselines/reference/duplicatePackage_referenceTypes.symbols new file mode 100644 index 00000000000..164da1c61d0 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_referenceTypes.symbols @@ -0,0 +1,33 @@ +=== /index.ts === +import * as a from "a"; +>a : Symbol(a, Decl(index.ts, 0, 6)) + +import { Foo } from "foo"; +>Foo : Symbol(Foo, Decl(index.ts, 1, 8)) + +let foo: Foo = a.foo; +>foo : Symbol(foo, Decl(index.ts, 3, 3)) +>Foo : Symbol(Foo, Decl(index.ts, 1, 8)) +>a.foo : Symbol(a.foo, Decl(index.d.ts, 2, 12)) +>a : Symbol(a, Decl(index.ts, 0, 6)) +>foo : Symbol(a.foo, Decl(index.d.ts, 2, 12)) + +=== /node_modules/a/index.d.ts === +/// +import { Foo } from "foo"; +>Foo : Symbol(Foo, Decl(index.d.ts, 1, 8)) + +export const foo: Foo; +>foo : Symbol(foo, Decl(index.d.ts, 2, 12)) +>Foo : Symbol(Foo, Decl(index.d.ts, 1, 8)) + +=== /node_modules/a/node_modules/foo/index.d.ts === +export class Foo { private x; } +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(index.d.ts, 0, 18)) + +=== /node_modules/@types/foo/index.d.ts === +export class Foo { private x; } +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(index.d.ts, 0, 18)) + diff --git a/tests/baselines/reference/duplicatePackage_referenceTypes.types b/tests/baselines/reference/duplicatePackage_referenceTypes.types new file mode 100644 index 00000000000..b7159e299f0 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_referenceTypes.types @@ -0,0 +1,33 @@ +=== /index.ts === +import * as a from "a"; +>a : typeof a + +import { Foo } from "foo"; +>Foo : typeof Foo + +let foo: Foo = a.foo; +>foo : Foo +>Foo : Foo +>a.foo : Foo +>a : typeof a +>foo : Foo + +=== /node_modules/a/index.d.ts === +/// +import { Foo } from "foo"; +>Foo : typeof Foo + +export const foo: Foo; +>foo : Foo +>Foo : Foo + +=== /node_modules/a/node_modules/foo/index.d.ts === +export class Foo { private x; } +>Foo : Foo +>x : any + +=== /node_modules/@types/foo/index.d.ts === +export class Foo { private x; } +>Foo : Foo +>x : any + diff --git a/tests/baselines/reference/duplicatePackage_subModule.js b/tests/baselines/reference/duplicatePackage_subModule.js new file mode 100644 index 00000000000..0a5793a79a2 --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_subModule.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/duplicatePackage_subModule.ts] //// + +//// [index.d.ts] +import Foo from "foo/Foo"; +export const o: Foo; + +//// [Foo.d.ts] +export default class Foo { + protected source: boolean; +} + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [Foo.d.ts] +export default class Foo { + protected source: boolean; +} + +//// [package.json] +{ "name": "foo", "version": "1.2.3" } + +//// [index.ts] +import Foo from "foo/Foo"; +import * as a from "a"; + +const o: Foo = a.o; + + +//// [index.js] +"use strict"; +exports.__esModule = true; +var a = require("a"); +var o = a.o; diff --git a/tests/baselines/reference/duplicatePackage_subModule.symbols b/tests/baselines/reference/duplicatePackage_subModule.symbols new file mode 100644 index 00000000000..538cd0d827d --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_subModule.symbols @@ -0,0 +1,38 @@ +=== /index.ts === +import Foo from "foo/Foo"; +>Foo : Symbol(Foo, Decl(index.ts, 0, 6)) + +import * as a from "a"; +>a : Symbol(a, Decl(index.ts, 1, 6)) + +const o: Foo = a.o; +>o : Symbol(o, Decl(index.ts, 3, 5)) +>Foo : Symbol(Foo, Decl(index.ts, 0, 6)) +>a.o : Symbol(a.o, Decl(index.d.ts, 1, 12)) +>a : Symbol(a, Decl(index.ts, 1, 6)) +>o : Symbol(a.o, Decl(index.d.ts, 1, 12)) + +=== /node_modules/a/index.d.ts === +import Foo from "foo/Foo"; +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 6)) + +export const o: Foo; +>o : Symbol(o, Decl(index.d.ts, 1, 12)) +>Foo : Symbol(Foo, Decl(index.d.ts, 0, 6)) + +=== /node_modules/a/node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Symbol(Foo, Decl(Foo.d.ts, 0, 0)) + + protected source: boolean; +>source : Symbol(Foo.source, Decl(Foo.d.ts, 0, 26)) +} + +=== /node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Symbol(Foo, Decl(Foo.d.ts, 0, 0)) + + protected source: boolean; +>source : Symbol(Foo.source, Decl(Foo.d.ts, 0, 26)) +} + diff --git a/tests/baselines/reference/duplicatePackage_subModule.types b/tests/baselines/reference/duplicatePackage_subModule.types new file mode 100644 index 00000000000..047f16d37ab --- /dev/null +++ b/tests/baselines/reference/duplicatePackage_subModule.types @@ -0,0 +1,38 @@ +=== /index.ts === +import Foo from "foo/Foo"; +>Foo : typeof Foo + +import * as a from "a"; +>a : typeof a + +const o: Foo = a.o; +>o : Foo +>Foo : Foo +>a.o : Foo +>a : typeof a +>o : Foo + +=== /node_modules/a/index.d.ts === +import Foo from "foo/Foo"; +>Foo : typeof Foo + +export const o: Foo; +>o : Foo +>Foo : Foo + +=== /node_modules/a/node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Foo + + protected source: boolean; +>source : boolean +} + +=== /node_modules/foo/Foo.d.ts === +export default class Foo { +>Foo : Foo + + protected source: boolean; +>source : boolean +} + diff --git a/tests/baselines/reference/library-reference-11.trace.json b/tests/baselines/reference/library-reference-11.trace.json index 053dc497065..ef99bb8912f 100644 --- a/tests/baselines/reference/library-reference-11.trace.json +++ b/tests/baselines/reference/library-reference-11.trace.json @@ -3,8 +3,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'.", "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", - "File '/a/node_modules/jquery.d.ts' does not exist.", "Found 'package.json' at '/a/node_modules/jquery/package.json'.", + "File '/a/node_modules/jquery.d.ts' does not exist.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/a/node_modules/jquery/jquery.d.ts'.", "File '/a/node_modules/jquery/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/a/node_modules/jquery/jquery.d.ts', result '/a/node_modules/jquery/jquery.d.ts'.", diff --git a/tests/baselines/reference/library-reference-12.trace.json b/tests/baselines/reference/library-reference-12.trace.json index d990709cac8..22b1232d30b 100644 --- a/tests/baselines/reference/library-reference-12.trace.json +++ b/tests/baselines/reference/library-reference-12.trace.json @@ -3,8 +3,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'.", "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", - "File '/a/node_modules/jquery.d.ts' does not exist.", "Found 'package.json' at '/a/node_modules/jquery/package.json'.", + "File '/a/node_modules/jquery.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'dist/jquery.d.ts' that references '/a/node_modules/jquery/dist/jquery.d.ts'.", "File '/a/node_modules/jquery/dist/jquery.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-3.trace.json b/tests/baselines/reference/library-reference-3.trace.json index 22747738c10..5b084f13738 100644 --- a/tests/baselines/reference/library-reference-3.trace.json +++ b/tests/baselines/reference/library-reference-3.trace.json @@ -2,8 +2,8 @@ "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========", "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/src'.", - "File '/src/node_modules/jquery.d.ts' does not exist.", "File '/src/node_modules/jquery/package.json' does not exist.", + "File '/src/node_modules/jquery.d.ts' does not exist.", "File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/node_modules/jquery/index.d.ts', result '/src/node_modules/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/library-reference-4.trace.json b/tests/baselines/reference/library-reference-4.trace.json index 03fdfa0e863..ceeb754bb0b 100644 --- a/tests/baselines/reference/library-reference-4.trace.json +++ b/tests/baselines/reference/library-reference-4.trace.json @@ -3,8 +3,8 @@ "Resolving with primary search path '/src'.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", - "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/package.json' does not exist.", + "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/foo/index.d.ts', result '/node_modules/foo/index.d.ts'.", "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========", @@ -12,24 +12,24 @@ "Resolving with primary search path '/src'.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", - "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/package.json' does not exist.", + "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/index.d.ts', result '/node_modules/bar/index.d.ts'.", "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory '/src'. ========", "Resolving with primary search path '/src'.", "Looking up in 'node_modules' folder, initial location '/node_modules/foo'.", - "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/foo/node_modules/alpha/index.d.ts', result '/node_modules/foo/node_modules/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========", "======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory '/src'. ========", "Resolving with primary search path '/src'.", "Looking up in 'node_modules' folder, initial location '/node_modules/bar'.", - "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/library-reference-5.trace.json b/tests/baselines/reference/library-reference-5.trace.json index cb14078670a..0cac2a8fec6 100644 --- a/tests/baselines/reference/library-reference-5.trace.json +++ b/tests/baselines/reference/library-reference-5.trace.json @@ -4,8 +4,8 @@ "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", - "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/package.json' does not exist.", + "File '/node_modules/foo.d.ts' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/foo/index.d.ts', result '/node_modules/foo/index.d.ts'.", "======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========", @@ -14,8 +14,8 @@ "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/src'.", "Directory '/src/node_modules' does not exist, skipping all lookups in it.", - "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/package.json' does not exist.", + "File '/node_modules/bar.d.ts' does not exist.", "File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/index.d.ts', result '/node_modules/bar/index.d.ts'.", "======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========", @@ -23,8 +23,8 @@ "Resolving with primary search path 'types'.", "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/foo'.", - "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/foo/node_modules/alpha/index.d.ts', result '/node_modules/foo/node_modules/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========", @@ -32,8 +32,8 @@ "Resolving with primary search path 'types'.", "Directory 'types' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/node_modules/bar'.", - "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/package.json' does not exist.", + "File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.", "File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/library-reference-7.trace.json b/tests/baselines/reference/library-reference-7.trace.json index 22747738c10..5b084f13738 100644 --- a/tests/baselines/reference/library-reference-7.trace.json +++ b/tests/baselines/reference/library-reference-7.trace.json @@ -2,8 +2,8 @@ "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========", "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/src'.", - "File '/src/node_modules/jquery.d.ts' does not exist.", "File '/src/node_modules/jquery/package.json' does not exist.", + "File '/src/node_modules/jquery.d.ts' does not exist.", "File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/node_modules/jquery/index.d.ts', result '/src/node_modules/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/library-reference-scoped-packages.trace.json b/tests/baselines/reference/library-reference-scoped-packages.trace.json index 54dcf95fe50..cfc88198201 100644 --- a/tests/baselines/reference/library-reference-scoped-packages.trace.json +++ b/tests/baselines/reference/library-reference-scoped-packages.trace.json @@ -4,8 +4,8 @@ "Directory 'types/@beep' does not exist, skipping all lookups in it.", "Looking up in 'node_modules' folder, initial location '/'.", "Scoped package detected, looking in 'beep__boop'", - "File '/node_modules/@types/beep__boop.d.ts' does not exist.", "File '/node_modules/@types/beep__boop/package.json' does not exist.", + "File '/node_modules/@types/beep__boop.d.ts' does not exist.", "File '/node_modules/@types/beep__boop/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/beep__boop/index.d.ts', result '/node_modules/@types/beep__boop/index.d.ts'.", "======== Type reference directive '@beep/boop' was successfully resolved to '/node_modules/@types/beep__boop/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json index 46f03d1e8c4..56bbee705bf 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json @@ -2,18 +2,18 @@ "======== Resolving module 'shortid' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'shortid' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/shortid/package.json' does not exist.", "File '/node_modules/shortid.ts' does not exist.", "File '/node_modules/shortid.tsx' does not exist.", "File '/node_modules/shortid.d.ts' does not exist.", - "File '/node_modules/shortid/package.json' does not exist.", "File '/node_modules/shortid/index.ts' does not exist.", "File '/node_modules/shortid/index.tsx' does not exist.", "File '/node_modules/shortid/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'shortid' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/shortid/package.json' does not exist.", "File '/node_modules/shortid.js' does not exist.", "File '/node_modules/shortid.jsx' does not exist.", - "File '/node_modules/shortid/package.json' does not exist.", "File '/node_modules/shortid/index.js' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/shortid/index.js', result '/node_modules/shortid/index.js'.", "======== Module name 'shortid' was successfully resolved to '/node_modules/shortid/index.js'. ========" diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json index 8c820e07e48..b619535487b 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json @@ -2,10 +2,10 @@ "======== Resolving module 'normalize.css' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'normalize.css' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "File '/node_modules/normalize.css.ts' does not exist.", "File '/node_modules/normalize.css.tsx' does not exist.", "File '/node_modules/normalize.css.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/normalize.css/index.ts' does not exist.", @@ -13,9 +13,9 @@ "File '/node_modules/normalize.css/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'normalize.css' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "File '/node_modules/normalize.css.js' does not exist.", "File '/node_modules/normalize.css.jsx' does not exist.", - "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "'package.json' has 'main' field 'normalize.css' that references '/node_modules/normalize.css/normalize.css'.", "File '/node_modules/normalize.css/normalize.css' exist - use it as a name resolution result.", "File '/node_modules/normalize.css/normalize.css' has an unsupported extension, so skipping it.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json index 3632a5c2242..50e7fa685a6 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json @@ -2,10 +2,10 @@ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", "File '/node_modules/foo.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'foo.js' that references '/node_modules/foo/foo.js'.", "File '/node_modules/foo/foo.js' exist - use it as a name resolution result.", @@ -24,9 +24,9 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' does not have a 'main' field.", "File '/node_modules/foo/index.js' does not exist.", "File '/node_modules/foo/index.jsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json index 6cfdb8b567e..9a0d5e095a5 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json @@ -2,18 +2,18 @@ "======== Resolving module 'js' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'js' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/js/package.json' does not exist.", "File '/node_modules/js.ts' does not exist.", "File '/node_modules/js.tsx' does not exist.", "File '/node_modules/js.d.ts' does not exist.", - "File '/node_modules/js/package.json' does not exist.", "File '/node_modules/js/index.ts' does not exist.", "File '/node_modules/js/index.tsx' does not exist.", "File '/node_modules/js/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'js' from 'node_modules' folder, target file type 'JavaScript'.", + "File '/node_modules/js/package.json' does not exist.", "File '/node_modules/js.js' does not exist.", "File '/node_modules/js.jsx' does not exist.", - "File '/node_modules/js/package.json' does not exist.", "File '/node_modules/js/index.js' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/js/index.js', result '/node_modules/js/index.js'.", "======== Module name 'js' was successfully resolved to '/node_modules/js/index.js'. ========" diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json index 2dd33953680..19e44e72d61 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks.trace.json @@ -20,10 +20,10 @@ "======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'library-a' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/src/library-b/node_modules/library-a/package.json' does not exist.", "File '/src/library-b/node_modules/library-a.ts' does not exist.", "File '/src/library-b/node_modules/library-a.tsx' does not exist.", "File '/src/library-b/node_modules/library-a.d.ts' does not exist.", - "File '/src/library-b/node_modules/library-a/package.json' does not exist.", "File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'.", "======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========" diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json index 837b740ffee..73e6a1df996 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json @@ -2,18 +2,18 @@ "======== Resolving type reference directive 'linked', containing file '/app/app.ts', root directory not set. ========", "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/app'.", - "File '/app/node_modules/linked.d.ts' does not exist.", "File '/app/node_modules/linked/package.json' does not exist.", + "File '/app/node_modules/linked.d.ts' does not exist.", "File '/app/node_modules/linked/index.d.ts' exist - use it as a name resolution result.", "======== Type reference directive 'linked' was successfully resolved to '/app/node_modules/linked/index.d.ts', primary: false. ========", "======== Resolving module 'real' from '/app/node_modules/linked/index.d.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'real' from 'node_modules' folder, target file type 'TypeScript'.", "Directory '/app/node_modules/linked/node_modules' does not exist, skipping all lookups in it.", + "File '/app/node_modules/real/package.json' does not exist.", "File '/app/node_modules/real.ts' does not exist.", "File '/app/node_modules/real.tsx' does not exist.", "File '/app/node_modules/real.d.ts' does not exist.", - "File '/app/node_modules/real/package.json' does not exist.", "File '/app/node_modules/real/index.ts' does not exist.", "File '/app/node_modules/real/index.tsx' does not exist.", "File '/app/node_modules/real/index.d.ts' exist - use it as a name resolution result.", @@ -21,10 +21,10 @@ "======== Resolving module 'linked' from '/app/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'linked' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/app/node_modules/linked/package.json' does not exist.", "File '/app/node_modules/linked.ts' does not exist.", "File '/app/node_modules/linked.tsx' does not exist.", "File '/app/node_modules/linked.d.ts' does not exist.", - "File '/app/node_modules/linked/package.json' does not exist.", "File '/app/node_modules/linked/index.ts' does not exist.", "File '/app/node_modules/linked/index.tsx' does not exist.", "File '/app/node_modules/linked/index.d.ts' exist - use it as a name resolution result.", @@ -32,10 +32,10 @@ "======== Resolving module 'linked2' from '/app/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'linked2' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/app/node_modules/linked2/package.json' does not exist.", "File '/app/node_modules/linked2.ts' does not exist.", "File '/app/node_modules/linked2.tsx' does not exist.", "File '/app/node_modules/linked2.d.ts' does not exist.", - "File '/app/node_modules/linked2/package.json' does not exist.", "File '/app/node_modules/linked2/index.ts' does not exist.", "File '/app/node_modules/linked2/index.tsx' does not exist.", "File '/app/node_modules/linked2/index.d.ts' exist - use it as a name resolution result.", @@ -44,10 +44,10 @@ "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'real' from 'node_modules' folder, target file type 'TypeScript'.", "Directory '/app/node_modules/linked2/node_modules' does not exist, skipping all lookups in it.", + "File '/app/node_modules/real/package.json' does not exist.", "File '/app/node_modules/real.ts' does not exist.", "File '/app/node_modules/real.tsx' does not exist.", "File '/app/node_modules/real.d.ts' does not exist.", - "File '/app/node_modules/real/package.json' does not exist.", "File '/app/node_modules/real/index.ts' does not exist.", "File '/app/node_modules/real/index.tsx' does not exist.", "File '/app/node_modules/real/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json index 65d89ed7458..48be1a4cda8 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_referenceTypes.trace.json @@ -3,8 +3,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/'.", "File '/node_modules/library-a.d.ts' does not exist.", - "File '/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-a/package.json' does not exist.", + "File '/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/library-a/index.d.ts', result '/node_modules/@types/library-a/index.d.ts'.", "======== Type reference directive 'library-a' was successfully resolved to '/node_modules/@types/library-a/index.d.ts', primary: false. ========", @@ -12,8 +12,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/'.", "File '/node_modules/library-b.d.ts' does not exist.", - "File '/node_modules/@types/library-b.d.ts' does not exist.", "File '/node_modules/@types/library-b/package.json' does not exist.", + "File '/node_modules/@types/library-b.d.ts' does not exist.", "File '/node_modules/@types/library-b/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/library-b/index.d.ts', result '/node_modules/@types/library-b/index.d.ts'.", "======== Type reference directive 'library-b' was successfully resolved to '/node_modules/@types/library-b/index.d.ts', primary: false. ========", @@ -21,8 +21,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/node_modules/@types/library-b'.", "File '/node_modules/@types/library-b/node_modules/library-a.d.ts' does not exist.", - "File '/node_modules/@types/library-b/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-b/node_modules/@types/library-a/package.json' does not exist.", + "File '/node_modules/@types/library-b/node_modules/@types/library-a.d.ts' does not exist.", "File '/node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts', result '/node_modules/@types/library-a/index.d.ts'.", "======== Type reference directive 'library-a' was successfully resolved to '/node_modules/@types/library-a/index.d.ts', primary: false. ========" diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json index 2dd33953680..19e44e72d61 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_withOutDir.trace.json @@ -20,10 +20,10 @@ "======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'library-a' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/src/library-b/node_modules/library-a/package.json' does not exist.", "File '/src/library-b/node_modules/library-a.ts' does not exist.", "File '/src/library-b/node_modules/library-a.tsx' does not exist.", "File '/src/library-b/node_modules/library-a.d.ts' does not exist.", - "File '/src/library-b/node_modules/library-a/package.json' does not exist.", "File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'.", "======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========" diff --git a/tests/baselines/reference/packageJsonMain.trace.json b/tests/baselines/reference/packageJsonMain.trace.json index 08daccbe479..842f70c3a02 100644 --- a/tests/baselines/reference/packageJsonMain.trace.json +++ b/tests/baselines/reference/packageJsonMain.trace.json @@ -2,10 +2,10 @@ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", "File '/node_modules/foo.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/foo/index.ts' does not exist.", @@ -13,9 +13,9 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", "File '/node_modules/foo/oof' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'JavaScript'.", @@ -25,10 +25,10 @@ "======== Resolving module 'bar' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'bar' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/bar/package.json'.", "File '/node_modules/bar.ts' does not exist.", "File '/node_modules/bar.tsx' does not exist.", "File '/node_modules/bar.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/bar/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/bar/index.ts' does not exist.", @@ -36,9 +36,9 @@ "File '/node_modules/bar/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'bar' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/bar/package.json'.", "File '/node_modules/bar.js' does not exist.", "File '/node_modules/bar.jsx' does not exist.", - "Found 'package.json' at '/node_modules/bar/package.json'.", "'package.json' has 'main' field 'rab.js' that references '/node_modules/bar/rab.js'.", "File '/node_modules/bar/rab.js' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/bar/rab.js', result '/node_modules/bar/rab.js'.", @@ -46,10 +46,10 @@ "======== Resolving module 'baz' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'baz' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/baz/package.json'.", "File '/node_modules/baz.ts' does not exist.", "File '/node_modules/baz.tsx' does not exist.", "File '/node_modules/baz.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/baz/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/baz/index.ts' does not exist.", @@ -57,9 +57,9 @@ "File '/node_modules/baz/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'baz' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/baz/package.json'.", "File '/node_modules/baz.js' does not exist.", "File '/node_modules/baz.jsx' does not exist.", - "Found 'package.json' at '/node_modules/baz/package.json'.", "'package.json' has 'main' field 'zab' that references '/node_modules/baz/zab'.", "File '/node_modules/baz/zab' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/baz/zab', target file type 'JavaScript'.", diff --git a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json index 53e1ad25605..763c86730ba 100644 --- a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json +++ b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json @@ -2,10 +2,10 @@ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", "File '/node_modules/foo.d.ts' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", "File '/node_modules/foo/index.ts' does not exist.", @@ -13,9 +13,9 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", "File '/node_modules/foo/oof' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'JavaScript'.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json index 6ac06e1dda1..ef2cb3b367f 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.trace.json @@ -23,10 +23,10 @@ "Loading module 'file4' from 'node_modules' folder, target file type 'TypeScript'.", "Directory 'c:/root/folder2/node_modules' does not exist, skipping all lookups in it.", "Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.", + "File 'c:/node_modules/file4/package.json' does not exist.", "File 'c:/node_modules/file4.ts' does not exist.", "File 'c:/node_modules/file4.tsx' does not exist.", "File 'c:/node_modules/file4.d.ts' does not exist.", - "File 'c:/node_modules/file4/package.json' does not exist.", "File 'c:/node_modules/file4/index.ts' does not exist.", "File 'c:/node_modules/file4/index.tsx' does not exist.", "File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json index 6ac06e1dda1..ef2cb3b367f 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.trace.json @@ -23,10 +23,10 @@ "Loading module 'file4' from 'node_modules' folder, target file type 'TypeScript'.", "Directory 'c:/root/folder2/node_modules' does not exist, skipping all lookups in it.", "Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.", + "File 'c:/node_modules/file4/package.json' does not exist.", "File 'c:/node_modules/file4.ts' does not exist.", "File 'c:/node_modules/file4.tsx' does not exist.", "File 'c:/node_modules/file4.d.ts' does not exist.", - "File 'c:/node_modules/file4/package.json' does not exist.", "File 'c:/node_modules/file4/index.ts' does not exist.", "File 'c:/node_modules/file4/index.tsx' does not exist.", "File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/scopedPackages.trace.json b/tests/baselines/reference/scopedPackages.trace.json index 20df3bec172..a2b8af48266 100644 --- a/tests/baselines/reference/scopedPackages.trace.json +++ b/tests/baselines/reference/scopedPackages.trace.json @@ -2,10 +2,10 @@ "======== Resolving module '@cow/boy' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@cow/boy' from 'node_modules' folder, target file type 'TypeScript'.", + "File '/node_modules/@cow/package.json' does not exist.", "File '/node_modules/@cow/boy.ts' does not exist.", "File '/node_modules/@cow/boy.tsx' does not exist.", "File '/node_modules/@cow/boy.d.ts' does not exist.", - "File '/node_modules/@cow/boy/package.json' does not exist.", "File '/node_modules/@cow/boy/index.ts' does not exist.", "File '/node_modules/@cow/boy/index.tsx' does not exist.", "File '/node_modules/@cow/boy/index.d.ts' exist - use it as a name resolution result.", @@ -15,8 +15,8 @@ "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@be/bop' from 'node_modules' folder, target file type 'TypeScript'.", "Scoped package detected, looking in 'be__bop'", - "File '/node_modules/@types/be__bop.d.ts' does not exist.", "File '/node_modules/@types/be__bop/package.json' does not exist.", + "File '/node_modules/@types/be__bop.d.ts' does not exist.", "File '/node_modules/@types/be__bop/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/be__bop/index.d.ts', result '/node_modules/@types/be__bop/index.d.ts'.", "======== Module name '@be/bop' was successfully resolved to '/node_modules/@types/be__bop/index.d.ts'. ========", @@ -24,6 +24,7 @@ "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@be/bop/e/z' from 'node_modules' folder, target file type 'TypeScript'.", "Scoped package detected, looking in 'be__bop/e/z'", + "File '/node_modules/@types/be__bop/package.json' does not exist.", "File '/node_modules/@types/be__bop/e/z.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/be__bop/e/z.d.ts', result '/node_modules/@types/be__bop/e/z.d.ts'.", "======== Module name '@be/bop/e/z' was successfully resolved to '/node_modules/@types/be__bop/e/z.d.ts'. ========" diff --git a/tests/baselines/reference/scopedPackagesClassic.trace.json b/tests/baselines/reference/scopedPackagesClassic.trace.json index c58c7d2ed10..b28156d1c33 100644 --- a/tests/baselines/reference/scopedPackagesClassic.trace.json +++ b/tests/baselines/reference/scopedPackagesClassic.trace.json @@ -2,8 +2,8 @@ "======== Resolving module '@see/saw' from '/a.ts'. ========", "Explicitly specified module resolution kind: 'Classic'.", "Scoped package detected, looking in 'see__saw'", - "File '/node_modules/@types/see__saw.d.ts' does not exist.", "File '/node_modules/@types/see__saw/package.json' does not exist.", + "File '/node_modules/@types/see__saw.d.ts' does not exist.", "File '/node_modules/@types/see__saw/index.d.ts' exist - use it as a name resolution result.", "======== Module name '@see/saw' was successfully resolved to '/node_modules/@types/see__saw/index.d.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup4.trace.json b/tests/baselines/reference/typingsLookup4.trace.json index d2087308d8e..133ea49c22a 100644 --- a/tests/baselines/reference/typingsLookup4.trace.json +++ b/tests/baselines/reference/typingsLookup4.trace.json @@ -5,8 +5,8 @@ "File '/node_modules/jquery.ts' does not exist.", "File '/node_modules/jquery.tsx' does not exist.", "File '/node_modules/jquery.d.ts' does not exist.", - "File '/node_modules/@types/jquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", "File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'.", @@ -17,8 +17,8 @@ "File '/node_modules/kquery.ts' does not exist.", "File '/node_modules/kquery.tsx' does not exist.", "File '/node_modules/kquery.d.ts' does not exist.", - "File '/node_modules/@types/kquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", + "File '/node_modules/@types/kquery.d.ts' does not exist.", "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", "File '/node_modules/@types/kquery/kquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/kquery/kquery', target file type 'TypeScript'.", @@ -33,8 +33,8 @@ "File '/node_modules/lquery.ts' does not exist.", "File '/node_modules/lquery.tsx' does not exist.", "File '/node_modules/lquery.d.ts' does not exist.", - "File '/node_modules/@types/lquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", + "File '/node_modules/@types/lquery.d.ts' does not exist.", "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", "File '/node_modules/@types/lquery/lquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/lquery/lquery', target file type 'TypeScript'.", @@ -47,8 +47,8 @@ "File '/node_modules/mquery.ts' does not exist.", "File '/node_modules/mquery.tsx' does not exist.", "File '/node_modules/mquery.d.ts' does not exist.", - "File '/node_modules/@types/mquery.d.ts' does not exist.", "Found 'package.json' at '/node_modules/@types/mquery/package.json'.", + "File '/node_modules/@types/mquery.d.ts' does not exist.", "'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.", "File '/node_modules/@types/mquery/mquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/mquery/mquery', target file type 'TypeScript'.", diff --git a/tests/baselines/reference/typingsLookupAmd.trace.json b/tests/baselines/reference/typingsLookupAmd.trace.json index ca64cf8fdf4..f18f63e7597 100644 --- a/tests/baselines/reference/typingsLookupAmd.trace.json +++ b/tests/baselines/reference/typingsLookupAmd.trace.json @@ -11,8 +11,8 @@ "File '/b.tsx' does not exist.", "File '/b.d.ts' does not exist.", "Directory '/x/y/node_modules' does not exist, skipping all lookups in it.", - "File '/x/node_modules/@types/b.d.ts' does not exist.", "File '/x/node_modules/@types/b/package.json' does not exist.", + "File '/x/node_modules/@types/b.d.ts' does not exist.", "File '/x/node_modules/@types/b/index.d.ts' exist - use it as a name resolution result.", "======== Module name 'b' was successfully resolved to '/x/node_modules/@types/b/index.d.ts'. ========", "======== Resolving module 'a' from '/x/node_modules/@types/b/index.d.ts'. ========", @@ -35,8 +35,8 @@ "Directory '/x/node_modules/@types/b/node_modules' does not exist, skipping all lookups in it.", "Directory '/x/node_modules/@types/node_modules' does not exist, skipping all lookups in it.", "File '/x/node_modules/@types/a.d.ts' does not exist.", - "File '/node_modules/@types/a.d.ts' does not exist.", "File '/node_modules/@types/a/package.json' does not exist.", + "File '/node_modules/@types/a.d.ts' does not exist.", "File '/node_modules/@types/a/index.d.ts' exist - use it as a name resolution result.", "======== Module name 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts'. ========", "======== Resolving type reference directive 'a', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", diff --git a/tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts b/tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts new file mode 100644 index 00000000000..19f56ed1325 --- /dev/null +++ b/tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts @@ -0,0 +1,17 @@ +// @noImplicitReferences: true + +// @Filename: /node_modules/foo/Foo.d.ts +export default class Foo { + protected source: boolean; +} + +// @Filename: /node_modules/foo/Bar.d.ts +// This is *not* the same! +export const x: number; + +// @Filename: /node_modules/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /index.ts +import Foo from "foo/Foo"; +import { x } from "foo/Bar"; diff --git a/tests/cases/compiler/duplicatePackage_referenceTypes.ts b/tests/cases/compiler/duplicatePackage_referenceTypes.ts new file mode 100644 index 00000000000..c6534fff70c --- /dev/null +++ b/tests/cases/compiler/duplicatePackage_referenceTypes.ts @@ -0,0 +1,24 @@ +// @noImplicitReferences: true + +// @Filename: /node_modules/a/index.d.ts +/// +import { Foo } from "foo"; +export const foo: Foo; + +// @Filename: /node_modules/a/node_modules/foo/index.d.ts +export class Foo { private x; } + +// @Filename: /node_modules/a/node_modules/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /node_modules/@types/foo/index.d.ts +export class Foo { private x; } + +// @Filename: /node_modules/@types/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /index.ts +import * as a from "a"; +import { Foo } from "foo"; + +let foo: Foo = a.foo; diff --git a/tests/cases/compiler/duplicatePackage_subModule.ts b/tests/cases/compiler/duplicatePackage_subModule.ts new file mode 100644 index 00000000000..4c704772eaf --- /dev/null +++ b/tests/cases/compiler/duplicatePackage_subModule.ts @@ -0,0 +1,27 @@ +// @noImplicitReferences: true + +// @Filename: /node_modules/a/index.d.ts +import Foo from "foo/Foo"; +export const o: Foo; + +// @Filename: /node_modules/a/node_modules/foo/Foo.d.ts +export default class Foo { + protected source: boolean; +} + +// @Filename: /node_modules/a/node_modules/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /node_modules/foo/Foo.d.ts +export default class Foo { + protected source: boolean; +} + +// @Filename: /node_modules/foo/package.json +{ "name": "foo", "version": "1.2.3" } + +// @Filename: /index.ts +import Foo from "foo/Foo"; +import * as a from "a"; + +const o: Foo = a.o; From 0e50da62c47368e7141301d0cf4e9cc105497ef2 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 13:11:21 -0700 Subject: [PATCH 091/216] Handle the combination of a write and a void return When the return type is void, there's no `returnValueProperty`, but that doesn't mean we don't need a `return` at the call site. Fixes #18140. --- src/harness/unittests/extractMethods.ts | 7 +++++ src/services/refactors/extractMethod.ts | 4 +++ .../extractMethod/extractMethod21.ts | 26 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/baselines/reference/extractMethod/extractMethod21.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index c8b4b35ff1c..6fe57895725 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -613,6 +613,13 @@ namespace A { [#|let a1 = { x: 1 }; return a1.x + 10;|] } +}`); + // Write + void return + testExtractMethod("extractMethod21", + `function foo() { + let x = 10; + [#|x++; + return;|] }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 25a995dc231..c497b126759 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -748,6 +748,10 @@ namespace ts.refactor.extractMethod { } else { newNodes.push(createStatement(createBinary(assignments[0].name, SyntaxKind.EqualsToken, call))); + + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(createReturn()); + } } } else { diff --git a/tests/baselines/reference/extractMethod/extractMethod21.ts b/tests/baselines/reference/extractMethod/extractMethod21.ts new file mode 100644 index 00000000000..4b73a6ed3c7 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod21.ts @@ -0,0 +1,26 @@ +// ==ORIGINAL== +function foo() { + let x = 10; + x++; + return; +} +// ==SCOPE::function 'foo'== +function foo() { + let x = 10; + return newFunction(); + + function newFunction() { + x++; + return; + } +} +// ==SCOPE::global scope== +function foo() { + let x = 10; + x = newFunction(x); + return; +} +function newFunction(x: number) { + x++; + return x; +} From 27f9cdb1aec60c60ed2af52c2e4f470f6ee7dcbe Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 7 Sep 2017 15:54:24 -0700 Subject: [PATCH 092/216] Explicitly avoid canonicalizing paths during configuration handling (#18316) * Explicitly avoid canonicalizing paths during configuration handling * Extract usage of identity in commandLineParser into single function, use identity in checker --- src/compiler/checker.ts | 5 +---- src/compiler/commandLineParser.ts | 12 +++++++++--- src/compiler/core.ts | 3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b05b69ef52..9c72a064b11 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -58,6 +58,7 @@ namespace ts { let symbolInstantiationDepth = 0; const emptySymbols = createSymbolTable(); + const identityMapper: (type: Type) => Type = identity; const compilerOptions = host.getCompilerOptions(); const languageVersion = getEmitScriptTarget(compilerOptions); @@ -8119,10 +8120,6 @@ namespace ts { mapper; } - function identityMapper(type: Type): Type { - return type; - } - function combineTypeMappers(mapper1: TypeMapper, mapper2: TypeMapper): TypeMapper { return t => instantiateType(mapper1(t), mapper2); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index dc9c2ad35ed..54e5ee1d01d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1385,6 +1385,12 @@ namespace ts { return x === undefined || x === null; } + function directoryOfCombinedPath(fileName: string, basePath: string) { + // Use the `identity` function to avoid canonicalizing the path, as it must remain noncanonical + // until consistient casing errors are reported + return getDirectoryPath(toPath(fileName, basePath, identity)); + } + /** * Parse the contents of a config file from json or json source file (tsconfig.json). * @param json The contents of the config file to parse @@ -1467,7 +1473,7 @@ namespace ts { includeSpecs = ["**/*"]; } - const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? getDirectoryPath(toPath(configFileName, basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames))) : basePath, options, host, errors, extraFileExtensions, sourceFile); + const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push( @@ -1577,7 +1583,7 @@ namespace ts { errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath; + const newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, createCompilerDiagnostic); } } @@ -1610,7 +1616,7 @@ namespace ts { onSetValidOptionKeyValueInRoot(key: string, _keyNode: PropertyName, value: CompilerOptionsValue, valueNode: Expression) { switch (key) { case "extends": - const newBase = configFileName ? getDirectoryPath(toPath(configFileName, basePath, getCanonicalFileName)) : basePath; + const newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; extendedConfigPath = getExtendsConfigPath( value, host, diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 8ad12a14011..f5e2a4069e4 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1228,6 +1228,9 @@ namespace ts { /** Does nothing. */ export function noop(): void {} + /** Returns its argument. */ + export function identity(x: T) { return x; } + /** Throws an error because a function is not implemented. */ export function notImplemented(): never { throw new Error("Not implemented"); From 4885560cb4a12c41f172c1bfdeedea806400b3e3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 7 Sep 2017 16:02:00 -0700 Subject: [PATCH 093/216] Eliminate intersections of unit types in union types --- src/compiler/checker.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 91653c140c8..379bc3377d2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7302,7 +7302,11 @@ namespace ts { if (flags & TypeFlags.Null) typeSet.containsNull = true; if (!(flags & TypeFlags.ContainsWideningType)) typeSet.containsNonWideningType = true; } - else if (!(flags & TypeFlags.Never)) { + else if (!(flags & TypeFlags.Never || flags & TypeFlags.Intersection && every((type).types, isUnitType))) { + // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are + // another form of 'never' (in that they have an empty value domain). We could in theory turn + // intersections of unit types into 'never' upon construction, but deferring the reduction makes it + // easier to reason about their origin. if (flags & TypeFlags.String) typeSet.containsString = true; if (flags & TypeFlags.Number) typeSet.containsNumber = true; if (flags & TypeFlags.StringOrNumberLiteral) typeSet.containsStringOrNumberLiteral = true; From 9d11fbb9b9c4e7fbbc4a54d1b95d41e28e13ea42 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 13:25:35 -0700 Subject: [PATCH 094/216] Correct permitted jumps check --- src/services/refactors/extractMethod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index c497b126759..e4fd0e85dc2 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -417,7 +417,7 @@ namespace ts.refactor.extractMethod { } } else { - if (!(permittedJumps & (SyntaxKind.BreakStatement ? PermittedJumps.Break : PermittedJumps.Continue))) { + if (!(permittedJumps & (node.kind === SyntaxKind.BreakStatement ? PermittedJumps.Break : PermittedJumps.Continue))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); } From a81fa7a801c7eff1865bcc2cd451bfc618ce832b Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 13:55:18 -0700 Subject: [PATCH 095/216] Make permittedJumps a parameter to eliminate save-restore pattern --- src/services/refactors/extractMethod.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index e4fd0e85dc2..b73613350a8 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -293,14 +293,13 @@ namespace ts.refactor.extractMethod { } let errors: Diagnostic[]; - let permittedJumps = PermittedJumps.Return; let seenLabels: Array<__String>; - visit(nodeToCheck); + visit(nodeToCheck, PermittedJumps.Return); return errors; - function visit(node: Node) { + function visit(node: Node, permittedJumps: PermittedJumps) { if (errors) { // already found an error - can stop now return true; @@ -351,7 +350,6 @@ namespace ts.refactor.extractMethod { // do not dive into functions or classes return false; } - const savedPermittedJumps = permittedJumps; if (node.parent) { switch (node.parent.kind) { case SyntaxKind.IfStatement: @@ -402,7 +400,7 @@ namespace ts.refactor.extractMethod { { const label = (node).label; (seenLabels || (seenLabels = [])).push(label.escapedText); - forEachChild(node, visit); + forEachChild(node, child => visit(child, permittedJumps)); seenLabels.pop(); break; } @@ -439,11 +437,10 @@ namespace ts.refactor.extractMethod { } break; default: - forEachChild(node, visit); + forEachChild(node, child => visit(child, permittedJumps)); break; } - permittedJumps = savedPermittedJumps; } } } From e3808b65d4291c982cba374d336d65b1be87fae2 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 14:23:11 -0700 Subject: [PATCH 096/216] Simplify and correct PermittedJumps computation 1. It was looking at the parent which wasn't guaranteed to be in the extracted range. 2. It was checking direct, rather than indirect containment - apparently to avoid applying the rules to certain expressions (which can't contain jumps anyway, unless they're in anonymous functions, in which case they're fine). Fixes #18144 --- src/harness/unittests/extractMethods.ts | 35 ++++++++++ src/services/refactors/extractMethod.ts | 64 ++++++++----------- .../extractMethod/extractMethod22.ts | 31 +++++++++ 3 files changed, 91 insertions(+), 39 deletions(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod22.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 6fe57895725..02ddbf4cae3 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -378,6 +378,32 @@ namespace A { "Cannot extract range containing conditional return statement." ]); + testExtractRangeFailed("extractRangeFailed7", + ` +function test(x: number) { + while (x) { + x--; + [#|break;|] + } +} + `, + [ + "Cannot extract range containing conditional break or continue statements." + ]); + + testExtractRangeFailed("extractRangeFailed8", + ` +function test(x: number) { + switch (x) { + case 1: + [#|break;|] + } +} + `, + [ + "Cannot extract range containing conditional break or continue statements." + ]); + testExtractMethod("extractMethod1", `namespace A { let x = 1; @@ -620,6 +646,15 @@ namespace A { let x = 10; [#|x++; return;|] +}`); + // Write + void return + testExtractMethod("extractMethod22", + `function test() { + try { + } + finally { + [#|return 1;|] + } }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index b73613350a8..c0031f26cc8 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -350,45 +350,31 @@ namespace ts.refactor.extractMethod { // do not dive into functions or classes return false; } - if (node.parent) { - switch (node.parent.kind) { - case SyntaxKind.IfStatement: - if ((node.parent).thenStatement === node || (node.parent).elseStatement === node) { - // forbid all jumps inside thenStatement or elseStatement - permittedJumps = PermittedJumps.None; - } - break; - case SyntaxKind.TryStatement: - if ((node.parent).tryBlock === node) { - // forbid all jumps inside try blocks - permittedJumps = PermittedJumps.None; - } - else if ((node.parent).finallyBlock === node) { - // allow unconditional returns from finally blocks - permittedJumps = PermittedJumps.Return; - } - break; - case SyntaxKind.CatchClause: - if ((node.parent).block === node) { - // forbid all jumps inside the block of catch clause - permittedJumps = PermittedJumps.None; - } - break; - case SyntaxKind.CaseClause: - if ((node).expression !== node) { - // allow unlabeled break inside case clauses - permittedJumps |= PermittedJumps.Break; - } - break; - default: - if (isIterationStatement(node.parent, /*lookInLabeledStatements*/ false)) { - if ((node.parent).statement === node) { - // allow unlabeled break/continue inside loops - permittedJumps |= PermittedJumps.Break | PermittedJumps.Continue; - } - } - break; - } + + switch (node.kind) { + case SyntaxKind.IfStatement: + permittedJumps = PermittedJumps.None; + break; + case SyntaxKind.TryStatement: + // forbid all jumps inside try blocks + permittedJumps = PermittedJumps.None; + break; + case SyntaxKind.Block: + if (node.parent && node.parent.kind === SyntaxKind.TryStatement && (node).finallyBlock === node) { + // allow unconditional returns from finally blocks + permittedJumps = PermittedJumps.Return; + } + break; + case SyntaxKind.CaseClause: + // allow unlabeled break inside case clauses + permittedJumps |= PermittedJumps.Break; + break; + default: + if (isIterationStatement(node, /*lookInLabeledStatements*/ false)) { + // allow unlabeled break/continue inside loops + permittedJumps |= PermittedJumps.Break | PermittedJumps.Continue; + } + break; } switch (node.kind) { diff --git a/tests/baselines/reference/extractMethod/extractMethod22.ts b/tests/baselines/reference/extractMethod/extractMethod22.ts new file mode 100644 index 00000000000..7603c01681f --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod22.ts @@ -0,0 +1,31 @@ +// ==ORIGINAL== +function test() { + try { + } + finally { + return 1; + } +} +// ==SCOPE::function 'test'== +function test() { + try { + } + finally { + return newFunction(); + } + + function newFunction() { + return 1; + } +} +// ==SCOPE::global scope== +function test() { + try { + } + finally { + return newFunction(); + } +} +function newFunction() { + return 1; +} From 73bc0c9796ce2e294e8b0fa1a1dec46da1268187 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 30 Aug 2017 14:36:20 -0700 Subject: [PATCH 097/216] Correct copied comment --- src/harness/unittests/extractMethods.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 02ddbf4cae3..75404d12bf0 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -647,7 +647,7 @@ function test(x: number) { [#|x++; return;|] }`); - // Write + void return + // Return in finally block testExtractMethod("extractMethod22", `function test() { try { From baefdd2ccb21542b7aeab8b6f825e45c516566da Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 7 Sep 2017 15:36:32 -0700 Subject: [PATCH 098/216] Revert "Make permittedJumps a parameter to eliminate save-restore pattern" This reverts commit 57906fe90e8efd2fb285fcb67f018c0438ba06dd. --- src/services/refactors/extractMethod.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index c0031f26cc8..83908def444 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -293,13 +293,14 @@ namespace ts.refactor.extractMethod { } let errors: Diagnostic[]; + let permittedJumps = PermittedJumps.Return; let seenLabels: Array<__String>; - visit(nodeToCheck, PermittedJumps.Return); + visit(nodeToCheck); return errors; - function visit(node: Node, permittedJumps: PermittedJumps) { + function visit(node: Node) { if (errors) { // already found an error - can stop now return true; @@ -350,6 +351,7 @@ namespace ts.refactor.extractMethod { // do not dive into functions or classes return false; } + const savedPermittedJumps = permittedJumps; switch (node.kind) { case SyntaxKind.IfStatement: @@ -386,7 +388,7 @@ namespace ts.refactor.extractMethod { { const label = (node).label; (seenLabels || (seenLabels = [])).push(label.escapedText); - forEachChild(node, child => visit(child, permittedJumps)); + forEachChild(node, visit); seenLabels.pop(); break; } @@ -423,10 +425,11 @@ namespace ts.refactor.extractMethod { } break; default: - forEachChild(node, child => visit(child, permittedJumps)); + forEachChild(node, visit); break; } + permittedJumps = savedPermittedJumps; } } } From 7aac67b9b4d42e4bdaa872c267465a268f0bd7a4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 16:22:16 -0700 Subject: [PATCH 099/216] Test: parsing of two-line @typedef jsdoc --- tests/baselines/reference/jsdocTwoLineTypedef.js | 10 ++++++++++ tests/baselines/reference/jsdocTwoLineTypedef.symbols | 9 +++++++++ tests/baselines/reference/jsdocTwoLineTypedef.types | 9 +++++++++ tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts | 6 ++++++ 4 files changed, 34 insertions(+) create mode 100644 tests/baselines/reference/jsdocTwoLineTypedef.js create mode 100644 tests/baselines/reference/jsdocTwoLineTypedef.symbols create mode 100644 tests/baselines/reference/jsdocTwoLineTypedef.types create mode 100644 tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts diff --git a/tests/baselines/reference/jsdocTwoLineTypedef.js b/tests/baselines/reference/jsdocTwoLineTypedef.js new file mode 100644 index 00000000000..b48d6a89a21 --- /dev/null +++ b/tests/baselines/reference/jsdocTwoLineTypedef.js @@ -0,0 +1,10 @@ +//// [jsdocTwoLineTypedef.ts] +// Regression from #18301 +/** + * @typedef LoadCallback + * @type {function} + */ +type LoadCallback = void; + + +//// [jsdocTwoLineTypedef.js] diff --git a/tests/baselines/reference/jsdocTwoLineTypedef.symbols b/tests/baselines/reference/jsdocTwoLineTypedef.symbols new file mode 100644 index 00000000000..80a69e5f52c --- /dev/null +++ b/tests/baselines/reference/jsdocTwoLineTypedef.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts === +// Regression from #18301 +/** + * @typedef LoadCallback + * @type {function} + */ +type LoadCallback = void; +>LoadCallback : Symbol(LoadCallback, Decl(jsdocTwoLineTypedef.ts, 0, 0)) + diff --git a/tests/baselines/reference/jsdocTwoLineTypedef.types b/tests/baselines/reference/jsdocTwoLineTypedef.types new file mode 100644 index 00000000000..5e0d05b3feb --- /dev/null +++ b/tests/baselines/reference/jsdocTwoLineTypedef.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts === +// Regression from #18301 +/** + * @typedef LoadCallback + * @type {function} + */ +type LoadCallback = void; +>LoadCallback : void + diff --git a/tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts b/tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts new file mode 100644 index 00000000000..2a7ad0d7dbf --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocTwoLineTypedef.ts @@ -0,0 +1,6 @@ +// Regression from #18301 +/** + * @typedef LoadCallback + * @type {function} + */ +type LoadCallback = void; From fb5e8c611083c92f9744847957d2014d65025e6b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 16:37:13 -0700 Subject: [PATCH 100/216] Fix forEachChild's visit of JSDocTypedefTag Also remove JSDocTypeLiteral.jsdocTypeTag, which made no sense since it was only useful when storing information for its parent `@typedef` tag. --- src/compiler/parser.ts | 16 +++++++++------- src/compiler/types.ts | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b0782b6707a..f81254572b7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -438,8 +438,10 @@ namespace ts { visitNode(cbNode, (node).typeExpression); } case SyntaxKind.JSDocTypeLiteral: - for (const tag of (node as JSDocTypeLiteral).jsDocPropertyTags) { - visitNode(cbNode, tag); + if ((node as JSDocTypeLiteral).jsDocPropertyTags) { + for (const tag of (node as JSDocTypeLiteral).jsDocPropertyTags) { + visitNode(cbNode, tag); + } } return; case SyntaxKind.PartiallyEmittedExpression: @@ -6672,19 +6674,18 @@ namespace ts { if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { let child: JSDocTypeTag | JSDocPropertyTag | false; let jsdocTypeLiteral: JSDocTypeLiteral; - let alreadyHasTypeTag = false; + let childTypeTag: JSDocTypeTag; const start = scanner.getStartPos(); while (child = tryParse(() => parseChildParameterOrPropertyTag(PropertyLikeParse.Property))) { if (!jsdocTypeLiteral) { jsdocTypeLiteral = createNode(SyntaxKind.JSDocTypeLiteral, start); } if (child.kind === SyntaxKind.JSDocTypeTag) { - if (alreadyHasTypeTag) { + if (childTypeTag) { break; } else { - jsdocTypeLiteral.jsDocTypeTag = child; - alreadyHasTypeTag = true; + childTypeTag = child; } } else { @@ -6698,7 +6699,8 @@ namespace ts { if (typeExpression && typeExpression.type.kind === SyntaxKind.ArrayType) { jsdocTypeLiteral.isArrayType = true; } - typedefTag.typeExpression = finishNode(jsdocTypeLiteral); + const useChildTypeTagAsType = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type); + typedefTag.typeExpression = useChildTypeTagAsType ? childTypeTag.typeExpression : finishNode(jsdocTypeLiteral); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 55baf9763c2..3a3736a5ceb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2211,7 +2211,6 @@ namespace ts { export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; jsDocPropertyTags?: ReadonlyArray; - jsDocTypeTag?: JSDocTypeTag; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } From 7d5b5e957ece7c3062bfe7478ed760dd4ee6d389 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 7 Sep 2017 16:38:17 -0700 Subject: [PATCH 101/216] Update baselines --- ...sCorrectly.typedefTagWithChildrenTags.json | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json index f0e42ae6325..08d270286b9 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json @@ -34,38 +34,6 @@ "kind": "JSDocTypeLiteral", "pos": 26, "end": 98, - "jsDocTypeTag": { - "kind": "JSDocTypeTag", - "pos": 28, - "end": 42, - "atToken": { - "kind": "AtToken", - "pos": 28, - "end": 29 - }, - "tagName": { - "kind": "Identifier", - "pos": 29, - "end": 33, - "escapedText": "type" - }, - "typeExpression": { - "kind": "JSDocTypeExpression", - "pos": 34, - "end": 42, - "type": { - "kind": "TypeReference", - "pos": 35, - "end": 41, - "typeName": { - "kind": "Identifier", - "pos": 35, - "end": 41, - "escapedText": "Object" - } - } - } - }, "jsDocPropertyTags": [ { "kind": "JSDocPropertyTag", From 9eecf8ca56e504874e64e5a9fb221c7c78adeb5f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 06:35:14 -0700 Subject: [PATCH 102/216] Report error on first token of excessively large function or module body --- src/compiler/checker.ts | 21 +++++++++++++-------- src/compiler/diagnosticMessages.json | 2 +- src/compiler/utilities.ts | 5 +++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c3e3473e3f8..06e21e18501 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11486,6 +11486,13 @@ namespace ts { return false; } + function reportFlowControlError(node: Node) { + const block = findAncestor(node, isFunctionOrModuleBlock); + const sourceFile = getSourceFileOfNode(node); + const span = getSpanOfTokenAtPosition(sourceFile, block.statements.pos); + diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); + } + function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; let flowLength = 0; @@ -11509,15 +11516,15 @@ namespace ts { return resultType; function getTypeAtFlowNode(flow: FlowNode): FlowType { - const saveFlowLength = flowLength; + flowLength++; while (true) { flowLength++; - if (flowLength === 5000) { - // The length of this particular control flow path is 5000 nodes or more. Rather than spending an - // excessive amount of time and possibly overflowing the call stack, we report an error and disable - // further control flow analysis in the containing function or module body. + if (flowLength >= 5000) { + // We have visited as many as 5000 nodes through as many as 2500 recursive invocations. Rather than + // spending an excessive amount of time and possibly overflowing the call stack, we report an error + // and disable further control flow analysis in the containing function or module body. flowAnalysisDisabled = true; - error(reference, Diagnostics.The_body_of_the_containing_function_or_module_is_too_large_for_control_flow_analysis); + reportFlowControlError(reference); return unknownType; } const flags = flow.flags; @@ -11527,7 +11534,6 @@ namespace ts { // antecedent of more than one node. for (let i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { - flowLength = saveFlowLength; return visitedFlowTypes[i]; } } @@ -11595,7 +11601,6 @@ namespace ts { visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; } - flowLength = saveFlowLength; return type; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b3668cc5acf..5cfa5f12731 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1920,7 +1920,7 @@ "category": "Error", "code": 2562 }, - "The body of the containing function or module is too large for control flow analysis.": { + "The containing function or module body is too large for control flow analysis.": { "category": "Error", "code": 2563 }, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2a07d2b6560..7c3dce15448 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4790,6 +4790,11 @@ namespace ts { return false; } + /* @internal */ + export function isFunctionOrModuleBlock(node: Node): boolean { + return isSourceFile(node) || isModuleBlock(node) || isBlock(node) && isFunctionLike(node.parent); + } + // Classes export function isClassElement(node: Node): node is ClassElement { const kind = node.kind; From 4ee7d3aeb20949dc30108236310aaf4cd7c91613 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 8 Sep 2017 07:18:37 -0700 Subject: [PATCH 103/216] Remove unnecessary check in emitNodeList (#18327) --- src/compiler/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5abeecd4107..8788e0c02f4 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2415,7 +2415,7 @@ namespace ts { return; } - const isEmpty = isUndefined || children.length === 0 || start >= children.length || count === 0; + const isEmpty = isUndefined || start >= children.length || count === 0; if (isEmpty && format & ListFormat.OptionalIfEmpty) { return; } From cab05ddd3fe70661a3c30bf2a912a444e9d4be55 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 8 Sep 2017 08:33:17 -0700 Subject: [PATCH 104/216] Inline variable to aid control flow --- src/compiler/parser.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f81254572b7..826f41d6bed 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6699,8 +6699,9 @@ namespace ts { if (typeExpression && typeExpression.type.kind === SyntaxKind.ArrayType) { jsdocTypeLiteral.isArrayType = true; } - const useChildTypeTagAsType = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type); - typedefTag.typeExpression = useChildTypeTagAsType ? childTypeTag.typeExpression : finishNode(jsdocTypeLiteral); + typedefTag.typeExpression = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? + childTypeTag.typeExpression : + finishNode(jsdocTypeLiteral); } } From 4966c65b7fa7e8370e4861a994fc1d55b9a5cc18 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 8 Sep 2017 20:15:39 +0100 Subject: [PATCH 105/216] Revert changes to other baselines --- .../reference/assignmentTypeNarrowing.js | 8 +- .../reference/asyncMethodWithSuper_es5.js | 4 +- .../blockScopedBindingUsedBeforeDef.js | 4 +- .../computedPropertiesInDestructuring1.js | 12 +- .../computedPropertiesInDestructuring2.js | 2 +- .../contextuallyTypedBindingInitializer.js | 2 +- ...extuallyTypedBindingInitializerNegative.js | 2 +- .../controlFlowDestructuringDeclaration.js | 18 +- ...onEmitDestructuringObjectLiteralPattern.js | 8 +- ...nEmitDestructuringObjectLiteralPattern1.js | 8 +- .../reference/declarationsAndAssignments.js | 8 +- ...ngObjectBindingPatternAndAssignment1ES5.js | 12 +- ...uringObjectBindingPatternAndAssignment3.js | 10 +- .../destructuringVariableDeclaration1ES5.js | 10 +- ...ucturingVariableDeclaration1ES5iterable.js | 10 +- .../destructuringVariableDeclaration2.js | 2 +- .../reference/downlevelLetConst12.js | 4 +- .../reference/downlevelLetConst13.js | 8 +- .../reference/downlevelLetConst14.js | 8 +- .../reference/downlevelLetConst15.js | 8 +- .../reference/downlevelLetConst16.js | 28 +- ...jectLiteralExpressionInArrowFunctionES5.js | 4 +- ...jectLiteralExpressionInArrowFunctionES6.js | 4 +- .../emitArrowFunctionWhenUsingArguments17.js | 2 +- .../emitArrowFunctionWhenUsingArguments18.js | 2 +- .../initializePropertiesWithRenamedLet.js | 8 +- .../baselines/reference/letInNonStrictMode.js | 2 +- .../literalTypesAndTypeAssertions.js | 8 +- .../reference/missingAndExcessProperties.js | 8 +- ...oImplicitAnyDestructuringVarDeclaration.js | 2 +- ...ImplicitAnyDestructuringVarDeclaration2.js | 2 +- ...bjectBindingPatternKeywordIdentifiers01.js | 2 +- ...bjectBindingPatternKeywordIdentifiers03.js | 2 +- ...bjectBindingPatternKeywordIdentifiers05.js | 2 +- ...bjectBindingPatternKeywordIdentifiers06.js | 2 +- .../shadowingViaLocalValueOrBindingElement.js | 8 +- ...thandPropertyAssignmentsInDestructuring.js | 16 +- ...ionDestructuringForObjectBindingPattern.js | 4 +- ...estructuringForObjectBindingPattern.js.map | 2 +- ...uringForObjectBindingPattern.sourcemap.txt | 200 +++++++------- ...ingForObjectBindingPatternDefaultValues.js | 4 +- ...orObjectBindingPatternDefaultValues.js.map | 2 +- ...tBindingPatternDefaultValues.sourcemap.txt | 258 +++++++++--------- ...gVariableStatementObjectBindingPattern1.js | 2 +- ...iableStatementObjectBindingPattern1.js.map | 2 +- ...atementObjectBindingPattern1.sourcemap.txt | 14 +- ...gVariableStatementObjectBindingPattern2.js | 2 +- ...iableStatementObjectBindingPattern2.js.map | 2 +- ...atementObjectBindingPattern2.sourcemap.txt | 14 +- ...gVariableStatementObjectBindingPattern3.js | 2 +- ...iableStatementObjectBindingPattern3.js.map | 2 +- ...atementObjectBindingPattern3.sourcemap.txt | 26 +- .../strictModeReservedWordInDestructuring.js | 2 +- .../strictModeUseContextualKeyword.js | 2 +- .../templateStringInObjectLiteral.js | 4 +- .../templateStringInPropertyName1.js | 2 +- .../templateStringInPropertyName2.js | 2 +- 57 files changed, 399 insertions(+), 399 deletions(-) diff --git a/tests/baselines/reference/assignmentTypeNarrowing.js b/tests/baselines/reference/assignmentTypeNarrowing.js index 7c85e7dccf6..92fd49d9941 100644 --- a/tests/baselines/reference/assignmentTypeNarrowing.js +++ b/tests/baselines/reference/assignmentTypeNarrowing.js @@ -37,13 +37,13 @@ x = [true][0]; x; // boolean _a = [1][0], x = _a === void 0 ? "" : _a; x; // string | number -(x = ({ x: true }).x); +(x = { x: true }.x); x; // boolean -(x = ({ y: 1 }).y); +(x = { y: 1 }.y); x; // number -(_b = ({ x: true }).x, x = _b === void 0 ? "" : _b); +(_b = { x: true }.x, x = _b === void 0 ? "" : _b); x; // string | boolean -(_c = ({ y: 1 }).y, x = _c === void 0 ? /a/ : _c); +(_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++) { diff --git a/tests/baselines/reference/asyncMethodWithSuper_es5.js b/tests/baselines/reference/asyncMethodWithSuper_es5.js index 0dbeedabe52..a2931b9f8e1 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es5.js +++ b/tests/baselines/reference/asyncMethodWithSuper_es5.js @@ -95,9 +95,9 @@ var B = /** @class */ (function (_super) { // element access (assign) _super.prototype["x"] = f; // destructuring assign with property access - (_super.prototype.x = ({ f: f }).f); + (_super.prototype.x = { f: f }.f); // destructuring assign with element access - (_super.prototype["x"] = ({ f: f }).f); + (_super.prototype["x"] = { f: f }.f); return [2 /*return*/]; }); }); diff --git a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js index 78fd3dfc92a..cc9ad56be88 100644 --- a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js +++ b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.js @@ -15,7 +15,7 @@ for (var _i = 0, _a = [{}]; _i < _a.length; _i++) { continue; } // 2: -for (var _c = a, a = ({})[_c]; false;) +for (var _c = a, a = {}[_c]; false;) continue; // 3: -var _d = b, b = ({})[_d]; +var _d = b, b = {}[_d]; diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1.js b/tests/baselines/reference/computedPropertiesInDestructuring1.js index 39d411fb851..e4f15e6b8bf 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1.js +++ b/tests/baselines/reference/computedPropertiesInDestructuring1.js @@ -40,10 +40,10 @@ let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; //// [computedPropertiesInDestructuring1.js] // destructuring in variable declarations var foo = "bar"; -var _a = foo, bar = ({ bar: "bar" })[_a]; -var bar2 = ({ bar: "bar" })["bar"]; +var _a = foo, bar = { bar: "bar" }[_a]; +var bar2 = { bar: "bar" }["bar"]; var foo2 = function () { return "bar"; }; -var _b = foo2(), bar3 = ({ bar: "bar" })[_b]; +var _b = foo2(), bar3 = { bar: "bar" }[_b]; var _c = foo, bar4 = [{ bar: "bar" }][0][_c]; var _d = foo2(), bar5 = [{ bar: "bar" }][0][_d]; function f1(_a) { @@ -65,9 +65,9 @@ function f5(_a) { var _e = foo(), bar6 = [{ bar: "bar" }][0][_e]; var _f = foo.toExponential(), bar7 = [{ bar: "bar" }][0][_f]; // destructuring assignment -(_g = foo, bar = ({ bar: "bar" })[_g]); -(bar2 = ({ bar: "bar" })["bar"]); -(_h = foo2(), bar3 = ({ bar: "bar" })[_h]); +(_g = foo, bar = { bar: "bar" }[_g]); +(bar2 = { bar: "bar" }["bar"]); +(_h = foo2(), bar3 = { bar: "bar" }[_h]); _j = foo, bar4 = [{ bar: "bar" }][0][_j]; _k = foo2(), bar5 = [{ bar: "bar" }][0][_k]; _l = foo(), bar4 = [{ bar: "bar" }][0][_l]; diff --git a/tests/baselines/reference/computedPropertiesInDestructuring2.js b/tests/baselines/reference/computedPropertiesInDestructuring2.js index 872cf7831c7..8579881b775 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring2.js +++ b/tests/baselines/reference/computedPropertiesInDestructuring2.js @@ -4,4 +4,4 @@ let {[foo2()]: bar3} = {}; //// [computedPropertiesInDestructuring2.js] var foo2 = function () { return "bar"; }; -var _a = foo2(), bar3 = ({})[_a]; +var _a = foo2(), bar3 = {}[_a]; diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.js b/tests/baselines/reference/contextuallyTypedBindingInitializer.js index 3b4956cb336..6542e747edc 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializer.js +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.js @@ -48,4 +48,4 @@ function g(_a) { function h(_a) { var _b = _a.prop, prop = _b === void 0 ? "foo" : _b; } -var _a = ({ stringIdentity: function (x) { return x; } }).stringIdentity, id = _a === void 0 ? function (arg) { return arg; } : _a; +var _a = { stringIdentity: function (x) { return x; } }.stringIdentity, id = _a === void 0 ? function (arg) { return arg; } : _a; diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js index a2d7ba8b1aa..bdc7ed68b3f 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js @@ -40,7 +40,7 @@ function f3(_a) { function ff(_a) { var _b = _a.nested, nestedRename = _b === void 0 ? { show: function (v) { return v; } } : _b; } -var _a = ({ stringIdentity: function (x) { return x; } }).stringIdentity, id = _a === void 0 ? function (arg) { return arg.length; } : _a; +var _a = { stringIdentity: function (x) { return x; } }.stringIdentity, id = _a === void 0 ? function (arg) { return arg.length; } : _a; function g(_a) { var _b = _a.prop, prop = _b === void 0 ? [101, 1234] : _b; } diff --git a/tests/baselines/reference/controlFlowDestructuringDeclaration.js b/tests/baselines/reference/controlFlowDestructuringDeclaration.js index a26899849be..39192f1baad 100644 --- a/tests/baselines/reference/controlFlowDestructuringDeclaration.js +++ b/tests/baselines/reference/controlFlowDestructuringDeclaration.js @@ -82,27 +82,27 @@ function f3() { z; } function f4() { - var x = ({ x: 1 }).x; + var x = { x: 1 }.x; x; - var y = ({ y: "" }).y; + var y = { y: "" }.y; y; - var _a = ({ z: undefined }).z, z = _a === void 0 ? "" : _a; + var _a = { z: undefined }.z, z = _a === void 0 ? "" : _a; z; } function f5() { - var x = ({ x: 1 }).x; + var x = { x: 1 }.x; x; - var y = ({ y: "" }).y; + var y = { y: "" }.y; y; - var _a = ({ z: undefined }).z, z = _a === void 0 ? "" : _a; + var _a = { z: undefined }.z, z = _a === void 0 ? "" : _a; z; } function f6() { - var x = ({}).x; + var x = {}.x; x; - var y = ({}).y; + var y = {}.y; y; - var _a = ({}).z, z = _a === void 0 ? "" : _a; + var _a = {}.z, z = _a === void 0 ? "" : _a; z; } function f7() { diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js index ef82e607758..0414017b776 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js @@ -23,11 +23,11 @@ module m { //// [declarationEmitDestructuringObjectLiteralPattern.js] var _a = { x: 5, y: "hello" }; -var x4 = ({ x4: 5, y4: "hello" }).x4; -var y5 = ({ x5: 5, y5: "hello" }).y5; +var x4 = { x4: 5, y4: "hello" }.x4; +var y5 = { x5: 5, y5: "hello" }.y5; var _b = { x6: 5, y6: "hello" }, x6 = _b.x6, y6 = _b.y6; -var a1 = ({ x7: 5, y7: "hello" }).x7; -var b1 = ({ x8: 5, y8: "hello" }).y8; +var a1 = { x7: 5, y7: "hello" }.x7; +var b1 = { x8: 5, y8: "hello" }.y8; var _c = { x9: 5, y9: "hello" }, a2 = _c.x9, b2 = _c.y9; var _d = { a: 1, b: { a: "hello", b: { a: true } } }, x11 = _d.a, _e = _d.b, y11 = _e.a, z11 = _e.b.a; function f15() { diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js index 974dc8cc24d..1e8279597d5 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern1.js @@ -9,11 +9,11 @@ var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" }; //// [declarationEmitDestructuringObjectLiteralPattern1.js] var _a = { x: 5, y: "hello" }; -var x4 = ({ x4: 5, y4: "hello" }).x4; -var y5 = ({ x5: 5, y5: "hello" }).y5; +var x4 = { x4: 5, y4: "hello" }.x4; +var y5 = { x5: 5, y5: "hello" }.y5; var _b = { x6: 5, y6: "hello" }, x6 = _b.x6, y6 = _b.y6; -var a1 = ({ x7: 5, y7: "hello" }).x7; -var b1 = ({ x8: 5, y8: "hello" }).y8; +var a1 = { x7: 5, y7: "hello" }.x7; +var b1 = { x8: 5, y8: "hello" }.y8; var _c = { x9: 5, y9: "hello" }, a2 = _c.x9, b2 = _c.y9; diff --git a/tests/baselines/reference/declarationsAndAssignments.js b/tests/baselines/reference/declarationsAndAssignments.js index d338b454b8b..3a2f9ef3b4e 100644 --- a/tests/baselines/reference/declarationsAndAssignments.js +++ b/tests/baselines/reference/declarationsAndAssignments.js @@ -201,13 +201,13 @@ function f1() { } function f2() { var _a = { x: 5, y: "hello" }; // Error, no x and y in target - var x = ({ x: 5, y: "hello" }).x; // Error, no y in target - var y = ({ x: 5, y: "hello" }).y; // Error, no x in target + var x = { x: 5, y: "hello" }.x; // Error, no y in target + var y = { x: 5, y: "hello" }.y; // Error, no x in target var _b = { x: 5, y: "hello" }, x = _b.x, y = _b.y; var x; var y; - var a = ({ x: 5, y: "hello" }).x; // Error, no y in target - var b = ({ x: 5, y: "hello" }).y; // Error, no x in target + var a = { x: 5, y: "hello" }.x; // Error, no y in target + var b = { x: 5, y: "hello" }.y; // Error, no x in target var _c = { x: 5, y: "hello" }, a = _c.x, b = _c.y; var a; var b; diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js index dee603bd47f..f201b17deda 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.js @@ -60,15 +60,15 @@ var {"prop2": d1} = foo1(); // V is an object assignment pattern and, for each assignment property P in V, // S is the type Any, or var a1 = undefined.a1; -var a2 = ({}).a2; +var a2 = {}.a2; // V is an object assignment pattern and, for each assignment property P in V, // S has an apparent property with the property name specified in // P of a type that is assignable to the target given in P, or -var b1 = ({ b1: 1 }).b1; -var _a = ({ b2: { b21: "world" } }).b2, b21 = (_a === void 0 ? { b21: "string" } : _a).b21; -var b3 = ({ 1: "string" })[1]; -var _b = ({ b4: 100000 }).b4, b4 = _b === void 0 ? 1 : _b; -var b52 = ({ b5: { b52: b52 } }).b5.b52; +var b1 = { b1: 1 }.b1; +var _a = { b2: { b21: "world" } }.b2, b21 = (_a === void 0 ? { b21: "string" } : _a).b21; +var b3 = { 1: "string" }[1]; +var _b = { b4: 100000 }.b4, b4 = _b === void 0 ? 1 : _b; +var b52 = { b5: { b52: b52 } }.b5.b52; function foo() { return { 1: true diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js index bec23431d98..0872a71c73b 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.js @@ -10,9 +10,9 @@ var {"prop"} = { "prop": 1 }; //// [destructuringObjectBindingPatternAndAssignment3.js] // Error -var h = ({ h: 1 }).h; -var i = ({ i: 2 }).i; -var i1 = ({ i1: 2 }).i1; +var h = { h: 1 }.h; +var i = { i: 2 }.i; +var i1 = { i1: 2 }.i1; var _a = undefined.f2, f21 = (_a === void 0 ? { f212: "string" } : _a).f21; -var = ({ 1: })[1]; -var = ({ "prop": 1 })["prop"]; +var = { 1: }[1]; +var = { "prop": 1 }["prop"]; diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.js b/tests/baselines/reference/destructuringVariableDeclaration1ES5.js index d627a87a986..6d731538d18 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.js +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.js @@ -48,7 +48,7 @@ var _a = { a1: 10, a2: "world" }, a1 = _a.a1, a2 = _a.a2; var _b = [1, [["hello"]], true], a3 = _b[0], a4 = _b[1][0][0], a5 = _b[2]; // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. -var _c = ({ b1: { b11: "world" } }).b1, b11 = (_c === void 0 ? { b11: "string" } : _c).b11; +var _c = { b1: { b11: "world" } }.b1, b11 = (_c === void 0 ? { b11: "string" } : _c).b11; var temp = { t1: true, t2: "false" }; var _d = [3, false, { t1: false, t2: "hello" }], _e = _d[0], b2 = _e === void 0 ? 3 : _e, _f = _d[1], b3 = _f === void 0 ? true : _f, _g = _d[2], b4 = _g === void 0 ? temp : _g; var _h = [undefined, undefined, undefined], _j = _h[0], b5 = _j === void 0 ? 3 : _j, _k = _h[1], b6 = _k === void 0 ? true : _k, _l = _h[2], b7 = _l === void 0 ? temp : _l; @@ -68,10 +68,10 @@ var _m = [1, "string"], d1 = _m[0], d2 = _m[1]; var temp1 = [true, false, true]; var _o = [1, "string"].concat(temp1), d3 = _o[0], d4 = _o[1]; // Combining both forms of destructuring, -var _p = ({ e: [1, 2, { b1: 4, b4: 0 }] }).e, e1 = _p[0], e2 = _p[1], _q = _p[2], e3 = _q === void 0 ? { b1: 1000, b4: 200 } : _q; -var _r = ({ f: [1, 2, { f3: 4, f5: 0 }] }).f, f1 = _r[0], f2 = _r[1], _s = _r[2], f4 = _s.f3, f5 = _s.f5; +var _p = { e: [1, 2, { b1: 4, b4: 0 }] }.e, e1 = _p[0], e2 = _p[1], _q = _p[2], e3 = _q === void 0 ? { b1: 1000, b4: 200 } : _q; +var _r = { f: [1, 2, { f3: 4, f5: 0 }] }.f, f1 = _r[0], f2 = _r[1], _s = _r[2], f4 = _s.f3, f5 = _s.f5; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. -var _t = ({ g: { g1: [1, 2] } }).g.g1, g1 = _t === void 0 ? [undefined, null] : _t; -var _u = ({ h: { h1: [1, 2] } }).h.h1, h1 = _u === void 0 ? [undefined, null] : _u; +var _t = { g: { g1: [1, 2] } }.g.g1, g1 = _t === void 0 ? [undefined, null] : _t; +var _u = { h: { h1: [1, 2] } }.h.h1, h1 = _u === void 0 ? [undefined, null] : _u; diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js index b59c7e1249b..83fb3de04fc 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js @@ -68,7 +68,7 @@ var _a = { a1: 10, a2: "world" }, a1 = _a.a1, a2 = _a.a2; var _b = __read([1, [["hello"]], true], 3), a3 = _b[0], _c = __read(_b[1], 1), _d = __read(_c[0], 1), a4 = _d[0], a5 = _b[2]; // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. -var _e = ({ b1: { b11: "world" } }).b1, b11 = (_e === void 0 ? { b11: "string" } : _e).b11; +var _e = { b1: { b11: "world" } }.b1, b11 = (_e === void 0 ? { b11: "string" } : _e).b11; var temp = { t1: true, t2: "false" }; var _f = __read([3, false, { t1: false, t2: "hello" }], 3), _g = _f[0], b2 = _g === void 0 ? 3 : _g, _h = _f[1], b3 = _h === void 0 ? true : _h, _j = _f[2], b4 = _j === void 0 ? temp : _j; var _k = __read([undefined, undefined, undefined], 3), _l = _k[0], b5 = _l === void 0 ? 3 : _l, _m = _k[1], b6 = _m === void 0 ? true : _m, _o = _k[2], b7 = _o === void 0 ? temp : _o; @@ -88,10 +88,10 @@ var _r = __read([1, "string"], 2), d1 = _r[0], d2 = _r[1]; var temp1 = [true, false, true]; var _s = __read(__spread([1, "string"], temp1), 2), d3 = _s[0], d4 = _s[1]; // Combining both forms of destructuring, -var _t = __read(({ e: [1, 2, { b1: 4, b4: 0 }] }).e, 3), e1 = _t[0], e2 = _t[1], _u = _t[2], e3 = _u === void 0 ? { b1: 1000, b4: 200 } : _u; -var _v = __read(({ f: [1, 2, { f3: 4, f5: 0 }] }).f, 4), f1 = _v[0], f2 = _v[1], _w = _v[2], f4 = _w.f3, f5 = _w.f5; +var _t = __read({ e: [1, 2, { b1: 4, b4: 0 }] }.e, 3), e1 = _t[0], e2 = _t[1], _u = _t[2], e3 = _u === void 0 ? { b1: 1000, b4: 200 } : _u; +var _v = __read({ f: [1, 2, { f3: 4, f5: 0 }] }.f, 4), f1 = _v[0], f2 = _v[1], _w = _v[2], f4 = _w.f3, f5 = _w.f5; // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. -var _x = ({ g: { g1: [1, 2] } }).g.g1, g1 = _x === void 0 ? [undefined, null] : _x; -var _y = ({ h: { h1: [1, 2] } }).h.h1, h1 = _y === void 0 ? [undefined, null] : _y; +var _x = { g: { g1: [1, 2] } }.g.g1, g1 = _x === void 0 ? [undefined, null] : _x; +var _y = { h: { h1: [1, 2] } }.h.h1, h1 = _y === void 0 ? [undefined, null] : _y; diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.js b/tests/baselines/reference/destructuringVariableDeclaration2.js index b3d4152892a..a4fadd850d7 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration2.js +++ b/tests/baselines/reference/destructuringVariableDeclaration2.js @@ -35,4 +35,4 @@ var _g = [1, 2, { c3: 4, c5: 0 }], c1 = _g[0], c2 = _g[1], _h = _g[2], c4 = _h.c // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. -var _j = ({ d: { d1: [1, 2] } }).d.d1, d1 = _j === void 0 ? ["string", null] : _j; // Error +var _j = { d: { d1: [1, 2] } }.d.d1, d1 = _j === void 0 ? ["string", null] : _j; // Error diff --git a/tests/baselines/reference/downlevelLetConst12.js b/tests/baselines/reference/downlevelLetConst12.js index 3ab90cee98d..bdc33aaba9d 100644 --- a/tests/baselines/reference/downlevelLetConst12.js +++ b/tests/baselines/reference/downlevelLetConst12.js @@ -16,6 +16,6 @@ const {a: baz4} = { a: 1 }; var foo; var bar = 1; var baz = [][0]; -var baz2 = ({ a: 1 }).a; +var baz2 = { a: 1 }.a; var baz3 = [][0]; -var baz4 = ({ a: 1 }).a; +var baz4 = { a: 1 }.a; diff --git a/tests/baselines/reference/downlevelLetConst13.js b/tests/baselines/reference/downlevelLetConst13.js index 64d169c4013..251468519ad 100644 --- a/tests/baselines/reference/downlevelLetConst13.js +++ b/tests/baselines/reference/downlevelLetConst13.js @@ -26,14 +26,14 @@ exports.foo = 10; exports.bar = "123"; exports.bar1 = [1][0]; exports.bar2 = [2][0]; -exports.bar3 = ({ a: 1 }).a; -exports.bar4 = ({ a: 1 }).a; +exports.bar3 = { a: 1 }.a; +exports.bar4 = { a: 1 }.a; var M; (function (M) { M.baz = 100; M.baz2 = true; M.bar5 = [1][0]; M.bar6 = [2][0]; - M.bar7 = ({ a: 1 }).a; - M.bar8 = ({ a: 1 }).a; + M.bar7 = { a: 1 }.a; + M.bar8 = { a: 1 }.a; })(M = exports.M || (exports.M = {})); diff --git a/tests/baselines/reference/downlevelLetConst14.js b/tests/baselines/reference/downlevelLetConst14.js index 0d671dbaaa7..cddfb967217 100644 --- a/tests/baselines/reference/downlevelLetConst14.js +++ b/tests/baselines/reference/downlevelLetConst14.js @@ -65,9 +65,9 @@ var z0, z1, z2, z3; use(z0_1); var z1_1 = [1][0]; use(z1_1); - var z2_1 = ({ a: 1 }).a; + var z2_1 = { a: 1 }.a; use(z2_1); - var z3_1 = ({ a: 1 }).a; + var z3_1 = { a: 1 }.a; use(z3_1); } use(x); @@ -82,7 +82,7 @@ var y = true; var z6_1 = [true][0]; { var y_2 = 1; - var z6_2 = ({ a: 1 }).a; + var z6_2 = { a: 1 }.a; use(y_2); use(z6_2); } @@ -98,7 +98,7 @@ var z5 = 1; var z5_1 = [5][0]; { var _z = 1; - var _z5 = ({ a: 1 }).a; + var _z5 = { a: 1 }.a; // try to step on generated name use(_z); } diff --git a/tests/baselines/reference/downlevelLetConst15.js b/tests/baselines/reference/downlevelLetConst15.js index bd70cfe767c..807f49bf84e 100644 --- a/tests/baselines/reference/downlevelLetConst15.js +++ b/tests/baselines/reference/downlevelLetConst15.js @@ -65,9 +65,9 @@ var z0, z1, z2, z3; use(z0_1); var z1_1 = [{ a: 1 }][0].a; use(z1_1); - var z2_1 = ({ a: 1 }).a; + var z2_1 = { a: 1 }.a; use(z2_1); - var z3_1 = ({ a: { b: 1 } }).a.b; + var z3_1 = { a: { b: 1 } }.a.b; use(z3_1); } use(x); @@ -82,7 +82,7 @@ var y = true; var z6_1 = [true][0]; { var y_2 = 1; - var z6_2 = ({ a: 1 }).a; + var z6_2 = { a: 1 }.a; use(y_2); use(z6_2); } @@ -98,7 +98,7 @@ var z5 = 1; var z5_1 = [5][0]; { var _z = 1; - var _z5 = ({ a: 1 }).a; + var _z5 = { a: 1 }.a; // try to step on generated name use(_z); } diff --git a/tests/baselines/reference/downlevelLetConst16.js b/tests/baselines/reference/downlevelLetConst16.js index 0231d98fec2..338489b20c3 100644 --- a/tests/baselines/reference/downlevelLetConst16.js +++ b/tests/baselines/reference/downlevelLetConst16.js @@ -240,7 +240,7 @@ function foo1() { use(x); var y = [1][0]; use(y); - var z = ({ a: 1 }).a; + var z = { a: 1 }.a; use(z); } function foo2() { @@ -249,7 +249,7 @@ function foo2() { use(x_1); var y_1 = [1][0]; use(y_1); - var z_1 = ({ a: 1 }).a; + var z_1 = { a: 1 }.a; use(z_1); } use(x); @@ -262,7 +262,7 @@ var A = /** @class */ (function () { use(x); var y = [1][0]; use(y); - var z = ({ a: 1 }).a; + var z = { a: 1 }.a; use(z); }; A.prototype.m2 = function () { @@ -271,7 +271,7 @@ var A = /** @class */ (function () { use(x_2); var y_2 = [1][0]; use(y_2); - var z_2 = ({ a: 1 }).a; + var z_2 = { a: 1 }.a; use(z_2); } use(x); @@ -286,7 +286,7 @@ var B = /** @class */ (function () { use(x); var y = [1][0]; use(y); - var z = ({ a: 1 }).a; + var z = { a: 1 }.a; use(z); }; B.prototype.m2 = function () { @@ -295,7 +295,7 @@ var B = /** @class */ (function () { use(x_3); var y_3 = [1][0]; use(y_3); - var z_3 = ({ a: 1 }).a; + var z_3 = { a: 1 }.a; use(z_3); } use(x); @@ -307,7 +307,7 @@ function bar1() { use(x); var y = [1][0]; use(y); - var z = ({ a: 1 }).a; + var z = { a: 1 }.a; use(z); } function bar2() { @@ -316,7 +316,7 @@ function bar2() { use(x_4); var y_4 = [1][0]; use(y_4); - var z_4 = ({ a: 1 }).a; + var z_4 = { a: 1 }.a; use(z_4); } use(x); @@ -327,7 +327,7 @@ var M1; use(x); var y = [1][0]; use(y); - var z = ({ a: 1 }).a; + var z = { a: 1 }.a; use(z); })(M1 || (M1 = {})); var M2; @@ -337,7 +337,7 @@ var M2; use(x_5); var y_5 = [1][0]; use(y_5); - var z_5 = ({ a: 1 }).a; + var z_5 = { a: 1 }.a; use(z_5); } use(x); @@ -348,7 +348,7 @@ var M3; use(x); var y = [1][0]; use(y); - var z = ({ a: 1 }).a; + var z = { a: 1 }.a; use(z); })(M3 || (M3 = {})); var M4; @@ -358,7 +358,7 @@ var M4; use(x_6); var y_6 = [1][0]; use(y_6); - var z_6 = ({ a: 1 }).a; + var z_6 = { a: 1 }.a; use(z_6); } use(x); @@ -372,7 +372,7 @@ function foo3() { for (var y_7 = [][0];;) { use(y_7); } - for (var z_7 = ({ a: 1 }).a;;) { + for (var z_7 = { a: 1 }.a;;) { use(z_7); } use(x); @@ -384,7 +384,7 @@ function foo4() { for (var y_8 = [][0];;) { use(y_8); } - for (var z_8 = ({ a: 1 }).a;;) { + for (var z_8 = { a: 1 }.a;;) { use(z_8); } use(x); diff --git a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js index 5d99dad3c0c..182e678b7bf 100644 --- a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js +++ b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js @@ -3,5 +3,5 @@ (x) => ({ "1": "one", "2": "two" } as { [key: string]: string }).x; //// [emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES5.js] -(function (x) { return ({ "1": "one", "2": "two" })[x]; }); -(function (x) { return ({ "1": "one", "2": "two" }).x; }); +(function (x) { return ({ "1": "one", "2": "two" }[x]); }); +(function (x) { return ({ "1": "one", "2": "two" }.x); }); diff --git a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js index dc3891a9bd4..8d7999b0da7 100644 --- a/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js +++ b/tests/baselines/reference/emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js @@ -3,5 +3,5 @@ (x) => ({ "1": "one", "2": "two" } as { [key: string]: string }).x; //// [emitAccessExpressionOfCastedObjectLiteralExpressionInArrowFunctionES6.js] -(x) => ({ "1": "one", "2": "two" })[x]; -(x) => ({ "1": "one", "2": "two" }).x; +(x) => ({ "1": "one", "2": "two" }[x]); +(x) => ({ "1": "one", "2": "two" }.x); diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17.js b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17.js index 7572b0c3af1..60044ac5dc4 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17.js +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17.js @@ -9,7 +9,7 @@ function f() { //// [emitArrowFunctionWhenUsingArguments17.js] function f() { - var arguments = ({ arguments: "hello" }).arguments; + var arguments = { arguments: "hello" }.arguments; if (Math.random()) { return function () { return arguments[0]; }; } diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18.js b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18.js index 3af9c580231..a88a01c7a56 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18.js +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments18.js @@ -8,7 +8,7 @@ function f() { //// [emitArrowFunctionWhenUsingArguments18.js] function f() { - var args = ({ arguments: arguments }).arguments; + var args = { arguments: arguments }.arguments; if (Math.random()) { return function () { return arguments; }; } diff --git a/tests/baselines/reference/initializePropertiesWithRenamedLet.js b/tests/baselines/reference/initializePropertiesWithRenamedLet.js index 0ed325b2a31..d6c53b7d525 100644 --- a/tests/baselines/reference/initializePropertiesWithRenamedLet.js +++ b/tests/baselines/reference/initializePropertiesWithRenamedLet.js @@ -24,9 +24,9 @@ if (true) { } var x, y, z; if (true) { - var x_1 = ({ x: 0 }).x; - var y_1 = ({ y: 0 }).y; + var x_1 = { x: 0 }.x; + var y_1 = { y: 0 }.y; var z_1; - (z_1 = ({ z: 0 }).z); - (z_1 = ({ z: 0 }).z); + (z_1 = { z: 0 }.z); + (z_1 = { z: 0 }.z); } diff --git a/tests/baselines/reference/letInNonStrictMode.js b/tests/baselines/reference/letInNonStrictMode.js index 3627a72e7ff..8e4920cc220 100644 --- a/tests/baselines/reference/letInNonStrictMode.js +++ b/tests/baselines/reference/letInNonStrictMode.js @@ -4,4 +4,4 @@ let {a: y} = {a: 1}; //// [letInNonStrictMode.js] var x = [1][0]; -var y = ({ a: 1 }).a; +var y = { a: 1 }.a; diff --git a/tests/baselines/reference/literalTypesAndTypeAssertions.js b/tests/baselines/reference/literalTypesAndTypeAssertions.js index 6c95fd45802..ab6a82852a5 100644 --- a/tests/baselines/reference/literalTypesAndTypeAssertions.js +++ b/tests/baselines/reference/literalTypesAndTypeAssertions.js @@ -22,7 +22,7 @@ var obj = { }; var x1 = 1; var x2 = 1; -var _a = ({ a: "foo" }).a, a = _a === void 0 ? "foo" : _a; -var _b = ({ b: "bar" }).b, b = _b === void 0 ? "foo" : _b; -var _c = ({ c: "bar" }).c, c = _c === void 0 ? "foo" : _c; -var _d = ({ d: "bar" }).d, d = _d === void 0 ? "foo" : _d; +var _a = { a: "foo" }.a, a = _a === void 0 ? "foo" : _a; +var _b = { b: "bar" }.b, b = _b === void 0 ? "foo" : _b; +var _c = { c: "bar" }.c, c = _c === void 0 ? "foo" : _c; +var _d = { d: "bar" }.d, d = _d === void 0 ? "foo" : _d; diff --git a/tests/baselines/reference/missingAndExcessProperties.js b/tests/baselines/reference/missingAndExcessProperties.js index 28e0f13b4bd..daefe18eed7 100644 --- a/tests/baselines/reference/missingAndExcessProperties.js +++ b/tests/baselines/reference/missingAndExcessProperties.js @@ -54,16 +54,16 @@ function f2() { // Excess properties function f3() { var _a = { x: 0, y: 0 }; - var x = ({ x: 0, y: 0 }).x; - var y = ({ x: 0, y: 0 }).y; + var x = { x: 0, y: 0 }.x; + var y = { x: 0, y: 0 }.y; var _b = { x: 0, y: 0 }, x = _b.x, y = _b.y; } // Excess properties function f4() { var x, y; ({ x: 0, y: 0 }); - (x = ({ x: 0, y: 0 }).x); - (y = ({ x: 0, y: 0 }).y); + (x = { x: 0, y: 0 }.x); + (y = { x: 0, y: 0 }.y); (_a = { x: 0, y: 0 }, x = _a.x, y = _a.y); var _a; } diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js index 1dbc933cbf5..85358df666e 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js @@ -16,5 +16,5 @@ var a = (void 0)[0], b = (void 0).b, c, d; // error var _a = (void 0)[0], a1 = _a === void 0 ? undefined : _a, _b = (void 0).b1, b1 = _b === void 0 ? null : _b, c1 = undefined, d1 = null; // error var a2 = (void 0)[0], b2 = (void 0).b2, c2, d2; var b3 = (void 0).b3, c3; // error in type instead -var a4 = [undefined][0], b4 = ({ b4: null }).b4, c4 = undefined, d4 = null; // error +var a4 = [undefined][0], b4 = { b4: null }.b4, c4 = undefined, d4 = null; // error var _c = [][0], a5 = _c === void 0 ? undefined : _c; // error diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js index 81d8ba6386f..79ee0b8830f 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js @@ -22,4 +22,4 @@ var _p = { x: 1, y: 2, z: 3 }, x = _p.x, y = _p.y, z = _p.z; // no error var _q = { x1: 1, y1: 2, z1: 3 }, _r = _q.x1, x1 = _r === void 0 ? 10 : _r, _s = _q.y1, y1 = _s === void 0 ? 10 : _s, _t = _q.z1, z1 = _t === void 0 ? 10 : _t; // no error var _u = { x2: 1, y2: 2, z2: 3 }, _v = _u.x2, x2 = _v === void 0 ? undefined : _v, _w = _u.y2, y2 = _w === void 0 ? undefined : _w, _x = _u.z2, z2 = _x === void 0 ? undefined : _x; // no error var _y = { x3: 1, y3: 2, z3: 3 }, _z = _y.x3, x3 = _z === void 0 ? undefined : _z, _0 = _y.y3, y3 = _0 === void 0 ? null : _0, _1 = _y.z3, z3 = _1 === void 0 ? undefined : _1; // no error -var x4 = ({ x4: undefined }).x4, y4 = ({ y4: null }).y4; // no error +var x4 = { x4: undefined }.x4, y4 = { y4: null }.y4; // no error diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js index 2bac381b603..ec0cae158fc 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js @@ -2,4 +2,4 @@ var { while } = { while: 1 } //// [objectBindingPatternKeywordIdentifiers01.js] -var = ({ "while": 1 })["while"]; +var = { "while": 1 }["while"]; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js index d1fb037dfbe..6c9a539bb69 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js @@ -2,4 +2,4 @@ var { "while" } = { while: 1 } //// [objectBindingPatternKeywordIdentifiers03.js] -var = ({ "while": 1 })["while"]; +var = { "while": 1 }["while"]; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.js index 146ac4b2077..08f8e632f29 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.js @@ -2,4 +2,4 @@ var { as } = { as: 1 } //// [objectBindingPatternKeywordIdentifiers05.js] -var as = ({ as: 1 }).as; +var as = { as: 1 }.as; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.js index d465161f4ce..9f29dfff1f8 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.js @@ -2,4 +2,4 @@ var { as: as } = { as: 1 } //// [objectBindingPatternKeywordIdentifiers06.js] -var as = ({ as: 1 }).as; +var as = { as: 1 }.as; diff --git a/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js b/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js index b3c44600d1d..e1cae9c73fe 100644 --- a/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js +++ b/tests/baselines/reference/shadowingViaLocalValueOrBindingElement.js @@ -15,9 +15,9 @@ if (true) { var x_1; if (true) { var x = 0; // Error - var _a = ({ x: 0 }).x, x = _a === void 0 ? 0 : _a; // Error - var _b = ({ x: 0 }).x, x = _b === void 0 ? 0 : _b; // Error - var x = ({ x: 0 }).x; // Error - var x = ({ x: 0 }).x; // Error + var _a = { x: 0 }.x, x = _a === void 0 ? 0 : _a; // Error + var _b = { x: 0 }.x, x = _b === void 0 ? 0 : _b; // Error + var x = { x: 0 }.x; // Error + var x = { x: 0 }.x; // Error } } diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js index 7e1c7622cf7..ca874652de8 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.js @@ -174,32 +174,32 @@ function foo({a = 4, b = { x: 5 }}) { }); (function () { var y; - (_a = ({ y: 1 }).y, y = _a === void 0 ? 5 : _a); + (_a = { y: 1 }.y, y = _a === void 0 ? 5 : _a); var _a; }); (function () { var y; - (_a = ({ y: 1 }).y, y = _a === void 0 ? 5 : _a); + (_a = { y: 1 }.y, y = _a === void 0 ? 5 : _a); var _a; }); (function () { var y0; - (_a = ({ y0: 1 }).y0, y0 = _a === void 0 ? 5 : _a); + (_a = { y0: 1 }.y0, y0 = _a === void 0 ? 5 : _a); var _a; }); (function () { var y0; - (_a = ({ y0: 1 }).y0, y0 = _a === void 0 ? 5 : _a); + (_a = { y0: 1 }.y0, y0 = _a === void 0 ? 5 : _a); var _a; }); (function () { var y1; - (_a = ({}).y1, y1 = _a === void 0 ? 5 : _a); + (_a = {}.y1, y1 = _a === void 0 ? 5 : _a); var _a; }); (function () { var y1; - (_a = ({}).y1, y1 = _a === void 0 ? 5 : _a); + (_a = {}.y1, y1 = _a === void 0 ? 5 : _a); var _a; }); (function () { @@ -224,12 +224,12 @@ function foo({a = 4, b = { x: 5 }}) { }); (function () { var z; - (_a = ({ z: { x: 1 } }).z, z = _a === void 0 ? { x: 5 } : _a); + (_a = { z: { x: 1 } }.z, z = _a === void 0 ? { x: 5 } : _a); var _a; }); (function () { var z; - (_a = ({ z: { x: 1 } }).z, z = _a === void 0 ? { x: 5 } : _a); + (_a = { z: { x: 1 } }.z, z = _a === void 0 ? { x: 5 } : _a); var _a; }); (function () { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js index 46d9e251439..ca29b2eabd8 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js @@ -81,7 +81,7 @@ for (var nameA = robot.name, i = 0; i < 1; i++) { for (var nameA = getRobot().name, i = 0; i < 1; i++) { console.log(nameA); } -for (var nameA = ({ name: "trimmer", skill: "trimming" }).name, i = 0; i < 1; i++) { +for (var nameA = { name: "trimmer", skill: "trimming" }.name, i = 0; i < 1; i++) { console.log(nameA); } for (var _a = multiRobot.skills, primaryA = _a.primary, secondaryA = _a.secondary, i = 0; i < 1; i++) { @@ -90,7 +90,7 @@ for (var _a = multiRobot.skills, primaryA = _a.primary, secondaryA = _a.secondar for (var _b = getMultiRobot().skills, primaryA = _b.primary, secondaryA = _b.secondary, i = 0; i < 1; i++) { console.log(primaryA); } -for (var _c = ({ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }).skills, primaryA = _c.primary, secondaryA = _c.secondary, i = 0; i < 1; i++) { +for (var _c = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }.skills, primaryA = _c.primary, secondaryA = _c.secondary, i = 0; i < 1; i++) { console.log(primaryA); } for (var nameA = robot.name, skillA = robot.skill, i = 0; i < 1; i++) { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js.map b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js.map index e0fa0db3b1a..a0295550f0b 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringForObjectBindingPattern.js.map] -{"version":3,"file":"sourceMapValidationDestructuringForObjectBindingPattern.js","sourceRoot":"","sources":["sourceMapValidationDestructuringForObjectBindingPattern.ts"],"names":[],"mappings":"AAgBA,IAAI,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACtD,IAAI,UAAU,GAAe,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACjG;IACI,MAAM,CAAC,KAAK,CAAC;AACjB,CAAC;AACD;IACI,MAAM,CAAC,UAAU,CAAC;AACtB,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,kBAAW,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,uBAAW,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,qDAAW,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACzF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,sBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,2BAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,uFAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAEzD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,kBAAW,EAAE,oBAAa,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,eAA0C,EAAzC,eAAW,EAAE,iBAAa,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,2CAA6E,EAA5E,eAAW,EAAE,iBAAa,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACxG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,uBAAW,EAAE,sBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC5G,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,oBAAsF,EAArF,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjH,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,8EACgF,EAD/E,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAErE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringForObjectBindingPattern.js","sourceRoot":"","sources":["sourceMapValidationDestructuringForObjectBindingPattern.ts"],"names":[],"mappings":"AAgBA,IAAI,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACtD,IAAI,UAAU,GAAe,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACjG;IACI,MAAM,CAAC,KAAK,CAAC;AACjB,CAAC;AACD;IACI,MAAM,CAAC,UAAU,CAAC;AACtB,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,kBAAW,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,uBAAW,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,mDAAW,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACzF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,sBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,2BAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAO,IAAA,qFAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAEzD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,kBAAW,EAAE,oBAAa,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,eAA0C,EAAzC,eAAW,EAAE,iBAAa,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,2CAA6E,EAA5E,eAAW,EAAE,iBAAa,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACxG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,uBAAW,EAAE,sBAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC5G,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,oBAAsF,EAArF,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjH,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,8EACgF,EAD/E,eAAW,EAAE,cAAoD,EAA1C,qBAAiB,EAAE,yBAAqB,EAErE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.sourcemap.txt index 94cab1030c8..5ea0b7e360d 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.sourcemap.txt @@ -396,33 +396,33 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPattern.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(14, 1) Source(31, 1) + SourceIndex(0) 2 >Emitted(14, 2) Source(31, 2) + SourceIndex(0) --- ->>>for (var nameA = ({ name: "trimmer", skill: "trimming" }).name, i = 0; i < 1; i++) { +>>>for (var nameA = { name: "trimmer", skill: "trimming" }.name, i = 0; i < 1; i++) { 1-> 2 >^^^ 3 > ^ 4 > ^ 5 > ^^^^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -7 > ^^ -8 > ^ -9 > ^^^ -10> ^ -11> ^^ -12> ^ -13> ^^^ -14> ^ -15> ^^ -16> ^ -17> ^^ -18> ^^ -19> ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^ +8 > ^ +9 > ^^^ +10> ^ +11> ^^ +12> ^ +13> ^^^ +14> ^ +15> ^^ +16> ^ +17> ^^ +18> ^^ +19> ^ 1-> > 2 >for @@ -430,38 +430,38 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPattern.ts 4 > (let { 5 > 6 > name: nameA -7 > } = { name: "trimmer", skill: "trimming" }, -8 > i -9 > = -10> 0 -11> ; -12> i -13> < -14> 1 -15> ; -16> i -17> ++ -18> ) -19> { +7 > } = { name: "trimmer", skill: "trimming" }, +8 > i +9 > = +10> 0 +11> ; +12> i +13> < +14> 1 +15> ; +16> i +17> ++ +18> ) +19> { 1->Emitted(15, 1) Source(32, 1) + SourceIndex(0) 2 >Emitted(15, 4) Source(32, 4) + SourceIndex(0) 3 >Emitted(15, 5) Source(32, 5) + SourceIndex(0) 4 >Emitted(15, 6) Source(32, 11) + SourceIndex(0) 5 >Emitted(15, 10) Source(32, 11) + SourceIndex(0) -6 >Emitted(15, 63) Source(32, 22) + SourceIndex(0) -7 >Emitted(15, 65) Source(32, 74) + SourceIndex(0) -8 >Emitted(15, 66) Source(32, 75) + SourceIndex(0) -9 >Emitted(15, 69) Source(32, 78) + SourceIndex(0) -10>Emitted(15, 70) Source(32, 79) + SourceIndex(0) -11>Emitted(15, 72) Source(32, 81) + SourceIndex(0) -12>Emitted(15, 73) Source(32, 82) + SourceIndex(0) -13>Emitted(15, 76) Source(32, 85) + SourceIndex(0) -14>Emitted(15, 77) Source(32, 86) + SourceIndex(0) -15>Emitted(15, 79) Source(32, 88) + SourceIndex(0) -16>Emitted(15, 80) Source(32, 89) + SourceIndex(0) -17>Emitted(15, 82) Source(32, 91) + SourceIndex(0) -18>Emitted(15, 84) Source(32, 93) + SourceIndex(0) -19>Emitted(15, 85) Source(32, 94) + SourceIndex(0) +6 >Emitted(15, 61) Source(32, 22) + SourceIndex(0) +7 >Emitted(15, 63) Source(32, 74) + SourceIndex(0) +8 >Emitted(15, 64) Source(32, 75) + SourceIndex(0) +9 >Emitted(15, 67) Source(32, 78) + SourceIndex(0) +10>Emitted(15, 68) Source(32, 79) + SourceIndex(0) +11>Emitted(15, 70) Source(32, 81) + SourceIndex(0) +12>Emitted(15, 71) Source(32, 82) + SourceIndex(0) +13>Emitted(15, 74) Source(32, 85) + SourceIndex(0) +14>Emitted(15, 75) Source(32, 86) + SourceIndex(0) +15>Emitted(15, 77) Source(32, 88) + SourceIndex(0) +16>Emitted(15, 78) Source(32, 89) + SourceIndex(0) +17>Emitted(15, 80) Source(32, 91) + SourceIndex(0) +18>Emitted(15, 82) Source(32, 93) + SourceIndex(0) +19>Emitted(15, 83) Source(32, 94) + SourceIndex(0) --- >>> console.log(nameA); 1 >^^^^ @@ -711,37 +711,37 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPattern.ts >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(23, 1) Source(40, 1) + SourceIndex(0) 2 >Emitted(23, 2) Source(40, 2) + SourceIndex(0) --- ->>>for (var _c = ({ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }).skills, primaryA = _c.primary, secondaryA = _c.secondary, i = 0; i < 1; i++) { +>>>for (var _c = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }.skills, primaryA = _c.primary, secondaryA = _c.secondary, i = 0; i < 1; i++) { 1-> 2 >^^^ 3 > ^ 4 > ^ 5 > ^^^^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -7 > ^^ -8 > ^^^^^^^^^^^^^^^^^^^^^ -9 > ^^ -10> ^^^^^^^^^^^^^^^^^^^^^^^^^ -11> ^^ -12> ^ -13> ^^^ -14> ^ -15> ^^ -16> ^ -17> ^^^ -18> ^ -19> ^^ -20> ^ -21> ^^ -22> ^^ -23> ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^ +8 > ^^^^^^^^^^^^^^^^^^^^^ +9 > ^^ +10> ^^^^^^^^^^^^^^^^^^^^^^^^^ +11> ^^ +12> ^ +13> ^^^ +14> ^ +15> ^^ +16> ^ +17> ^^^ +18> ^ +19> ^^ +20> ^ +21> ^^ +22> ^^ +23> ^ 1-> > 2 >for @@ -749,48 +749,48 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPattern.ts 4 > (let { 5 > 6 > skills: { primary: primaryA, secondary: secondaryA } -7 > -8 > primary: primaryA -9 > , -10> secondary: secondaryA -11> } } = - > { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, - > -12> i -13> = -14> 0 -15> ; -16> i -17> < -18> 1 -19> ; -20> i -21> ++ -22> ) -23> { +7 > +8 > primary: primaryA +9 > , +10> secondary: secondaryA +11> } } = + > { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, + > +12> i +13> = +14> 0 +15> ; +16> i +17> < +18> 1 +19> ; +20> i +21> ++ +22> ) +23> { 1->Emitted(24, 1) Source(41, 1) + SourceIndex(0) 2 >Emitted(24, 4) Source(41, 4) + SourceIndex(0) 3 >Emitted(24, 5) Source(41, 5) + SourceIndex(0) 4 >Emitted(24, 6) Source(41, 12) + SourceIndex(0) 5 >Emitted(24, 10) Source(41, 12) + SourceIndex(0) -6 >Emitted(24, 97) Source(41, 64) + SourceIndex(0) -7 >Emitted(24, 99) Source(41, 22) + SourceIndex(0) -8 >Emitted(24, 120) Source(41, 39) + SourceIndex(0) -9 >Emitted(24, 122) Source(41, 41) + SourceIndex(0) -10>Emitted(24, 147) Source(41, 62) + SourceIndex(0) -11>Emitted(24, 149) Source(43, 5) + SourceIndex(0) -12>Emitted(24, 150) Source(43, 6) + SourceIndex(0) -13>Emitted(24, 153) Source(43, 9) + SourceIndex(0) -14>Emitted(24, 154) Source(43, 10) + SourceIndex(0) -15>Emitted(24, 156) Source(43, 12) + SourceIndex(0) -16>Emitted(24, 157) Source(43, 13) + SourceIndex(0) -17>Emitted(24, 160) Source(43, 16) + SourceIndex(0) -18>Emitted(24, 161) Source(43, 17) + SourceIndex(0) -19>Emitted(24, 163) Source(43, 19) + SourceIndex(0) -20>Emitted(24, 164) Source(43, 20) + SourceIndex(0) -21>Emitted(24, 166) Source(43, 22) + SourceIndex(0) -22>Emitted(24, 168) Source(43, 24) + SourceIndex(0) -23>Emitted(24, 169) Source(43, 25) + SourceIndex(0) +6 >Emitted(24, 95) Source(41, 64) + SourceIndex(0) +7 >Emitted(24, 97) Source(41, 22) + SourceIndex(0) +8 >Emitted(24, 118) Source(41, 39) + SourceIndex(0) +9 >Emitted(24, 120) Source(41, 41) + SourceIndex(0) +10>Emitted(24, 145) Source(41, 62) + SourceIndex(0) +11>Emitted(24, 147) Source(43, 5) + SourceIndex(0) +12>Emitted(24, 148) Source(43, 6) + SourceIndex(0) +13>Emitted(24, 151) Source(43, 9) + SourceIndex(0) +14>Emitted(24, 152) Source(43, 10) + SourceIndex(0) +15>Emitted(24, 154) Source(43, 12) + SourceIndex(0) +16>Emitted(24, 155) Source(43, 13) + SourceIndex(0) +17>Emitted(24, 158) Source(43, 16) + SourceIndex(0) +18>Emitted(24, 159) Source(43, 17) + SourceIndex(0) +19>Emitted(24, 161) Source(43, 19) + SourceIndex(0) +20>Emitted(24, 162) Source(43, 20) + SourceIndex(0) +21>Emitted(24, 164) Source(43, 22) + SourceIndex(0) +22>Emitted(24, 166) Source(43, 24) + SourceIndex(0) +23>Emitted(24, 167) Source(43, 25) + SourceIndex(0) --- >>> console.log(primaryA); 1 >^^^^ diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js index 3a3ffc6b8d4..785148ba652 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js @@ -112,7 +112,7 @@ for (var _a = robot.name, nameA = _a === void 0 ? "noName" : _a, i = 0; i < 1; i for (var _b = getRobot().name, nameA = _b === void 0 ? "noName" : _b, i = 0; i < 1; i++) { console.log(nameA); } -for (var _c = ({ name: "trimmer", skill: "trimming" }).name, nameA = _c === void 0 ? "noName" : _c, i = 0; i < 1; i++) { +for (var _c = { name: "trimmer", skill: "trimming" }.name, nameA = _c === void 0 ? "noName" : _c, i = 0; i < 1; i++) { console.log(nameA); } for (var _d = multiRobot.skills, _e = _d === void 0 ? { primary: "none", secondary: "none" } : _d, _f = _e.primary, primaryA = _f === void 0 ? "primary" : _f, _g = _e.secondary, secondaryA = _g === void 0 ? "secondary" : _g, i = 0; i < 1; i++) { @@ -121,7 +121,7 @@ for (var _d = multiRobot.skills, _e = _d === void 0 ? { primary: "none", seconda for (var _h = getMultiRobot().skills, _j = _h === void 0 ? { primary: "none", secondary: "none" } : _h, _k = _j.primary, primaryA = _k === void 0 ? "primary" : _k, _l = _j.secondary, secondaryA = _l === void 0 ? "secondary" : _l, i = 0; i < 1; i++) { console.log(primaryA); } -for (var _m = ({ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }).skills, _o = _m === void 0 ? { primary: "none", secondary: "none" } : _m, _p = _o.primary, primaryA = _p === void 0 ? "primary" : _p, _q = _o.secondary, secondaryA = _q === void 0 ? "secondary" : _q, i = 0; i < 1; i++) { +for (var _m = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }.skills, _o = _m === void 0 ? { primary: "none", secondary: "none" } : _m, _p = _o.primary, primaryA = _p === void 0 ? "primary" : _p, _q = _o.secondary, secondaryA = _q === void 0 ? "secondary" : _q, i = 0; i < 1; i++) { console.log(primaryA); } for (var _r = robot.name, nameA = _r === void 0 ? "noName" : _r, _s = robot.skill, skillA = _s === void 0 ? "skill" : _s, i = 0; i < 1; i++) { diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map index ac5719ded6a..0e96b80e749 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js.map] -{"version":3,"file":"sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.ts"],"names":[],"mappings":"AAgBA,IAAI,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACtD,IAAI,UAAU,GAAe,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACjG;IACI,MAAM,CAAC,KAAK,CAAC;AACjB,CAAC;AACD;IACI,MAAM,CAAC,UAAU,CAAC;AACtB,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,eAAqB,EAArB,qCAAqB,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,oBAAsB,EAAtB,qCAAsB,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,kDAAsB,EAAtB,qCAAsB,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CACA,IAAA,sBAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAE3B,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CACA,IAAA,2BAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAEtB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CACA,IAAA,uFAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAGvC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,eAAsB,EAAtB,qCAAsB,EAAE,gBAAuB,EAAvB,qCAAuB,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,eAA+D,EAA9D,YAAsB,EAAtB,qCAAsB,EAAE,aAAuB,EAAvB,qCAAuB,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC1F,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,2CAAkG,EAAjG,YAAsB,EAAtB,qCAAsB,EAAE,aAAuB,EAAvB,qCAAuB,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC7H,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CACA,IAAA,oBAAsB,EAAtB,qCAAsB,EACtB,sBAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAE3B,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,oBAMU,EALf,YAAsB,EAAtB,qCAAsB,EACtB,cAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAEtB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,+EAMgF,EALrF,cAAsB,EAAtB,uCAAsB,EACtB,gBAG0C,EAH1C,mEAG0C,EAFtC,iBAA6B,EAA7B,2CAA6B,EAC7B,mBAAmC,EAAnC,+CAAmC,EAGvC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.js","sourceRoot":"","sources":["sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.ts"],"names":[],"mappings":"AAgBA,IAAI,KAAK,GAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACtD,IAAI,UAAU,GAAe,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;AACjG;IACI,MAAM,CAAC,KAAK,CAAC;AACjB,CAAC;AACD;IACI,MAAM,CAAC,UAAU,CAAC;AACtB,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,eAAqB,EAArB,qCAAqB,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,oBAAsB,EAAtB,qCAAsB,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAM,IAAA,gDAAsB,EAAtB,qCAAsB,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CACA,IAAA,sBAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAE3B,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CACA,IAAA,2BAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAEtB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CACA,IAAA,qFAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAGvC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AAED,GAAG,CAAC,CAAM,IAAA,eAAsB,EAAtB,qCAAsB,EAAE,gBAAuB,EAAvB,qCAAuB,EAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,eAA+D,EAA9D,YAAsB,EAAtB,qCAAsB,EAAE,aAAuB,EAAvB,qCAAuB,EAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC1F,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,2CAAkG,EAAjG,YAAsB,EAAtB,qCAAsB,EAAE,aAAuB,EAAvB,qCAAuB,EAAoD,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAC7H,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AACD,GAAG,CAAC,CACA,IAAA,oBAAsB,EAAtB,qCAAsB,EACtB,sBAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAE3B,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,oBAMU,EALf,YAAsB,EAAtB,qCAAsB,EACtB,cAG0C,EAH1C,gEAG0C,EAFtC,eAA6B,EAA7B,yCAA6B,EAC7B,iBAAmC,EAAnC,6CAAmC,EAEtB,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC;AACD,GAAG,CAAC,CAAK,IAAA,+EAMgF,EALrF,cAAsB,EAAtB,uCAAsB,EACtB,gBAG0C,EAH1C,mEAG0C,EAFtC,iBAA6B,EAA7B,2CAA6B,EAC7B,mBAAmC,EAAnC,+CAAmC,EAGvC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.sourcemap.txt index 61eeccd186f..ebe3dccdad7 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.sourcemap.txt @@ -408,35 +408,35 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPatternDefaultValues. >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(14, 1) Source(31, 1) + SourceIndex(0) 2 >Emitted(14, 2) Source(31, 2) + SourceIndex(0) --- ->>>for (var _c = ({ name: "trimmer", skill: "trimming" }).name, nameA = _c === void 0 ? "noName" : _c, i = 0; i < 1; i++) { +>>>for (var _c = { name: "trimmer", skill: "trimming" }.name, nameA = _c === void 0 ? "noName" : _c, i = 0; i < 1; i++) { 1-> 2 >^^^ 3 > ^ 4 > ^ 5 > ^^^^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -7 > ^^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -9 > ^^ -10> ^ -11> ^^^ -12> ^ -13> ^^ -14> ^ -15> ^^^ -16> ^ -17> ^^ -18> ^ -19> ^^ -20> ^^ -21> ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +9 > ^^ +10> ^ +11> ^^^ +12> ^ +13> ^^ +14> ^ +15> ^^^ +16> ^ +17> ^^ +18> ^ +19> ^^ +20> ^^ +21> ^ 1-> > 2 >for @@ -444,42 +444,42 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPatternDefaultValues. 4 > (let { 5 > 6 > name: nameA = "noName" -7 > -8 > name: nameA = "noName" -9 > } = { name: "trimmer", skill: "trimming" }, -10> i -11> = -12> 0 -13> ; -14> i -15> < -16> 1 -17> ; -18> i -19> ++ -20> ) -21> { +7 > +8 > name: nameA = "noName" +9 > } = { name: "trimmer", skill: "trimming" }, +10> i +11> = +12> 0 +13> ; +14> i +15> < +16> 1 +17> ; +18> i +19> ++ +20> ) +21> { 1->Emitted(15, 1) Source(32, 1) + SourceIndex(0) 2 >Emitted(15, 4) Source(32, 4) + SourceIndex(0) 3 >Emitted(15, 5) Source(32, 5) + SourceIndex(0) 4 >Emitted(15, 6) Source(32, 11) + SourceIndex(0) 5 >Emitted(15, 10) Source(32, 11) + SourceIndex(0) -6 >Emitted(15, 60) Source(32, 33) + SourceIndex(0) -7 >Emitted(15, 62) Source(32, 11) + SourceIndex(0) -8 >Emitted(15, 99) Source(32, 33) + SourceIndex(0) -9 >Emitted(15, 101) Source(32, 85) + SourceIndex(0) -10>Emitted(15, 102) Source(32, 86) + SourceIndex(0) -11>Emitted(15, 105) Source(32, 89) + SourceIndex(0) -12>Emitted(15, 106) Source(32, 90) + SourceIndex(0) -13>Emitted(15, 108) Source(32, 92) + SourceIndex(0) -14>Emitted(15, 109) Source(32, 93) + SourceIndex(0) -15>Emitted(15, 112) Source(32, 96) + SourceIndex(0) -16>Emitted(15, 113) Source(32, 97) + SourceIndex(0) -17>Emitted(15, 115) Source(32, 99) + SourceIndex(0) -18>Emitted(15, 116) Source(32, 100) + SourceIndex(0) -19>Emitted(15, 118) Source(32, 102) + SourceIndex(0) -20>Emitted(15, 120) Source(32, 104) + SourceIndex(0) -21>Emitted(15, 121) Source(32, 105) + SourceIndex(0) +6 >Emitted(15, 58) Source(32, 33) + SourceIndex(0) +7 >Emitted(15, 60) Source(32, 11) + SourceIndex(0) +8 >Emitted(15, 97) Source(32, 33) + SourceIndex(0) +9 >Emitted(15, 99) Source(32, 85) + SourceIndex(0) +10>Emitted(15, 100) Source(32, 86) + SourceIndex(0) +11>Emitted(15, 103) Source(32, 89) + SourceIndex(0) +12>Emitted(15, 104) Source(32, 90) + SourceIndex(0) +13>Emitted(15, 106) Source(32, 92) + SourceIndex(0) +14>Emitted(15, 107) Source(32, 93) + SourceIndex(0) +15>Emitted(15, 110) Source(32, 96) + SourceIndex(0) +16>Emitted(15, 111) Source(32, 97) + SourceIndex(0) +17>Emitted(15, 113) Source(32, 99) + SourceIndex(0) +18>Emitted(15, 114) Source(32, 100) + SourceIndex(0) +19>Emitted(15, 116) Source(32, 102) + SourceIndex(0) +20>Emitted(15, 118) Source(32, 104) + SourceIndex(0) +21>Emitted(15, 119) Source(32, 105) + SourceIndex(0) --- >>> console.log(nameA); 1 >^^^^ @@ -785,43 +785,43 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPatternDefaultValues. >>>} 1 > 2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >} 1 >Emitted(23, 1) Source(50, 1) + SourceIndex(0) 2 >Emitted(23, 2) Source(50, 2) + SourceIndex(0) --- ->>>for (var _m = ({ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }).skills, _o = _m === void 0 ? { primary: "none", secondary: "none" } : _m, _p = _o.primary, primaryA = _p === void 0 ? "primary" : _p, _q = _o.secondary, secondaryA = _q === void 0 ? "secondary" : _q, i = 0; i < 1; i++) { +>>>for (var _m = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }.skills, _o = _m === void 0 ? { primary: "none", secondary: "none" } : _m, _p = _o.primary, primaryA = _p === void 0 ? "primary" : _p, _q = _o.secondary, secondaryA = _q === void 0 ? "secondary" : _q, i = 0; i < 1; i++) { 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> ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +9 > ^^ +10> ^^^^^^^^^^^^^^^ +11> ^^ +12> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13> ^^ +14> ^^^^^^^^^^^^^^^^^ +15> ^^ +16> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +17> ^^ +18> ^ +19> ^^^ +20> ^ +21> ^^ +22> ^ +23> ^^^ +24> ^ +25> ^^ +26> ^ +27> ^^ +28> ^^ +29> ^ 1-> > 2 >for @@ -833,65 +833,65 @@ sourceFile:sourceMapValidationDestructuringForObjectBindingPatternDefaultValues. > primary: primaryA = "primary", > secondary: secondaryA = "secondary" > } = { primary: "none", secondary: "none" } -7 > -8 > skills: { - > primary: primaryA = "primary", - > secondary: secondaryA = "secondary" - > } = { primary: "none", secondary: "none" } -9 > -10> primary: primaryA = "primary" -11> -12> primary: primaryA = "primary" -13> , - > -14> secondary: secondaryA = "secondary" -15> -16> secondary: secondaryA = "secondary" -17> - > } = { primary: "none", secondary: "none" } - > } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, - > -18> i -19> = -20> 0 -21> ; -22> i -23> < -24> 1 -25> ; -26> i -27> ++ -28> ) -29> { +7 > +8 > skills: { + > primary: primaryA = "primary", + > secondary: secondaryA = "secondary" + > } = { primary: "none", secondary: "none" } +9 > +10> primary: primaryA = "primary" +11> +12> primary: primaryA = "primary" +13> , + > +14> secondary: secondaryA = "secondary" +15> +16> secondary: secondaryA = "secondary" +17> + > } = { primary: "none", secondary: "none" } + > } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, + > +18> i +19> = +20> 0 +21> ; +22> i +23> < +24> 1 +25> ; +26> i +27> ++ +28> ) +29> { 1->Emitted(24, 1) Source(51, 1) + SourceIndex(0) 2 >Emitted(24, 4) Source(51, 4) + SourceIndex(0) 3 >Emitted(24, 5) Source(51, 5) + SourceIndex(0) 4 >Emitted(24, 6) Source(52, 5) + SourceIndex(0) 5 >Emitted(24, 10) Source(52, 5) + SourceIndex(0) -6 >Emitted(24, 97) Source(55, 47) + SourceIndex(0) -7 >Emitted(24, 99) Source(52, 5) + SourceIndex(0) -8 >Emitted(24, 163) Source(55, 47) + SourceIndex(0) -9 >Emitted(24, 165) Source(53, 9) + SourceIndex(0) -10>Emitted(24, 180) Source(53, 38) + SourceIndex(0) -11>Emitted(24, 182) Source(53, 9) + SourceIndex(0) -12>Emitted(24, 223) Source(53, 38) + SourceIndex(0) -13>Emitted(24, 225) Source(54, 9) + SourceIndex(0) -14>Emitted(24, 242) Source(54, 44) + SourceIndex(0) -15>Emitted(24, 244) Source(54, 9) + SourceIndex(0) -16>Emitted(24, 289) Source(54, 44) + SourceIndex(0) -17>Emitted(24, 291) Source(57, 5) + SourceIndex(0) -18>Emitted(24, 292) Source(57, 6) + SourceIndex(0) -19>Emitted(24, 295) Source(57, 9) + SourceIndex(0) -20>Emitted(24, 296) Source(57, 10) + SourceIndex(0) -21>Emitted(24, 298) Source(57, 12) + SourceIndex(0) -22>Emitted(24, 299) Source(57, 13) + SourceIndex(0) -23>Emitted(24, 302) Source(57, 16) + SourceIndex(0) -24>Emitted(24, 303) Source(57, 17) + SourceIndex(0) -25>Emitted(24, 305) Source(57, 19) + SourceIndex(0) -26>Emitted(24, 306) Source(57, 20) + SourceIndex(0) -27>Emitted(24, 308) Source(57, 22) + SourceIndex(0) -28>Emitted(24, 310) Source(57, 24) + SourceIndex(0) -29>Emitted(24, 311) Source(57, 25) + SourceIndex(0) +6 >Emitted(24, 95) Source(55, 47) + SourceIndex(0) +7 >Emitted(24, 97) Source(52, 5) + SourceIndex(0) +8 >Emitted(24, 161) Source(55, 47) + SourceIndex(0) +9 >Emitted(24, 163) Source(53, 9) + SourceIndex(0) +10>Emitted(24, 178) Source(53, 38) + SourceIndex(0) +11>Emitted(24, 180) Source(53, 9) + SourceIndex(0) +12>Emitted(24, 221) Source(53, 38) + SourceIndex(0) +13>Emitted(24, 223) Source(54, 9) + SourceIndex(0) +14>Emitted(24, 240) Source(54, 44) + SourceIndex(0) +15>Emitted(24, 242) Source(54, 9) + SourceIndex(0) +16>Emitted(24, 287) Source(54, 44) + SourceIndex(0) +17>Emitted(24, 289) Source(57, 5) + SourceIndex(0) +18>Emitted(24, 290) Source(57, 6) + SourceIndex(0) +19>Emitted(24, 293) Source(57, 9) + SourceIndex(0) +20>Emitted(24, 294) Source(57, 10) + SourceIndex(0) +21>Emitted(24, 296) Source(57, 12) + SourceIndex(0) +22>Emitted(24, 297) Source(57, 13) + SourceIndex(0) +23>Emitted(24, 300) Source(57, 16) + SourceIndex(0) +24>Emitted(24, 301) Source(57, 17) + SourceIndex(0) +25>Emitted(24, 303) Source(57, 19) + SourceIndex(0) +26>Emitted(24, 304) Source(57, 20) + SourceIndex(0) +27>Emitted(24, 306) Source(57, 22) + SourceIndex(0) +28>Emitted(24, 308) Source(57, 24) + SourceIndex(0) +29>Emitted(24, 309) Source(57, 25) + SourceIndex(0) --- >>> console.log(primaryA); 1 >^^^^ diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js index 164159655b2..a20e7578d93 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js @@ -2,5 +2,5 @@ var {x} = { x: 20 }; //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js] -var x = ({ x: 20 }).x; +var x = { x: 20 }.x; //# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map index b1104fa4eab..b0a552391c9 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts"],"names":[],"mappings":"AAAK,IAAA,iBAAC,CAAc"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts"],"names":[],"mappings":"AAAK,IAAA,eAAC,CAAc"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt index fb41dc6233f..0c554c986a4 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.sourcemap.txt @@ -8,19 +8,19 @@ sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern1. emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.ts ------------------------------------------------------------------- ->>>var x = ({ x: 20 }).x; +>>>var x = { x: 20 }.x; 1 > 2 >^^^^ -3 > ^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >var { 2 > 3 > x -4 > } = { x: 20 }; +4 > } = { x: 20 }; 1 >Emitted(1, 1) Source(1, 6) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 6) + SourceIndex(0) -3 >Emitted(1, 22) Source(1, 7) + SourceIndex(0) -4 >Emitted(1, 23) Source(1, 21) + SourceIndex(0) +3 >Emitted(1, 20) Source(1, 7) + SourceIndex(0) +4 >Emitted(1, 21) Source(1, 21) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js index 771bda92ef4..44295762d6d 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js @@ -3,6 +3,6 @@ var {x} = { x: 20 }; var { a, b } = { a: 30, b: 40 }; //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js] -var x = ({ x: 20 }).x; +var x = { x: 20 }.x; var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; //# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map index 5acc1fea7fa..eb36a3b9022 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts"],"names":[],"mappings":"AAAK,IAAA,iBAAC,CAAc;AAChB,IAAA,qBAA2B,EAAzB,QAAC,EAAE,QAAC,CAAsB"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts"],"names":[],"mappings":"AAAK,IAAA,eAAC,CAAc;AAChB,IAAA,qBAA2B,EAAzB,QAAC,EAAE,QAAC,CAAsB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt index 51c431c5da5..2390f91a8b1 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.sourcemap.txt @@ -8,20 +8,20 @@ sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern2. emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.js sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.ts ------------------------------------------------------------------- ->>>var x = ({ x: 20 }).x; +>>>var x = { x: 20 }.x; 1 > 2 >^^^^ -3 > ^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^ +4 > ^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >var { 2 > 3 > x -4 > } = { x: 20 }; +4 > } = { x: 20 }; 1 >Emitted(1, 1) Source(1, 6) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 6) + SourceIndex(0) -3 >Emitted(1, 22) Source(1, 7) + SourceIndex(0) -4 >Emitted(1, 23) Source(1, 21) + SourceIndex(0) +3 >Emitted(1, 20) Source(1, 7) + SourceIndex(0) +4 >Emitted(1, 21) Source(1, 21) + SourceIndex(0) --- >>>var _a = { a: 30, b: 40 }, a = _a.a, b = _a.b; 1-> diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js index 3ef30f1a8aa..88a5bce4dcc 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js @@ -2,5 +2,5 @@ var {x = 500} = { x: 20 }; //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js] -var _a = ({ x: 20 }).x, x = _a === void 0 ? 500 : _a; +var _a = { x: 20 }.x, x = _a === void 0 ? 500 : _a; //# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map index d974f0b7c78..1faa8f8e71a 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map] -{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts"],"names":[],"mappings":"AAAK,IAAA,kBAAO,EAAP,4BAAO,CAAc"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js","sourceRoot":"","sources":["sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts"],"names":[],"mappings":"AAAK,IAAA,gBAAO,EAAP,4BAAO,CAAc"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt index 7c06d77cf83..d58e756de42 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.sourcemap.txt @@ -8,25 +8,25 @@ sources: sourceMapValidationDestructuringVariableStatementObjectBindingPattern3. emittedFile:tests/cases/compiler/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js sourceFile:sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.ts ------------------------------------------------------------------- ->>>var _a = ({ x: 20 }).x, x = _a === void 0 ? 500 : _a; +>>>var _a = { x: 20 }.x, x = _a === void 0 ? 500 : _a; 1 > 2 >^^^^ -3 > ^^^^^^^^^^^^^^^^^^ -4 > ^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -6 > ^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^ +4 > ^^ +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +6 > ^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >var { 2 > 3 > x = 500 -4 > -5 > x = 500 -6 > } = { x: 20 }; +4 > +5 > x = 500 +6 > } = { x: 20 }; 1 >Emitted(1, 1) Source(1, 6) + SourceIndex(0) 2 >Emitted(1, 5) Source(1, 6) + SourceIndex(0) -3 >Emitted(1, 23) Source(1, 13) + SourceIndex(0) -4 >Emitted(1, 25) Source(1, 6) + SourceIndex(0) -5 >Emitted(1, 53) Source(1, 13) + SourceIndex(0) -6 >Emitted(1, 54) Source(1, 27) + SourceIndex(0) +3 >Emitted(1, 21) Source(1, 13) + SourceIndex(0) +4 >Emitted(1, 23) Source(1, 6) + SourceIndex(0) +5 >Emitted(1, 51) Source(1, 13) + SourceIndex(0) +6 >Emitted(1, 52) Source(1, 27) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.js.map \ No newline at end of file diff --git a/tests/baselines/reference/strictModeReservedWordInDestructuring.js b/tests/baselines/reference/strictModeReservedWordInDestructuring.js index 7186683bdff..78c8ab788ca 100644 --- a/tests/baselines/reference/strictModeReservedWordInDestructuring.js +++ b/tests/baselines/reference/strictModeReservedWordInDestructuring.js @@ -11,7 +11,7 @@ var { public: a, protected: b } = { public: 1, protected: 2 }; //// [strictModeReservedWordInDestructuring.js] "use strict"; var public = [1][0]; -var public = ({ x: 1 }).x; +var public = { x: 1 }.x; var private = [["hello"]][0][0]; var _a = { y: { s: 1 }, z: { o: { p: 'h' } } }, static = _a.y.s, package = _a.z.o.p; var _b = { public: 1, protected: 2 }, public = _b.public, protected = _b.protected; diff --git a/tests/baselines/reference/strictModeUseContextualKeyword.js b/tests/baselines/reference/strictModeUseContextualKeyword.js index 0e28f5828fd..6d5d3dfd5e0 100644 --- a/tests/baselines/reference/strictModeUseContextualKeyword.js +++ b/tests/baselines/reference/strictModeUseContextualKeyword.js @@ -27,5 +27,5 @@ function F() { function as() { } } function H() { - var as = ({ as: 1 }).as; + var as = { as: 1 }.as; } diff --git a/tests/baselines/reference/templateStringInObjectLiteral.js b/tests/baselines/reference/templateStringInObjectLiteral.js index 5a096b0adfa..0381e9a95e7 100644 --- a/tests/baselines/reference/templateStringInObjectLiteral.js +++ b/tests/baselines/reference/templateStringInObjectLiteral.js @@ -5,8 +5,8 @@ var x = { } //// [templateStringInObjectLiteral.js] -var x = (_a = ["b"], _a.raw = ["b"], ({ +var x = (_a = ["b"], _a.raw = ["b"], { a: "abc" + 123 + "def" -})(_a)); +}(_a)); 321; var _a; diff --git a/tests/baselines/reference/templateStringInPropertyName1.js b/tests/baselines/reference/templateStringInPropertyName1.js index 18e35c475e3..239ba78d827 100644 --- a/tests/baselines/reference/templateStringInPropertyName1.js +++ b/tests/baselines/reference/templateStringInPropertyName1.js @@ -4,6 +4,6 @@ var x = { } //// [templateStringInPropertyName1.js] -var x = (_a = ["a"], _a.raw = ["a"], ({})(_a)); +var x = (_a = ["a"], _a.raw = ["a"], {}(_a)); 321; var _a; diff --git a/tests/baselines/reference/templateStringInPropertyName2.js b/tests/baselines/reference/templateStringInPropertyName2.js index 1a2995ca08f..8a71a6e30be 100644 --- a/tests/baselines/reference/templateStringInPropertyName2.js +++ b/tests/baselines/reference/templateStringInPropertyName2.js @@ -4,6 +4,6 @@ var x = { } //// [templateStringInPropertyName2.js] -var x = (_a = ["abc", "def", "ghi"], _a.raw = ["abc", "def", "ghi"], ({})(_a, 123, 456)); +var x = (_a = ["abc", "def", "ghi"], _a.raw = ["abc", "def", "ghi"], {}(_a, 123, 456)); 321; var _a; From 37d320d0c813298eac473a5678cd64947edeb391 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 14:19:18 -0700 Subject: [PATCH 106/216] Rename visitedFlowXXX to sharedFlowXXX --- src/compiler/checker.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06e21e18501..521ce94ee3a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -333,7 +333,7 @@ namespace ts { let flowLoopStart = 0; let flowLoopCount = 0; - let visitedFlowCount = 0; + let sharedFlowCount = 0; let flowAnalysisDisabled = false; const emptyStringType = getLiteralType(""); @@ -352,8 +352,8 @@ namespace ts { const flowLoopNodes: FlowNode[] = []; const flowLoopKeys: string[] = []; const flowLoopTypes: Type[][] = []; - const visitedFlowNodes: FlowNode[] = []; - const visitedFlowTypes: FlowType[] = []; + const sharedFlowNodes: FlowNode[] = []; + const sharedFlowTypes: FlowType[] = []; const potentialThisCollisions: Node[] = []; const potentialNewTargetCollisions: Node[] = []; const awaitedTypeStack: number[] = []; @@ -11502,9 +11502,9 @@ namespace ts { if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; } - const visitedFlowStart = visitedFlowCount; + const sharedFlowStart = sharedFlowCount; const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); - visitedFlowCount = visitedFlowStart; + sharedFlowCount = sharedFlowStart; // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without @@ -11532,9 +11532,9 @@ namespace ts { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. - for (let i = visitedFlowStart; i < visitedFlowCount; i++) { - if (visitedFlowNodes[i] === flow) { - return visitedFlowTypes[i]; + for (let i = sharedFlowStart; i < sharedFlowCount; i++) { + if (sharedFlowNodes[i] === flow) { + return sharedFlowTypes[i]; } } } @@ -11597,9 +11597,9 @@ namespace ts { } if (flags & FlowFlags.Shared) { // Record visited node and the associated type in the cache. - visitedFlowNodes[visitedFlowCount] = flow; - visitedFlowTypes[visitedFlowCount] = type; - visitedFlowCount++; + sharedFlowNodes[sharedFlowCount] = flow; + sharedFlowTypes[sharedFlowCount] = type; + sharedFlowCount++; } return type; } From 26903552fe3ec570161b8478f11472e55e415e1c Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 8 Sep 2017 13:07:32 -0700 Subject: [PATCH 107/216] Improve insertion position of extracted methods Old: End of target scope New: Before the first non-constructor function following the extracted range in the target scope --- src/compiler/utilities.ts | 2 +- src/services/refactors/extractMethod.ts | 43 +++++++++++++++++++++-- tests/cases/fourslash/extract-method13.ts | 18 +++++++--- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 06b8437f76b..3d24dfc1670 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -505,7 +505,7 @@ namespace ts { } } - function staticAssertNever(_: never): void {} + export function staticAssertNever(_: never): void {} // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 83908def444..50da5fccf10 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -697,8 +697,14 @@ namespace ts.refactor.extractMethod { } const changeTracker = textChanges.ChangeTracker.fromContext(context); - // insert function at the end of the scope - changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); + const minInsertionPos = (isReadonlyArray(range.range) ? lastOrUndefined(range.range) : range.range).end; + const nodeToInsertBefore = getNodeToInsertBefore(minInsertionPos, scope); + if (nodeToInsertBefore) { + changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newFunction, { suffix: context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); + } const newNodes: Node[] = []; // replace range with function call @@ -831,6 +837,39 @@ namespace ts.refactor.extractMethod { return "__return"; } + function getStatementsOrClassElements(scope: Scope): ReadonlyArray | ReadonlyArray { + if (isFunctionLike(scope)) { + const body = scope.body; + if (isBlock(body)) { + return body.statements; + } + } + else if (isModuleBlock(scope) || isSourceFile(scope)) { + return scope.statements; + } + else if (isClassLike(scope)) { + return scope.members; + } + else { + staticAssertNever(scope); + } + + return emptyArray; + } + + /** + * If `scope` contains a function after `minPos`, then return the first such function. + * Otherwise, return `undefined`. + */ + function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { + const children = getStatementsOrClassElements(scope); + for (const child of children) { + if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { + return child; + } + } + } + function transformFunctionBody(body: Node) { if (isBlock(body) && !writes && substitutions.size === 0) { // already block, no writes to propagate back, no substitutions - can use node as is diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index 94ad86e4399..c000ff27a1f 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -16,6 +16,16 @@ edit.applyRefactor({ actionDescription: "Extract function into class 'C'", }); +verify.currentFileContentIs(`class C { + static j = 1 + 1; + constructor(q: string = C.newFunction()) { + } + + private static newFunction(): string { + return "a" + "b"; + } +}`); + goTo.select('c', 'd'); edit.applyRefactor({ refactorName: "Extract Method", @@ -28,11 +38,11 @@ verify.currentFileContentIs(`class C { constructor(q: string = C.newFunction()) { } - private static newFunction(): string { - return "a" + "b"; - } - private static newFunction_1() { return 1 + 1; } + + private static newFunction(): string { + return "a" + "b"; + } }`); \ No newline at end of file From 409d6597ebde2fce5673c9704907e339c8a5dc2d Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 8 Sep 2017 14:22:44 -0700 Subject: [PATCH 108/216] Add `never` helper function (#18287) * Add `never` helper function * Move to Debug.assertNever, keep old messages --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9c72a064b11..aa5fbd6421c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1687,7 +1687,7 @@ namespace ts { undefined; } else { - Debug.fail("Unknown entity name kind."); + Debug.assertNever(name, "Unknown entity name kind."); } Debug.assert((getCheckFlags(symbol) & CheckFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -16357,7 +16357,7 @@ namespace ts { // This code-path is called by language service return resolveStatelessJsxOpeningLikeElement(node, checkExpression((node).tagName), candidatesOutArray); } - Debug.fail("Branch in 'resolveSignature' should be unreachable."); + Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } /** @@ -24535,7 +24535,7 @@ namespace ts { currentKind = SetAccessor; } else { - Debug.fail("Unexpected syntax kind:" + (prop).kind); + Debug.assertNever(prop, "Unexpected syntax kind:" + (prop).kind); } const effectiveName = getPropertyNameForPropertyNameNode(name); From 25268ce3682486e6d1d24d45f4f616a3b28db612 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 14:24:32 -0700 Subject: [PATCH 109/216] Separate counters for stack depth and visited flow nodes --- src/compiler/checker.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 521ce94ee3a..f5d75ccd569 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -334,7 +334,7 @@ namespace ts { let flowLoopStart = 0; let flowLoopCount = 0; let sharedFlowCount = 0; - let flowAnalysisDisabled = false; + let flowNodeCount = 0; const emptyStringType = getLiteralType(""); const zeroType = getLiteralType(0); @@ -11495,8 +11495,8 @@ namespace ts { function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; - let flowLength = 0; - if (flowAnalysisDisabled) { + let flowDepth = 0; + if (flowNodeCount < 0) { return unknownType; } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { @@ -11516,14 +11516,14 @@ namespace ts { return resultType; function getTypeAtFlowNode(flow: FlowNode): FlowType { - flowLength++; + flowDepth++; while (true) { - flowLength++; - if (flowLength >= 5000) { - // We have visited as many as 5000 nodes through as many as 2500 recursive invocations. Rather than - // spending an excessive amount of time and possibly overflowing the call stack, we report an error + flowNodeCount++; + if (flowDepth >= 2500 || flowNodeCount >= 100000000) { + // We have made over 2500 recursive invocations or visited over 100M flow nodes. Rather than + // overflowing the call stack or spending an excessive amount of time, we report an error // and disable further control flow analysis in the containing function or module body. - flowAnalysisDisabled = true; + flowNodeCount = -1; reportFlowControlError(reference); return unknownType; } @@ -11534,6 +11534,7 @@ namespace ts { // antecedent of more than one node. for (let i = sharedFlowStart; i < sharedFlowCount; i++) { if (sharedFlowNodes[i] === flow) { + flowDepth--; return sharedFlowTypes[i]; } } @@ -11601,6 +11602,7 @@ namespace ts { sharedFlowTypes[sharedFlowCount] = type; sharedFlowCount++; } + flowDepth--; return type; } } @@ -19976,9 +19978,15 @@ namespace ts { if (node.kind === SyntaxKind.Block) { checkGrammarStatementInAmbientContext(node); } - const saveFlowAnalysisDisabled = flowAnalysisDisabled; - forEach(node.statements, checkSourceElement); - flowAnalysisDisabled = saveFlowAnalysisDisabled; + if (isFunctionOrModuleBlock(node)) { + const saveFlowNodeCount = flowNodeCount; + flowNodeCount = 0; + forEach(node.statements, checkSourceElement); + flowNodeCount = saveFlowNodeCount; + } + else { + forEach(node.statements, checkSourceElement); + } if (node.locals) { registerForUnusedIdentifiersCheck(node); } @@ -22568,7 +22576,7 @@ namespace ts { deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; - flowAnalysisDisabled = false; + flowNodeCount = 0; forEach(node.statements, checkSourceElement); From e77425f9846dcdf500af3ffcb00c236fce864106 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 8 Sep 2017 14:36:21 -0700 Subject: [PATCH 110/216] Delete staticAssertNever in favor of assertTypeIsNever --- src/compiler/utilities.ts | 4 +--- src/services/refactors/extractMethod.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3d24dfc1670..c75977d1ee2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -500,13 +500,11 @@ namespace ts { case SyntaxKind.ArrowFunction: return true; default: - staticAssertNever(node); + assertTypeIsNever(node); return false; } } - export function staticAssertNever(_: never): void {} - // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. export function getEnclosingBlockScopeContainer(node: Node): Node { diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 50da5fccf10..383302889bc 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -851,7 +851,7 @@ namespace ts.refactor.extractMethod { return scope.members; } else { - staticAssertNever(scope); + assertTypeIsNever(scope); } return emptyArray; From c671c3ac06af37c949bb0886c2a0f3582ba749c2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 15:51:11 -0700 Subject: [PATCH 111/216] Only track flow analysis stack depth --- src/compiler/checker.ts | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9970aa0b3ed..53c2177a70a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -335,7 +335,7 @@ namespace ts { let flowLoopStart = 0; let flowLoopCount = 0; let sharedFlowCount = 0; - let flowNodeCount = 0; + let flowAnalysisDisabled = false; const emptyStringType = getLiteralType(""); const zeroType = getLiteralType(0); @@ -11470,7 +11470,7 @@ namespace ts { function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string; let flowDepth = 0; - if (flowNodeCount < 0) { + if (flowAnalysisDisabled) { return unknownType; } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & TypeFlags.Narrowable)) { @@ -11490,17 +11490,15 @@ namespace ts { return resultType; function getTypeAtFlowNode(flow: FlowNode): FlowType { + if (flowDepth === 2500) { + // We have made 2500 recursive invocations. To avoid overflowing the call stack we report an error + // and disable further control flow analysis in the containing function or module body. + flowAnalysisDisabled = true; + reportFlowControlError(reference); + return unknownType; + } flowDepth++; while (true) { - flowNodeCount++; - if (flowDepth >= 2500 || flowNodeCount >= 100000000) { - // We have made over 2500 recursive invocations or visited over 100M flow nodes. Rather than - // overflowing the call stack or spending an excessive amount of time, we report an error - // and disable further control flow analysis in the containing function or module body. - flowNodeCount = -1; - reportFlowControlError(reference); - return unknownType; - } const flags = flow.flags; if (flags & FlowFlags.Shared) { // We cache results of flow type resolution for shared nodes that were previously visited in @@ -19963,10 +19961,9 @@ namespace ts { checkGrammarStatementInAmbientContext(node); } if (isFunctionOrModuleBlock(node)) { - const saveFlowNodeCount = flowNodeCount; - flowNodeCount = 0; + const saveFlowAnalysisDisabled = flowAnalysisDisabled; forEach(node.statements, checkSourceElement); - flowNodeCount = saveFlowNodeCount; + flowAnalysisDisabled = saveFlowAnalysisDisabled; } else { forEach(node.statements, checkSourceElement); @@ -22560,7 +22557,7 @@ namespace ts { deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; - flowNodeCount = 0; + flowAnalysisDisabled = false; forEach(node.statements, checkSourceElement); From 4ba50aadb0a08965f115b5bcc9cf13e0d20a2034 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 15:51:25 -0700 Subject: [PATCH 112/216] Update test --- tests/cases/compiler/largeControlFlowGraph.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/cases/compiler/largeControlFlowGraph.ts b/tests/cases/compiler/largeControlFlowGraph.ts index 0503c80095b..6cd64530718 100644 --- a/tests/cases/compiler/largeControlFlowGraph.ts +++ b/tests/cases/compiler/largeControlFlowGraph.ts @@ -1,3 +1,5 @@ +// @strict: true + // The control flow graph for the following statement block is 10000 nodes deep. Check that // we gracefully handle this, possibly by issuing an error. const data = []; From c646971cecfe27235c0b07e3bb9d7f868fc0c7f9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Sep 2017 15:52:02 -0700 Subject: [PATCH 113/216] Accept new baselines --- tests/baselines/reference/largeControlFlowGraph.errors.txt | 6 +++--- tests/baselines/reference/largeControlFlowGraph.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/largeControlFlowGraph.errors.txt b/tests/baselines/reference/largeControlFlowGraph.errors.txt index f9dad52c79f..23095c25f74 100644 --- a/tests/baselines/reference/largeControlFlowGraph.errors.txt +++ b/tests/baselines/reference/largeControlFlowGraph.errors.txt @@ -1,10 +1,12 @@ -tests/cases/compiler/largeControlFlowGraph.ts(5003,1): error TS2563: The body of the containing function or module is too large for control flow analysis. +tests/cases/compiler/largeControlFlowGraph.ts(3,1): error TS2563: The containing function or module body is too large for control flow analysis. ==== tests/cases/compiler/largeControlFlowGraph.ts (1 errors) ==== // The control flow graph for the following statement block is 10000 nodes deep. Check that // we gracefully handle this, possibly by issuing an error. const data = []; + ~~~~~ +!!! error TS2563: The containing function or module body is too large for control flow analysis. data[0] = 0; data[0] = 0; data[0] = 0; @@ -5005,8 +5007,6 @@ tests/cases/compiler/largeControlFlowGraph.ts(5003,1): error TS2563: The body of data[0] = 0; data[0] = 0; data[0] = 0; - ~~~~ -!!! error TS2563: The body of the containing function or module is too large for control flow analysis. data[0] = 0; data[0] = 0; data[0] = 0; diff --git a/tests/baselines/reference/largeControlFlowGraph.js b/tests/baselines/reference/largeControlFlowGraph.js index ee1edbe8984..6476cbc11d2 100644 --- a/tests/baselines/reference/largeControlFlowGraph.js +++ b/tests/baselines/reference/largeControlFlowGraph.js @@ -10005,6 +10005,7 @@ data[0] = 0; //// [largeControlFlowGraph.js] +"use strict"; // The control flow graph for the following statement block is 10000 nodes deep. Check that // we gracefully handle this, possibly by issuing an error. var data = []; From 62899d10cddc58aea83e32a695141ca1dde66dd4 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 8 Sep 2017 16:45:47 -0700 Subject: [PATCH 114/216] Add simple baseline tests for insertion positions --- src/harness/unittests/extractMethods.ts | 58 ++++++++++++++++++- .../extractMethod/extractMethod23.ts | 43 ++++++++++++++ .../extractMethod/extractMethod24.ts | 43 ++++++++++++++ .../extractMethod/extractMethod25.ts | 26 +++++++++ .../extractMethod/extractMethod26.ts | 31 ++++++++++ .../extractMethod/extractMethod27.ts | 34 +++++++++++ .../extractMethod/extractMethod28.ts | 34 +++++++++++ 7 files changed, 267 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod23.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod24.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod25.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod26.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod27.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod28.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 75404d12bf0..edcc80cd57c 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -224,7 +224,7 @@ namespace ts { testExtractRange(` function f() { while (true) { - [#| + [#| if (x) { return; } |] @@ -234,7 +234,7 @@ namespace ts { testExtractRange(` function f() { while (true) { - [#| + [#| [$|if (x) { } return;|] @@ -655,6 +655,60 @@ function test(x: number) { finally { [#|return 1;|] } +}`); + // Extraction position - namespace + testExtractMethod("extractMethod23", + `namespace NS { + function M1() { } + function M2() { + [#|return 1;|] + } + function M3() { } +}`); + // Extraction position - function + testExtractMethod("extractMethod24", + `function Outer() { + function M1() { } + function M2() { + [#|return 1;|] + } + function M3() { } +}`); + // Extraction position - file + testExtractMethod("extractMethod25", + `function M1() { } +function M2() { + [#|return 1;|] +} +function M3() { }`); + // Extraction position - class without ctor + testExtractMethod("extractMethod26", + `class C { + M1() { } + M2() { + [#|return 1;|] + } + M3() { } +}`); + // Extraction position - class with ctor in middle + testExtractMethod("extractMethod27", + `class C { + M1() { } + M2() { + [#|return 1;|] + } + constructor() { } + M3() { } +}`); + // Extraction position - class with ctor at end + testExtractMethod("extractMethod28", + `class C { + M1() { } + M2() { + [#|return 1;|] + } + M3() { } + constructor() { } }`); }); diff --git a/tests/baselines/reference/extractMethod/extractMethod23.ts b/tests/baselines/reference/extractMethod/extractMethod23.ts new file mode 100644 index 00000000000..8bc3db86cc1 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod23.ts @@ -0,0 +1,43 @@ +// ==ORIGINAL== +namespace NS { + function M1() { } + function M2() { + return 1; + } + function M3() { } +} +// ==SCOPE::function 'M2'== +namespace NS { + function M1() { } + function M2() { + return newFunction(); + + function newFunction() { + return 1; + } + } + function M3() { } +} +// ==SCOPE::namespace 'NS'== +namespace NS { + function M1() { } + function M2() { + return newFunction(); + } + function newFunction() { + return 1; + } + + function M3() { } +} +// ==SCOPE::global scope== +namespace NS { + function M1() { } + function M2() { + return newFunction(); + } + function M3() { } +} +function newFunction() { + return 1; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod24.ts b/tests/baselines/reference/extractMethod/extractMethod24.ts new file mode 100644 index 00000000000..ec6d6cd3f12 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod24.ts @@ -0,0 +1,43 @@ +// ==ORIGINAL== +function Outer() { + function M1() { } + function M2() { + return 1; + } + function M3() { } +} +// ==SCOPE::function 'M2'== +function Outer() { + function M1() { } + function M2() { + return newFunction(); + + function newFunction() { + return 1; + } + } + function M3() { } +} +// ==SCOPE::function 'Outer'== +function Outer() { + function M1() { } + function M2() { + return newFunction(); + } + function newFunction() { + return 1; + } + + function M3() { } +} +// ==SCOPE::global scope== +function Outer() { + function M1() { } + function M2() { + return newFunction(); + } + function M3() { } +} +function newFunction() { + return 1; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod25.ts b/tests/baselines/reference/extractMethod/extractMethod25.ts new file mode 100644 index 00000000000..a7a971315a1 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod25.ts @@ -0,0 +1,26 @@ +// ==ORIGINAL== +function M1() { } +function M2() { + return 1; +} +function M3() { } +// ==SCOPE::function 'M2'== +function M1() { } +function M2() { + return newFunction(); + + function newFunction() { + return 1; + } +} +function M3() { } +// ==SCOPE::global scope== +function M1() { } +function M2() { + return newFunction(); +} +function newFunction() { + return 1; +} + +function M3() { } \ No newline at end of file diff --git a/tests/baselines/reference/extractMethod/extractMethod26.ts b/tests/baselines/reference/extractMethod/extractMethod26.ts new file mode 100644 index 00000000000..d0619ea9b0a --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod26.ts @@ -0,0 +1,31 @@ +// ==ORIGINAL== +class C { + M1() { } + M2() { + return 1; + } + M3() { } +} +// ==SCOPE::class 'C'== +class C { + M1() { } + M2() { + return this.newFunction(); + } + private newFunction() { + return 1; + } + + M3() { } +} +// ==SCOPE::global scope== +class C { + M1() { } + M2() { + return newFunction(); + } + M3() { } +} +function newFunction() { + return 1; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod27.ts b/tests/baselines/reference/extractMethod/extractMethod27.ts new file mode 100644 index 00000000000..9f1f1e84a77 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod27.ts @@ -0,0 +1,34 @@ +// ==ORIGINAL== +class C { + M1() { } + M2() { + return 1; + } + constructor() { } + M3() { } +} +// ==SCOPE::class 'C'== +class C { + M1() { } + M2() { + return this.newFunction(); + } + constructor() { } + private newFunction() { + return 1; + } + + M3() { } +} +// ==SCOPE::global scope== +class C { + M1() { } + M2() { + return newFunction(); + } + constructor() { } + M3() { } +} +function newFunction() { + return 1; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod28.ts b/tests/baselines/reference/extractMethod/extractMethod28.ts new file mode 100644 index 00000000000..9b97e581548 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod28.ts @@ -0,0 +1,34 @@ +// ==ORIGINAL== +class C { + M1() { } + M2() { + return 1; + } + M3() { } + constructor() { } +} +// ==SCOPE::class 'C'== +class C { + M1() { } + M2() { + return this.newFunction(); + } + private newFunction() { + return 1; + } + + M3() { } + constructor() { } +} +// ==SCOPE::global scope== +class C { + M1() { } + M2() { + return newFunction(); + } + M3() { } + constructor() { } +} +function newFunction() { + return 1; +} From 018c645913425dfdaadf99bbfb014ca05e6076d5 Mon Sep 17 00:00:00 2001 From: Andy Date: Sat, 9 Sep 2017 05:52:08 -0700 Subject: [PATCH 115/216] In import code fix, don't treat a re-export as an import (#18341) --- src/services/codefixes/importFixes.ts | 30 +++++++------------ .../fourslash/importNameCodeFixReExport.ts | 16 ++++++++++ 2 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 tests/cases/fourslash/importNameCodeFixReExport.ts diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 99b677ebd3d..96f4b7ad4b5 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -133,7 +133,7 @@ namespace ts.codefix { const symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map - const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; + const cachedImportDeclarations: AnyImportSyntax[][] = []; let lastImportDeclaration: Node; const currentTokenMeaning = getMeaningFromLocation(token); @@ -199,28 +199,20 @@ namespace ts.codefix { return cached; } - const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = []; - for (const importModuleSpecifier of sourceFile.imports) { - const importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); - if (importSymbol === moduleSymbol) { - existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); - } - } + const existingDeclarations = mapDefined(sourceFile.imports, importModuleSpecifier => + checker.getSymbolAtLocation(importModuleSpecifier) === moduleSymbol ? getImportDeclaration(importModuleSpecifier) : undefined); cachedImportDeclarations[moduleSymbolId] = existingDeclarations; return existingDeclarations; - function getImportDeclaration(moduleSpecifier: LiteralExpression) { - let node: Node = moduleSpecifier; - while (node) { - if (node.kind === SyntaxKind.ImportDeclaration) { - return node; - } - if (node.kind === SyntaxKind.ImportEqualsDeclaration) { - return node; - } - node = node.parent; + function getImportDeclaration({ parent }: LiteralExpression): AnyImportSyntax { + switch (parent.kind) { + case SyntaxKind.ImportDeclaration: + return parent as ImportDeclaration; + case SyntaxKind.ExternalModuleReference: + return (parent as ExternalModuleReference).parent; + default: + return undefined; } - return undefined; } } diff --git a/tests/cases/fourslash/importNameCodeFixReExport.ts b/tests/cases/fourslash/importNameCodeFixReExport.ts new file mode 100644 index 00000000000..c77d32cc458 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixReExport.ts @@ -0,0 +1,16 @@ +/// + +// Test that we are not fooled by a re-export existing in the file already + +// @Filename: /a.ts +////export const x = 0"; + +// @Filename: /b.ts +////[|export { x } from "./a"; +////x;|] + +goTo.file("/b.ts"); +verify.rangeAfterCodeFix(`import { x } from "./a"; + +export { x } from "./a"; +x;`, /*includeWhiteSpace*/ true); From e51e91dd2c372a9d8e6cead2589c30fbe488c333 Mon Sep 17 00:00:00 2001 From: Andy Date: Sat, 9 Sep 2017 05:52:52 -0700 Subject: [PATCH 116/216] Change wording of scope description (#18342) --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/utilities.ts | 27 +++++-- src/services/refactors/extractMethod.ts | 75 ++++++++++--------- .../reference/extractMethod/extractMethod1.ts | 8 +- .../extractMethod/extractMethod10.ts | 6 +- .../extractMethod/extractMethod11.ts | 6 +- .../extractMethod/extractMethod12.ts | 2 +- .../extractMethod/extractMethod13.ts | 6 +- .../extractMethod/extractMethod14.ts | 6 +- .../extractMethod/extractMethod15.ts | 6 +- .../extractMethod/extractMethod16.ts | 4 +- .../extractMethod/extractMethod17.ts | 4 +- .../extractMethod/extractMethod18.ts | 4 +- .../extractMethod/extractMethod19.ts | 4 +- .../reference/extractMethod/extractMethod2.ts | 8 +- .../extractMethod/extractMethod20.ts | 4 +- .../extractMethod/extractMethod21.ts | 4 +- .../extractMethod/extractMethod22.ts | 4 +- .../reference/extractMethod/extractMethod3.ts | 8 +- .../reference/extractMethod/extractMethod4.ts | 8 +- .../reference/extractMethod/extractMethod5.ts | 8 +- .../reference/extractMethod/extractMethod6.ts | 8 +- .../reference/extractMethod/extractMethod7.ts | 8 +- .../reference/extractMethod/extractMethod8.ts | 8 +- .../reference/extractMethod/extractMethod9.ts | 8 +- .../fourslash/extract-method-formatting.ts | 2 +- tests/cases/fourslash/extract-method1.ts | 2 +- tests/cases/fourslash/extract-method10.ts | 2 +- tests/cases/fourslash/extract-method13.ts | 4 +- tests/cases/fourslash/extract-method14.ts | 2 +- tests/cases/fourslash/extract-method15.ts | 2 +- tests/cases/fourslash/extract-method18.ts | 2 +- tests/cases/fourslash/extract-method19.ts | 2 +- tests/cases/fourslash/extract-method2.ts | 2 +- tests/cases/fourslash/extract-method21.ts | 2 +- tests/cases/fourslash/extract-method24.ts | 2 +- tests/cases/fourslash/extract-method25.ts | 2 +- tests/cases/fourslash/extract-method5.ts | 2 +- tests/cases/fourslash/extract-method7.ts | 2 +- 39 files changed, 140 insertions(+), 126 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9a3492e5c37..c7713839ce3 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3696,7 +3696,7 @@ "code": 95003 }, - "Extract function into {0}": { + "Extract to {0}": { "category": "Message", "code": 95004 } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 06b8437f76b..d88966e4481 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4829,16 +4829,29 @@ namespace ts { } /* @internal */ - export function isFunctionLikeKind(kind: SyntaxKind): boolean { + export function isFunctionLikeDeclaration(node: Node): node is FunctionLikeDeclaration { + return node && isFunctionLikeDeclarationKind(node.kind); + } + + function isFunctionLikeDeclarationKind(kind: SyntaxKind): boolean { switch (kind) { - case SyntaxKind.Constructor: - case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ArrowFunction: case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: + case SyntaxKind.Constructor: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return true; + default: + return false; + } + } + + /* @internal */ + export function isFunctionLikeKind(kind: SyntaxKind): boolean { + switch (kind) { + case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: @@ -4846,9 +4859,9 @@ namespace ts { case SyntaxKind.JSDocFunctionType: case SyntaxKind.ConstructorType: return true; + default: + return isFunctionLikeDeclarationKind(kind); } - - return false; } // Classes diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 83908def444..8521e2fac0b 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -40,7 +40,7 @@ namespace ts.refactor.extractMethod { // Don't issue refactorings with duplicated names. // Scopes come back in "innermost first" order, so extractions will // preferentially go into nearer scopes - const description = formatStringFromArgs(Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [extr.scopeDescription]); if (!usedNames.has(description)) { usedNames.set(description, true); actions.push({ @@ -543,44 +543,45 @@ namespace ts.refactor.extractMethod { } } - function getDescriptionForScope(scope: Scope) { - if (isFunctionLike(scope)) { - switch (scope.kind) { - case SyntaxKind.Constructor: - return "constructor"; - case SyntaxKind.FunctionExpression: - return scope.name - ? `function expression ${scope.name.text}` - : "anonymous function expression"; - case SyntaxKind.FunctionDeclaration: - return `function '${scope.name.text}'`; - case SyntaxKind.ArrowFunction: - return "arrow function"; - case SyntaxKind.MethodDeclaration: - return `method '${scope.name.getText()}`; - case SyntaxKind.GetAccessor: - return `'get ${scope.name.getText()}'`; - case SyntaxKind.SetAccessor: - return `'set ${scope.name.getText()}'`; - } - } - else if (isModuleBlock(scope)) { - return `namespace '${scope.parent.name.getText()}'`; - } - else if (isClassLike(scope)) { - return scope.kind === SyntaxKind.ClassDeclaration - ? `class '${scope.name.text}'` - : scope.name && scope.name.text - ? `class expression '${scope.name.text}'` - : "anonymous class expression"; - } - else if (isSourceFile(scope)) { - return scope.externalModuleIndicator ? "module scope" : "global scope"; - } - else { - return "unknown"; + function getDescriptionForScope(scope: Scope): string { + return isFunctionLikeDeclaration(scope) + ? `inner function in ${getDescriptionForFunctionLikeDeclaration(scope)}` + : isClassLike(scope) + ? `method in ${getDescriptionForClassLikeDeclaration(scope)}` + : `function in ${getDescriptionForModuleLikeDeclaration(scope)}`; + } + function getDescriptionForFunctionLikeDeclaration(scope: FunctionLikeDeclaration): string { + switch (scope.kind) { + case SyntaxKind.Constructor: + return "constructor"; + case SyntaxKind.FunctionExpression: + return scope.name + ? `function expression '${scope.name.text}'` + : "anonymous function expression"; + case SyntaxKind.FunctionDeclaration: + return `function '${scope.name.text}'`; + case SyntaxKind.ArrowFunction: + return "arrow function"; + case SyntaxKind.MethodDeclaration: + return `method '${scope.name.getText()}`; + case SyntaxKind.GetAccessor: + return `'get ${scope.name.getText()}'`; + case SyntaxKind.SetAccessor: + return `'set ${scope.name.getText()}'`; + default: + Debug.assertNever(scope); } } + function getDescriptionForClassLikeDeclaration(scope: ClassLikeDeclaration): string { + return scope.kind === SyntaxKind.ClassDeclaration + ? `class '${scope.name.text}'` + : scope.name ? `class expression '${scope.name.text}'` : "anonymous class expression"; + } + function getDescriptionForModuleLikeDeclaration(scope: SourceFile | ModuleBlock): string { + return scope.kind === SyntaxKind.ModuleBlock + ? `namespace '${scope.parent.name.getText()}'` + : scope.externalModuleIndicator ? "module scope" : "global scope"; + } function getUniqueName(isNameOkay: (name: string) => boolean) { let functionNameText = "newFunction"; diff --git a/tests/baselines/reference/extractMethod/extractMethod1.ts b/tests/baselines/reference/extractMethod/extractMethod1.ts index bfe80cb6c9b..660380c1253 100644 --- a/tests/baselines/reference/extractMethod/extractMethod1.ts +++ b/tests/baselines/reference/extractMethod/extractMethod1.ts @@ -14,7 +14,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod10.ts b/tests/baselines/reference/extractMethod/extractMethod10.ts index 97bd5cbd503..13108a08131 100644 --- a/tests/baselines/reference/extractMethod/extractMethod10.ts +++ b/tests/baselines/reference/extractMethod/extractMethod10.ts @@ -9,7 +9,7 @@ namespace A { } } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== namespace A { export interface I { x: number }; class C { @@ -24,7 +24,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { export interface I { x: number }; class C { @@ -39,7 +39,7 @@ namespace A { return a1.x + 10; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { export interface I { x: number }; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod11.ts b/tests/baselines/reference/extractMethod/extractMethod11.ts index 4999df4a706..5a2e0da826a 100644 --- a/tests/baselines/reference/extractMethod/extractMethod11.ts +++ b/tests/baselines/reference/extractMethod/extractMethod11.ts @@ -11,7 +11,7 @@ namespace A { } } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== namespace A { let y = 1; class C { @@ -30,7 +30,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let y = 1; class C { @@ -49,7 +49,7 @@ namespace A { return { __return: a1.x + 10, z }; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod12.ts b/tests/baselines/reference/extractMethod/extractMethod12.ts index 2b95a545ce1..98428a67bd0 100644 --- a/tests/baselines/reference/extractMethod/extractMethod12.ts +++ b/tests/baselines/reference/extractMethod/extractMethod12.ts @@ -13,7 +13,7 @@ namespace A { } } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== namespace A { let y = 1; class C { diff --git a/tests/baselines/reference/extractMethod/extractMethod13.ts b/tests/baselines/reference/extractMethod/extractMethod13.ts index 8f76dea88aa..44968ac4dcf 100644 --- a/tests/baselines/reference/extractMethod/extractMethod13.ts +++ b/tests/baselines/reference/extractMethod/extractMethod13.ts @@ -14,7 +14,7 @@ } } } -// ==SCOPE::function 'F2'== +// ==SCOPE::inner function in function 'F2'== (u1a: U1a, u1b: U1b) => { function F1(t1a: T1a, t1b: T1b) { (u2a: U2a, u2b: U2b) => { @@ -34,7 +34,7 @@ } } } -// ==SCOPE::function 'F1'== +// ==SCOPE::inner function in function 'F1'== (u1a: U1a, u1b: U1b) => { function F1(t1a: T1a, t1b: T1b) { (u2a: U2a, u2b: U2b) => { @@ -54,7 +54,7 @@ } } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== (u1a: U1a, u1b: U1b) => { function F1(t1a: T1a, t1b: T1b) { (u2a: U2a, u2b: U2b) => { diff --git a/tests/baselines/reference/extractMethod/extractMethod14.ts b/tests/baselines/reference/extractMethod/extractMethod14.ts index 38e4c380ebc..4db0e748907 100644 --- a/tests/baselines/reference/extractMethod/extractMethod14.ts +++ b/tests/baselines/reference/extractMethod/extractMethod14.ts @@ -5,7 +5,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { newFunction(); @@ -16,7 +16,7 @@ function F(t1: T) { } } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { newFunction(t2); @@ -27,7 +27,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F(t1: T) { function F(t2: T) { newFunction(t1, t2); diff --git a/tests/baselines/reference/extractMethod/extractMethod15.ts b/tests/baselines/reference/extractMethod/extractMethod15.ts index ba5b9b3ad01..7d1c8aa4507 100644 --- a/tests/baselines/reference/extractMethod/extractMethod15.ts +++ b/tests/baselines/reference/extractMethod/extractMethod15.ts @@ -4,7 +4,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { newFunction(); @@ -14,7 +14,7 @@ function F(t1: T) { } } } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { newFunction(t2); @@ -24,7 +24,7 @@ function F(t1: T) { t2.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F(t1: T) { function F(t2: U) { newFunction(t2); diff --git a/tests/baselines/reference/extractMethod/extractMethod16.ts b/tests/baselines/reference/extractMethod/extractMethod16.ts index 1ce88b93145..2ecb0703660 100644 --- a/tests/baselines/reference/extractMethod/extractMethod16.ts +++ b/tests/baselines/reference/extractMethod/extractMethod16.ts @@ -2,7 +2,7 @@ function F() { const array: T[] = []; } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F() { const array: T[] = newFunction(); @@ -10,7 +10,7 @@ function F() { return []; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F() { const array: T[] = newFunction(); } diff --git a/tests/baselines/reference/extractMethod/extractMethod17.ts b/tests/baselines/reference/extractMethod/extractMethod17.ts index d800c79f3bd..d0401b6b472 100644 --- a/tests/baselines/reference/extractMethod/extractMethod17.ts +++ b/tests/baselines/reference/extractMethod/extractMethod17.ts @@ -4,7 +4,7 @@ class C { t1.toString(); } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { this.newFunction(t1); @@ -14,7 +14,7 @@ class C { t1.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { newFunction(t1); diff --git a/tests/baselines/reference/extractMethod/extractMethod18.ts b/tests/baselines/reference/extractMethod/extractMethod18.ts index ce6a90c3790..85ef9a5d5c0 100644 --- a/tests/baselines/reference/extractMethod/extractMethod18.ts +++ b/tests/baselines/reference/extractMethod/extractMethod18.ts @@ -4,7 +4,7 @@ class C { t1.toString(); } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { this.newFunction(t1); @@ -14,7 +14,7 @@ class C { t1.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { newFunction(t1); diff --git a/tests/baselines/reference/extractMethod/extractMethod19.ts b/tests/baselines/reference/extractMethod/extractMethod19.ts index 1bf25550172..80d3c61d1ee 100644 --- a/tests/baselines/reference/extractMethod/extractMethod19.ts +++ b/tests/baselines/reference/extractMethod/extractMethod19.ts @@ -2,7 +2,7 @@ function F(v: V) { v.toString(); } -// ==SCOPE::function 'F'== +// ==SCOPE::inner function in function 'F'== function F(v: V) { newFunction(); @@ -10,7 +10,7 @@ function F(v: V) { v.toString(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function F(v: V) { newFunction(v); } diff --git a/tests/baselines/reference/extractMethod/extractMethod2.ts b/tests/baselines/reference/extractMethod/extractMethod2.ts index 3b61a98d001..17ca6a6ba22 100644 --- a/tests/baselines/reference/extractMethod/extractMethod2.ts +++ b/tests/baselines/reference/extractMethod/extractMethod2.ts @@ -12,7 +12,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; function foo() { @@ -30,7 +30,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; function foo() { @@ -48,7 +48,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; function foo() { @@ -66,7 +66,7 @@ namespace A { return foo(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod20.ts b/tests/baselines/reference/extractMethod/extractMethod20.ts index 7c35caee30f..7d65bfca1a9 100644 --- a/tests/baselines/reference/extractMethod/extractMethod20.ts +++ b/tests/baselines/reference/extractMethod/extractMethod20.ts @@ -5,7 +5,7 @@ const _ = class { return a1.x + 10; } } -// ==SCOPE::anonymous class expression== +// ==SCOPE::method in anonymous class expression== const _ = class { a() { return this.newFunction(); @@ -16,7 +16,7 @@ const _ = class { return a1.x + 10; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== const _ = class { a() { return newFunction(); diff --git a/tests/baselines/reference/extractMethod/extractMethod21.ts b/tests/baselines/reference/extractMethod/extractMethod21.ts index 4b73a6ed3c7..6fb5fc43155 100644 --- a/tests/baselines/reference/extractMethod/extractMethod21.ts +++ b/tests/baselines/reference/extractMethod/extractMethod21.ts @@ -4,7 +4,7 @@ function foo() { x++; return; } -// ==SCOPE::function 'foo'== +// ==SCOPE::inner function in function 'foo'== function foo() { let x = 10; return newFunction(); @@ -14,7 +14,7 @@ function foo() { return; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function foo() { let x = 10; x = newFunction(x); diff --git a/tests/baselines/reference/extractMethod/extractMethod22.ts b/tests/baselines/reference/extractMethod/extractMethod22.ts index 7603c01681f..1bb76ef67ba 100644 --- a/tests/baselines/reference/extractMethod/extractMethod22.ts +++ b/tests/baselines/reference/extractMethod/extractMethod22.ts @@ -6,7 +6,7 @@ function test() { return 1; } } -// ==SCOPE::function 'test'== +// ==SCOPE::inner function in function 'test'== function test() { try { } @@ -18,7 +18,7 @@ function test() { return 1; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function test() { try { } diff --git a/tests/baselines/reference/extractMethod/extractMethod3.ts b/tests/baselines/reference/extractMethod/extractMethod3.ts index 0837fbfc10d..0d8481c9841 100644 --- a/tests/baselines/reference/extractMethod/extractMethod3.ts +++ b/tests/baselines/reference/extractMethod/extractMethod3.ts @@ -11,7 +11,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { function foo() { } @@ -28,7 +28,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { function foo() { } @@ -45,7 +45,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { function foo() { } @@ -62,7 +62,7 @@ namespace A { return foo(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod4.ts b/tests/baselines/reference/extractMethod/extractMethod4.ts index 4e9811501f4..4f6a5d85f89 100644 --- a/tests/baselines/reference/extractMethod/extractMethod4.ts +++ b/tests/baselines/reference/extractMethod/extractMethod4.ts @@ -13,7 +13,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { function foo() { } @@ -32,7 +32,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { function foo() { } @@ -51,7 +51,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { function foo() { } @@ -70,7 +70,7 @@ namespace A { return foo(); } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { function foo() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod5.ts b/tests/baselines/reference/extractMethod/extractMethod5.ts index 77b2f7b5545..10ff0005f73 100644 --- a/tests/baselines/reference/extractMethod/extractMethod5.ts +++ b/tests/baselines/reference/extractMethod/extractMethod5.ts @@ -14,7 +14,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; export function foo() { @@ -55,7 +55,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; export function foo() { @@ -76,7 +76,7 @@ namespace A { return a; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod6.ts b/tests/baselines/reference/extractMethod/extractMethod6.ts index 3c8c0a99b70..40135e6ec97 100644 --- a/tests/baselines/reference/extractMethod/extractMethod6.ts +++ b/tests/baselines/reference/extractMethod/extractMethod6.ts @@ -14,7 +14,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; export function foo() { @@ -34,7 +34,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; export function foo() { @@ -56,7 +56,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; export function foo() { @@ -78,7 +78,7 @@ namespace A { return { __return: foo(), a }; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; export function foo() { diff --git a/tests/baselines/reference/extractMethod/extractMethod7.ts b/tests/baselines/reference/extractMethod/extractMethod7.ts index 3f1e25991bd..d01532da796 100644 --- a/tests/baselines/reference/extractMethod/extractMethod7.ts +++ b/tests/baselines/reference/extractMethod/extractMethod7.ts @@ -16,7 +16,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; export namespace C { @@ -38,7 +38,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; export namespace C { @@ -62,7 +62,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; export namespace C { @@ -86,7 +86,7 @@ namespace A { return { __return: C.foo(), a }; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; export namespace C { diff --git a/tests/baselines/reference/extractMethod/extractMethod8.ts b/tests/baselines/reference/extractMethod/extractMethod8.ts index e6d933ec309..d59ca5dc238 100644 --- a/tests/baselines/reference/extractMethod/extractMethod8.ts +++ b/tests/baselines/reference/extractMethod/extractMethod8.ts @@ -8,7 +8,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { let x = 1; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { let x = 1; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { let x = 1; namespace B { @@ -50,7 +50,7 @@ namespace A { return 1 + a1 + x; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { let x = 1; namespace B { diff --git a/tests/baselines/reference/extractMethod/extractMethod9.ts b/tests/baselines/reference/extractMethod/extractMethod9.ts index 6d0672f11c1..342e3c10eee 100644 --- a/tests/baselines/reference/extractMethod/extractMethod9.ts +++ b/tests/baselines/reference/extractMethod/extractMethod9.ts @@ -8,7 +8,7 @@ namespace A { } } } -// ==SCOPE::function 'a'== +// ==SCOPE::inner function in function 'a'== namespace A { export interface I { x: number }; namespace B { @@ -22,7 +22,7 @@ namespace A { } } } -// ==SCOPE::namespace 'B'== +// ==SCOPE::function in namespace 'B'== namespace A { export interface I { x: number }; namespace B { @@ -36,7 +36,7 @@ namespace A { } } } -// ==SCOPE::namespace 'A'== +// ==SCOPE::function in namespace 'A'== namespace A { export interface I { x: number }; namespace B { @@ -50,7 +50,7 @@ namespace A { return a1.x + 10; } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace A { export interface I { x: number }; namespace B { diff --git a/tests/cases/fourslash/extract-method-formatting.ts b/tests/cases/fourslash/extract-method-formatting.ts index 1342e5632e8..a346ad3bbd9 100644 --- a/tests/cases/fourslash/extract-method-formatting.ts +++ b/tests/cases/fourslash/extract-method-formatting.ts @@ -9,7 +9,7 @@ goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs( `function f(x: number): number { diff --git a/tests/cases/fourslash/extract-method1.ts b/tests/cases/fourslash/extract-method1.ts index ff061295c8c..64dffc15a90 100644 --- a/tests/cases/fourslash/extract-method1.ts +++ b/tests/cases/fourslash/extract-method1.ts @@ -16,7 +16,7 @@ goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'Foo'", + actionDescription: "Extract to method in class 'Foo'", }); verify.currentFileContentIs( `class Foo { diff --git a/tests/cases/fourslash/extract-method10.ts b/tests/cases/fourslash/extract-method10.ts index ffbee7350e2..73ef3029e24 100644 --- a/tests/cases/fourslash/extract-method10.ts +++ b/tests/cases/fourslash/extract-method10.ts @@ -7,5 +7,5 @@ goTo.select('1', '2'); edit.applyRefactor({ refactorName: "Extract Method", actionName: 'scope_0', - actionDescription: "Extract function into module scope", + actionDescription: "Extract to function in module scope", }); diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index 94ad86e4399..707921546c5 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -13,14 +13,14 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'C'", + actionDescription: "Extract to method in class 'C'", }); goTo.select('c', 'd'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'C'", + actionDescription: "Extract to method in class 'C'", }); verify.currentFileContentIs(`class C { diff --git a/tests/cases/fourslash/extract-method14.ts b/tests/cases/fourslash/extract-method14.ts index 696bb664bd3..770ed3d0fcb 100644 --- a/tests/cases/fourslash/extract-method14.ts +++ b/tests/cases/fourslash/extract-method14.ts @@ -14,7 +14,7 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function foo() { var i = 10; diff --git a/tests/cases/fourslash/extract-method15.ts b/tests/cases/fourslash/extract-method15.ts index 93aa357cfee..8d3db633b11 100644 --- a/tests/cases/fourslash/extract-method15.ts +++ b/tests/cases/fourslash/extract-method15.ts @@ -12,7 +12,7 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function foo() { diff --git a/tests/cases/fourslash/extract-method18.ts b/tests/cases/fourslash/extract-method18.ts index d99d14bac73..6d4d06ca7bf 100644 --- a/tests/cases/fourslash/extract-method18.ts +++ b/tests/cases/fourslash/extract-method18.ts @@ -12,7 +12,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function fn() { const x = { m: 1 }; diff --git a/tests/cases/fourslash/extract-method19.ts b/tests/cases/fourslash/extract-method19.ts index e4fb3e6e111..da999fcc093 100644 --- a/tests/cases/fourslash/extract-method19.ts +++ b/tests/cases/fourslash/extract-method19.ts @@ -12,7 +12,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into function 'fn'", + actionDescription: "Extract to inner function in function 'fn'", }); verify.currentFileContentIs(`function fn() { newFunction_1(); diff --git a/tests/cases/fourslash/extract-method2.ts b/tests/cases/fourslash/extract-method2.ts index 508836c4199..021716b6e48 100644 --- a/tests/cases/fourslash/extract-method2.ts +++ b/tests/cases/fourslash/extract-method2.ts @@ -13,7 +13,7 @@ goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_2", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs( `namespace NS { diff --git a/tests/cases/fourslash/extract-method21.ts b/tests/cases/fourslash/extract-method21.ts index c32df5b5979..f19d4b05912 100644 --- a/tests/cases/fourslash/extract-method21.ts +++ b/tests/cases/fourslash/extract-method21.ts @@ -15,7 +15,7 @@ verify.refactorAvailable('Extract Method'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into class 'Foo'", + actionDescription: "Extract to method in class 'Foo'", }); verify.currentFileContentIs(`class Foo { diff --git a/tests/cases/fourslash/extract-method24.ts b/tests/cases/fourslash/extract-method24.ts index 615cb2ac4d2..e5f923bb80d 100644 --- a/tests/cases/fourslash/extract-method24.ts +++ b/tests/cases/fourslash/extract-method24.ts @@ -10,7 +10,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function M() { let a = [1,2,3]; diff --git a/tests/cases/fourslash/extract-method25.ts b/tests/cases/fourslash/extract-method25.ts index 8585dd06fd4..d18d0691e61 100644 --- a/tests/cases/fourslash/extract-method25.ts +++ b/tests/cases/fourslash/extract-method25.ts @@ -11,7 +11,7 @@ goTo.select('a', 'b') edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into function 'fn'", + actionDescription: "Extract to inner function in function 'fn'", }); verify.currentFileContentIs(`function fn() { var q = newFunction() diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index 8b0bd4fec6d..014dfb35d08 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -12,7 +12,7 @@ goTo.select('start', 'end'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into function 'f'", + actionDescription: "Extract to inner function in function 'f'", }); // TODO: GH#18091 (fix formatting to use `2 ? 1 :` and not `2?1:`) verify.currentFileContentIs( diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index d10c7c3136e..d8459bf77ad 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -10,7 +10,7 @@ goTo.select('a', 'b'); edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", - actionDescription: "Extract function into global scope", + actionDescription: "Extract to function in global scope", }); verify.currentFileContentIs(`function fn(x = newFunction()) { } From f40f0db6766b06ce60832be7835b074897521192 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 9 Sep 2017 12:43:39 -0700 Subject: [PATCH 117/216] Preserve intersections on the source side in type inference --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa5fbd6421c..411b085508b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10578,7 +10578,7 @@ namespace ts { priority = savePriority; } } - else if (source.flags & TypeFlags.UnionOrIntersection) { + else if (source.flags & TypeFlags.Union) { // Source is a union or intersection type, infer from each constituent type const sourceTypes = (source).types; for (const sourceType of sourceTypes) { @@ -10587,7 +10587,7 @@ namespace ts { } else { source = getApparentType(source); - if (source.flags & TypeFlags.Object) { + if (source.flags & (TypeFlags.Object | TypeFlags.Intersection)) { const key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -10667,7 +10667,7 @@ namespace ts { function inferFromProperties(source: Type, target: Type) { const properties = getPropertiesOfObjectType(target); for (const targetProp of properties) { - const sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + const sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } From c6af0015a3639bbd50b7f347ed15d1408be7b945 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 9 Sep 2017 12:52:10 -0700 Subject: [PATCH 118/216] Fix fourslash tests --- tests/cases/fourslash/tsxQuickInfo6.ts | 2 +- tests/cases/fourslash/tsxQuickInfo7.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/cases/fourslash/tsxQuickInfo6.ts b/tests/cases/fourslash/tsxQuickInfo6.ts index e125336e513..515928b7734 100644 --- a/tests/cases/fourslash/tsxQuickInfo6.ts +++ b/tests/cases/fourslash/tsxQuickInfo6.ts @@ -15,5 +15,5 @@ verify.quickInfos({ 1: "function ComponentSpecific(l: {\n prop: number;\n}): any", - 2: "function ComponentSpecific(l: {\n prop: number;\n}): any" + 2: "function ComponentSpecific(l: {\n prop: number & \"hello\";\n}): any" }); diff --git a/tests/cases/fourslash/tsxQuickInfo7.ts b/tests/cases/fourslash/tsxQuickInfo7.ts index d0ec1916b43..72de1128049 100644 --- a/tests/cases/fourslash/tsxQuickInfo7.ts +++ b/tests/cases/fourslash/tsxQuickInfo7.ts @@ -24,6 +24,6 @@ verify.quickInfos({ 3: "function OverloadComponent(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)", 4: "function OverloadComponent(attr: {\n b: number;\n a?: string;\n \"ignore-prop\": boolean;\n}): any (+2 overloads)", 5: "function OverloadComponent(): any (+2 overloads)", - 6: "function OverloadComponent(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)", - 7: "function OverloadComponent(attr: {\n b: number;\n a: boolean;\n}): any (+2 overloads)", + 6: "function OverloadComponent(attr: {\n b: string & number;\n a: boolean;\n}): any (+2 overloads)", + 7: "function OverloadComponent(attr: {\n b: number & string;\n a: boolean;\n}): any (+2 overloads)", }); From 9871c04e54a60c70680b44afad28ee8a2020366d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 9 Sep 2017 13:06:28 -0700 Subject: [PATCH 119/216] Add tests --- .../reference/intersectionTypeInference2.js | 23 +++++++ .../intersectionTypeInference2.symbols | 56 +++++++++++++++++ .../intersectionTypeInference2.types | 62 +++++++++++++++++++ .../intersectionTypeInference2.ts | 15 +++++ 4 files changed, 156 insertions(+) create mode 100644 tests/baselines/reference/intersectionTypeInference2.js create mode 100644 tests/baselines/reference/intersectionTypeInference2.symbols create mode 100644 tests/baselines/reference/intersectionTypeInference2.types create mode 100644 tests/cases/conformance/types/intersection/intersectionTypeInference2.ts diff --git a/tests/baselines/reference/intersectionTypeInference2.js b/tests/baselines/reference/intersectionTypeInference2.js new file mode 100644 index 00000000000..804b8d85206 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference2.js @@ -0,0 +1,23 @@ +//// [intersectionTypeInference2.ts] +declare function f(x: { prop: T }): T; + +declare const a: { prop: string } & { prop: number }; +declare const b: { prop: string & number }; + +f(a); // string & number +f(b); // string & number + +// Repro from #18354 + +declare function f2(obj: {[K in keyof T]: T[K]}, key: Key): T[Key]; + +declare const obj: { a: string } & { b: string }; +f2(obj, 'a'); +f2(obj, 'b'); + + +//// [intersectionTypeInference2.js] +f(a); // string & number +f(b); // string & number +f2(obj, 'a'); +f2(obj, 'b'); diff --git a/tests/baselines/reference/intersectionTypeInference2.symbols b/tests/baselines/reference/intersectionTypeInference2.symbols new file mode 100644 index 00000000000..b04de204de1 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference2.symbols @@ -0,0 +1,56 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeInference2.ts === +declare function f(x: { prop: T }): T; +>f : Symbol(f, Decl(intersectionTypeInference2.ts, 0, 0)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 0, 19)) +>x : Symbol(x, Decl(intersectionTypeInference2.ts, 0, 22)) +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 0, 26)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 0, 19)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 0, 19)) + +declare const a: { prop: string } & { prop: number }; +>a : Symbol(a, Decl(intersectionTypeInference2.ts, 2, 13)) +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 2, 18)) +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 2, 37)) + +declare const b: { prop: string & number }; +>b : Symbol(b, Decl(intersectionTypeInference2.ts, 3, 13)) +>prop : Symbol(prop, Decl(intersectionTypeInference2.ts, 3, 18)) + +f(a); // string & number +>f : Symbol(f, Decl(intersectionTypeInference2.ts, 0, 0)) +>a : Symbol(a, Decl(intersectionTypeInference2.ts, 2, 13)) + +f(b); // string & number +>f : Symbol(f, Decl(intersectionTypeInference2.ts, 0, 0)) +>b : Symbol(b, Decl(intersectionTypeInference2.ts, 3, 13)) + +// Repro from #18354 + +declare function f2(obj: {[K in keyof T]: T[K]}, key: Key): T[Key]; +>f2 : Symbol(f2, Decl(intersectionTypeInference2.ts, 6, 5)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>Key : Symbol(Key, Decl(intersectionTypeInference2.ts, 10, 22)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 10, 44)) +>K : Symbol(K, Decl(intersectionTypeInference2.ts, 10, 51)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>K : Symbol(K, Decl(intersectionTypeInference2.ts, 10, 51)) +>key : Symbol(key, Decl(intersectionTypeInference2.ts, 10, 72)) +>Key : Symbol(Key, Decl(intersectionTypeInference2.ts, 10, 22)) +>T : Symbol(T, Decl(intersectionTypeInference2.ts, 10, 20)) +>Key : Symbol(Key, Decl(intersectionTypeInference2.ts, 10, 22)) + +declare const obj: { a: string } & { b: string }; +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 12, 13)) +>a : Symbol(a, Decl(intersectionTypeInference2.ts, 12, 20)) +>b : Symbol(b, Decl(intersectionTypeInference2.ts, 12, 36)) + +f2(obj, 'a'); +>f2 : Symbol(f2, Decl(intersectionTypeInference2.ts, 6, 5)) +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 12, 13)) + +f2(obj, 'b'); +>f2 : Symbol(f2, Decl(intersectionTypeInference2.ts, 6, 5)) +>obj : Symbol(obj, Decl(intersectionTypeInference2.ts, 12, 13)) + diff --git a/tests/baselines/reference/intersectionTypeInference2.types b/tests/baselines/reference/intersectionTypeInference2.types new file mode 100644 index 00000000000..41e1b3483c8 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeInference2.types @@ -0,0 +1,62 @@ +=== tests/cases/conformance/types/intersection/intersectionTypeInference2.ts === +declare function f(x: { prop: T }): T; +>f : (x: { prop: T; }) => T +>T : T +>x : { prop: T; } +>prop : T +>T : T +>T : T + +declare const a: { prop: string } & { prop: number }; +>a : { prop: string; } & { prop: number; } +>prop : string +>prop : number + +declare const b: { prop: string & number }; +>b : { prop: string & number; } +>prop : string & number + +f(a); // string & number +>f(a) : string & number +>f : (x: { prop: T; }) => T +>a : { prop: string; } & { prop: number; } + +f(b); // string & number +>f(b) : string & number +>f : (x: { prop: T; }) => T +>b : { prop: string & number; } + +// Repro from #18354 + +declare function f2(obj: {[K in keyof T]: T[K]}, key: Key): T[Key]; +>f2 : (obj: { [K in keyof T]: T[K]; }, key: Key) => T[Key] +>T : T +>Key : Key +>T : T +>obj : { [K in keyof T]: T[K]; } +>K : K +>T : T +>T : T +>K : K +>key : Key +>Key : Key +>T : T +>Key : Key + +declare const obj: { a: string } & { b: string }; +>obj : { a: string; } & { b: string; } +>a : string +>b : string + +f2(obj, 'a'); +>f2(obj, 'a') : string +>f2 : (obj: { [K in keyof T]: T[K]; }, key: Key) => T[Key] +>obj : { a: string; } & { b: string; } +>'a' : "a" + +f2(obj, 'b'); +>f2(obj, 'b') : string +>f2 : (obj: { [K in keyof T]: T[K]; }, key: Key) => T[Key] +>obj : { a: string; } & { b: string; } +>'b' : "b" + diff --git a/tests/cases/conformance/types/intersection/intersectionTypeInference2.ts b/tests/cases/conformance/types/intersection/intersectionTypeInference2.ts new file mode 100644 index 00000000000..d32441cfee8 --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionTypeInference2.ts @@ -0,0 +1,15 @@ +declare function f(x: { prop: T }): T; + +declare const a: { prop: string } & { prop: number }; +declare const b: { prop: string & number }; + +f(a); // string & number +f(b); // string & number + +// Repro from #18354 + +declare function f2(obj: {[K in keyof T]: T[K]}, key: Key): T[Key]; + +declare const obj: { a: string } & { b: string }; +f2(obj, 'a'); +f2(obj, 'b'); From dc8d47c51d794f681896e18c92347353b1deb864 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sat, 9 Sep 2017 15:56:11 -0700 Subject: [PATCH 120/216] Remove bisect.cmd, remove reference to missing dts, update usage (#18353) --- scripts/bisect-test.ts | 10 ++++++---- scripts/bisect.cmd | 30 ------------------------------ 2 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 scripts/bisect.cmd diff --git a/scripts/bisect-test.ts b/scripts/bisect-test.ts index 93a516bc899..948b272470f 100644 --- a/scripts/bisect-test.ts +++ b/scripts/bisect-test.ts @@ -1,5 +1,7 @@ -/// - +/** + * You should have ts-node installed globally before executing this, probably! + * Otherwise you'll need to compile this script before you start bisecting! + */ import cp = require('child_process'); import fs = require('fs'); @@ -42,8 +44,8 @@ jake.on('close', jakeExitCode => { }); } else { console.log('Unknown command line arguments.'); - console.log('Usage (compile errors): git bisect run scripts\bisect.js "foo.ts --module amd" compiles'); - console.log('Usage (emit check): git bisect run scripts\bisect.js bar.ts emits bar.js "_this = this"'); + console.log('Usage (compile errors): git bisect run ts-node scripts\bisect-test.ts "../failure.ts --module amd" !compiles'); + console.log('Usage (emit check): git bisect run ts-node scripts\bisect-test.ts bar.ts emits bar.js "_this = this"'); // Aborts the 'git bisect run' process process.exit(-1); } diff --git a/scripts/bisect.cmd b/scripts/bisect.cmd deleted file mode 100644 index 148722665d4..00000000000 --- a/scripts/bisect.cmd +++ /dev/null @@ -1,30 +0,0 @@ -echo off -IF NOT EXIST scripts\bisect.cmd GOTO :wrongdir -IF "%1" == "" GOTO :usage -IF "%1" == "GO" GOTO :run -GOTO :copy - -:usage -echo Usage: bisect GoodCommit BadCommit test.ts compiles -echo Usage: bisect GoodCommit BadCommit test.ts emits test.js "var x = 3" -GOTO :eof - -:copy -copy scripts\bisect.cmd scripts\bisect-fresh.cmd -scripts\bisect-fresh GO %* -GOTO :eof - -:run -call jake local -node built/local/tsc.js scripts/bisect-test.ts --module commonjs -git bisect start %2 %3 -git bisect run node scripts/bisect-test.js %4 %5 %6 %7 -del scripts\bisect-test.js -del scripts\bisect-fresh.cmd -GOTO :eof - -:wrongdir -@echo Run this file from the repo folder, not the scripts folder -GOTO :eof - -:eof \ No newline at end of file From eb80799ef0e2e47d8a1ae74f395d1fcadd263340 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sat, 9 Sep 2017 16:30:06 -0700 Subject: [PATCH 121/216] Care about esnext where we look for es2015 (#18331) * Care about esnext where we look for es2015 * Update diagnostic message to be more agnostic --- src/compiler/checker.ts | 12 ++-- src/compiler/diagnosticMessages.json | 4 +- src/compiler/factory.ts | 3 +- src/compiler/transformers/ts.ts | 3 +- .../reference/es6ExportAssignment.errors.txt | 4 +- .../reference/es6ExportAssignment2.errors.txt | 4 +- .../reference/es6ExportEquals.errors.txt | 4 +- .../es6ImportEqualsDeclaration.errors.txt | 8 +-- .../baselines/reference/es6modulekind.symbols | 2 +- tests/baselines/reference/es6modulekind.types | 2 +- .../es6modulekindWithES2015Target.symbols | 2 +- .../es6modulekindWithES2015Target.types | 2 +- .../es6modulekindWithES5Target.symbols | 2 +- .../es6modulekindWithES5Target.types | 2 +- .../es6modulekindWithES5Target10.errors.txt | 12 ++-- .../es6modulekindWithES5Target11.symbols | 2 +- .../es6modulekindWithES5Target11.types | 2 +- .../es6modulekindWithES5Target12.symbols | 2 +- .../es6modulekindWithES5Target12.types | 2 +- .../es6modulekindWithES5Target2.symbols | 2 +- .../es6modulekindWithES5Target2.types | 2 +- .../es6modulekindWithES5Target3.symbols | 2 +- .../es6modulekindWithES5Target3.types | 2 +- .../es6modulekindWithES5Target4.symbols | 2 +- .../es6modulekindWithES5Target4.types | 2 +- .../es6modulekindWithES5Target5.symbols | 2 +- .../es6modulekindWithES5Target5.types | 2 +- .../es6modulekindWithES5Target6.symbols | 2 +- .../es6modulekindWithES5Target6.types | 2 +- .../es6modulekindWithES5Target7.symbols | 2 +- .../es6modulekindWithES5Target7.types | 2 +- .../es6modulekindWithES5Target8.symbols | 2 +- .../es6modulekindWithES5Target8.types | 2 +- .../es6modulekindWithES5Target9.errors.txt | 12 ++-- tests/baselines/reference/esnextmodulekind.js | 22 ++++++ .../reference/esnextmodulekind.symbols | 15 ++++ .../reference/esnextmodulekind.types | 16 +++++ .../esnextmodulekindWithES2015Target.js | 22 ++++++ .../esnextmodulekindWithES2015Target.symbols | 15 ++++ .../esnextmodulekindWithES2015Target.types | 16 +++++ .../esnextmodulekindWithES5Target.js | 57 +++++++++++++++ .../esnextmodulekindWithES5Target.symbols | 46 ++++++++++++ .../esnextmodulekindWithES5Target.types | 50 +++++++++++++ ...esnextmodulekindWithES5Target10.errors.txt | 18 +++++ .../esnextmodulekindWithES5Target10.js | 9 +++ .../esnextmodulekindWithES5Target11.js | 32 +++++++++ .../esnextmodulekindWithES5Target11.symbols | 26 +++++++ .../esnextmodulekindWithES5Target11.types | 28 ++++++++ .../esnextmodulekindWithES5Target12.js | 70 +++++++++++++++++++ .../esnextmodulekindWithES5Target12.symbols | 61 ++++++++++++++++ .../esnextmodulekindWithES5Target12.types | 68 ++++++++++++++++++ .../esnextmodulekindWithES5Target2.js | 18 +++++ .../esnextmodulekindWithES5Target2.symbols | 14 ++++ .../esnextmodulekindWithES5Target2.types | 16 +++++ .../esnextmodulekindWithES5Target3.js | 28 ++++++++ .../esnextmodulekindWithES5Target3.symbols | 20 ++++++ .../esnextmodulekindWithES5Target3.types | 22 ++++++ .../esnextmodulekindWithES5Target4.js | 11 +++ .../esnextmodulekindWithES5Target4.symbols | 7 ++ .../esnextmodulekindWithES5Target4.types | 7 ++ .../esnextmodulekindWithES5Target5.js | 18 +++++ .../esnextmodulekindWithES5Target5.symbols | 14 ++++ .../esnextmodulekindWithES5Target5.types | 14 ++++ .../esnextmodulekindWithES5Target6.js | 24 +++++++ .../esnextmodulekindWithES5Target6.symbols | 16 +++++ .../esnextmodulekindWithES5Target6.types | 18 +++++ .../esnextmodulekindWithES5Target7.js | 15 ++++ .../esnextmodulekindWithES5Target7.symbols | 15 ++++ .../esnextmodulekindWithES5Target7.types | 16 +++++ .../esnextmodulekindWithES5Target8.js | 7 ++ .../esnextmodulekindWithES5Target8.symbols | 7 ++ .../esnextmodulekindWithES5Target8.types | 9 +++ .../esnextmodulekindWithES5Target9.errors.txt | 36 ++++++++++ .../esnextmodulekindWithES5Target9.js | 30 ++++++++ .../externalModules/es6}/es6modulekind.ts | 0 .../es6}/es6modulekindWithES2015Target.ts | 0 .../es6}/es6modulekindWithES5Target.ts | 0 .../es6}/es6modulekindWithES5Target10.ts | 0 .../es6}/es6modulekindWithES5Target11.ts | 0 .../es6}/es6modulekindWithES5Target12.ts | 0 .../es6}/es6modulekindWithES5Target2.ts | 0 .../es6}/es6modulekindWithES5Target3.ts | 0 .../es6}/es6modulekindWithES5Target4.ts | 0 .../es6}/es6modulekindWithES5Target5.ts | 0 .../es6}/es6modulekindWithES5Target6.ts | 0 .../es6}/es6modulekindWithES5Target7.ts | 0 .../es6}/es6modulekindWithES5Target8.ts | 0 .../es6}/es6modulekindWithES5Target9.ts | 0 .../esnext/esnextmodulekind.ts | 17 +++++ .../esnextmodulekindWithES2015Target.ts | 17 +++++ .../esnext/esnextmodulekindWithES5Target.ts | 22 ++++++ .../esnext/esnextmodulekindWithES5Target10.ts | 9 +++ .../esnext/esnextmodulekindWithES5Target11.ts | 12 ++++ .../esnext/esnextmodulekindWithES5Target12.ts | 39 +++++++++++ .../esnext/esnextmodulekindWithES5Target2.ts | 8 +++ .../esnext/esnextmodulekindWithES5Target3.ts | 12 ++++ .../esnext/esnextmodulekindWithES5Target4.ts | 5 ++ .../esnext/esnextmodulekindWithES5Target5.ts | 11 +++ .../esnext/esnextmodulekindWithES5Target6.ts | 11 +++ .../esnext/esnextmodulekindWithES5Target7.ts | 10 +++ .../esnext/esnextmodulekindWithES5Target8.ts | 5 ++ .../esnext/esnextmodulekindWithES5Target9.ts | 20 ++++++ 102 files changed, 1209 insertions(+), 56 deletions(-) create mode 100644 tests/baselines/reference/esnextmodulekind.js create mode 100644 tests/baselines/reference/esnextmodulekind.symbols create mode 100644 tests/baselines/reference/esnextmodulekind.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES2015Target.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES2015Target.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES2015Target.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target10.errors.txt create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target10.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target11.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target11.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target11.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target12.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target12.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target12.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target2.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target2.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target2.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target3.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target3.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target3.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target4.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target4.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target4.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target5.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target5.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target5.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target6.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target6.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target6.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target7.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target7.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target7.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target8.js create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target8.symbols create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target8.types create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target9.errors.txt create mode 100644 tests/baselines/reference/esnextmodulekindWithES5Target9.js rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekind.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES2015Target.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target10.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target11.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target12.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target2.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target3.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target4.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target5.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target6.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target7.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target8.ts (100%) rename tests/cases/{compiler => conformance/externalModules/es6}/es6modulekindWithES5Target9.ts (100%) create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts create mode 100644 tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa5fbd6421c..ff5d1c661e8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22149,9 +22149,9 @@ namespace ts { } } else { - if (modulekind === ModuleKind.ES2015 && !isInAmbientContext(node)) { + if (modulekind >= ModuleKind.ES2015 && !isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -22187,7 +22187,7 @@ namespace ts { error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } - if (modulekind !== ModuleKind.System && modulekind !== ModuleKind.ES2015) { + if (modulekind !== ModuleKind.System && modulekind !== ModuleKind.ES2015 && modulekind !== ModuleKind.ESNext) { checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar); } } @@ -22249,9 +22249,9 @@ namespace ts { checkExternalModuleExports(container); if (node.isExportEquals && !isInAmbientContext(node)) { - if (modulekind === ModuleKind.ES2015) { + if (modulekind >= ModuleKind.ES2015) { // export assignment is not supported in es6 modules - grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); + grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ModuleKind.System) { // system modules does not support export assignment @@ -24851,7 +24851,7 @@ namespace ts { } } - if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit && + if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.ESNext && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit && !isInAmbientContext(node.parent.parent) && hasModifier(node.parent.parent, ModifierFlags.Export)) { checkESModuleMarker(node.name); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c7713839ce3..14fb7499f8f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -627,11 +627,11 @@ "category": "Error", "code": 1200 }, - "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { + "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { "category": "Error", "code": 1202 }, - "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.": { + "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.": { "category": "Error", "code": 1203 }, diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 2bf6d6e879d..0369be30076 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -4158,7 +4158,8 @@ namespace ts { const moduleKind = getEmitModuleKind(compilerOptions); let create = hasExportStarsToExportValues && moduleKind !== ModuleKind.System - && moduleKind !== ModuleKind.ES2015; + && moduleKind !== ModuleKind.ES2015 + && moduleKind !== ModuleKind.ESNext; if (!create) { const helpers = getEmitHelpers(node); if (helpers) { diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index ebce55aa7e5..8640c642675 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -521,7 +521,7 @@ namespace ts { function visitSourceFile(node: SourceFile) { const alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && - !(isExternalModule(node) && moduleKind === ModuleKind.ES2015); + !(isExternalModule(node) && moduleKind >= ModuleKind.ES2015); return updateSourceFileNode( node, visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); @@ -2665,6 +2665,7 @@ namespace ts { return isExportOfNamespace(node) || (isExternalModuleExport(node) && moduleKind !== ModuleKind.ES2015 + && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System); } diff --git a/tests/baselines/reference/es6ExportAssignment.errors.txt b/tests/baselines/reference/es6ExportAssignment.errors.txt index 55a150f47ad..eea3299f56e 100644 --- a/tests/baselines/reference/es6ExportAssignment.errors.txt +++ b/tests/baselines/reference/es6ExportAssignment.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/es6ExportAssignment.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/compiler/es6ExportAssignment.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/es6ExportAssignment.ts (1 errors) ==== var a = 10; export = a; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. \ No newline at end of file +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportAssignment2.errors.txt b/tests/baselines/reference/es6ExportAssignment2.errors.txt index 9065f9ba6ce..c735da428cb 100644 --- a/tests/baselines/reference/es6ExportAssignment2.errors.txt +++ b/tests/baselines/reference/es6ExportAssignment2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/compiler/a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/a.ts (1 errors) ==== var a = 10; export = a; // Error: export = not allowed in ES6 ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/b.ts (0 errors) ==== import * as a from "a"; diff --git a/tests/baselines/reference/es6ExportEquals.errors.txt b/tests/baselines/reference/es6ExportEquals.errors.txt index fa6e8519918..05f093db853 100644 --- a/tests/baselines/reference/es6ExportEquals.errors.txt +++ b/tests/baselines/reference/es6ExportEquals.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/es6ExportEquals.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/compiler/es6ExportEquals.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. tests/cases/compiler/es6ExportEquals.ts(3,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -7,7 +7,7 @@ tests/cases/compiler/es6ExportEquals.ts(3,1): error TS2309: An export assignment export = f; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt index 37870a2a366..696c71950cd 100644 --- a/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt +++ b/tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. -tests/cases/compiler/server.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +tests/cases/compiler/server.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. ==== tests/cases/compiler/client.ts (1 errors) ==== import a = require("server"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. ==== tests/cases/compiler/server.ts (1 errors) ==== var a = 10; export = a; ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6modulekind.symbols b/tests/baselines/reference/es6modulekind.symbols index cc563db6826..185969969a1 100644 --- a/tests/baselines/reference/es6modulekind.symbols +++ b/tests/baselines/reference/es6modulekind.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekind.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekind.ts === export default class A >A : Symbol(A, Decl(es6modulekind.ts, 0, 0)) { diff --git a/tests/baselines/reference/es6modulekind.types b/tests/baselines/reference/es6modulekind.types index a8b6fa077f0..4b150f00729 100644 --- a/tests/baselines/reference/es6modulekind.types +++ b/tests/baselines/reference/es6modulekind.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekind.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekind.ts === export default class A >A : A { diff --git a/tests/baselines/reference/es6modulekindWithES2015Target.symbols b/tests/baselines/reference/es6modulekindWithES2015Target.symbols index b7cf2e19c74..9c9f1e904ad 100644 --- a/tests/baselines/reference/es6modulekindWithES2015Target.symbols +++ b/tests/baselines/reference/es6modulekindWithES2015Target.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES2015Target.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts === export default class A >A : Symbol(A, Decl(es6modulekindWithES2015Target.ts, 0, 0)) { diff --git a/tests/baselines/reference/es6modulekindWithES2015Target.types b/tests/baselines/reference/es6modulekindWithES2015Target.types index 018d06e0745..46f44784d74 100644 --- a/tests/baselines/reference/es6modulekindWithES2015Target.types +++ b/tests/baselines/reference/es6modulekindWithES2015Target.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES2015Target.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts === export default class A >A : A { diff --git a/tests/baselines/reference/es6modulekindWithES5Target.symbols b/tests/baselines/reference/es6modulekindWithES5Target.symbols index edba44a2223..2b91794b97e 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts === export class C { >C : Symbol(C, Decl(es6modulekindWithES5Target.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target.types b/tests/baselines/reference/es6modulekindWithES5Target.types index 018114be43d..9d9b7704552 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target.types +++ b/tests/baselines/reference/es6modulekindWithES5Target.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts === export class C { >C : C diff --git a/tests/baselines/reference/es6modulekindWithES5Target10.errors.txt b/tests/baselines/reference/es6modulekindWithES5Target10.errors.txt index 16dfab25794..d4164e56491 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target10.errors.txt +++ b/tests/baselines/reference/es6modulekindWithES5Target10.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/es6modulekindWithES5Target10.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. -tests/cases/compiler/es6modulekindWithES5Target10.ts(1,20): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target10.ts(6,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts(1,20): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts(6,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -==== tests/cases/compiler/es6modulekindWithES5Target10.ts (3 errors) ==== +==== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts (3 errors) ==== import i = require("mod"); // Error; ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. ~~~~~ !!! error TS2307: Cannot find module 'mod'. @@ -15,4 +15,4 @@ tests/cases/compiler/es6modulekindWithES5Target10.ts(6,1): error TS1203: Export } export = N; // Error ~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead. \ No newline at end of file +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/es6modulekindWithES5Target11.symbols b/tests/baselines/reference/es6modulekindWithES5Target11.symbols index 39c351a0e5e..429a3982c10 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target11.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target11.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target11.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts === declare function foo(...args: any[]): any; >foo : Symbol(foo, Decl(es6modulekindWithES5Target11.ts, 0, 0)) >args : Symbol(args, Decl(es6modulekindWithES5Target11.ts, 0, 21)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target11.types b/tests/baselines/reference/es6modulekindWithES5Target11.types index 497d8e0af78..9ace8e2d37d 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target11.types +++ b/tests/baselines/reference/es6modulekindWithES5Target11.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target11.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts === declare function foo(...args: any[]): any; >foo : (...args: any[]) => any >args : any[] diff --git a/tests/baselines/reference/es6modulekindWithES5Target12.symbols b/tests/baselines/reference/es6modulekindWithES5Target12.symbols index a16baab08ce..dd8746ecad3 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target12.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target12.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target12.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts === export class C { >C : Symbol(C, Decl(es6modulekindWithES5Target12.ts, 0, 0), Decl(es6modulekindWithES5Target12.ts, 1, 1)) } diff --git a/tests/baselines/reference/es6modulekindWithES5Target12.types b/tests/baselines/reference/es6modulekindWithES5Target12.types index 7d38adb3f46..ecb29ca021a 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target12.types +++ b/tests/baselines/reference/es6modulekindWithES5Target12.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target12.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts === export class C { >C : C } diff --git a/tests/baselines/reference/es6modulekindWithES5Target2.symbols b/tests/baselines/reference/es6modulekindWithES5Target2.symbols index 66f1375e6e5..ff0f5c4388e 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target2.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target2.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target2.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts === export default class C { >C : Symbol(C, Decl(es6modulekindWithES5Target2.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target2.types b/tests/baselines/reference/es6modulekindWithES5Target2.types index 6540471c890..d120f0c5b56 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target2.types +++ b/tests/baselines/reference/es6modulekindWithES5Target2.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target2.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts === export default class C { >C : C diff --git a/tests/baselines/reference/es6modulekindWithES5Target3.symbols b/tests/baselines/reference/es6modulekindWithES5Target3.symbols index cc0b1ecc89d..8dc8b658a28 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target3.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target3.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target3.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts === declare function foo(...args: any[]): any; >foo : Symbol(foo, Decl(es6modulekindWithES5Target3.ts, 0, 0)) >args : Symbol(args, Decl(es6modulekindWithES5Target3.ts, 0, 21)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target3.types b/tests/baselines/reference/es6modulekindWithES5Target3.types index d2cc641b732..f7059999daf 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target3.types +++ b/tests/baselines/reference/es6modulekindWithES5Target3.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target3.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts === declare function foo(...args: any[]): any; >foo : (...args: any[]) => any >args : any[] diff --git a/tests/baselines/reference/es6modulekindWithES5Target4.symbols b/tests/baselines/reference/es6modulekindWithES5Target4.symbols index f7ff2d07016..4b672f1f3f1 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target4.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target4.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target4.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts === class E { } >E : Symbol(E, Decl(es6modulekindWithES5Target4.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target4.types b/tests/baselines/reference/es6modulekindWithES5Target4.types index 20bea4e397b..4429c443d36 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target4.types +++ b/tests/baselines/reference/es6modulekindWithES5Target4.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target4.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts === class E { } >E : E diff --git a/tests/baselines/reference/es6modulekindWithES5Target5.symbols b/tests/baselines/reference/es6modulekindWithES5Target5.symbols index d4401b86d6b..cc6833f753b 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target5.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target5.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target5.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts === export enum E1 { >E1 : Symbol(E1, Decl(es6modulekindWithES5Target5.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target5.types b/tests/baselines/reference/es6modulekindWithES5Target5.types index 5abe6f5b165..b5e69598788 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target5.types +++ b/tests/baselines/reference/es6modulekindWithES5Target5.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target5.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts === export enum E1 { >E1 : E1 diff --git a/tests/baselines/reference/es6modulekindWithES5Target6.symbols b/tests/baselines/reference/es6modulekindWithES5Target6.symbols index b07af7462ba..6f17707b708 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target6.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target6.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target6.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts === export function f1(d = 0) { >f1 : Symbol(f1, Decl(es6modulekindWithES5Target6.ts, 0, 0)) >d : Symbol(d, Decl(es6modulekindWithES5Target6.ts, 0, 19)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target6.types b/tests/baselines/reference/es6modulekindWithES5Target6.types index 5296f4730b3..611edc9bbaa 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target6.types +++ b/tests/baselines/reference/es6modulekindWithES5Target6.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target6.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts === export function f1(d = 0) { >f1 : (d?: number) => void >d : number diff --git a/tests/baselines/reference/es6modulekindWithES5Target7.symbols b/tests/baselines/reference/es6modulekindWithES5Target7.symbols index bcc89efaeab..0cdb72fcc54 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target7.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target7.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target7.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts === export namespace N { >N : Symbol(N, Decl(es6modulekindWithES5Target7.ts, 0, 0)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target7.types b/tests/baselines/reference/es6modulekindWithES5Target7.types index 0e534b85c54..5a386abe7e6 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target7.types +++ b/tests/baselines/reference/es6modulekindWithES5Target7.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target7.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts === export namespace N { >N : typeof N diff --git a/tests/baselines/reference/es6modulekindWithES5Target8.symbols b/tests/baselines/reference/es6modulekindWithES5Target8.symbols index 1a5e54ce96d..a487c30a444 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target8.symbols +++ b/tests/baselines/reference/es6modulekindWithES5Target8.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target8.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts === export const c = 0; >c : Symbol(c, Decl(es6modulekindWithES5Target8.ts, 0, 12)) diff --git a/tests/baselines/reference/es6modulekindWithES5Target8.types b/tests/baselines/reference/es6modulekindWithES5Target8.types index 4bfea977016..8a91f27b10d 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target8.types +++ b/tests/baselines/reference/es6modulekindWithES5Target8.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es6modulekindWithES5Target8.ts === +=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts === export const c = 0; >c : 0 >0 : 0 diff --git a/tests/baselines/reference/es6modulekindWithES5Target9.errors.txt b/tests/baselines/reference/es6modulekindWithES5Target9.errors.txt index af941e65bbe..10351e92529 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target9.errors.txt +++ b/tests/baselines/reference/es6modulekindWithES5Target9.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/es6modulekindWithES5Target9.ts(1,15): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target9.ts(3,17): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target9.ts(5,20): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target9.ts(13,15): error TS2307: Cannot find module 'mod'. -tests/cases/compiler/es6modulekindWithES5Target9.ts(15,17): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(1,15): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(3,17): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(5,20): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(13,15): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(15,17): error TS2307: Cannot find module 'mod'. -==== tests/cases/compiler/es6modulekindWithES5Target9.ts (5 errors) ==== +==== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts (5 errors) ==== import d from "mod"; ~~~~~ !!! error TS2307: Cannot find module 'mod'. diff --git a/tests/baselines/reference/esnextmodulekind.js b/tests/baselines/reference/esnextmodulekind.js new file mode 100644 index 00000000000..073c319c861 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekind.js @@ -0,0 +1,22 @@ +//// [esnextmodulekind.ts] +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [esnextmodulekind.js] +export default class A { + constructor() { + } + B() { + return 42; + } +} diff --git a/tests/baselines/reference/esnextmodulekind.symbols b/tests/baselines/reference/esnextmodulekind.symbols new file mode 100644 index 00000000000..5cd1de6716b --- /dev/null +++ b/tests/baselines/reference/esnextmodulekind.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts === +export default class A +>A : Symbol(A, Decl(esnextmodulekind.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(A.B, Decl(esnextmodulekind.ts, 5, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/esnextmodulekind.types b/tests/baselines/reference/esnextmodulekind.types new file mode 100644 index 00000000000..a4e66e350b7 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekind.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts === +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : 42 + } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES2015Target.js b/tests/baselines/reference/esnextmodulekindWithES2015Target.js new file mode 100644 index 00000000000..fbaf4625244 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES2015Target.js @@ -0,0 +1,22 @@ +//// [esnextmodulekindWithES2015Target.ts] +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} + +//// [esnextmodulekindWithES2015Target.js] +export default class A { + constructor() { + } + B() { + return 42; + } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES2015Target.symbols b/tests/baselines/reference/esnextmodulekindWithES2015Target.symbols new file mode 100644 index 00000000000..68909c42291 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES2015Target.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts === +export default class A +>A : Symbol(A, Decl(esnextmodulekindWithES2015Target.ts, 0, 0)) +{ + constructor () + { + + } + + public B() +>B : Symbol(A.B, Decl(esnextmodulekindWithES2015Target.ts, 5, 5)) + { + return 42; + } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES2015Target.types b/tests/baselines/reference/esnextmodulekindWithES2015Target.types new file mode 100644 index 00000000000..647d40731e8 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES2015Target.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts === +export default class A +>A : A +{ + constructor () + { + + } + + public B() +>B : () => number + { + return 42; +>42 : 42 + } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target.js b/tests/baselines/reference/esnextmodulekindWithES5Target.js new file mode 100644 index 00000000000..061dd3e4050 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target.js @@ -0,0 +1,57 @@ +//// [esnextmodulekindWithES5Target.ts] +export class C { + static s = 0; + p = 1; + method() { } +} +export { C as C2 }; + +declare function foo(...args: any[]): any; +@foo +export class D { + static s = 0; + p = 1; + method() { } +} +export { D as D2 }; + +class E { } +export {E}; + + +//// [esnextmodulekindWithES5Target.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var C = /** @class */ (function () { + function C() { + this.p = 1; + } + C.prototype.method = function () { }; + C.s = 0; + return C; +}()); +export { C }; +export { C as C2 }; +var D = /** @class */ (function () { + function D() { + this.p = 1; + } + D.prototype.method = function () { }; + D.s = 0; + D = __decorate([ + foo + ], D); + return D; +}()); +export { D }; +export { D as D2 }; +var E = /** @class */ (function () { + function E() { + } + return E; +}()); +export { E }; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target.symbols new file mode 100644 index 00000000000..ae548754ae2 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target.symbols @@ -0,0 +1,46 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts === +export class C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target.ts, 0, 0)) + + static s = 0; +>s : Symbol(C.s, Decl(esnextmodulekindWithES5Target.ts, 0, 16)) + + p = 1; +>p : Symbol(C.p, Decl(esnextmodulekindWithES5Target.ts, 1, 17)) + + method() { } +>method : Symbol(C.method, Decl(esnextmodulekindWithES5Target.ts, 2, 10)) +} +export { C as C2 }; +>C : Symbol(C2, Decl(esnextmodulekindWithES5Target.ts, 5, 8)) +>C2 : Symbol(C2, Decl(esnextmodulekindWithES5Target.ts, 5, 8)) + +declare function foo(...args: any[]): any; +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target.ts, 5, 19)) +>args : Symbol(args, Decl(esnextmodulekindWithES5Target.ts, 7, 21)) + +@foo +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target.ts, 5, 19)) + +export class D { +>D : Symbol(D, Decl(esnextmodulekindWithES5Target.ts, 7, 42)) + + static s = 0; +>s : Symbol(D.s, Decl(esnextmodulekindWithES5Target.ts, 9, 16)) + + p = 1; +>p : Symbol(D.p, Decl(esnextmodulekindWithES5Target.ts, 10, 17)) + + method() { } +>method : Symbol(D.method, Decl(esnextmodulekindWithES5Target.ts, 11, 10)) +} +export { D as D2 }; +>D : Symbol(D2, Decl(esnextmodulekindWithES5Target.ts, 14, 8)) +>D2 : Symbol(D2, Decl(esnextmodulekindWithES5Target.ts, 14, 8)) + +class E { } +>E : Symbol(E, Decl(esnextmodulekindWithES5Target.ts, 14, 19)) + +export {E}; +>E : Symbol(E, Decl(esnextmodulekindWithES5Target.ts, 17, 8)) + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target.types b/tests/baselines/reference/esnextmodulekindWithES5Target.types new file mode 100644 index 00000000000..89b35314e86 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target.types @@ -0,0 +1,50 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts === +export class C { +>C : C + + static s = 0; +>s : number +>0 : 0 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} +export { C as C2 }; +>C : typeof C +>C2 : typeof C + +declare function foo(...args: any[]): any; +>foo : (...args: any[]) => any +>args : any[] + +@foo +>foo : (...args: any[]) => any + +export class D { +>D : D + + static s = 0; +>s : number +>0 : 0 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} +export { D as D2 }; +>D : typeof D +>D2 : typeof D + +class E { } +>E : E + +export {E}; +>E : typeof E + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target10.errors.txt b/tests/baselines/reference/esnextmodulekindWithES5Target10.errors.txt new file mode 100644 index 00000000000..4793bc650ad --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target10.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts(1,20): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts(6,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + + +==== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts (3 errors) ==== + import i = require("mod"); // Error; + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + + namespace N { + } + export = N; // Error + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. \ No newline at end of file diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target10.js b/tests/baselines/reference/esnextmodulekindWithES5Target10.js new file mode 100644 index 00000000000..e68e1d72b98 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target10.js @@ -0,0 +1,9 @@ +//// [esnextmodulekindWithES5Target10.ts] +import i = require("mod"); // Error; + + +namespace N { +} +export = N; // Error + +//// [esnextmodulekindWithES5Target10.js] diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target11.js b/tests/baselines/reference/esnextmodulekindWithES5Target11.js new file mode 100644 index 00000000000..58b18c4e829 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target11.js @@ -0,0 +1,32 @@ +//// [esnextmodulekindWithES5Target11.ts] +declare function foo(...args: any[]): any; +@foo +export default class C { + static x() { return C.y; } + static y = 1 + p = 1; + method() { } +} + +//// [esnextmodulekindWithES5Target11.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var C = /** @class */ (function () { + function C() { + this.p = 1; + } + C_1 = C; + C.x = function () { return C_1.y; }; + C.prototype.method = function () { }; + C.y = 1; + C = C_1 = __decorate([ + foo + ], C); + return C; + var C_1; +}()); +export default C; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target11.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target11.symbols new file mode 100644 index 00000000000..c7261964049 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target11.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts === +declare function foo(...args: any[]): any; +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target11.ts, 0, 0)) +>args : Symbol(args, Decl(esnextmodulekindWithES5Target11.ts, 0, 21)) + +@foo +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target11.ts, 0, 0)) + +export default class C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target11.ts, 0, 42)) + + static x() { return C.y; } +>x : Symbol(C.x, Decl(esnextmodulekindWithES5Target11.ts, 2, 24)) +>C.y : Symbol(C.y, Decl(esnextmodulekindWithES5Target11.ts, 3, 30)) +>C : Symbol(C, Decl(esnextmodulekindWithES5Target11.ts, 0, 42)) +>y : Symbol(C.y, Decl(esnextmodulekindWithES5Target11.ts, 3, 30)) + + static y = 1 +>y : Symbol(C.y, Decl(esnextmodulekindWithES5Target11.ts, 3, 30)) + + p = 1; +>p : Symbol(C.p, Decl(esnextmodulekindWithES5Target11.ts, 4, 16)) + + method() { } +>method : Symbol(C.method, Decl(esnextmodulekindWithES5Target11.ts, 5, 10)) +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target11.types b/tests/baselines/reference/esnextmodulekindWithES5Target11.types new file mode 100644 index 00000000000..733ae8c55f9 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target11.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts === +declare function foo(...args: any[]): any; +>foo : (...args: any[]) => any +>args : any[] + +@foo +>foo : (...args: any[]) => any + +export default class C { +>C : C + + static x() { return C.y; } +>x : () => number +>C.y : number +>C : typeof C +>y : number + + static y = 1 +>y : number +>1 : 1 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target12.js b/tests/baselines/reference/esnextmodulekindWithES5Target12.js new file mode 100644 index 00000000000..72d85ba1450 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target12.js @@ -0,0 +1,70 @@ +//// [esnextmodulekindWithES5Target12.ts] +export class C { +} + +export namespace C { + export const x = 1; +} + +export enum E { + w = 1 +} + +export enum E { + x = 2 +} + +export namespace E { + export const y = 1; +} + +export namespace E { + export const z = 1; +} + +export namespace N { +} + +export namespace N { + export const x = 1; +} + +export function F() { +} + +export namespace F { + export const x = 1; +} + +//// [esnextmodulekindWithES5Target12.js] +var C = /** @class */ (function () { + function C() { + } + return C; +}()); +export { C }; +(function (C) { + C.x = 1; +})(C || (C = {})); +export var E; +(function (E) { + E[E["w"] = 1] = "w"; +})(E || (E = {})); +(function (E) { + E[E["x"] = 2] = "x"; +})(E || (E = {})); +(function (E) { + E.y = 1; +})(E || (E = {})); +(function (E) { + E.z = 1; +})(E || (E = {})); +export var N; +(function (N) { + N.x = 1; +})(N || (N = {})); +export function F() { +} +(function (F) { + F.x = 1; +})(F || (F = {})); diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols new file mode 100644 index 00000000000..f28d6cb4158 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target12.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts === +export class C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target12.ts, 0, 0), Decl(esnextmodulekindWithES5Target12.ts, 1, 1)) +} + +export namespace C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target12.ts, 0, 0), Decl(esnextmodulekindWithES5Target12.ts, 1, 1)) + + export const x = 1; +>x : Symbol(x, Decl(esnextmodulekindWithES5Target12.ts, 4, 16)) +} + +export enum E { +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) + + w = 1 +>w : Symbol(E.w, Decl(esnextmodulekindWithES5Target12.ts, 7, 15)) +} + +export enum E { +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) + + x = 2 +>x : Symbol(E.x, Decl(esnextmodulekindWithES5Target12.ts, 11, 15)) +} + +export namespace E { +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) + + export const y = 1; +>y : Symbol(y, Decl(esnextmodulekindWithES5Target12.ts, 16, 16)) +} + +export namespace E { +>E : Symbol(E, Decl(esnextmodulekindWithES5Target12.ts, 5, 1), Decl(esnextmodulekindWithES5Target12.ts, 9, 1), Decl(esnextmodulekindWithES5Target12.ts, 13, 1), Decl(esnextmodulekindWithES5Target12.ts, 17, 1)) + + export const z = 1; +>z : Symbol(z, Decl(esnextmodulekindWithES5Target12.ts, 20, 16)) +} + +export namespace N { +>N : Symbol(N, Decl(esnextmodulekindWithES5Target12.ts, 21, 1), Decl(esnextmodulekindWithES5Target12.ts, 24, 1)) +} + +export namespace N { +>N : Symbol(N, Decl(esnextmodulekindWithES5Target12.ts, 21, 1), Decl(esnextmodulekindWithES5Target12.ts, 24, 1)) + + export const x = 1; +>x : Symbol(x, Decl(esnextmodulekindWithES5Target12.ts, 27, 16)) +} + +export function F() { +>F : Symbol(F, Decl(esnextmodulekindWithES5Target12.ts, 28, 1), Decl(esnextmodulekindWithES5Target12.ts, 31, 1)) +} + +export namespace F { +>F : Symbol(F, Decl(esnextmodulekindWithES5Target12.ts, 28, 1), Decl(esnextmodulekindWithES5Target12.ts, 31, 1)) + + export const x = 1; +>x : Symbol(x, Decl(esnextmodulekindWithES5Target12.ts, 34, 16)) +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target12.types b/tests/baselines/reference/esnextmodulekindWithES5Target12.types new file mode 100644 index 00000000000..608cf700cfd --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target12.types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts === +export class C { +>C : C +} + +export namespace C { +>C : typeof C + + export const x = 1; +>x : 1 +>1 : 1 +} + +export enum E { +>E : E + + w = 1 +>w : E.w +>1 : 1 +} + +export enum E { +>E : E + + x = 2 +>x : E.x +>2 : 2 +} + +export namespace E { +>E : typeof E + + export const y = 1; +>y : 1 +>1 : 1 +} + +export namespace E { +>E : typeof E + + export const z = 1; +>z : 1 +>1 : 1 +} + +export namespace N { +>N : typeof N +} + +export namespace N { +>N : typeof N + + export const x = 1; +>x : 1 +>1 : 1 +} + +export function F() { +>F : typeof F +} + +export namespace F { +>F : typeof F + + export const x = 1; +>x : 1 +>1 : 1 +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target2.js b/tests/baselines/reference/esnextmodulekindWithES5Target2.js new file mode 100644 index 00000000000..dd2a0b301a3 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target2.js @@ -0,0 +1,18 @@ +//// [esnextmodulekindWithES5Target2.ts] +export default class C { + static s = 0; + p = 1; + method() { } +} + + +//// [esnextmodulekindWithES5Target2.js] +var C = /** @class */ (function () { + function C() { + this.p = 1; + } + C.prototype.method = function () { }; + C.s = 0; + return C; +}()); +export default C; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target2.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target2.symbols new file mode 100644 index 00000000000..c1626775f65 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target2.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts === +export default class C { +>C : Symbol(C, Decl(esnextmodulekindWithES5Target2.ts, 0, 0)) + + static s = 0; +>s : Symbol(C.s, Decl(esnextmodulekindWithES5Target2.ts, 0, 24)) + + p = 1; +>p : Symbol(C.p, Decl(esnextmodulekindWithES5Target2.ts, 1, 17)) + + method() { } +>method : Symbol(C.method, Decl(esnextmodulekindWithES5Target2.ts, 2, 10)) +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target2.types b/tests/baselines/reference/esnextmodulekindWithES5Target2.types new file mode 100644 index 00000000000..165ef17ced9 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target2.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts === +export default class C { +>C : C + + static s = 0; +>s : number +>0 : 0 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target3.js b/tests/baselines/reference/esnextmodulekindWithES5Target3.js new file mode 100644 index 00000000000..e46e7c1bcac --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target3.js @@ -0,0 +1,28 @@ +//// [esnextmodulekindWithES5Target3.ts] +declare function foo(...args: any[]): any; +@foo +export default class D { + static s = 0; + p = 1; + method() { } +} + +//// [esnextmodulekindWithES5Target3.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var D = /** @class */ (function () { + function D() { + this.p = 1; + } + D.prototype.method = function () { }; + D.s = 0; + D = __decorate([ + foo + ], D); + return D; +}()); +export default D; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target3.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target3.symbols new file mode 100644 index 00000000000..3c34e0f2d81 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target3.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts === +declare function foo(...args: any[]): any; +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target3.ts, 0, 0)) +>args : Symbol(args, Decl(esnextmodulekindWithES5Target3.ts, 0, 21)) + +@foo +>foo : Symbol(foo, Decl(esnextmodulekindWithES5Target3.ts, 0, 0)) + +export default class D { +>D : Symbol(D, Decl(esnextmodulekindWithES5Target3.ts, 0, 42)) + + static s = 0; +>s : Symbol(D.s, Decl(esnextmodulekindWithES5Target3.ts, 2, 24)) + + p = 1; +>p : Symbol(D.p, Decl(esnextmodulekindWithES5Target3.ts, 3, 17)) + + method() { } +>method : Symbol(D.method, Decl(esnextmodulekindWithES5Target3.ts, 4, 10)) +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target3.types b/tests/baselines/reference/esnextmodulekindWithES5Target3.types new file mode 100644 index 00000000000..15a6ba1ce5f --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target3.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts === +declare function foo(...args: any[]): any; +>foo : (...args: any[]) => any +>args : any[] + +@foo +>foo : (...args: any[]) => any + +export default class D { +>D : D + + static s = 0; +>s : number +>0 : 0 + + p = 1; +>p : number +>1 : 1 + + method() { } +>method : () => void +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target4.js b/tests/baselines/reference/esnextmodulekindWithES5Target4.js new file mode 100644 index 00000000000..c31286cd30e --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target4.js @@ -0,0 +1,11 @@ +//// [esnextmodulekindWithES5Target4.ts] +class E { } +export default E; + +//// [esnextmodulekindWithES5Target4.js] +var E = /** @class */ (function () { + function E() { + } + return E; +}()); +export default E; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target4.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target4.symbols new file mode 100644 index 00000000000..06ac0dc56e5 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target4.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts === +class E { } +>E : Symbol(E, Decl(esnextmodulekindWithES5Target4.ts, 0, 0)) + +export default E; +>E : Symbol(E, Decl(esnextmodulekindWithES5Target4.ts, 0, 0)) + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target4.types b/tests/baselines/reference/esnextmodulekindWithES5Target4.types new file mode 100644 index 00000000000..b9ed448e9b8 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target4.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts === +class E { } +>E : E + +export default E; +>E : E + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target5.js b/tests/baselines/reference/esnextmodulekindWithES5Target5.js new file mode 100644 index 00000000000..178a6c366f8 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target5.js @@ -0,0 +1,18 @@ +//// [esnextmodulekindWithES5Target5.ts] +export enum E1 { + value1 +} + +export const enum E2 { + value1 +} + +//// [esnextmodulekindWithES5Target5.js] +export var E1; +(function (E1) { + E1[E1["value1"] = 0] = "value1"; +})(E1 || (E1 = {})); +export var E2; +(function (E2) { + E2[E2["value1"] = 0] = "value1"; +})(E2 || (E2 = {})); diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target5.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target5.symbols new file mode 100644 index 00000000000..26db8dab610 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target5.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts === +export enum E1 { +>E1 : Symbol(E1, Decl(esnextmodulekindWithES5Target5.ts, 0, 0)) + + value1 +>value1 : Symbol(E1.value1, Decl(esnextmodulekindWithES5Target5.ts, 0, 16)) +} + +export const enum E2 { +>E2 : Symbol(E2, Decl(esnextmodulekindWithES5Target5.ts, 2, 1)) + + value1 +>value1 : Symbol(E2.value1, Decl(esnextmodulekindWithES5Target5.ts, 4, 22)) +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target5.types b/tests/baselines/reference/esnextmodulekindWithES5Target5.types new file mode 100644 index 00000000000..c838a953ef9 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target5.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts === +export enum E1 { +>E1 : E1 + + value1 +>value1 : E1 +} + +export const enum E2 { +>E2 : E2 + + value1 +>value1 : E2 +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target6.js b/tests/baselines/reference/esnextmodulekindWithES5Target6.js new file mode 100644 index 00000000000..85a87acacef --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target6.js @@ -0,0 +1,24 @@ +//// [esnextmodulekindWithES5Target6.ts] +export function f1(d = 0) { +} + +export function f2(...arg) { +} + +export default function f3(d = 0) { +} + + +//// [esnextmodulekindWithES5Target6.js] +export function f1(d) { + if (d === void 0) { d = 0; } +} +export function f2() { + var arg = []; + for (var _i = 0; _i < arguments.length; _i++) { + arg[_i] = arguments[_i]; + } +} +export default function f3(d) { + if (d === void 0) { d = 0; } +} diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target6.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target6.symbols new file mode 100644 index 00000000000..a77b1691a05 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target6.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts === +export function f1(d = 0) { +>f1 : Symbol(f1, Decl(esnextmodulekindWithES5Target6.ts, 0, 0)) +>d : Symbol(d, Decl(esnextmodulekindWithES5Target6.ts, 0, 19)) +} + +export function f2(...arg) { +>f2 : Symbol(f2, Decl(esnextmodulekindWithES5Target6.ts, 1, 1)) +>arg : Symbol(arg, Decl(esnextmodulekindWithES5Target6.ts, 3, 19)) +} + +export default function f3(d = 0) { +>f3 : Symbol(f3, Decl(esnextmodulekindWithES5Target6.ts, 4, 1)) +>d : Symbol(d, Decl(esnextmodulekindWithES5Target6.ts, 6, 27)) +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target6.types b/tests/baselines/reference/esnextmodulekindWithES5Target6.types new file mode 100644 index 00000000000..ac826125710 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target6.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts === +export function f1(d = 0) { +>f1 : (d?: number) => void +>d : number +>0 : 0 +} + +export function f2(...arg) { +>f2 : (...arg: any[]) => void +>arg : any[] +} + +export default function f3(d = 0) { +>f3 : (d?: number) => void +>d : number +>0 : 0 +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target7.js b/tests/baselines/reference/esnextmodulekindWithES5Target7.js new file mode 100644 index 00000000000..be9e6984f42 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target7.js @@ -0,0 +1,15 @@ +//// [esnextmodulekindWithES5Target7.ts] +export namespace N { + var x = 0; +} + +export namespace N2 { + export interface I { } +} + + +//// [esnextmodulekindWithES5Target7.js] +export var N; +(function (N) { + var x = 0; +})(N || (N = {})); diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target7.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target7.symbols new file mode 100644 index 00000000000..bf23ed8e3c5 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target7.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts === +export namespace N { +>N : Symbol(N, Decl(esnextmodulekindWithES5Target7.ts, 0, 0)) + + var x = 0; +>x : Symbol(x, Decl(esnextmodulekindWithES5Target7.ts, 1, 7)) +} + +export namespace N2 { +>N2 : Symbol(N2, Decl(esnextmodulekindWithES5Target7.ts, 2, 1)) + + export interface I { } +>I : Symbol(I, Decl(esnextmodulekindWithES5Target7.ts, 4, 21)) +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target7.types b/tests/baselines/reference/esnextmodulekindWithES5Target7.types new file mode 100644 index 00000000000..6d0887adf69 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target7.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts === +export namespace N { +>N : typeof N + + var x = 0; +>x : number +>0 : 0 +} + +export namespace N2 { +>N2 : any + + export interface I { } +>I : I +} + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target8.js b/tests/baselines/reference/esnextmodulekindWithES5Target8.js new file mode 100644 index 00000000000..6a73cbb6b6c --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target8.js @@ -0,0 +1,7 @@ +//// [esnextmodulekindWithES5Target8.ts] +export const c = 0; +export let l = 1; + +//// [esnextmodulekindWithES5Target8.js] +export var c = 0; +export var l = 1; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target8.symbols b/tests/baselines/reference/esnextmodulekindWithES5Target8.symbols new file mode 100644 index 00000000000..a2fa5496c97 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target8.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts === +export const c = 0; +>c : Symbol(c, Decl(esnextmodulekindWithES5Target8.ts, 0, 12)) + +export let l = 1; +>l : Symbol(l, Decl(esnextmodulekindWithES5Target8.ts, 1, 10)) + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target8.types b/tests/baselines/reference/esnextmodulekindWithES5Target8.types new file mode 100644 index 00000000000..deb60c9c0df --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target8.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts === +export const c = 0; +>c : 0 +>0 : 0 + +export let l = 1; +>l : number +>1 : 1 + diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target9.errors.txt b/tests/baselines/reference/esnextmodulekindWithES5Target9.errors.txt new file mode 100644 index 00000000000..cccb20f9659 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target9.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(1,15): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(3,17): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(5,20): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(13,15): error TS2307: Cannot find module 'mod'. +tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts(15,17): error TS2307: Cannot find module 'mod'. + + +==== tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts (5 errors) ==== + import d from "mod"; + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + import {a} from "mod"; + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + import * as M from "mod"; + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + export {a}; + + export {M}; + + export {d}; + + export * from "mod"; + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + export {b} from "mod" + ~~~~~ +!!! error TS2307: Cannot find module 'mod'. + + export default d; + \ No newline at end of file diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target9.js b/tests/baselines/reference/esnextmodulekindWithES5Target9.js new file mode 100644 index 00000000000..65197694501 --- /dev/null +++ b/tests/baselines/reference/esnextmodulekindWithES5Target9.js @@ -0,0 +1,30 @@ +//// [esnextmodulekindWithES5Target9.ts] +import d from "mod"; + +import {a} from "mod"; + +import * as M from "mod"; + +export {a}; + +export {M}; + +export {d}; + +export * from "mod"; + +export {b} from "mod" + +export default d; + + +//// [esnextmodulekindWithES5Target9.js] +import d from "mod"; +import { a } from "mod"; +import * as M from "mod"; +export { a }; +export { M }; +export { d }; +export * from "mod"; +export { b } from "mod"; +export default d; diff --git a/tests/cases/compiler/es6modulekind.ts b/tests/cases/conformance/externalModules/es6/es6modulekind.ts similarity index 100% rename from tests/cases/compiler/es6modulekind.ts rename to tests/cases/conformance/externalModules/es6/es6modulekind.ts diff --git a/tests/cases/compiler/es6modulekindWithES2015Target.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES2015Target.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target10.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target10.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target11.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target11.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target12.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target12.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target2.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target2.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target3.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target3.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target4.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target4.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target5.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target5.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target6.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target6.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target7.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target7.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target8.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target8.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts diff --git a/tests/cases/compiler/es6modulekindWithES5Target9.ts b/tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts similarity index 100% rename from tests/cases/compiler/es6modulekindWithES5Target9.ts rename to tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts new file mode 100644 index 00000000000..59b61f742b4 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekind.ts @@ -0,0 +1,17 @@ +// @target: ES6 +// @sourcemap: false +// @declaration: false +// @module: esnext + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts new file mode 100644 index 00000000000..aaf79e6607d --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES2015Target.ts @@ -0,0 +1,17 @@ +// @target: es2015 +// @sourcemap: false +// @declaration: false +// @module: es6 + +export default class A +{ + constructor () + { + + } + + public B() + { + return 42; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts new file mode 100644 index 00000000000..98c38ee6e3a --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target.ts @@ -0,0 +1,22 @@ +// @target: es5 +// @module: esnext +// @experimentalDecorators: true + +export class C { + static s = 0; + p = 1; + method() { } +} +export { C as C2 }; + +declare function foo(...args: any[]): any; +@foo +export class D { + static s = 0; + p = 1; + method() { } +} +export { D as D2 }; + +class E { } +export {E}; diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts new file mode 100644 index 00000000000..2505870ed8e --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target10.ts @@ -0,0 +1,9 @@ +// @target: es5 +// @module: esnext + +import i = require("mod"); // Error; + + +namespace N { +} +export = N; // Error \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts new file mode 100644 index 00000000000..29f883acd68 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target11.ts @@ -0,0 +1,12 @@ +// @target: es5 +// @module: esnext +// @experimentalDecorators: true + +declare function foo(...args: any[]): any; +@foo +export default class C { + static x() { return C.y; } + static y = 1 + p = 1; + method() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts new file mode 100644 index 00000000000..93c29f88ae5 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target12.ts @@ -0,0 +1,39 @@ +// @target: es5 +// @module: esnext + +export class C { +} + +export namespace C { + export const x = 1; +} + +export enum E { + w = 1 +} + +export enum E { + x = 2 +} + +export namespace E { + export const y = 1; +} + +export namespace E { + export const z = 1; +} + +export namespace N { +} + +export namespace N { + export const x = 1; +} + +export function F() { +} + +export namespace F { + export const x = 1; +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts new file mode 100644 index 00000000000..3b94c938cd1 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target2.ts @@ -0,0 +1,8 @@ +// @target: es5 +// @module: esnext + +export default class C { + static s = 0; + p = 1; + method() { } +} diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts new file mode 100644 index 00000000000..6726db916e5 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target3.ts @@ -0,0 +1,12 @@ +// @target: es5 +// @module: esnext +// @experimentalDecorators: true + + +declare function foo(...args: any[]): any; +@foo +export default class D { + static s = 0; + p = 1; + method() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts new file mode 100644 index 00000000000..090ecc64305 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target4.ts @@ -0,0 +1,5 @@ +// @target: es5 +// @module: esnext + +class E { } +export default E; \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts new file mode 100644 index 00000000000..9dd83fd45db --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target5.ts @@ -0,0 +1,11 @@ +// @target: es5 +// @module: esnext +// @preserveConstEnums: true + +export enum E1 { + value1 +} + +export const enum E2 { + value1 +} \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts new file mode 100644 index 00000000000..2c53a8a9254 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target6.ts @@ -0,0 +1,11 @@ +// @target: es5 +// @module: esnext + +export function f1(d = 0) { +} + +export function f2(...arg) { +} + +export default function f3(d = 0) { +} diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts new file mode 100644 index 00000000000..4d22faba173 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target7.ts @@ -0,0 +1,10 @@ +// @target: es5 +// @module: esnext + +export namespace N { + var x = 0; +} + +export namespace N2 { + export interface I { } +} diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts new file mode 100644 index 00000000000..530f4c88c39 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target8.ts @@ -0,0 +1,5 @@ +// @target: es5 +// @module: esnext + +export const c = 0; +export let l = 1; \ No newline at end of file diff --git a/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts new file mode 100644 index 00000000000..d91d6399ad3 --- /dev/null +++ b/tests/cases/conformance/externalModules/esnext/esnextmodulekindWithES5Target9.ts @@ -0,0 +1,20 @@ +// @target: es5 +// @module: esnext + +import d from "mod"; + +import {a} from "mod"; + +import * as M from "mod"; + +export {a}; + +export {M}; + +export {d}; + +export * from "mod"; + +export {b} from "mod" + +export default d; From 63d746bc4c5f3cee42e65462705a038e4a7412fa Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Sep 2017 10:24:27 -0700 Subject: [PATCH 122/216] Higher order inference for mapped, index and lookup types --- src/compiler/checker.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ff5d1c661e8..4f2f065f4f3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10386,7 +10386,7 @@ namespace ts { // results for union and intersection types for performance reasons. function couldContainTypeVariables(type: Type): boolean { const objectFlags = getObjectFlags(type); - return !!(type.flags & TypeFlags.TypeVariable || + return !!(type.flags & (TypeFlags.TypeVariable | TypeFlags.Index) || objectFlags & ObjectFlags.Reference && forEach((type).typeArguments, couldContainTypeVariables) || objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class) || objectFlags & ObjectFlags.Mapped || @@ -10554,6 +10554,13 @@ namespace ts { inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & TypeFlags.Index && target.flags & TypeFlags.Index) { + inferFromTypes((source).type, (target).type); + } + else if (source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess) { + inferFromTypes((source).objectType, (target).objectType); + inferFromTypes((source).indexType, (target).indexType); + } else if (target.flags & TypeFlags.UnionOrIntersection) { const targetTypes = (target).types; let typeVariableCount = 0; @@ -10627,6 +10634,12 @@ namespace ts { } function inferFromObjectTypes(source: Type, target: Type) { + if (isGenericMappedType(source) && isGenericMappedType(target)) { + // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer + // from S to T and from X to Y. + inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + } if (getObjectFlags(target) & ObjectFlags.Mapped) { const constraintType = getConstraintTypeFromMappedType(target); if (constraintType.flags & TypeFlags.Index) { From 0823eba8a3257b80df68494ac0d534ac9b6bd16b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Sep 2017 10:38:46 -0700 Subject: [PATCH 123/216] Add tests --- .../higherOrderMappedIndexLookupInference.js | 43 ++++++++ ...herOrderMappedIndexLookupInference.symbols | 98 +++++++++++++++++ ...igherOrderMappedIndexLookupInference.types | 104 ++++++++++++++++++ .../higherOrderMappedIndexLookupInference.ts | 25 +++++ 4 files changed, 270 insertions(+) create mode 100644 tests/baselines/reference/higherOrderMappedIndexLookupInference.js create mode 100644 tests/baselines/reference/higherOrderMappedIndexLookupInference.symbols create mode 100644 tests/baselines/reference/higherOrderMappedIndexLookupInference.types create mode 100644 tests/cases/compiler/higherOrderMappedIndexLookupInference.ts diff --git a/tests/baselines/reference/higherOrderMappedIndexLookupInference.js b/tests/baselines/reference/higherOrderMappedIndexLookupInference.js new file mode 100644 index 00000000000..e8e09a59713 --- /dev/null +++ b/tests/baselines/reference/higherOrderMappedIndexLookupInference.js @@ -0,0 +1,43 @@ +//// [higherOrderMappedIndexLookupInference.ts] +// @strict + +function f1(a: () => keyof T, b: () => keyof U) { + a = b; + b = a; +} + +function f2(a: () => T[K], b: () => U[L]) { + a = b; + b = a; +} + +function f3(a: () => { [K in keyof T]: T[K] }, b: () => { [K in keyof U]: U[K] }) { + a = b; + b = a; +} + +// Repro from #18338 + +type IdMapped = { [K in keyof T]: T[K] } + +declare const f: () => IdMapped; +declare const g: () => { [K in keyof U]: U[K] }; + +const h: typeof g = f; + + +//// [higherOrderMappedIndexLookupInference.js] +// @strict +function f1(a, b) { + a = b; + b = a; +} +function f2(a, b) { + a = b; + b = a; +} +function f3(a, b) { + a = b; + b = a; +} +var h = f; diff --git a/tests/baselines/reference/higherOrderMappedIndexLookupInference.symbols b/tests/baselines/reference/higherOrderMappedIndexLookupInference.symbols new file mode 100644 index 00000000000..44ecb1e6d02 --- /dev/null +++ b/tests/baselines/reference/higherOrderMappedIndexLookupInference.symbols @@ -0,0 +1,98 @@ +=== tests/cases/compiler/higherOrderMappedIndexLookupInference.ts === +// @strict + +function f1(a: () => keyof T, b: () => keyof U) { +>f1 : Symbol(f1, Decl(higherOrderMappedIndexLookupInference.ts, 0, 0)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 2, 12)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 2, 16)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 2, 16)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 2, 32)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 2, 37)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 2, 37)) + + a = b; +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 2, 12)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 2, 32)) + + b = a; +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 2, 32)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 2, 12)) +} + +function f2(a: () => T[K], b: () => U[L]) { +>f2 : Symbol(f2, Decl(higherOrderMappedIndexLookupInference.ts, 5, 1)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 7, 12)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 7, 16)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 7, 18)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 7, 16)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 7, 16)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 7, 18)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 7, 48)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 7, 53)) +>L : Symbol(L, Decl(higherOrderMappedIndexLookupInference.ts, 7, 55)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 7, 53)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 7, 53)) +>L : Symbol(L, Decl(higherOrderMappedIndexLookupInference.ts, 7, 55)) + + a = b; +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 7, 12)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 7, 48)) + + b = a; +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 7, 48)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 7, 12)) +} + +function f3(a: () => { [K in keyof T]: T[K] }, b: () => { [K in keyof U]: U[K] }) { +>f3 : Symbol(f3, Decl(higherOrderMappedIndexLookupInference.ts, 10, 1)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 12, 12)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 12, 16)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 12, 27)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 12, 16)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 12, 16)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 12, 27)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 12, 49)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 12, 54)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 12, 65)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 12, 54)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 12, 54)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 12, 65)) + + a = b; +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 12, 12)) +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 12, 49)) + + b = a; +>b : Symbol(b, Decl(higherOrderMappedIndexLookupInference.ts, 12, 49)) +>a : Symbol(a, Decl(higherOrderMappedIndexLookupInference.ts, 12, 12)) +} + +// Repro from #18338 + +type IdMapped = { [K in keyof T]: T[K] } +>IdMapped : Symbol(IdMapped, Decl(higherOrderMappedIndexLookupInference.ts, 15, 1)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 19, 14)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 19, 22)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 19, 14)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 19, 14)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 19, 22)) + +declare const f: () => IdMapped; +>f : Symbol(f, Decl(higherOrderMappedIndexLookupInference.ts, 21, 13)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 21, 18)) +>IdMapped : Symbol(IdMapped, Decl(higherOrderMappedIndexLookupInference.ts, 15, 1)) +>T : Symbol(T, Decl(higherOrderMappedIndexLookupInference.ts, 21, 18)) + +declare const g: () => { [K in keyof U]: U[K] }; +>g : Symbol(g, Decl(higherOrderMappedIndexLookupInference.ts, 22, 13)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 22, 18)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 22, 29)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 22, 18)) +>U : Symbol(U, Decl(higherOrderMappedIndexLookupInference.ts, 22, 18)) +>K : Symbol(K, Decl(higherOrderMappedIndexLookupInference.ts, 22, 29)) + +const h: typeof g = f; +>h : Symbol(h, Decl(higherOrderMappedIndexLookupInference.ts, 24, 5)) +>g : Symbol(g, Decl(higherOrderMappedIndexLookupInference.ts, 22, 13)) +>f : Symbol(f, Decl(higherOrderMappedIndexLookupInference.ts, 21, 13)) + diff --git a/tests/baselines/reference/higherOrderMappedIndexLookupInference.types b/tests/baselines/reference/higherOrderMappedIndexLookupInference.types new file mode 100644 index 00000000000..f1c2b0aa17b --- /dev/null +++ b/tests/baselines/reference/higherOrderMappedIndexLookupInference.types @@ -0,0 +1,104 @@ +=== tests/cases/compiler/higherOrderMappedIndexLookupInference.ts === +// @strict + +function f1(a: () => keyof T, b: () => keyof U) { +>f1 : (a: () => keyof T, b: () => keyof U) => void +>a : () => keyof T +>T : T +>T : T +>b : () => keyof U +>U : U +>U : U + + a = b; +>a = b : () => keyof U +>a : () => keyof T +>b : () => keyof U + + b = a; +>b = a : () => keyof T +>b : () => keyof U +>a : () => keyof T +} + +function f2(a: () => T[K], b: () => U[L]) { +>f2 : (a: () => T[K], b: () => U[L]) => void +>a : () => T[K] +>T : T +>K : K +>T : T +>T : T +>K : K +>b : () => U[L] +>U : U +>L : L +>U : U +>U : U +>L : L + + a = b; +>a = b : () => U[L] +>a : () => T[K] +>b : () => U[L] + + b = a; +>b = a : () => T[K] +>b : () => U[L] +>a : () => T[K] +} + +function f3(a: () => { [K in keyof T]: T[K] }, b: () => { [K in keyof U]: U[K] }) { +>f3 : (a: () => { [K in keyof T]: T[K]; }, b: () => { [K in keyof U]: U[K]; }) => void +>a : () => { [K in keyof T]: T[K]; } +>T : T +>K : K +>T : T +>T : T +>K : K +>b : () => { [K in keyof U]: U[K]; } +>U : U +>K : K +>U : U +>U : U +>K : K + + a = b; +>a = b : () => { [K in keyof U]: U[K]; } +>a : () => { [K in keyof T]: T[K]; } +>b : () => { [K in keyof U]: U[K]; } + + b = a; +>b = a : () => { [K in keyof T]: T[K]; } +>b : () => { [K in keyof U]: U[K]; } +>a : () => { [K in keyof T]: T[K]; } +} + +// Repro from #18338 + +type IdMapped = { [K in keyof T]: T[K] } +>IdMapped : IdMapped +>T : T +>K : K +>T : T +>T : T +>K : K + +declare const f: () => IdMapped; +>f : () => IdMapped +>T : T +>IdMapped : IdMapped +>T : T + +declare const g: () => { [K in keyof U]: U[K] }; +>g : () => { [K in keyof U]: U[K]; } +>U : U +>K : K +>U : U +>U : U +>K : K + +const h: typeof g = f; +>h : () => { [K in keyof U]: U[K]; } +>g : () => { [K in keyof U]: U[K]; } +>f : () => IdMapped + diff --git a/tests/cases/compiler/higherOrderMappedIndexLookupInference.ts b/tests/cases/compiler/higherOrderMappedIndexLookupInference.ts new file mode 100644 index 00000000000..96156283915 --- /dev/null +++ b/tests/cases/compiler/higherOrderMappedIndexLookupInference.ts @@ -0,0 +1,25 @@ +// @strict + +function f1(a: () => keyof T, b: () => keyof U) { + a = b; + b = a; +} + +function f2(a: () => T[K], b: () => U[L]) { + a = b; + b = a; +} + +function f3(a: () => { [K in keyof T]: T[K] }, b: () => { [K in keyof U]: U[K] }) { + a = b; + b = a; +} + +// Repro from #18338 + +type IdMapped = { [K in keyof T]: T[K] } + +declare const f: () => IdMapped; +declare const g: () => { [K in keyof U]: U[K] }; + +const h: typeof g = f; From 6c2fe29a72e8ad8d9ca178eeafe8d9bfa7a5b6bc Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Sep 2017 11:02:11 -0700 Subject: [PATCH 124/216] Accept new baselines --- tests/baselines/reference/keyofAndIndexedAccess.types | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 25d79e3f4ff..4bd5bb4e3c4 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -205,7 +205,7 @@ type Q40 = (Shape | Options)["visible"]; // boolean | "yes" | "no" >Options : Options type Q41 = (Shape & Options)["visible"]; // true & "yes" | true & "no" | false & "yes" | false & "no" ->Q41 : (true & "yes") | (true & "no") | (false & "yes") | (false & "no") +>Q41 : never >Shape : Shape >Options : Options From 2fdb5b8659bbf909a90f11d1e31b43bbe0da934c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 11 Sep 2017 11:16:01 -0700 Subject: [PATCH 125/216] assignContextualParameterTypes handles arguments object Previously, it would crash — the arguments object is a transient symbol with no declaration, and `getEffectiveTypeAnnotationNode` does not accept `undefined`. --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ff5d1c661e8..b8b2e8edb82 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16665,8 +16665,9 @@ namespace ts { } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + // parameter might be a transient symbol generated by use of `arguments` in the function body. const parameter = lastOrUndefined(signature.parameters); - if (!getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { + if (isTransientSymbol(parameter) || !getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { const contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } From 4e04a740f884d71668754efc4b0064976fe45773 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 11 Sep 2017 11:17:14 -0700 Subject: [PATCH 126/216] Test:contextual typing of arguments obj in JS files --- .../contextuallyTypeArgumentsKeyword.symbols | 14 ++++++++++++++ .../contextuallyTypeArgumentsKeyword.types | 18 ++++++++++++++++++ .../contextuallyTypeArgumentsKeyword.ts | 11 +++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/baselines/reference/contextuallyTypeArgumentsKeyword.symbols create mode 100644 tests/baselines/reference/contextuallyTypeArgumentsKeyword.types create mode 100644 tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts diff --git a/tests/baselines/reference/contextuallyTypeArgumentsKeyword.symbols b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.symbols new file mode 100644 index 00000000000..556c362f27e --- /dev/null +++ b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/foo.js === +// Repro for #16585 +const x = { +>x : Symbol(x, Decl(foo.js, 1, 5)) + + bar() { +>bar : Symbol(bar, Decl(foo.js, 1, 11)) + + setTimeout(function() { arguments }, 0); +>setTimeout : Symbol(setTimeout, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>arguments : Symbol(arguments) + } +} + diff --git a/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types new file mode 100644 index 00000000000..2f90f47f370 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/foo.js === +// Repro for #16585 +const x = { +>x : { [x: string]: any; bar(): void; } +>{ bar() { setTimeout(function() { arguments }, 0); }} : { [x: string]: any; bar(): void; } + + bar() { +>bar : () => void + + setTimeout(function() { arguments }, 0); +>setTimeout(function() { arguments }, 0) : number +>setTimeout : { (handler: (...args: any[]) => void, timeout: number): number; (handler: any, timeout?: any, ...args: any[]): number; } +>function() { arguments } : (...args: any[]) => void +>arguments : IArguments +>0 : 0 + } +} + diff --git a/tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts b/tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts new file mode 100644 index 00000000000..9421e70c4e8 --- /dev/null +++ b/tests/cases/compiler/contextuallyTypeArgumentsKeyword.ts @@ -0,0 +1,11 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @lib: es2017, dom +// @Filename: foo.js +// Repro for #16585 +const x = { + bar() { + setTimeout(function() { arguments }, 0); + } +} From 29d5e4daddc3a97ec81b338b6a3a5ae1892288fe Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Tue, 12 Sep 2017 02:21:35 +0800 Subject: [PATCH 127/216] fix #18225, fix error message on abstract class instance (#18368) * fix #18225, fix error message on abstract class instance abstract class check should be inside constructor call * add new test and accept baseline --- src/compiler/checker.ts | 20 +++++++++---------- .../reference/newAbstractInstance.errors.txt | 10 ++++++++++ .../reference/newAbstractInstance.js | 13 ++++++++++++ tests/cases/compiler/newAbstractInstance.ts | 3 +++ 4 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/newAbstractInstance.errors.txt create mode 100644 tests/baselines/reference/newAbstractInstance.js create mode 100644 tests/cases/compiler/newAbstractInstance.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ff5d1c661e8..66ae64e199b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16128,16 +16128,6 @@ namespace ts { return resolveErrorCall(node); } - // If the expression is a class of abstract type, then it cannot be instantiated. - // Note, only class declarations can be declared abstract. - // In the case of a merged class-module or class-interface declaration, - // only the class declaration node will have the Abstract flag set. - const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && hasModifier(valueDecl, ModifierFlags.Abstract)) { - error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(getNameOfDeclaration(valueDecl))); - return resolveErrorCall(node); - } - // TS 1.0 spec: 4.11 // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. @@ -16157,6 +16147,16 @@ namespace ts { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && hasModifier(valueDecl, ModifierFlags.Abstract)) { + error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(getNameOfDeclaration(valueDecl))); + return resolveErrorCall(node); + } + return resolveCall(node, constructSignatures, candidatesOutArray); } diff --git a/tests/baselines/reference/newAbstractInstance.errors.txt b/tests/baselines/reference/newAbstractInstance.errors.txt new file mode 100644 index 00000000000..13a5aff9df3 --- /dev/null +++ b/tests/baselines/reference/newAbstractInstance.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/newAbstractInstance.ts(3,1): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + + +==== tests/cases/compiler/newAbstractInstance.ts (1 errors) ==== + abstract class B { } + declare const b: B; + new b(); + ~~~~~~~ +!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + \ No newline at end of file diff --git a/tests/baselines/reference/newAbstractInstance.js b/tests/baselines/reference/newAbstractInstance.js new file mode 100644 index 00000000000..4a84b42cc20 --- /dev/null +++ b/tests/baselines/reference/newAbstractInstance.js @@ -0,0 +1,13 @@ +//// [newAbstractInstance.ts] +abstract class B { } +declare const b: B; +new b(); + + +//// [newAbstractInstance.js] +var B = /** @class */ (function () { + function B() { + } + return B; +}()); +new b(); diff --git a/tests/cases/compiler/newAbstractInstance.ts b/tests/cases/compiler/newAbstractInstance.ts new file mode 100644 index 00000000000..f686aafa005 --- /dev/null +++ b/tests/cases/compiler/newAbstractInstance.ts @@ -0,0 +1,3 @@ +abstract class B { } +declare const b: B; +new b(); From 1ee3b651418b6a4813f21970f4685f7ca1587827 Mon Sep 17 00:00:00 2001 From: Thomas den Hollander Date: Mon, 11 Sep 2017 20:22:46 +0200 Subject: [PATCH 128/216] Change typed array signatures (#18367) --- src/lib/es5.d.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 6033a8fd989..820a90554ea 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1744,8 +1744,8 @@ interface Int8Array { interface Int8ArrayConstructor { readonly prototype: Int8Array; new(length: number): Int8Array; - new(array: ArrayLike): Int8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int8Array; /** * The size in bytes of each element in the array. @@ -2012,8 +2012,8 @@ interface Uint8Array { interface Uint8ArrayConstructor { readonly prototype: Uint8Array; new(length: number): Uint8Array; - new(array: ArrayLike): Uint8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8Array; /** * The size in bytes of each element in the array. @@ -2279,8 +2279,8 @@ interface Uint8ClampedArray { interface Uint8ClampedArrayConstructor { readonly prototype: Uint8ClampedArray; new(length: number): Uint8ClampedArray; - new(array: ArrayLike): Uint8ClampedArray; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8ClampedArray; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8ClampedArray; /** * The size in bytes of each element in the array. @@ -2544,8 +2544,8 @@ interface Int16Array { interface Int16ArrayConstructor { readonly prototype: Int16Array; new(length: number): Int16Array; - new(array: ArrayLike): Int16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int16Array; /** * The size in bytes of each element in the array. @@ -2812,8 +2812,8 @@ interface Uint16Array { interface Uint16ArrayConstructor { readonly prototype: Uint16Array; new(length: number): Uint16Array; - new(array: ArrayLike): Uint16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint16Array; /** * The size in bytes of each element in the array. @@ -3079,8 +3079,8 @@ interface Int32Array { interface Int32ArrayConstructor { readonly prototype: Int32Array; new(length: number): Int32Array; - new(array: ArrayLike): Int32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int32Array; /** * The size in bytes of each element in the array. @@ -3345,8 +3345,8 @@ interface Uint32Array { interface Uint32ArrayConstructor { readonly prototype: Uint32Array; new(length: number): Uint32Array; - new(array: ArrayLike): Uint32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint32Array; /** * The size in bytes of each element in the array. @@ -3612,8 +3612,8 @@ interface Float32Array { interface Float32ArrayConstructor { readonly prototype: Float32Array; new(length: number): Float32Array; - new(array: ArrayLike): Float32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float32Array; /** * The size in bytes of each element in the array. @@ -3880,8 +3880,8 @@ interface Float64Array { interface Float64ArrayConstructor { readonly prototype: Float64Array; new(length: number): Float64Array; - new(array: ArrayLike): Float64Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float64Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float64Array; /** * The size in bytes of each element in the array. From 403f585622192d2ebf53196354b87cf467ea1908 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 12 Sep 2017 10:43:24 -0700 Subject: [PATCH 129/216] enclosingDeclaration can be undefined within getAccessibleSymbolChain (#18400) --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c87062a212f..c169dcb83ca 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2063,7 +2063,7 @@ namespace ts { return rightMeaning === SymbolFlags.Value ? SymbolFlags.Value : SymbolFlags.Namespace; } - function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined { + function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined { if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } @@ -2112,7 +2112,7 @@ namespace ts { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.escapedName !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier) - && !(isUMDExportSymbol(symbolFromSymbolTable) && isExternalModule(getSourceFileOfNode(enclosingDeclaration))) + && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && isExternalModule(getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration))) { @@ -2132,7 +2132,7 @@ namespace ts { } } - function needsQualification(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags) { + function needsQualification(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags) { let qualify = false; forEachSymbolTableInScope(enclosingDeclaration, symbolTable => { // If symbol of this name is not available in the symbol table we are ok From 4c4316da722840a66a2412201e258feeae7cff14 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 12 Sep 2017 14:01:05 -0700 Subject: [PATCH 130/216] Fail spec parsing lambdas on parameter missing a = Fail speculative parsing of arrow function expressions whenever it has a parameter with an initialiser that is missing '='. Ordinarily this is allowed for better error recovery in the language service, but for speculative parsing, the errors can compound. When the initialiser is an error, and when the '=>' is missing (which is also allowed), what is putatively an arrow function may actually be something else. For example, `(a / 8) + function () { }` is currently parsed as if someone had intended to write `(a = /8)+function()/) => { }` but they forgot the `=` of the initialiser, the `=>` of the lambda, forgot to close the regular expression, and mistakenly inserted a newline right after the regular expression. --- src/compiler/parser.ts | 39 +++++++++---------- .../parserArrowFunctionExpression5.symbols | 15 +++++++ .../parserArrowFunctionExpression5.types | 25 ++++++++++++ ...gularExpressionDivideAmbiguity7.errors.txt | 12 ++++++ ...parserRegularExpressionDivideAmbiguity7.js | 8 ++++ .../parserArrowFunctionExpression6.ts | 3 ++ ...parserRegularExpressionDivideAmbiguity7.ts | 2 + 7 files changed, 84 insertions(+), 20 deletions(-) create mode 100644 tests/baselines/reference/parserArrowFunctionExpression5.symbols create mode 100644 tests/baselines/reference/parserArrowFunctionExpression5.types create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.errors.txt create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.js create mode 100644 tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts create mode 100644 tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 63f1696832b..eaddab96b5c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2240,7 +2240,7 @@ namespace ts { isStartOfType(/*inStartOfParameter*/ true); } - function parseParameter(): ParameterDeclaration { + function parseParameter(requireEqualsToken?: boolean): ParameterDeclaration { const node = createNode(SyntaxKind.Parameter); if (token() === SyntaxKind.ThisKeyword) { node.name = createIdentifier(/*isIdentifier*/ true); @@ -2269,19 +2269,11 @@ namespace ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ true); + node.initializer = parseInitializer(/*inParameter*/ true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - function parseBindingElementInitializer(inParameter: boolean) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - - function parseParameterInitializer() { - return parseInitializer(/*inParameter*/ true); - } - function fillSignature( returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, flags: SignatureFlags, @@ -2334,7 +2326,8 @@ namespace ts { setYieldContext(!!(flags & SignatureFlags.Yield)); setAwaitContext(!!(flags & SignatureFlags.Await)); - const result = parseDelimitedList(ParsingContext.Parameters, flags & SignatureFlags.JSDoc ? parseJSDocParameter : parseParameter); + const result = parseDelimitedList(ParsingContext.Parameters, + flags & SignatureFlags.JSDoc ? parseJSDocParameter : () => parseParameter(!!(flags & SignatureFlags.RequireCompleteParameterList))); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -3017,7 +3010,7 @@ namespace ts { return expr; } - function parseInitializer(inParameter: boolean): Expression { + function parseInitializer(inParameter: boolean, requireEqualsToken?: boolean): Expression { if (token() !== SyntaxKind.EqualsToken) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse @@ -3032,11 +3025,18 @@ namespace ts { // do not try to parse initializer return undefined; } + if (inParameter && requireEqualsToken) { + // this occurs with speculative parsing of lambdas, so try to consume the initializer, + // but signal that the parameter was missing the equals sign so it can abort if it wants + parseAssignmentExpressionOrHigher(); + const result = createNode(SyntaxKind.Identifier, scanner.getStartPos()) as Identifier; + result.escapedText = "= not found" as __String; + return result; + } } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(SyntaxKind.EqualsToken); return parseAssignmentExpressionOrHigher(); } @@ -3351,8 +3351,7 @@ namespace ts { function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction | undefined { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" if (token() === SyntaxKind.AsyncKeyword) { - const isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); - if (isUnParenthesizedAsyncArrowFunction === Tristate.True) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === Tristate.True) { const asyncModifier = parseModifiersForArrowFunction(); const expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); return parseSimpleArrowFunctionExpression(expr, asyncModifier); @@ -3386,7 +3385,6 @@ namespace ts { const node = createNode(SyntaxKind.ArrowFunction); node.modifiers = parseModifiersForArrowFunction(); const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; - // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -3409,7 +3407,8 @@ namespace ts { // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) { + if (!allowAmbiguity && ((token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) || + find(node.parameters, p => p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"))) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -5158,7 +5157,7 @@ namespace ts { const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } @@ -5175,7 +5174,7 @@ namespace ts { node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } @@ -5214,7 +5213,7 @@ namespace ts { node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseNonParameterInitializer(); } return finishNode(node); } diff --git a/tests/baselines/reference/parserArrowFunctionExpression5.symbols b/tests/baselines/reference/parserArrowFunctionExpression5.symbols new file mode 100644 index 00000000000..d2b369c70de --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression5.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts === +function foo(q: string, b: number) { +>foo : Symbol(foo, Decl(parserArrowFunctionExpression5.ts, 0, 0)) +>q : Symbol(q, Decl(parserArrowFunctionExpression5.ts, 0, 13)) +>b : Symbol(b, Decl(parserArrowFunctionExpression5.ts, 0, 23)) + + return true ? (q ? true : false) : (b = q.length, function() { }); +>q : Symbol(q, Decl(parserArrowFunctionExpression5.ts, 0, 13)) +>b : Symbol(b, Decl(parserArrowFunctionExpression5.ts, 0, 23)) +>q.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>q : Symbol(q, Decl(parserArrowFunctionExpression5.ts, 0, 13)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + +}; + diff --git a/tests/baselines/reference/parserArrowFunctionExpression5.types b/tests/baselines/reference/parserArrowFunctionExpression5.types new file mode 100644 index 00000000000..ea9d9395fc0 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression5.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression5.ts === +function foo(q: string, b: number) { +>foo : (q: string, b: number) => boolean | (() => void) +>q : string +>b : number + + return true ? (q ? true : false) : (b = q.length, function() { }); +>true ? (q ? true : false) : (b = q.length, function() { }) : boolean | (() => void) +>true : true +>(q ? true : false) : boolean +>q ? true : false : boolean +>q : string +>true : true +>false : false +>(b = q.length, function() { }) : () => void +>b = q.length, function() { } : () => void +>b = q.length : number +>b : number +>q.length : number +>q : string +>length : number +>function() { } : () => void + +}; + diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.errors.txt b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.errors.txt new file mode 100644 index 00000000000..4ec2f5358f7 --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts(1,2): error TS2304: Cannot find name 'a'. +tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts(2,3): error TS1005: ';' expected. + + +==== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts (2 errors) ==== + (a/8 + ~ +!!! error TS2304: Cannot find name 'a'. + ){} + ~ +!!! error TS1005: ';' expected. + \ No newline at end of file diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.js b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.js new file mode 100644 index 00000000000..e2af8b6f5b7 --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity7.js @@ -0,0 +1,8 @@ +//// [parserRegularExpressionDivideAmbiguity7.ts] +(a/8 + ){} + + +//// [parserRegularExpressionDivideAmbiguity7.js] +(a / 8); +{ } diff --git a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts new file mode 100644 index 00000000000..d4af97ddf7d --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts @@ -0,0 +1,3 @@ +function foo(q: string, b: number) { + return true ? (q ? true : false) : (b = q.length, function() { }); +}; diff --git a/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts new file mode 100644 index 00000000000..54f19f7964e --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity7.ts @@ -0,0 +1,2 @@ +(a/8 + ){} From d8ace9ddfbc923d782e5ae7142c20f8c1debbc78 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 12 Sep 2017 14:41:51 -0700 Subject: [PATCH 131/216] Don't parse param init when = is required but missing Makes another test case pass that was taking exponential time to parse, because now it notices that the = is not present and doesn't even try to parse the initialiser expression. --- src/compiler/parser.ts | 5 +- ...parserRegularExpressionDivideAmbiguity6.js | 46 ++ ...rRegularExpressionDivideAmbiguity6.symbols | 172 ++++++ ...serRegularExpressionDivideAmbiguity6.types | 498 ++++++++++++++++++ ...parserRegularExpressionDivideAmbiguity6.ts | 21 + 5 files changed, 739 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.js create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.symbols create mode 100644 tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.types create mode 100644 tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index eaddab96b5c..6d6b757f6e9 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3026,9 +3026,8 @@ namespace ts { return undefined; } if (inParameter && requireEqualsToken) { - // this occurs with speculative parsing of lambdas, so try to consume the initializer, - // but signal that the parameter was missing the equals sign so it can abort if it wants - parseAssignmentExpressionOrHigher(); + // = is required when speculatively parsing arrow function parameters, + // so return a fake initializer as a signal that the equals token was missing const result = createNode(SyntaxKind.Identifier, scanner.getStartPos()) as Identifier; result.escapedText = "= not found" as __String; return result; diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.js b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.js new file mode 100644 index 00000000000..dfcecd0b383 --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.js @@ -0,0 +1,46 @@ +//// [parserRegularExpressionDivideAmbiguity6.ts] +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { + let r = []; + let v; + r[0] = (v = a0*a0) & 0xFFFF; + r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF; + r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF; + r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF; + r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF; + r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF; + r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF; + r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF; + r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF; + r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF; + r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF; + r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF; + r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF; + r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF; + r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF; + r[15] = ((v / 0x10000) | 0); + return r; +} + + +//// [parserRegularExpressionDivideAmbiguity6.js] +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { + var r = []; + var v; + r[0] = (v = a0 * a0) & 0xFFFF; + r[1] = (v = ((v / 0x10000) | 0) + 2 * a0 * a1) & 0xFFFF; + r[2] = (v = ((v / 0x10000) | 0) + 2 * a0 * a2 + a1 * a1) & 0xFFFF; + r[3] = (v = ((v / 0x10000) | 0) + 2 * a0 * a3 + 2 * a1 * a2) & 0xFFFF; + r[4] = (v = ((v / 0x10000) | 0) + 2 * a0 * a4 + 2 * a1 * a3 + a2 * a2) & 0xFFFF; + r[5] = (v = ((v / 0x10000) | 0) + 2 * a0 * a5 + 2 * a1 * a4 + 2 * a2 * a3) & 0xFFFF; + r[6] = (v = ((v / 0x10000) | 0) + 2 * a0 * a6 + 2 * a1 * a5 + 2 * a2 * a4 + a3 * a3) & 0xFFFF; + r[7] = (v = ((v / 0x10000) | 0) + 2 * a0 * a7 + 2 * a1 * a6 + 2 * a2 * a5 + 2 * a3 * a4) & 0xFFFF; + r[8] = (v = ((v / 0x10000) | 0) + 2 * a1 * a7 + 2 * a2 * a6 + 2 * a3 * a5 + a4 * a4) & 0xFFFF; + r[9] = (v = ((v / 0x10000) | 0) + 2 * a2 * a7 + 2 * a3 * a6 + 2 * a4 * a5) & 0xFFFF; + r[10] = (v = ((v / 0x10000) | 0) + 2 * a3 * a7 + 2 * a4 * a6 + a5 * a5) & 0xFFFF; + r[11] = (v = ((v / 0x10000) | 0) + 2 * a4 * a7 + 2 * a5 * a6) & 0xFFFF; + r[12] = (v = ((v / 0x10000) | 0) + 2 * a5 * a7 + a6 * a6) & 0xFFFF; + r[13] = (v = ((v / 0x10000) | 0) + 2 * a6 * a7) & 0xFFFF; + r[14] = (v = ((v / 0x10000) | 0) + a7 * a7) & 0xFFFF; + r[15] = ((v / 0x10000) | 0); + return r; +} diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.symbols b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.symbols new file mode 100644 index 00000000000..3ae02bb1888 --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.symbols @@ -0,0 +1,172 @@ +=== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts === +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { +>c255lsqr8h : Symbol(c255lsqr8h, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 0)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) + + let r = []; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) + + let v; +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) + + r[0] = (v = a0*a0) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) + + r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) + + r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) + + r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) + + r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) + + r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) + + r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) + + r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a0 : Symbol(a0, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 47)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) + + r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a1 : Symbol(a1, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 43)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) + + r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a2 : Symbol(a2, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 39)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) + + r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a3 : Symbol(a3, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 35)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) + + r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a4 : Symbol(a4, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 31)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) + + r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a5 : Symbol(a5, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 27)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) + + r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a6 : Symbol(a6, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 23)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) + + r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) +>a7 : Symbol(a7, Decl(parserRegularExpressionDivideAmbiguity6.ts, 0, 20)) + + r[15] = ((v / 0x10000) | 0); +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +>v : Symbol(v, Decl(parserRegularExpressionDivideAmbiguity6.ts, 2, 7)) + + return r; +>r : Symbol(r, Decl(parserRegularExpressionDivideAmbiguity6.ts, 1, 7)) +} + diff --git a/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.types b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.types new file mode 100644 index 00000000000..50c3d2f92ad --- /dev/null +++ b/tests/baselines/reference/parserRegularExpressionDivideAmbiguity6.types @@ -0,0 +1,498 @@ +=== tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts === +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { +>c255lsqr8h : (a7: any, a6: any, a5: any, a4: any, a3: any, a2: any, a1: any, a0: any) => any[] +>a7 : any +>a6 : any +>a5 : any +>a4 : any +>a3 : any +>a2 : any +>a1 : any +>a0 : any + + let r = []; +>r : any[] +>[] : undefined[] + + let v; +>v : any + + r[0] = (v = a0*a0) & 0xFFFF; +>r[0] = (v = a0*a0) & 0xFFFF : number +>r[0] : any +>r : any[] +>0 : 0 +>(v = a0*a0) & 0xFFFF : number +>(v = a0*a0) : number +>v = a0*a0 : number +>v : any +>a0*a0 : number +>a0 : any +>a0 : any +>0xFFFF : 65535 + + r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF; +>r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF : number +>r[1] : any +>r : any[] +>1 : 1 +>(v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a1) : number +>v = ((v / 0x10000) | 0) + 2*a0*a1 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a1 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a1 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a1 : any +>0xFFFF : 65535 + + r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF; +>r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF : number +>r[2] : any +>r : any[] +>2 : 2 +>(v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) : number +>v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a2 + a1*a1 : number +>((v / 0x10000) | 0) + 2*a0*a2 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a2 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a2 : any +>a1*a1 : number +>a1 : any +>a1 : any +>0xFFFF : 65535 + + r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF; +>r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF : number +>r[3] : any +>r : any[] +>3 : 3 +>(v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) : number +>v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2 : number +>((v / 0x10000) | 0) + 2*a0*a3 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a3 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a3 : any +>2*a1*a2 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a2 : any +>0xFFFF : 65535 + + r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF; +>r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF : number +>r[4] : any +>r : any[] +>4 : 4 +>(v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) : number +>v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2 : number +>((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 : number +>((v / 0x10000) | 0) + 2*a0*a4 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a4 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a4 : any +>2*a1*a3 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a3 : any +>a2*a2 : number +>a2 : any +>a2 : any +>0xFFFF : 65535 + + r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF; +>r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF : number +>r[5] : any +>r : any[] +>5 : 5 +>(v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) : number +>v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3 : number +>((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 : number +>((v / 0x10000) | 0) + 2*a0*a5 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a5 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a5 : any +>2*a1*a4 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a4 : any +>2*a2*a3 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a3 : any +>0xFFFF : 65535 + + r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF; +>r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF : number +>r[6] : any +>r : any[] +>6 : 6 +>(v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) : number +>v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3 : number +>((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 : number +>((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 : number +>((v / 0x10000) | 0) + 2*a0*a6 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a6 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a6 : any +>2*a1*a5 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a5 : any +>2*a2*a4 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a4 : any +>a3*a3 : number +>a3 : any +>a3 : any +>0xFFFF : 65535 + + r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF; +>r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF : number +>r[7] : any +>r : any[] +>7 : 7 +>(v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) : number +>v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4 : number +>v : any +>((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4 : number +>((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 : number +>((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 : number +>((v / 0x10000) | 0) + 2*a0*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a0*a7 : number +>2*a0 : number +>2 : 2 +>a0 : any +>a7 : any +>2*a1*a6 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a6 : any +>2*a2*a5 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a5 : any +>2*a3*a4 : number +>2*a3 : number +>2 : 2 +>a3 : any +>a4 : any +>0xFFFF : 65535 + + r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF; +>r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF : number +>r[8] : any +>r : any[] +>8 : 8 +>(v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) : number +>v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4 : number +>v : any +>((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4 : number +>((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 : number +>((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 : number +>((v / 0x10000) | 0) + 2*a1*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a1*a7 : number +>2*a1 : number +>2 : 2 +>a1 : any +>a7 : any +>2*a2*a6 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a6 : any +>2*a3*a5 : number +>2*a3 : number +>2 : 2 +>a3 : any +>a5 : any +>a4*a4 : number +>a4 : any +>a4 : any +>0xFFFF : 65535 + + r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF; +>r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF : number +>r[9] : any +>r : any[] +>9 : 9 +>(v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) : number +>v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5 : number +>v : any +>((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5 : number +>((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 : number +>((v / 0x10000) | 0) + 2*a2*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a2*a7 : number +>2*a2 : number +>2 : 2 +>a2 : any +>a7 : any +>2*a3*a6 : number +>2*a3 : number +>2 : 2 +>a3 : any +>a6 : any +>2*a4*a5 : number +>2*a4 : number +>2 : 2 +>a4 : any +>a5 : any +>0xFFFF : 65535 + + r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF; +>r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF : number +>r[10] : any +>r : any[] +>10 : 10 +>(v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) : number +>v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5 : number +>v : any +>((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5 : number +>((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 : number +>((v / 0x10000) | 0) + 2*a3*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a3*a7 : number +>2*a3 : number +>2 : 2 +>a3 : any +>a7 : any +>2*a4*a6 : number +>2*a4 : number +>2 : 2 +>a4 : any +>a6 : any +>a5*a5 : number +>a5 : any +>a5 : any +>0xFFFF : 65535 + + r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF; +>r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF : number +>r[11] : any +>r : any[] +>11 : 11 +>(v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) : number +>v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6 : number +>v : any +>((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6 : number +>((v / 0x10000) | 0) + 2*a4*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a4*a7 : number +>2*a4 : number +>2 : 2 +>a4 : any +>a7 : any +>2*a5*a6 : number +>2*a5 : number +>2 : 2 +>a5 : any +>a6 : any +>0xFFFF : 65535 + + r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF; +>r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF : number +>r[12] : any +>r : any[] +>12 : 12 +>(v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) : number +>v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6 : number +>v : any +>((v / 0x10000) | 0) + 2*a5*a7 + a6*a6 : number +>((v / 0x10000) | 0) + 2*a5*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a5*a7 : number +>2*a5 : number +>2 : 2 +>a5 : any +>a7 : any +>a6*a6 : number +>a6 : any +>a6 : any +>0xFFFF : 65535 + + r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF; +>r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF : number +>r[13] : any +>r : any[] +>13 : 13 +>(v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + 2*a6*a7) : number +>v = ((v / 0x10000) | 0) + 2*a6*a7 : number +>v : any +>((v / 0x10000) | 0) + 2*a6*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>2*a6*a7 : number +>2*a6 : number +>2 : 2 +>a6 : any +>a7 : any +>0xFFFF : 65535 + + r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF; +>r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF : number +>r[14] : any +>r : any[] +>14 : 14 +>(v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF : number +>(v = ((v / 0x10000) | 0) + a7*a7) : number +>v = ((v / 0x10000) | 0) + a7*a7 : number +>v : any +>((v / 0x10000) | 0) + a7*a7 : number +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 +>a7*a7 : number +>a7 : any +>a7 : any +>0xFFFF : 65535 + + r[15] = ((v / 0x10000) | 0); +>r[15] = ((v / 0x10000) | 0) : number +>r[15] : any +>r : any[] +>15 : 15 +>((v / 0x10000) | 0) : number +>(v / 0x10000) | 0 : number +>(v / 0x10000) : number +>v / 0x10000 : number +>v : any +>0x10000 : 65536 +>0 : 0 + + return r; +>r : any[] +} + diff --git a/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts new file mode 100644 index 00000000000..e2e742fd6bf --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpressionDivideAmbiguity6.ts @@ -0,0 +1,21 @@ +function c255lsqr8h(a7, a6, a5, a4, a3, a2, a1, a0) { + let r = []; + let v; + r[0] = (v = a0*a0) & 0xFFFF; + r[1] = (v = ((v / 0x10000) | 0) + 2*a0*a1) & 0xFFFF; + r[2] = (v = ((v / 0x10000) | 0) + 2*a0*a2 + a1*a1) & 0xFFFF; + r[3] = (v = ((v / 0x10000) | 0) + 2*a0*a3 + 2*a1*a2) & 0xFFFF; + r[4] = (v = ((v / 0x10000) | 0) + 2*a0*a4 + 2*a1*a3 + a2*a2) & 0xFFFF; + r[5] = (v = ((v / 0x10000) | 0) + 2*a0*a5 + 2*a1*a4 + 2*a2*a3) & 0xFFFF; + r[6] = (v = ((v / 0x10000) | 0) + 2*a0*a6 + 2*a1*a5 + 2*a2*a4 + a3*a3) & 0xFFFF; + r[7] = (v = ((v / 0x10000) | 0) + 2*a0*a7 + 2*a1*a6 + 2*a2*a5 + 2*a3*a4) & 0xFFFF; + r[8] = (v = ((v / 0x10000) | 0) + 2*a1*a7 + 2*a2*a6 + 2*a3*a5 + a4*a4) & 0xFFFF; + r[9] = (v = ((v / 0x10000) | 0) + 2*a2*a7 + 2*a3*a6 + 2*a4*a5) & 0xFFFF; + r[10] = (v = ((v / 0x10000) | 0) + 2*a3*a7 + 2*a4*a6 + a5*a5) & 0xFFFF; + r[11] = (v = ((v / 0x10000) | 0) + 2*a4*a7 + 2*a5*a6) & 0xFFFF; + r[12] = (v = ((v / 0x10000) | 0) + 2*a5*a7 + a6*a6) & 0xFFFF; + r[13] = (v = ((v / 0x10000) | 0) + 2*a6*a7) & 0xFFFF; + r[14] = (v = ((v / 0x10000) | 0) + a7*a7) & 0xFFFF; + r[15] = ((v / 0x10000) | 0); + return r; +} From 74ecef418dcf795c483bffb14b97159acd496313 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 12 Sep 2017 14:43:56 -0700 Subject: [PATCH 132/216] Add missed baselines --- .../parserArrowFunctionExpression6.js | 11 ++++++++ .../parserArrowFunctionExpression6.symbols | 15 +++++++++++ .../parserArrowFunctionExpression6.types | 25 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 tests/baselines/reference/parserArrowFunctionExpression6.js create mode 100644 tests/baselines/reference/parserArrowFunctionExpression6.symbols create mode 100644 tests/baselines/reference/parserArrowFunctionExpression6.types diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.js b/tests/baselines/reference/parserArrowFunctionExpression6.js new file mode 100644 index 00000000000..1de3035cc76 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression6.js @@ -0,0 +1,11 @@ +//// [parserArrowFunctionExpression6.ts] +function foo(q: string, b: number) { + return true ? (q ? true : false) : (b = q.length, function() { }); +}; + + +//// [parserArrowFunctionExpression6.js] +function foo(q, b) { + return true ? (q ? true : false) : (b = q.length, function () { }); +} +; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.symbols b/tests/baselines/reference/parserArrowFunctionExpression6.symbols new file mode 100644 index 00000000000..9b3afdbb950 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression6.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts === +function foo(q: string, b: number) { +>foo : Symbol(foo, Decl(parserArrowFunctionExpression6.ts, 0, 0)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) +>b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) + + return true ? (q ? true : false) : (b = q.length, function() { }); +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) +>b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) +>q.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + +}; + diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.types b/tests/baselines/reference/parserArrowFunctionExpression6.types new file mode 100644 index 00000000000..6cc4f16e216 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression6.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts === +function foo(q: string, b: number) { +>foo : (q: string, b: number) => boolean | (() => void) +>q : string +>b : number + + return true ? (q ? true : false) : (b = q.length, function() { }); +>true ? (q ? true : false) : (b = q.length, function() { }) : boolean | (() => void) +>true : true +>(q ? true : false) : boolean +>q ? true : false : boolean +>q : string +>true : true +>false : false +>(b = q.length, function() { }) : () => void +>b = q.length, function() { } : () => void +>b = q.length : number +>b : number +>q.length : number +>q : string +>length : number +>function() { } : () => void + +}; + From ece4e4f701813855371e8302a1ac82c3a65a5f70 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 12 Sep 2017 18:11:12 -0700 Subject: [PATCH 133/216] Fix fourslash baselines 40e459117aeb0b792a23d6805af884b594dd42c4 was out of date in a way that didn't register as a conflict. --- tests/baselines/reference/extractMethod/extractMethod23.ts | 6 +++--- tests/baselines/reference/extractMethod/extractMethod24.ts | 6 +++--- tests/baselines/reference/extractMethod/extractMethod25.ts | 4 ++-- tests/baselines/reference/extractMethod/extractMethod26.ts | 4 ++-- tests/baselines/reference/extractMethod/extractMethod27.ts | 4 ++-- tests/baselines/reference/extractMethod/extractMethod28.ts | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/baselines/reference/extractMethod/extractMethod23.ts b/tests/baselines/reference/extractMethod/extractMethod23.ts index 8bc3db86cc1..0c56434447e 100644 --- a/tests/baselines/reference/extractMethod/extractMethod23.ts +++ b/tests/baselines/reference/extractMethod/extractMethod23.ts @@ -6,7 +6,7 @@ namespace NS { } function M3() { } } -// ==SCOPE::function 'M2'== +// ==SCOPE::inner function in function 'M2'== namespace NS { function M1() { } function M2() { @@ -18,7 +18,7 @@ namespace NS { } function M3() { } } -// ==SCOPE::namespace 'NS'== +// ==SCOPE::function in namespace 'NS'== namespace NS { function M1() { } function M2() { @@ -30,7 +30,7 @@ namespace NS { function M3() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== namespace NS { function M1() { } function M2() { diff --git a/tests/baselines/reference/extractMethod/extractMethod24.ts b/tests/baselines/reference/extractMethod/extractMethod24.ts index ec6d6cd3f12..0b33289708f 100644 --- a/tests/baselines/reference/extractMethod/extractMethod24.ts +++ b/tests/baselines/reference/extractMethod/extractMethod24.ts @@ -6,7 +6,7 @@ function Outer() { } function M3() { } } -// ==SCOPE::function 'M2'== +// ==SCOPE::inner function in function 'M2'== function Outer() { function M1() { } function M2() { @@ -18,7 +18,7 @@ function Outer() { } function M3() { } } -// ==SCOPE::function 'Outer'== +// ==SCOPE::inner function in function 'Outer'== function Outer() { function M1() { } function M2() { @@ -30,7 +30,7 @@ function Outer() { function M3() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function Outer() { function M1() { } function M2() { diff --git a/tests/baselines/reference/extractMethod/extractMethod25.ts b/tests/baselines/reference/extractMethod/extractMethod25.ts index a7a971315a1..c77ec1abbfd 100644 --- a/tests/baselines/reference/extractMethod/extractMethod25.ts +++ b/tests/baselines/reference/extractMethod/extractMethod25.ts @@ -4,7 +4,7 @@ function M2() { return 1; } function M3() { } -// ==SCOPE::function 'M2'== +// ==SCOPE::inner function in function 'M2'== function M1() { } function M2() { return newFunction(); @@ -14,7 +14,7 @@ function M2() { } } function M3() { } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== function M1() { } function M2() { return newFunction(); diff --git a/tests/baselines/reference/extractMethod/extractMethod26.ts b/tests/baselines/reference/extractMethod/extractMethod26.ts index d0619ea9b0a..84dc82f7fed 100644 --- a/tests/baselines/reference/extractMethod/extractMethod26.ts +++ b/tests/baselines/reference/extractMethod/extractMethod26.ts @@ -6,7 +6,7 @@ class C { } M3() { } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M1() { } M2() { @@ -18,7 +18,7 @@ class C { M3() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M1() { } M2() { diff --git a/tests/baselines/reference/extractMethod/extractMethod27.ts b/tests/baselines/reference/extractMethod/extractMethod27.ts index 9f1f1e84a77..ce21f1e1fed 100644 --- a/tests/baselines/reference/extractMethod/extractMethod27.ts +++ b/tests/baselines/reference/extractMethod/extractMethod27.ts @@ -7,7 +7,7 @@ class C { constructor() { } M3() { } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M1() { } M2() { @@ -20,7 +20,7 @@ class C { M3() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M1() { } M2() { diff --git a/tests/baselines/reference/extractMethod/extractMethod28.ts b/tests/baselines/reference/extractMethod/extractMethod28.ts index 9b97e581548..e3d0fc3b9ea 100644 --- a/tests/baselines/reference/extractMethod/extractMethod28.ts +++ b/tests/baselines/reference/extractMethod/extractMethod28.ts @@ -7,7 +7,7 @@ class C { M3() { } constructor() { } } -// ==SCOPE::class 'C'== +// ==SCOPE::method in class 'C'== class C { M1() { } M2() { @@ -20,7 +20,7 @@ class C { M3() { } constructor() { } } -// ==SCOPE::global scope== +// ==SCOPE::function in global scope== class C { M1() { } M2() { From a02aaf2625342f101fe1a4c94c5ac0ceb9a2cff1 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 12 Sep 2017 18:07:25 -0700 Subject: [PATCH 134/216] Forbid extraction of empty spans --- src/harness/unittests/extractMethods.ts | 6 ++++++ src/services/refactors/extractMethod.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index edcc80cd57c..d0ce38126d8 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -404,6 +404,12 @@ function test(x: number) { "Cannot extract range containing conditional break or continue statements." ]); + testExtractRangeFailed("extractRangeFailed9", + `var x = ([#||]1 + 2);`, + [ + "Statement or expression expected." + ]); + testExtractMethod("extractMethod1", `namespace A { let x = 1; diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index b0554138134..fc3abc2f367 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -162,6 +162,11 @@ namespace ts.refactor.extractMethod { */ export function getRangeToExtract(sourceFile: SourceFile, span: TextSpan): RangeToExtract { const length = span.length || 0; + + if (length === 0) { + return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.StatementOrExpressionExpected)] }; + } + // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) let start = getParentNodeInSpan(getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); From 78f4cbe53c8696d6f8b23424fcfd666c7d71ba01 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Sep 2017 06:37:59 -0700 Subject: [PATCH 135/216] Add tests --- .../intersectionOfUnionOfUnitTypes.js | 47 ++++++ .../intersectionOfUnionOfUnitTypes.symbols | 156 ++++++++++++++++++ .../intersectionOfUnionOfUnitTypes.types | 156 ++++++++++++++++++ .../intersectionOfUnionOfUnitTypes.ts | 24 +++ 4 files changed, 383 insertions(+) create mode 100644 tests/baselines/reference/intersectionOfUnionOfUnitTypes.js create mode 100644 tests/baselines/reference/intersectionOfUnionOfUnitTypes.symbols create mode 100644 tests/baselines/reference/intersectionOfUnionOfUnitTypes.types create mode 100644 tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts diff --git a/tests/baselines/reference/intersectionOfUnionOfUnitTypes.js b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.js new file mode 100644 index 00000000000..09a2ab974f4 --- /dev/null +++ b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.js @@ -0,0 +1,47 @@ +//// [intersectionOfUnionOfUnitTypes.ts] +// @strict + +const enum E { A, B, C, D, E, F } + +let x0: ('a' | 'b' | 'c') & ('a' | 'b' | 'c'); // 'a' | 'b' | 'c' +let x1: ('a' | 'b' | 'c') & ('b' | 'c' | 'd'); // 'b' | 'c' +let x2: ('a' | 'b' | 'c') & ('c' | 'd' | 'e'); // 'c' +let x3: ('a' | 'b' | 'c') & ('d' | 'e' | 'f'); // never +let x4: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e'); // 'c' +let x5: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e') & ('d' | 'e' | 'f'); // never + +let y0: (0 | 1 | 2) & (0 | 1 | 2); // 0 | 1 | 2 +let y1: (0 | 1 | 2) & (1 | 2 | 3); // 1 | 2 +let y2: (0 | 1 | 2) & (2 | 3 | 4); // 2 +let y3: (0 | 1 | 2) & (3 | 4 | 5); // never +let y4: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4); // 2 +let y5: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4) & (3 | 4 | 5); // never + +let z0: (E.A | E.B | E.C) & (E.A | E.B | E.C); // E.A | E.B | E.C +let z1: (E.A | E.B | E.C) & (E.B | E.C | E.D); // E.B | E.C +let z2: (E.A | E.B | E.C) & (E.C | E.D | E.E); // E.C +let z3: (E.A | E.B | E.C) & (E.D | E.E | E.F); // never +let z4: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E); // E.C +let z5: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E) & (E.D | E.E | E.F); // never + + +//// [intersectionOfUnionOfUnitTypes.js] +// @strict +var x0; // 'a' | 'b' | 'c' +var x1; // 'b' | 'c' +var x2; // 'c' +var x3; // never +var x4; // 'c' +var x5; // never +var y0; // 0 | 1 | 2 +var y1; // 1 | 2 +var y2; // 2 +var y3; // never +var y4; // 2 +var y5; // never +var z0; // E.A | E.B | E.C +var z1; // E.B | E.C +var z2; // E.C +var z3; // never +var z4; // E.C +var z5; // never diff --git a/tests/baselines/reference/intersectionOfUnionOfUnitTypes.symbols b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.symbols new file mode 100644 index 00000000000..6f5f70bd290 --- /dev/null +++ b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.symbols @@ -0,0 +1,156 @@ +=== tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts === +// @strict + +const enum E { A, B, C, D, E, F } +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) +>F : Symbol(E.F, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 29)) + +let x0: ('a' | 'b' | 'c') & ('a' | 'b' | 'c'); // 'a' | 'b' | 'c' +>x0 : Symbol(x0, Decl(intersectionOfUnionOfUnitTypes.ts, 4, 3)) + +let x1: ('a' | 'b' | 'c') & ('b' | 'c' | 'd'); // 'b' | 'c' +>x1 : Symbol(x1, Decl(intersectionOfUnionOfUnitTypes.ts, 5, 3)) + +let x2: ('a' | 'b' | 'c') & ('c' | 'd' | 'e'); // 'c' +>x2 : Symbol(x2, Decl(intersectionOfUnionOfUnitTypes.ts, 6, 3)) + +let x3: ('a' | 'b' | 'c') & ('d' | 'e' | 'f'); // never +>x3 : Symbol(x3, Decl(intersectionOfUnionOfUnitTypes.ts, 7, 3)) + +let x4: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e'); // 'c' +>x4 : Symbol(x4, Decl(intersectionOfUnionOfUnitTypes.ts, 8, 3)) + +let x5: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e') & ('d' | 'e' | 'f'); // never +>x5 : Symbol(x5, Decl(intersectionOfUnionOfUnitTypes.ts, 9, 3)) + +let y0: (0 | 1 | 2) & (0 | 1 | 2); // 0 | 1 | 2 +>y0 : Symbol(y0, Decl(intersectionOfUnionOfUnitTypes.ts, 11, 3)) + +let y1: (0 | 1 | 2) & (1 | 2 | 3); // 1 | 2 +>y1 : Symbol(y1, Decl(intersectionOfUnionOfUnitTypes.ts, 12, 3)) + +let y2: (0 | 1 | 2) & (2 | 3 | 4); // 2 +>y2 : Symbol(y2, Decl(intersectionOfUnionOfUnitTypes.ts, 13, 3)) + +let y3: (0 | 1 | 2) & (3 | 4 | 5); // never +>y3 : Symbol(y3, Decl(intersectionOfUnionOfUnitTypes.ts, 14, 3)) + +let y4: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4); // 2 +>y4 : Symbol(y4, Decl(intersectionOfUnionOfUnitTypes.ts, 15, 3)) + +let y5: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4) & (3 | 4 | 5); // never +>y5 : Symbol(y5, Decl(intersectionOfUnionOfUnitTypes.ts, 16, 3)) + +let z0: (E.A | E.B | E.C) & (E.A | E.B | E.C); // E.A | E.B | E.C +>z0 : Symbol(z0, Decl(intersectionOfUnionOfUnitTypes.ts, 18, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) + +let z1: (E.A | E.B | E.C) & (E.B | E.C | E.D); // E.B | E.C +>z1 : Symbol(z1, Decl(intersectionOfUnionOfUnitTypes.ts, 19, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) + +let z2: (E.A | E.B | E.C) & (E.C | E.D | E.E); // E.C +>z2 : Symbol(z2, Decl(intersectionOfUnionOfUnitTypes.ts, 20, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) + +let z3: (E.A | E.B | E.C) & (E.D | E.E | E.F); // never +>z3 : Symbol(z3, Decl(intersectionOfUnionOfUnitTypes.ts, 21, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>F : Symbol(E.F, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 29)) + +let z4: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E); // E.C +>z4 : Symbol(z4, Decl(intersectionOfUnionOfUnitTypes.ts, 22, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) + +let z5: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E) & (E.D | E.E | E.F); // never +>z5 : Symbol(z5, Decl(intersectionOfUnionOfUnitTypes.ts, 23, 3)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>A : Symbol(E.A, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 14)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>B : Symbol(E.B, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 17)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>C : Symbol(E.C, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 20)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>D : Symbol(E.D, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 23)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>E : Symbol(E.E, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 26)) +>E : Symbol(E, Decl(intersectionOfUnionOfUnitTypes.ts, 0, 0)) +>F : Symbol(E.F, Decl(intersectionOfUnionOfUnitTypes.ts, 2, 29)) + diff --git a/tests/baselines/reference/intersectionOfUnionOfUnitTypes.types b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.types new file mode 100644 index 00000000000..aa7fa0074ed --- /dev/null +++ b/tests/baselines/reference/intersectionOfUnionOfUnitTypes.types @@ -0,0 +1,156 @@ +=== tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts === +// @strict + +const enum E { A, B, C, D, E, F } +>E : E +>A : E.A +>B : E.B +>C : E.C +>D : E.D +>E : E.E +>F : E.F + +let x0: ('a' | 'b' | 'c') & ('a' | 'b' | 'c'); // 'a' | 'b' | 'c' +>x0 : "a" | "b" | "c" + +let x1: ('a' | 'b' | 'c') & ('b' | 'c' | 'd'); // 'b' | 'c' +>x1 : "b" | "c" + +let x2: ('a' | 'b' | 'c') & ('c' | 'd' | 'e'); // 'c' +>x2 : "c" + +let x3: ('a' | 'b' | 'c') & ('d' | 'e' | 'f'); // never +>x3 : never + +let x4: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e'); // 'c' +>x4 : "c" + +let x5: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e') & ('d' | 'e' | 'f'); // never +>x5 : never + +let y0: (0 | 1 | 2) & (0 | 1 | 2); // 0 | 1 | 2 +>y0 : 0 | 1 | 2 + +let y1: (0 | 1 | 2) & (1 | 2 | 3); // 1 | 2 +>y1 : 1 | 2 + +let y2: (0 | 1 | 2) & (2 | 3 | 4); // 2 +>y2 : 2 + +let y3: (0 | 1 | 2) & (3 | 4 | 5); // never +>y3 : never + +let y4: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4); // 2 +>y4 : 2 + +let y5: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4) & (3 | 4 | 5); // never +>y5 : never + +let z0: (E.A | E.B | E.C) & (E.A | E.B | E.C); // E.A | E.B | E.C +>z0 : E.A | E.B | E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C + +let z1: (E.A | E.B | E.C) & (E.B | E.C | E.D); // E.B | E.C +>z1 : E.B | E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>D : E.D + +let z2: (E.A | E.B | E.C) & (E.C | E.D | E.E); // E.C +>z2 : E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>E : E.E + +let z3: (E.A | E.B | E.C) & (E.D | E.E | E.F); // never +>z3 : never +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>E : E.E +>E : any +>F : E.F + +let z4: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E); // E.C +>z4 : E.C +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>E : E.E + +let z5: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E) & (E.D | E.E | E.F); // never +>z5 : never +>E : any +>A : E.A +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>B : E.B +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>C : E.C +>E : any +>D : E.D +>E : any +>E : E.E +>E : any +>D : E.D +>E : any +>E : E.E +>E : any +>F : E.F + diff --git a/tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts b/tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts new file mode 100644 index 00000000000..28492b1d94b --- /dev/null +++ b/tests/cases/conformance/types/intersection/intersectionOfUnionOfUnitTypes.ts @@ -0,0 +1,24 @@ +// @strict + +const enum E { A, B, C, D, E, F } + +let x0: ('a' | 'b' | 'c') & ('a' | 'b' | 'c'); // 'a' | 'b' | 'c' +let x1: ('a' | 'b' | 'c') & ('b' | 'c' | 'd'); // 'b' | 'c' +let x2: ('a' | 'b' | 'c') & ('c' | 'd' | 'e'); // 'c' +let x3: ('a' | 'b' | 'c') & ('d' | 'e' | 'f'); // never +let x4: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e'); // 'c' +let x5: ('a' | 'b' | 'c') & ('b' | 'c' | 'd') & ('c' | 'd' | 'e') & ('d' | 'e' | 'f'); // never + +let y0: (0 | 1 | 2) & (0 | 1 | 2); // 0 | 1 | 2 +let y1: (0 | 1 | 2) & (1 | 2 | 3); // 1 | 2 +let y2: (0 | 1 | 2) & (2 | 3 | 4); // 2 +let y3: (0 | 1 | 2) & (3 | 4 | 5); // never +let y4: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4); // 2 +let y5: (0 | 1 | 2) & (1 | 2 | 3) & (2 | 3 | 4) & (3 | 4 | 5); // never + +let z0: (E.A | E.B | E.C) & (E.A | E.B | E.C); // E.A | E.B | E.C +let z1: (E.A | E.B | E.C) & (E.B | E.C | E.D); // E.B | E.C +let z2: (E.A | E.B | E.C) & (E.C | E.D | E.E); // E.C +let z3: (E.A | E.B | E.C) & (E.D | E.E | E.F); // never +let z4: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E); // E.C +let z5: (E.A | E.B | E.C) & (E.B | E.C | E.D) & (E.C | E.D | E.E) & (E.D | E.E | E.F); // never From c3199c7772010bfab3c5b7da2d0d2a2cc4010871 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 13 Sep 2017 09:02:10 -0700 Subject: [PATCH 136/216] extractMethod: Support renameLocation (#18050) * extractMethod: Support renameLocation * Add tslint disable * Properly analyze list of changes to always get a correct rename location * Update test * Ensure name is really unique * Improvements to test code * Respond to PR comments --- src/harness/fourslash.ts | 38 +- src/harness/unittests/extractMethods.ts | 7 +- src/server/client.ts | 4 +- .../refactors/convertFunctionToEs6Class.ts | 4 +- src/services/refactors/extractMethod.ts | 397 +++++++++--------- src/services/types.ts | 4 +- .../reference/extractMethod/extractMethod1.ts | 8 +- .../extractMethod/extractMethod10.ts | 6 +- .../extractMethod/extractMethod11.ts | 6 +- .../extractMethod/extractMethod12.ts | 2 +- .../extractMethod/extractMethod13.ts | 6 +- .../extractMethod/extractMethod14.ts | 6 +- .../extractMethod/extractMethod15.ts | 6 +- .../extractMethod/extractMethod16.ts | 4 +- .../extractMethod/extractMethod17.ts | 4 +- .../extractMethod/extractMethod18.ts | 4 +- .../extractMethod/extractMethod19.ts | 4 +- .../reference/extractMethod/extractMethod2.ts | 8 +- .../extractMethod/extractMethod20.ts | 4 +- .../extractMethod/extractMethod21.ts | 4 +- .../extractMethod/extractMethod22.ts | 4 +- .../extractMethod/extractMethod23.ts | 6 +- .../extractMethod/extractMethod24.ts | 6 +- .../extractMethod/extractMethod25.ts | 4 +- .../extractMethod/extractMethod26.ts | 4 +- .../extractMethod/extractMethod27.ts | 4 +- .../extractMethod/extractMethod28.ts | 4 +- .../reference/extractMethod/extractMethod3.ts | 8 +- .../reference/extractMethod/extractMethod4.ts | 8 +- .../reference/extractMethod/extractMethod5.ts | 8 +- .../reference/extractMethod/extractMethod6.ts | 8 +- .../reference/extractMethod/extractMethod7.ts | 8 +- .../reference/extractMethod/extractMethod8.ts | 8 +- .../reference/extractMethod/extractMethod9.ts | 8 +- .../fourslash/extract-method-formatting.ts | 9 +- .../fourslash/extract-method-uniqueName.ts | 20 + tests/cases/fourslash/extract-method1.ts | 8 +- tests/cases/fourslash/extract-method10.ts | 7 + tests/cases/fourslash/extract-method13.ts | 20 +- tests/cases/fourslash/extract-method14.ts | 9 +- tests/cases/fourslash/extract-method15.ts | 10 +- tests/cases/fourslash/extract-method18.ts | 9 +- tests/cases/fourslash/extract-method19.ts | 9 +- tests/cases/fourslash/extract-method2.ts | 8 +- tests/cases/fourslash/extract-method21.ts | 10 +- tests/cases/fourslash/extract-method24.ts | 9 +- tests/cases/fourslash/extract-method25.ts | 9 +- tests/cases/fourslash/extract-method5.ts | 9 +- tests/cases/fourslash/extract-method7.ts | 7 +- tests/cases/fourslash/fourslash.ts | 2 +- 50 files changed, 431 insertions(+), 338 deletions(-) create mode 100644 tests/cases/fourslash/extract-method-uniqueName.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 598cfc2fd7e..d89a4677ef9 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2758,11 +2758,11 @@ namespace FourSlash { } } - private getSelection() { - return ({ + private getSelection(): ts.TextRange { + return { pos: this.currentCaretPosition, end: this.selectionEnd === -1 ? this.currentCaretPosition : this.selectionEnd - }); + }; } public verifyRefactorAvailable(negative: boolean, name: string, actionName?: string) { @@ -2803,7 +2803,7 @@ namespace FourSlash { } } - public applyRefactor({ refactorName, actionName, actionDescription }: FourSlashInterface.ApplyRefactorOptions) { + public applyRefactor({ refactorName, actionName, actionDescription, newContent: newContentWithRenameMarker }: FourSlashInterface.ApplyRefactorOptions) { const range = this.getSelection(); const refactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, range); const refactor = refactors.find(r => r.name === refactorName); @@ -2823,6 +2823,35 @@ namespace FourSlash { for (const edit of editInfo.edits) { this.applyEdits(edit.fileName, edit.textChanges, /*isFormattingEdit*/ false); } + + const { renamePosition, newContent } = parseNewContent(); + + this.verifyCurrentFileContent(newContent); + + if (renamePosition === undefined) { + if (editInfo.renameLocation !== undefined) { + this.raiseError(`Did not expect a rename location, got ${editInfo.renameLocation}`); + } + } + else { + // TODO: test editInfo.renameFilename value + assert.isDefined(editInfo.renameFilename); + if (renamePosition !== editInfo.renameLocation) { + this.raiseError(`Expected rename position of ${renamePosition}, but got ${editInfo.renameLocation}`); + } + } + + function parseNewContent(): { renamePosition: number | undefined, newContent: string } { + const renamePosition = newContentWithRenameMarker.indexOf("/*RENAME*/"); + if (renamePosition === -1) { + return { renamePosition: undefined, newContent: newContentWithRenameMarker }; + } + else { + const newContent = newContentWithRenameMarker.slice(0, renamePosition) + newContentWithRenameMarker.slice(renamePosition + "/*RENAME*/".length); + return { renamePosition, newContent }; + } + } + } public verifyFileAfterApplyingRefactorAtMarker( @@ -4319,6 +4348,7 @@ namespace FourSlashInterface { refactorName: string; actionName: string; actionDescription: string; + newContent: string; } export interface CompletionsAtOptions { diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index edcc80cd57c..c836698aeb4 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -745,9 +745,12 @@ function M3() { }`); data.push(`// ==ORIGINAL==`); data.push(sourceFile.text); for (const r of results) { - const changes = refactor.extractMethod.getPossibleExtractions(result.targetRange, context, results.indexOf(r))[0].changes; + const { renameLocation, edits } = refactor.extractMethod.getExtractionAtIndex(result.targetRange, context, results.indexOf(r)); + assert.lengthOf(edits, 1); data.push(`// ==SCOPE::${r.scopeDescription}==`); - data.push(textChanges.applyChanges(sourceFile.text, changes[0].textChanges)); + const newText = textChanges.applyChanges(sourceFile.text, edits[0].textChanges); + const newTextWithRename = newText.slice(0, renameLocation) + "/*RENAME*/" + newText.slice(renameLocation); + data.push(newTextWithRename); } return data.join(newLineCharacter); }); diff --git a/src/server/client.ts b/src/server/client.ts index 4acd862a89a..0ffac42dae4 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -586,9 +586,7 @@ namespace ts.server { const response = this.processResponse(request); if (!response.body) { - return { - edits: [] - }; + return { edits: [], renameFilename: undefined, renameLocation: undefined }; } const edits: FileTextChanges[] = this.convertCodeEditsToTextChanges(response.body.edits); diff --git a/src/services/refactors/convertFunctionToEs6Class.ts b/src/services/refactors/convertFunctionToEs6Class.ts index 40ef4ed2a2e..e4cd1a42083 100644 --- a/src/services/refactors/convertFunctionToEs6Class.ts +++ b/src/services/refactors/convertFunctionToEs6Class.ts @@ -97,7 +97,9 @@ namespace ts.refactor.convertFunctionToES6Class { } return { - edits: changeTracker.getChanges() + edits: changeTracker.getChanges(), + renameFilename: undefined, + renameLocation: undefined, }; function deleteNode(node: Node, inList = false) { diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index b0554138134..7b5e1e40c7e 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -31,16 +31,16 @@ namespace ts.refactor.extractMethod { const usedNames: Map = createMap(); let i = 0; - for (const extr of extractions) { + for (const { scopeDescription, errors } of extractions) { // Skip these since we don't have a way to report errors yet - if (extr.errors && extr.errors.length) { + if (errors.length) { continue; } // Don't issue refactorings with duplicated names. // Scopes come back in "innermost first" order, so extractions will // preferentially go into nearer scopes - const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [extr.scopeDescription]); + const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [scopeDescription]); if (!usedNames.has(description)) { usedNames.set(description, true); actions.push({ @@ -75,10 +75,7 @@ namespace ts.refactor.extractMethod { const index = +parsedIndexMatch[1]; Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); - const extractions = getPossibleExtractions(targetRange, context, index); - // Scope is no longer valid from when the user issued the refactor (??) - Debug.assert(extractions !== undefined, "The extraction went missing? How?"); - return ({ edits: extractions[0].changes }); + return getExtractionAtIndex(targetRange, context, index); } // Move these into diagnostic messages if they become user-facing @@ -102,7 +99,7 @@ namespace ts.refactor.extractMethod { export const CannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts"); } - export enum RangeFacts { + enum RangeFacts { None = 0, HasReturn = 1 << 0, IsGenerator = 1 << 1, @@ -117,7 +114,7 @@ namespace ts.refactor.extractMethod { /** * Represents an expression or a list of statements that should be extracted with some extra information */ - export interface TargetRange { + interface TargetRange { readonly range: Expression | Statement[]; readonly facts: RangeFacts; /** @@ -130,7 +127,7 @@ namespace ts.refactor.extractMethod { /** * Result of 'getRangeToExtract' operation: contains either a range or a list of errors */ - export type RangeToExtract = { + type RangeToExtract = { readonly targetRange?: never; readonly errors: ReadonlyArray; } | { @@ -141,18 +138,7 @@ namespace ts.refactor.extractMethod { /* * Scopes that can store newly extracted method */ - export type Scope = FunctionLikeDeclaration | SourceFile | ModuleBlock | ClassLikeDeclaration; - - /** - * Result of 'extractRange' operation for a specific scope. - * Stores either a list of changes that should be applied to extract a range or a list of errors - */ - export interface ExtractResultForScope { - readonly scope: Scope; - readonly scopeDescription: string; - readonly changes?: FileTextChanges[]; - readonly errors?: Diagnostic[]; - } + type Scope = FunctionLikeDeclaration | SourceFile | ModuleBlock | ClassLikeDeclaration; /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array @@ -160,6 +146,7 @@ namespace ts.refactor.extractMethod { * process may fail, in which case a set of errors is returned instead (these are currently * not shown to the user, but can be used by us diagnostically) */ + // exported only for tests export function getRangeToExtract(sourceFile: SourceFile, span: TextSpan): RangeToExtract { const length = span.length || 0; // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. @@ -458,7 +445,7 @@ namespace ts.refactor.extractMethod { * you may be able to extract into a class method *or* local closure *or* namespace function, * depending on what's in the extracted body. */ - export function collectEnclosingScopes(range: TargetRange): Scope[] | undefined { + function collectEnclosingScopes(range: TargetRange): Scope[] | undefined { let current: Node = isReadonlyArray(range.range) ? firstOrUndefined(range.range) : range.range; if (range.facts & RangeFacts.UsesThis) { // if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class @@ -494,12 +481,32 @@ namespace ts.refactor.extractMethod { return scopes; } + // exported only for tests + export function getExtractionAtIndex(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number): RefactorEditInfo { + const { scopes, readsAndWrites: { target, usagesPerScope, errorsPerScope } } = getPossibleExtractionsWorker(targetRange, context); + Debug.assert(!errorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); + context.cancellationToken.throwIfCancellationRequested(); + return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context); + } + + interface PossibleExtraction { + readonly scopeDescription: string; + readonly errors: ReadonlyArray; + } /** * Given a piece of text to extract ('targetRange'), computes a list of possible extractions. * Each returned ExtractResultForScope corresponds to a possible target scope and is either a set of changes * or an error explaining why we can't extract into that scope. */ - export function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number = undefined): ReadonlyArray | undefined { + // exported only for tests + export function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext): ReadonlyArray | undefined { + const { scopes, readsAndWrites: { errorsPerScope } } = getPossibleExtractionsWorker(targetRange, context); + // Need the inner type annotation to avoid https://github.com/Microsoft/TypeScript/issues/7547 + return scopes.map((scope, i): PossibleExtraction => + ({ scopeDescription: getDescriptionForScope(scope), errors: errorsPerScope[i] })); + } + + function getPossibleExtractionsWorker(targetRange: TargetRange, context: RefactorContext): { readonly scopes: Scope[], readonly readsAndWrites: ReadsAndWrites } { const { file: sourceFile } = context; if (targetRange === undefined) { @@ -512,35 +519,14 @@ namespace ts.refactor.extractMethod { } const enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); - const { target, usagesPerScope, errorsPerScope } = collectReadsAndWrites( + const readsAndWrites = collectReadsAndWrites( targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker(), context.cancellationToken); - - context.cancellationToken.throwIfCancellationRequested(); - - if (requestedChangesIndex !== undefined) { - if (errorsPerScope[requestedChangesIndex].length) { - return undefined; - } - return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; - } - else { - return scopes.map((scope, i) => { - const errors = errorsPerScope[i]; - if (errors.length) { - return { - scope, - scopeDescription: getDescriptionForScope(scope), - errors - }; - } - return { scope, scopeDescription: getDescriptionForScope(scope) }; - }); - } + return { scopes, readsAndWrites }; } function getDescriptionForScope(scope: Scope): string { @@ -583,34 +569,33 @@ namespace ts.refactor.extractMethod { : scope.externalModuleIndicator ? "module scope" : "global scope"; } - function getUniqueName(isNameOkay: (name: string) => boolean) { + function getUniqueName(fileText: string): string { let functionNameText = "newFunction"; - if (isNameOkay(functionNameText)) { - return functionNameText; - } - let i = 1; - while (!isNameOkay(functionNameText = `newFunction_${i}`)) { - i++; + for (let i = 1; fileText.indexOf(functionNameText) !== -1; i++) { + functionNameText = `newFunction_${i}`; } return functionNameText; } - export function extractFunctionInScope( + /** + * Result of 'extractRange' operation for a specific scope. + * Stores either a list of changes that should be applied to extract a range or a list of errors + */ + function extractFunctionInScope( node: Statement | Expression | Block, scope: Scope, { usages: usagesInScope, typeParameterUsages, substitutions }: ScopeUsages, range: TargetRange, - context: RefactorContext): ExtractResultForScope { + context: RefactorContext): RefactorEditInfo { const checker = context.program.getTypeChecker(); // Make a unique name for the extracted function const file = scope.getSourceFile(); - const functionNameText: string = getUniqueName(n => !file.identifiers.has(n)); + const functionNameText = getUniqueName(file.text); const isJS = isInJavaScriptFile(scope); - const functionName = createIdentifier(functionNameText as string); - const functionReference = createIdentifier(functionNameText as string); + const functionName = createIdentifier(functionNameText); let returnType: TypeNode = undefined; const parameters: ParameterDeclaration[] = []; @@ -660,7 +645,7 @@ namespace ts.refactor.extractMethod { returnType = checker.typeToTypeNode(contextualType); } - const { body, returnValueProperty } = transformFunctionBody(node); + const { body, returnValueProperty } = transformFunctionBody(node, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)); let newFunction: MethodDeclaration | FunctionDeclaration; if (isClassLike(scope)) { @@ -709,8 +694,10 @@ namespace ts.refactor.extractMethod { const newNodes: Node[] = []; // replace range with function call + const called = getCalledExpression(scope, range, functionNameText); + let call: Expression = createCall( - isClassLike(scope) ? createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? createIdentifier(scope.name.getText()) : createThis(), functionReference) : functionReference, + called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { @@ -779,147 +766,174 @@ namespace ts.refactor.extractMethod { changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); } - return { - scope, - scopeDescription: getDescriptionForScope(scope), - changes: changeTracker.getChanges() - }; + const edits = changeTracker.getChanges(); + const renameRange = isReadonlyArray(range.range) ? range.range[0] : range.range; - function getFirstDeclaration(type: Type): Declaration | undefined { - let firstDeclaration = undefined; + const renameFilename = renameRange.getSourceFile().fileName; + const renameLocation = getRenameLocation(edits, renameFilename, functionNameText); + return { renameFilename, renameLocation, edits }; + } - const symbol = type.symbol; - if (symbol && symbol.declarations) { - for (const declaration of symbol.declarations) { - if (firstDeclaration === undefined || declaration.pos < firstDeclaration.pos) { - firstDeclaration = declaration; - } + function getRenameLocation(edits: ReadonlyArray, renameFilename: string, functionNameText: string): number { + let delta = 0; + for (const { fileName, textChanges } of edits) { + Debug.assert(fileName === renameFilename); + for (const change of textChanges) { + const { span, newText } = change; + // TODO(acasey): We are assuming that the call expression comes before the function declaration, + // because we want the new cursor to be on the call expression, + // which is closer to where the user was before extracting the function. + const index = newText.indexOf(functionNameText); + if (index !== -1) { + return span.start + delta + index; + } + delta += newText.length - span.length; + } + } + throw new Error(); // Didn't find the text we inserted? + } + + function getFirstDeclaration(type: Type): Declaration | undefined { + let firstDeclaration = undefined; + + const symbol = type.symbol; + if (symbol && symbol.declarations) { + for (const declaration of symbol.declarations) { + if (firstDeclaration === undefined || declaration.pos < firstDeclaration.pos) { + firstDeclaration = declaration; } } - - return firstDeclaration; } - function compareTypesByDeclarationOrder( - {type: type1, declaration: declaration1}: {type: Type, declaration?: Declaration}, - {type: type2, declaration: declaration2}: {type: Type, declaration?: Declaration}) { + return firstDeclaration; + } - if (declaration1) { - if (declaration2) { - const positionDiff = declaration1.pos - declaration2.pos; - if (positionDiff !== 0) { - return positionDiff; - } + function compareTypesByDeclarationOrder( + {type: type1, declaration: declaration1}: {type: Type, declaration?: Declaration}, + {type: type2, declaration: declaration2}: {type: Type, declaration?: Declaration}) { + + if (declaration1) { + if (declaration2) { + const positionDiff = declaration1.pos - declaration2.pos; + if (positionDiff !== 0) { + return positionDiff; } - else { - return 1; // Sort undeclared type parameters to the front. - } - } - else if (declaration2) { - return -1; // Sort undeclared type parameters to the front. - } - - const name1 = type1.symbol ? type1.symbol.getName() : ""; - const name2 = type2.symbol ? type2.symbol.getName() : ""; - const nameDiff = compareStrings(name1, name2); - if (nameDiff !== 0) { - return nameDiff; - } - - // IDs are guaranteed to be unique, so this ensures a total ordering. - return type1.id - type2.id; - } - - function getPropertyAssignmentsForWrites(writes: UsageEntry[]) { - return writes.map(w => createShorthandPropertyAssignment(w.symbol.name)); - } - - function generateReturnValueProperty() { - return "__return"; - } - - function getStatementsOrClassElements(scope: Scope): ReadonlyArray | ReadonlyArray { - if (isFunctionLike(scope)) { - const body = scope.body; - if (isBlock(body)) { - return body.statements; - } - } - else if (isModuleBlock(scope) || isSourceFile(scope)) { - return scope.statements; - } - else if (isClassLike(scope)) { - return scope.members; } else { - assertTypeIsNever(scope); - } - - return emptyArray; - } - - /** - * If `scope` contains a function after `minPos`, then return the first such function. - * Otherwise, return `undefined`. - */ - function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { - const children = getStatementsOrClassElements(scope); - for (const child of children) { - if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { - return child; - } + return 1; // Sort undeclared type parameters to the front. } } + else if (declaration2) { + return -1; // Sort undeclared type parameters to the front. + } - function transformFunctionBody(body: Node) { - if (isBlock(body) && !writes && substitutions.size === 0) { - // already block, no writes to propagate back, no substitutions - can use node as is - return { body: createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; - } - let returnValueProperty: string; - const statements = createNodeArray(isBlock(body) ? body.statements.slice(0) : [isStatement(body) ? body : createReturn(body)]); - // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions - if (writes || substitutions.size) { - const rewrittenStatements = visitNodes(statements, visitor).slice(); - if (writes && !(range.facts & RangeFacts.HasReturn) && isStatement(body)) { - // add return at the end to propagate writes back in case if control flow falls out of the function body - // it is ok to know that range has at least one return since it we only allow unconditional returns - const assignments = getPropertyAssignmentsForWrites(writes); - if (assignments.length === 1) { - rewrittenStatements.push(createReturn(assignments[0].name)); - } - else { - rewrittenStatements.push(createReturn(createObjectLiteral(assignments))); - } - } - return { body: createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty }; - } - else { - return { body: createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; - } + const name1 = type1.symbol ? type1.symbol.getName() : ""; + const name2 = type2.symbol ? type2.symbol.getName() : ""; + const nameDiff = compareStrings(name1, name2); + if (nameDiff !== 0) { + return nameDiff; + } - function visitor(node: Node): VisitResult { - if (node.kind === SyntaxKind.ReturnStatement && writes) { - const assignments: ObjectLiteralElementLike[] = getPropertyAssignmentsForWrites(writes); - if ((node).expression) { - if (!returnValueProperty) { - returnValueProperty = generateReturnValueProperty(); - } - assignments.unshift(createPropertyAssignment(returnValueProperty, visitNode((node).expression, visitor))); - } - if (assignments.length === 1) { - return createReturn(assignments[0].name as Expression); - } - else { - return createReturn(createObjectLiteral(assignments)); - } + // IDs are guaranteed to be unique, so this ensures a total ordering. + return type1.id - type2.id; + } + + function getCalledExpression(scope: Node, range: TargetRange, functionNameText: string): Expression { + const functionReference = createIdentifier(functionNameText); + if (isClassLike(scope)) { + const lhs = range.facts & RangeFacts.InStaticRegion ? createIdentifier(scope.name.text) : createThis(); + return createPropertyAccess(lhs, functionReference); + } + else { + return functionReference; + } + } + + function transformFunctionBody(body: Node, writes: ReadonlyArray, substitutions: ReadonlyMap, hasReturn: boolean): { body: Block, returnValueProperty: string } { + if (isBlock(body) && !writes && substitutions.size === 0) { + // already block, no writes to propagate back, no substitutions - can use node as is + return { body: createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; + } + let returnValueProperty: string; + const statements = createNodeArray(isBlock(body) ? body.statements.slice(0) : [isStatement(body) ? body : createReturn(body)]); + // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions + if (writes || substitutions.size) { + const rewrittenStatements = visitNodes(statements, visitor).slice(); + if (writes && !hasReturn && isStatement(body)) { + // add return at the end to propagate writes back in case if control flow falls out of the function body + // it is ok to know that range has at least one return since it we only allow unconditional returns + const assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(createReturn(assignments[0].name)); } else { - const substitution = substitutions.get(getNodeId(node).toString()); - return substitution || visitEachChild(node, visitor, nullTransformationContext); + rewrittenStatements.push(createReturn(createObjectLiteral(assignments))); } } + return { body: createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty }; } + else { + return { body: createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; + } + + function visitor(node: Node): VisitResult { + if (node.kind === SyntaxKind.ReturnStatement && writes) { + const assignments: ObjectLiteralElementLike[] = getPropertyAssignmentsForWrites(writes); + if ((node).expression) { + if (!returnValueProperty) { + returnValueProperty = "__return"; + } + assignments.unshift(createPropertyAssignment(returnValueProperty, visitNode((node).expression, visitor))); + } + if (assignments.length === 1) { + return createReturn(assignments[0].name as Expression); + } + else { + return createReturn(createObjectLiteral(assignments)); + } + } + else { + const substitution = substitutions.get(getNodeId(node).toString()); + return substitution || visitEachChild(node, visitor, nullTransformationContext); + } + } + } + + function getStatementsOrClassElements(scope: Scope): ReadonlyArray | ReadonlyArray { + if (isFunctionLike(scope)) { + const body = scope.body; + if (isBlock(body)) { + return body.statements; + } + } + else if (isModuleBlock(scope) || isSourceFile(scope)) { + return scope.statements; + } + else if (isClassLike(scope)) { + return scope.members; + } + else { + assertTypeIsNever(scope); + } + + return emptyArray; + } + + /** + * If `scope` contains a function after `minPos`, then return the first such function. + * Otherwise, return `undefined`. + */ + function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { + const children = getStatementsOrClassElements(scope); + for (const child of children) { + if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { + return child; + } + } + } + + function getPropertyAssignmentsForWrites(writes: ReadonlyArray): ShorthandPropertyAssignment[] { + return writes.map(w => createShorthandPropertyAssignment(w.symbol.name)); } function isReadonlyArray(v: any): v is ReadonlyArray { @@ -948,25 +962,30 @@ namespace ts.refactor.extractMethod { Write = 2 } - export interface UsageEntry { + interface UsageEntry { readonly usage: Usage; readonly symbol: Symbol; readonly node: Node; } - export interface ScopeUsages { - usages: Map; - typeParameterUsages: Map; // Key is type ID - substitutions: Map; + interface ScopeUsages { + readonly usages: Map; + readonly typeParameterUsages: Map; // Key is type ID + readonly substitutions: Map; } + interface ReadsAndWrites { + readonly target: Expression | Block; + readonly usagesPerScope: ReadonlyArray; + readonly errorsPerScope: ReadonlyArray>; + } function collectReadsAndWrites( targetRange: TargetRange, scopes: Scope[], enclosingTextRange: TextRange, sourceFile: SourceFile, checker: TypeChecker, - cancellationToken: CancellationToken) { + cancellationToken: CancellationToken): ReadsAndWrites { const allTypeParameterUsages = createMap(); // Key is type ID const usagesPerScope: ScopeUsages[] = []; diff --git a/src/services/types.ts b/src/services/types.ts index 8a23bfec1c5..a971995f050 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -414,8 +414,8 @@ namespace ts { */ export interface RefactorEditInfo { edits: FileTextChanges[]; - renameFilename?: string; - renameLocation?: number; + renameFilename: string | undefined; + renameLocation: number | undefined; } export interface TextInsertion { diff --git a/tests/baselines/reference/extractMethod/extractMethod1.ts b/tests/baselines/reference/extractMethod/extractMethod1.ts index 660380c1253..86c28b5f4d2 100644 --- a/tests/baselines/reference/extractMethod/extractMethod1.ts +++ b/tests/baselines/reference/extractMethod/extractMethod1.ts @@ -23,7 +23,7 @@ namespace A { function a() { let a = 1; - newFunction(); + /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -43,7 +43,7 @@ namespace A { function a() { let a = 1; - a = newFunction(a); + a = /*RENAME*/newFunction(a); } function newFunction(a: number) { @@ -64,7 +64,7 @@ namespace A { function a() { let a = 1; - a = newFunction(a); + a = /*RENAME*/newFunction(a); } } @@ -85,7 +85,7 @@ namespace A { function a() { let a = 1; - a = newFunction(x, a, foo); + a = /*RENAME*/newFunction(x, a, foo); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod10.ts b/tests/baselines/reference/extractMethod/extractMethod10.ts index 13108a08131..e3eb73b661e 100644 --- a/tests/baselines/reference/extractMethod/extractMethod10.ts +++ b/tests/baselines/reference/extractMethod/extractMethod10.ts @@ -15,7 +15,7 @@ namespace A { class C { a() { let z = 1; - return this.newFunction(); + return this./*RENAME*/newFunction(); } private newFunction() { @@ -30,7 +30,7 @@ namespace A { class C { a() { let z = 1; - return newFunction(); + return /*RENAME*/newFunction(); } } @@ -45,7 +45,7 @@ namespace A { class C { a() { let z = 1; - return newFunction(); + return /*RENAME*/newFunction(); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod11.ts b/tests/baselines/reference/extractMethod/extractMethod11.ts index 5a2e0da826a..43fdd75b76f 100644 --- a/tests/baselines/reference/extractMethod/extractMethod11.ts +++ b/tests/baselines/reference/extractMethod/extractMethod11.ts @@ -18,7 +18,7 @@ namespace A { a() { let z = 1; var __return: any; - ({ __return, z } = this.newFunction(z)); + ({ __return, z } = this./*RENAME*/newFunction(z)); return __return; } @@ -37,7 +37,7 @@ namespace A { a() { let z = 1; var __return: any; - ({ __return, z } = newFunction(z)); + ({ __return, z } = /*RENAME*/newFunction(z)); return __return; } } @@ -56,7 +56,7 @@ namespace A { a() { let z = 1; var __return: any; - ({ __return, y, z } = newFunction(y, z)); + ({ __return, y, z } = /*RENAME*/newFunction(y, z)); return __return; } } diff --git a/tests/baselines/reference/extractMethod/extractMethod12.ts b/tests/baselines/reference/extractMethod/extractMethod12.ts index 98428a67bd0..2f3082cf280 100644 --- a/tests/baselines/reference/extractMethod/extractMethod12.ts +++ b/tests/baselines/reference/extractMethod/extractMethod12.ts @@ -21,7 +21,7 @@ namespace A { a() { let z = 1; var __return: any; - ({ __return, z } = this.newFunction(z)); + ({ __return, z } = this./*RENAME*/newFunction(z)); return __return; } diff --git a/tests/baselines/reference/extractMethod/extractMethod13.ts b/tests/baselines/reference/extractMethod/extractMethod13.ts index 44968ac4dcf..121d7eeecfa 100644 --- a/tests/baselines/reference/extractMethod/extractMethod13.ts +++ b/tests/baselines/reference/extractMethod/extractMethod13.ts @@ -20,7 +20,7 @@ (u2a: U2a, u2b: U2b) => { function F2(t2a: T2a, t2b: T2b) { (u3a: U3a, u3b: U3b) => { - newFunction(u3a); + /*RENAME*/newFunction(u3a); } function newFunction(u3a: U3a) { @@ -40,7 +40,7 @@ (u2a: U2a, u2b: U2b) => { function F2(t2a: T2a, t2b: T2b) { (u3a: U3a, u3b: U3b) => { - newFunction(t2a, u2a, u3a); + /*RENAME*/newFunction(t2a, u2a, u3a); } } } @@ -60,7 +60,7 @@ (u2a: U2a, u2b: U2b) => { function F2(t2a: T2a, t2b: T2b) { (u3a: U3a, u3b: U3b) => { - newFunction(t1a, t2a, u1a, u2a, u3a); + /*RENAME*/newFunction(t1a, t2a, u1a, u2a, u3a); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod14.ts b/tests/baselines/reference/extractMethod/extractMethod14.ts index 4db0e748907..d3dcded2c42 100644 --- a/tests/baselines/reference/extractMethod/extractMethod14.ts +++ b/tests/baselines/reference/extractMethod/extractMethod14.ts @@ -8,7 +8,7 @@ function F(t1: T) { // ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { - newFunction(); + /*RENAME*/newFunction(); function newFunction() { t1.toString(); @@ -19,7 +19,7 @@ function F(t1: T) { // ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: T) { - newFunction(t2); + /*RENAME*/newFunction(t2); } function newFunction(t2: T) { @@ -30,7 +30,7 @@ function F(t1: T) { // ==SCOPE::function in global scope== function F(t1: T) { function F(t2: T) { - newFunction(t1, t2); + /*RENAME*/newFunction(t1, t2); } } function newFunction(t1: T, t2: T) { diff --git a/tests/baselines/reference/extractMethod/extractMethod15.ts b/tests/baselines/reference/extractMethod/extractMethod15.ts index 7d1c8aa4507..50516445c87 100644 --- a/tests/baselines/reference/extractMethod/extractMethod15.ts +++ b/tests/baselines/reference/extractMethod/extractMethod15.ts @@ -7,7 +7,7 @@ function F(t1: T) { // ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { - newFunction(); + /*RENAME*/newFunction(); function newFunction() { t2.toString(); @@ -17,7 +17,7 @@ function F(t1: T) { // ==SCOPE::inner function in function 'F'== function F(t1: T) { function F(t2: U) { - newFunction(t2); + /*RENAME*/newFunction(t2); } function newFunction(t2: U) { @@ -27,7 +27,7 @@ function F(t1: T) { // ==SCOPE::function in global scope== function F(t1: T) { function F(t2: U) { - newFunction(t2); + /*RENAME*/newFunction(t2); } } function newFunction(t2: U) { diff --git a/tests/baselines/reference/extractMethod/extractMethod16.ts b/tests/baselines/reference/extractMethod/extractMethod16.ts index 2ecb0703660..e58bbf576c6 100644 --- a/tests/baselines/reference/extractMethod/extractMethod16.ts +++ b/tests/baselines/reference/extractMethod/extractMethod16.ts @@ -4,7 +4,7 @@ function F() { } // ==SCOPE::inner function in function 'F'== function F() { - const array: T[] = newFunction(); + const array: T[] = /*RENAME*/newFunction(); function newFunction(): T[] { return []; @@ -12,7 +12,7 @@ function F() { } // ==SCOPE::function in global scope== function F() { - const array: T[] = newFunction(); + const array: T[] = /*RENAME*/newFunction(); } function newFunction(): T[] { return []; diff --git a/tests/baselines/reference/extractMethod/extractMethod17.ts b/tests/baselines/reference/extractMethod/extractMethod17.ts index d0401b6b472..f79abcca792 100644 --- a/tests/baselines/reference/extractMethod/extractMethod17.ts +++ b/tests/baselines/reference/extractMethod/extractMethod17.ts @@ -7,7 +7,7 @@ class C { // ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { - this.newFunction(t1); + this./*RENAME*/newFunction(t1); } private newFunction(t1: T1) { @@ -17,7 +17,7 @@ class C { // ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { - newFunction(t1); + /*RENAME*/newFunction(t1); } } function newFunction(t1: T1) { diff --git a/tests/baselines/reference/extractMethod/extractMethod18.ts b/tests/baselines/reference/extractMethod/extractMethod18.ts index 85ef9a5d5c0..122eced75d5 100644 --- a/tests/baselines/reference/extractMethod/extractMethod18.ts +++ b/tests/baselines/reference/extractMethod/extractMethod18.ts @@ -7,7 +7,7 @@ class C { // ==SCOPE::method in class 'C'== class C { M(t1: T1, t2: T2) { - this.newFunction(t1); + this./*RENAME*/newFunction(t1); } private newFunction(t1: T1) { @@ -17,7 +17,7 @@ class C { // ==SCOPE::function in global scope== class C { M(t1: T1, t2: T2) { - newFunction(t1); + /*RENAME*/newFunction(t1); } } function newFunction(t1: T1) { diff --git a/tests/baselines/reference/extractMethod/extractMethod19.ts b/tests/baselines/reference/extractMethod/extractMethod19.ts index 80d3c61d1ee..61d35f97db5 100644 --- a/tests/baselines/reference/extractMethod/extractMethod19.ts +++ b/tests/baselines/reference/extractMethod/extractMethod19.ts @@ -4,7 +4,7 @@ function F(v: V) { } // ==SCOPE::inner function in function 'F'== function F(v: V) { - newFunction(); + /*RENAME*/newFunction(); function newFunction() { v.toString(); @@ -12,7 +12,7 @@ function F(v: V) { } // ==SCOPE::function in global scope== function F(v: V) { - newFunction(v); + /*RENAME*/newFunction(v); } function newFunction(v: V) { v.toString(); diff --git a/tests/baselines/reference/extractMethod/extractMethod2.ts b/tests/baselines/reference/extractMethod/extractMethod2.ts index 17ca6a6ba22..b83cc6f32c6 100644 --- a/tests/baselines/reference/extractMethod/extractMethod2.ts +++ b/tests/baselines/reference/extractMethod/extractMethod2.ts @@ -20,7 +20,7 @@ namespace A { namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -38,7 +38,7 @@ namespace A { namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { @@ -56,7 +56,7 @@ namespace A { namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } } @@ -74,7 +74,7 @@ namespace A { namespace B { function a() { - return newFunction(x, foo); + return /*RENAME*/newFunction(x, foo); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod20.ts b/tests/baselines/reference/extractMethod/extractMethod20.ts index 7d65bfca1a9..6e0148e0991 100644 --- a/tests/baselines/reference/extractMethod/extractMethod20.ts +++ b/tests/baselines/reference/extractMethod/extractMethod20.ts @@ -8,7 +8,7 @@ const _ = class { // ==SCOPE::method in anonymous class expression== const _ = class { a() { - return this.newFunction(); + return this./*RENAME*/newFunction(); } private newFunction() { @@ -19,7 +19,7 @@ const _ = class { // ==SCOPE::function in global scope== const _ = class { a() { - return newFunction(); + return /*RENAME*/newFunction(); } } function newFunction() { diff --git a/tests/baselines/reference/extractMethod/extractMethod21.ts b/tests/baselines/reference/extractMethod/extractMethod21.ts index 6fb5fc43155..2c4ffd1bdb8 100644 --- a/tests/baselines/reference/extractMethod/extractMethod21.ts +++ b/tests/baselines/reference/extractMethod/extractMethod21.ts @@ -7,7 +7,7 @@ function foo() { // ==SCOPE::inner function in function 'foo'== function foo() { let x = 10; - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { x++; @@ -17,7 +17,7 @@ function foo() { // ==SCOPE::function in global scope== function foo() { let x = 10; - x = newFunction(x); + x = /*RENAME*/newFunction(x); return; } function newFunction(x: number) { diff --git a/tests/baselines/reference/extractMethod/extractMethod22.ts b/tests/baselines/reference/extractMethod/extractMethod22.ts index 1bb76ef67ba..990bfdf0575 100644 --- a/tests/baselines/reference/extractMethod/extractMethod22.ts +++ b/tests/baselines/reference/extractMethod/extractMethod22.ts @@ -11,7 +11,7 @@ function test() { try { } finally { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { @@ -23,7 +23,7 @@ function test() { try { } finally { - return newFunction(); + return /*RENAME*/newFunction(); } } function newFunction() { diff --git a/tests/baselines/reference/extractMethod/extractMethod23.ts b/tests/baselines/reference/extractMethod/extractMethod23.ts index 0c56434447e..b9bc4264ea6 100644 --- a/tests/baselines/reference/extractMethod/extractMethod23.ts +++ b/tests/baselines/reference/extractMethod/extractMethod23.ts @@ -10,7 +10,7 @@ namespace NS { namespace NS { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { return 1; @@ -22,7 +22,7 @@ namespace NS { namespace NS { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { return 1; @@ -34,7 +34,7 @@ namespace NS { namespace NS { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function M3() { } } diff --git a/tests/baselines/reference/extractMethod/extractMethod24.ts b/tests/baselines/reference/extractMethod/extractMethod24.ts index 0b33289708f..a9dc25d32ea 100644 --- a/tests/baselines/reference/extractMethod/extractMethod24.ts +++ b/tests/baselines/reference/extractMethod/extractMethod24.ts @@ -10,7 +10,7 @@ function Outer() { function Outer() { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { return 1; @@ -22,7 +22,7 @@ function Outer() { function Outer() { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { return 1; @@ -34,7 +34,7 @@ function Outer() { function Outer() { function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function M3() { } } diff --git a/tests/baselines/reference/extractMethod/extractMethod25.ts b/tests/baselines/reference/extractMethod/extractMethod25.ts index c77ec1abbfd..dc376781346 100644 --- a/tests/baselines/reference/extractMethod/extractMethod25.ts +++ b/tests/baselines/reference/extractMethod/extractMethod25.ts @@ -7,7 +7,7 @@ function M3() { } // ==SCOPE::inner function in function 'M2'== function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { return 1; @@ -17,7 +17,7 @@ function M3() { } // ==SCOPE::function in global scope== function M1() { } function M2() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { return 1; diff --git a/tests/baselines/reference/extractMethod/extractMethod26.ts b/tests/baselines/reference/extractMethod/extractMethod26.ts index 84dc82f7fed..b49e8ab9508 100644 --- a/tests/baselines/reference/extractMethod/extractMethod26.ts +++ b/tests/baselines/reference/extractMethod/extractMethod26.ts @@ -10,7 +10,7 @@ class C { class C { M1() { } M2() { - return this.newFunction(); + return this./*RENAME*/newFunction(); } private newFunction() { return 1; @@ -22,7 +22,7 @@ class C { class C { M1() { } M2() { - return newFunction(); + return /*RENAME*/newFunction(); } M3() { } } diff --git a/tests/baselines/reference/extractMethod/extractMethod27.ts b/tests/baselines/reference/extractMethod/extractMethod27.ts index ce21f1e1fed..0ec214bb5ed 100644 --- a/tests/baselines/reference/extractMethod/extractMethod27.ts +++ b/tests/baselines/reference/extractMethod/extractMethod27.ts @@ -11,7 +11,7 @@ class C { class C { M1() { } M2() { - return this.newFunction(); + return this./*RENAME*/newFunction(); } constructor() { } private newFunction() { @@ -24,7 +24,7 @@ class C { class C { M1() { } M2() { - return newFunction(); + return /*RENAME*/newFunction(); } constructor() { } M3() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod28.ts b/tests/baselines/reference/extractMethod/extractMethod28.ts index e3d0fc3b9ea..ab6ce220bd7 100644 --- a/tests/baselines/reference/extractMethod/extractMethod28.ts +++ b/tests/baselines/reference/extractMethod/extractMethod28.ts @@ -11,7 +11,7 @@ class C { class C { M1() { } M2() { - return this.newFunction(); + return this./*RENAME*/newFunction(); } private newFunction() { return 1; @@ -24,7 +24,7 @@ class C { class C { M1() { } M2() { - return newFunction(); + return /*RENAME*/newFunction(); } M3() { } constructor() { } diff --git a/tests/baselines/reference/extractMethod/extractMethod3.ts b/tests/baselines/reference/extractMethod/extractMethod3.ts index 0d8481c9841..0af79791fe7 100644 --- a/tests/baselines/reference/extractMethod/extractMethod3.ts +++ b/tests/baselines/reference/extractMethod/extractMethod3.ts @@ -18,7 +18,7 @@ namespace A { namespace B { function* a(z: number) { - return yield* newFunction(); + return yield* /*RENAME*/newFunction(); function* newFunction() { let y = 5; @@ -35,7 +35,7 @@ namespace A { namespace B { function* a(z: number) { - return yield* newFunction(z); + return yield* /*RENAME*/newFunction(z); } function* newFunction(z: number) { @@ -52,7 +52,7 @@ namespace A { namespace B { function* a(z: number) { - return yield* newFunction(z); + return yield* /*RENAME*/newFunction(z); } } @@ -69,7 +69,7 @@ namespace A { namespace B { function* a(z: number) { - return yield* newFunction(z, foo); + return yield* /*RENAME*/newFunction(z, foo); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod4.ts b/tests/baselines/reference/extractMethod/extractMethod4.ts index 4f6a5d85f89..e0a636135d4 100644 --- a/tests/baselines/reference/extractMethod/extractMethod4.ts +++ b/tests/baselines/reference/extractMethod/extractMethod4.ts @@ -20,7 +20,7 @@ namespace A { namespace B { async function a(z: number, z1: any) { - return await newFunction(); + return await /*RENAME*/newFunction(); async function newFunction() { let y = 5; @@ -39,7 +39,7 @@ namespace A { namespace B { async function a(z: number, z1: any) { - return await newFunction(z, z1); + return await /*RENAME*/newFunction(z, z1); } async function newFunction(z: number, z1: any) { @@ -58,7 +58,7 @@ namespace A { namespace B { async function a(z: number, z1: any) { - return await newFunction(z, z1); + return await /*RENAME*/newFunction(z, z1); } } @@ -77,7 +77,7 @@ namespace A { namespace B { async function a(z: number, z1: any) { - return await newFunction(z, z1, foo); + return await /*RENAME*/newFunction(z, z1, foo); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod5.ts b/tests/baselines/reference/extractMethod/extractMethod5.ts index 10ff0005f73..fc15f6762e5 100644 --- a/tests/baselines/reference/extractMethod/extractMethod5.ts +++ b/tests/baselines/reference/extractMethod/extractMethod5.ts @@ -23,7 +23,7 @@ namespace A { function a() { let a = 1; - newFunction(); + /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -43,7 +43,7 @@ namespace A { function a() { let a = 1; - a = newFunction(a); + a = /*RENAME*/newFunction(a); } function newFunction(a: number) { @@ -64,7 +64,7 @@ namespace A { function a() { let a = 1; - a = newFunction(a); + a = /*RENAME*/newFunction(a); } } @@ -85,7 +85,7 @@ namespace A { function a() { let a = 1; - a = newFunction(x, a); + a = /*RENAME*/newFunction(x, a); } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod6.ts b/tests/baselines/reference/extractMethod/extractMethod6.ts index 40135e6ec97..37112b80e9e 100644 --- a/tests/baselines/reference/extractMethod/extractMethod6.ts +++ b/tests/baselines/reference/extractMethod/extractMethod6.ts @@ -23,7 +23,7 @@ namespace A { function a() { let a = 1; - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -44,7 +44,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(a)); + ({ __return, a } = /*RENAME*/newFunction(a)); return __return; } @@ -66,7 +66,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(a)); + ({ __return, a } = /*RENAME*/newFunction(a)); return __return; } } @@ -88,7 +88,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(x, a)); + ({ __return, a } = /*RENAME*/newFunction(x, a)); return __return; } } diff --git a/tests/baselines/reference/extractMethod/extractMethod7.ts b/tests/baselines/reference/extractMethod/extractMethod7.ts index d01532da796..8859b7b4fdd 100644 --- a/tests/baselines/reference/extractMethod/extractMethod7.ts +++ b/tests/baselines/reference/extractMethod/extractMethod7.ts @@ -27,7 +27,7 @@ namespace A { function a() { let a = 1; - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { let y = 5; @@ -50,7 +50,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(a)); + ({ __return, a } = /*RENAME*/newFunction(a)); return __return; } @@ -74,7 +74,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(a)); + ({ __return, a } = /*RENAME*/newFunction(a)); return __return; } } @@ -98,7 +98,7 @@ namespace A { let a = 1; var __return: any; - ({ __return, a } = newFunction(x, a)); + ({ __return, a } = /*RENAME*/newFunction(x, a)); return __return; } } diff --git a/tests/baselines/reference/extractMethod/extractMethod8.ts b/tests/baselines/reference/extractMethod/extractMethod8.ts index d59ca5dc238..cb06470d385 100644 --- a/tests/baselines/reference/extractMethod/extractMethod8.ts +++ b/tests/baselines/reference/extractMethod/extractMethod8.ts @@ -14,7 +14,7 @@ namespace A { namespace B { function a() { let a1 = 1; - return newFunction() + 100; + return /*RENAME*/newFunction() + 100; function newFunction() { return 1 + a1 + x; @@ -28,7 +28,7 @@ namespace A { namespace B { function a() { let a1 = 1; - return newFunction(a1) + 100; + return /*RENAME*/newFunction(a1) + 100; } function newFunction(a1: number) { @@ -42,7 +42,7 @@ namespace A { namespace B { function a() { let a1 = 1; - return newFunction(a1) + 100; + return /*RENAME*/newFunction(a1) + 100; } } @@ -56,7 +56,7 @@ namespace A { namespace B { function a() { let a1 = 1; - return newFunction(a1, x) + 100; + return /*RENAME*/newFunction(a1, x) + 100; } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod9.ts b/tests/baselines/reference/extractMethod/extractMethod9.ts index 342e3c10eee..022dab82363 100644 --- a/tests/baselines/reference/extractMethod/extractMethod9.ts +++ b/tests/baselines/reference/extractMethod/extractMethod9.ts @@ -13,7 +13,7 @@ namespace A { export interface I { x: number }; namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); function newFunction() { let a1: I = { x: 1 }; @@ -27,7 +27,7 @@ namespace A { export interface I { x: number }; namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } function newFunction() { @@ -41,7 +41,7 @@ namespace A { export interface I { x: number }; namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } } @@ -55,7 +55,7 @@ namespace A { export interface I { x: number }; namespace B { function a() { - return newFunction(); + return /*RENAME*/newFunction(); } } } diff --git a/tests/cases/fourslash/extract-method-formatting.ts b/tests/cases/fourslash/extract-method-formatting.ts index a346ad3bbd9..e4193fd8db3 100644 --- a/tests/cases/fourslash/extract-method-formatting.ts +++ b/tests/cases/fourslash/extract-method-formatting.ts @@ -10,10 +10,8 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs( -`function f(x: number): number { - return newFunction(x); + newContent: `function f(x: number): number { + return /*RENAME*/newFunction(x); } function newFunction(x: number) { switch (x) { @@ -21,4 +19,5 @@ function newFunction(x: number) { return 0; } } -`); +` +}); diff --git a/tests/cases/fourslash/extract-method-uniqueName.ts b/tests/cases/fourslash/extract-method-uniqueName.ts new file mode 100644 index 00000000000..44f026ae8a8 --- /dev/null +++ b/tests/cases/fourslash/extract-method-uniqueName.ts @@ -0,0 +1,20 @@ +/// + +////// newFunction +/////*start*/1 + 1/*end*/; + +goTo.select('start', 'end') +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract to function in global scope", + newContent: +`// newFunction +/*RENAME*/newFunction_1(); + +function newFunction_1() { + // newFunction + 1 + 1; +} +` +}); diff --git a/tests/cases/fourslash/extract-method1.ts b/tests/cases/fourslash/extract-method1.ts index 64dffc15a90..a8d421923b1 100644 --- a/tests/cases/fourslash/extract-method1.ts +++ b/tests/cases/fourslash/extract-method1.ts @@ -17,11 +17,10 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to method in class 'Foo'", -}); -verify.currentFileContentIs( + newContent: `class Foo { someMethod(m: number) { - this.newFunction(m); + this./*RENAME*/newFunction(m); var q = 10; return q; } @@ -33,4 +32,5 @@ verify.currentFileContentIs( var z = y + x; console.log(z); } -}`); +}` +}); diff --git a/tests/cases/fourslash/extract-method10.ts b/tests/cases/fourslash/extract-method10.ts index 73ef3029e24..215196d6c51 100644 --- a/tests/cases/fourslash/extract-method10.ts +++ b/tests/cases/fourslash/extract-method10.ts @@ -8,4 +8,11 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: 'scope_0', actionDescription: "Extract to function in module scope", + newContent: +`export {}; // Make this a module +(x => x)(/*RENAME*/newFunction())(1); +function newFunction(): (x: any) => any { + return x => x; +} +` }); diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index fa84ec4fb62..274753fd5cd 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -14,6 +14,16 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to method in class 'C'", + newContent: +`class C { + static j = 1 + 1; + constructor(q: string = C./*RENAME*/newFunction()) { + } + + private static newFunction(): string { + return "a" + "b"; + } +}` }); verify.currentFileContentIs(`class C { @@ -31,10 +41,9 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to method in class 'C'", -}); - -verify.currentFileContentIs(`class C { - static j = C.newFunction_1(); + newContent: +`class C { + static j = C./*RENAME*/newFunction_1(); constructor(q: string = C.newFunction()) { } @@ -45,4 +54,5 @@ verify.currentFileContentIs(`class C { private static newFunction(): string { return "a" + "b"; } -}`); \ No newline at end of file +}` +}); diff --git a/tests/cases/fourslash/extract-method14.ts b/tests/cases/fourslash/extract-method14.ts index 770ed3d0fcb..27a561743c6 100644 --- a/tests/cases/fourslash/extract-method14.ts +++ b/tests/cases/fourslash/extract-method14.ts @@ -15,14 +15,15 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs(`function foo() { + newContent: +`function foo() { var i = 10; var __return: any; - ({ __return, i } = newFunction(i)); + ({ __return, i } = n/*RENAME*/ewFunction(i)); return __return; } function newFunction(i) { return { __return: i++, i }; } -`); \ No newline at end of file +` +}); diff --git a/tests/cases/fourslash/extract-method15.ts b/tests/cases/fourslash/extract-method15.ts index 8d3db633b11..c3db3186cdf 100644 --- a/tests/cases/fourslash/extract-method15.ts +++ b/tests/cases/fourslash/extract-method15.ts @@ -13,14 +13,14 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); - -verify.currentFileContentIs(`function foo() { + newContent: +`function foo() { var i = 10; - i = newFunction(i); + i = /*RENAME*/newFunction(i); } function newFunction(i: number) { i++; return i; } -`); +` +}); diff --git a/tests/cases/fourslash/extract-method18.ts b/tests/cases/fourslash/extract-method18.ts index 6d4d06ca7bf..8ff1cc3028d 100644 --- a/tests/cases/fourslash/extract-method18.ts +++ b/tests/cases/fourslash/extract-method18.ts @@ -13,12 +13,13 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs(`function fn() { + newContent: +`function fn() { const x = { m: 1 }; - newFunction(x); + /*RENAME*/newFunction(x); } function newFunction(x: { m: number; }) { x.m = 3; } -`); +` +}); diff --git a/tests/cases/fourslash/extract-method19.ts b/tests/cases/fourslash/extract-method19.ts index da999fcc093..56d6b02560f 100644 --- a/tests/cases/fourslash/extract-method19.ts +++ b/tests/cases/fourslash/extract-method19.ts @@ -13,13 +13,14 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to inner function in function 'fn'", -}); -verify.currentFileContentIs(`function fn() { - newFunction_1(); + newContent: +`function fn() { + /*RENAME*/newFunction_1(); function newFunction_1() { console.log("hi"); } } -function newFunction() { }`); +function newFunction() { }` +}); diff --git a/tests/cases/fourslash/extract-method2.ts b/tests/cases/fourslash/extract-method2.ts index 021716b6e48..6fbe7394c2f 100644 --- a/tests/cases/fourslash/extract-method2.ts +++ b/tests/cases/fourslash/extract-method2.ts @@ -14,18 +14,18 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_2", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs( + newContent: `namespace NS { class Q { foo() { console.log('100'); const m = 10, j = "hello", k = {x: "what"}; - const q = newFunction(m, j, k); + const q = /*RENAME*/newFunction(m, j, k); } } } function newFunction(m: number, j: string, k: { x: string; }) { return m + j + k; } -`); +` +}); diff --git a/tests/cases/fourslash/extract-method21.ts b/tests/cases/fourslash/extract-method21.ts index f19d4b05912..8e3baf61949 100644 --- a/tests/cases/fourslash/extract-method21.ts +++ b/tests/cases/fourslash/extract-method21.ts @@ -16,14 +16,14 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to method in class 'Foo'", -}); - -verify.currentFileContentIs(`class Foo { + newContent: +`class Foo { static method() { - return Foo.newFunction(); + return Foo./*RENAME*/newFunction(); } private static newFunction() { return 1; } -}`); \ No newline at end of file +}` +}); diff --git a/tests/cases/fourslash/extract-method24.ts b/tests/cases/fourslash/extract-method24.ts index e5f923bb80d..5706c5c7a54 100644 --- a/tests/cases/fourslash/extract-method24.ts +++ b/tests/cases/fourslash/extract-method24.ts @@ -11,13 +11,14 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_1", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs(`function M() { + newContent: +`function M() { let a = [1,2,3]; let x = 0; - console.log(newFunction(a, x)); + console.log(/*RENAME*/newFunction(a, x)); } function newFunction(a: number[], x: number): any { return a[x]; } -`); \ No newline at end of file +` +}); diff --git a/tests/cases/fourslash/extract-method25.ts b/tests/cases/fourslash/extract-method25.ts index d18d0691e61..4fb2193adf3 100644 --- a/tests/cases/fourslash/extract-method25.ts +++ b/tests/cases/fourslash/extract-method25.ts @@ -12,12 +12,13 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to inner function in function 'fn'", -}); -verify.currentFileContentIs(`function fn() { - var q = newFunction() + newContent: +`function fn() { + var q = /*RENAME*/newFunction() q[0]++ function newFunction() { return [0]; } -}`); +}` +}); diff --git a/tests/cases/fourslash/extract-method5.ts b/tests/cases/fourslash/extract-method5.ts index 014dfb35d08..b27d9a8209b 100644 --- a/tests/cases/fourslash/extract-method5.ts +++ b/tests/cases/fourslash/extract-method5.ts @@ -13,13 +13,12 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to inner function in function 'f'", -}); -// TODO: GH#18091 (fix formatting to use `2 ? 1 :` and not `2?1:`) -verify.currentFileContentIs( + newContent: `function f() { - var x: 1 | 2 | 3 = newFunction(); + var x: 1 | 2 | 3 = /*RENAME*/newFunction(); function newFunction(): 1 | 2 | 3 { return 1 + 1 === 2 ? 1 : 2; } -}`); \ No newline at end of file +}` +}); diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index d8459bf77ad..c28e12dce8c 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -11,10 +11,11 @@ edit.applyRefactor({ refactorName: "Extract Method", actionName: "scope_0", actionDescription: "Extract to function in global scope", -}); -verify.currentFileContentIs(`function fn(x = newFunction()) { + newContent: +`function fn(x = /*RENAME*/newFunction()) { } function newFunction() { return 1 + 1; } -`); +` +}); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 119780872e9..7901d9550cb 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -310,7 +310,7 @@ declare namespace FourSlashInterface { enableFormatting(): void; disableFormatting(): void; - applyRefactor(options: { refactorName: string, actionName: string, actionDescription: string }): void; + applyRefactor(options: { refactorName: string, actionName: string, actionDescription: string, newContent: string }): void; } class debug { printCurrentParameterHelp(): void; From 2a70bf51589c4312a9329bce68cb2b5c9876e613 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 13 Sep 2017 09:02:33 -0700 Subject: [PATCH 137/216] Don't count a write-only reference as a use (#17752) * Don't count a write-only reference as a use * Split isWriteAccess to isWriteOnlyAccess and isReadOnlyAccess * Update "unusedParameterUsedInTypeOf" to use "b" * Update diagnostic messages: "is never used" -> "its value is never read" * Use a WriteKind enum * Rename enum and move documentation to enum members --- src/compiler/checker.ts | 102 ++++++++++-------- src/compiler/diagnosticMessages.json | 4 +- src/compiler/transformers/es2017.ts | 7 -- src/compiler/transformers/generators.ts | 4 - src/compiler/tsc.ts | 3 +- src/compiler/utilities.ts | 40 +++++++ src/harness/compilerRunner.ts | 18 ---- src/harness/unittests/compileOnSave.ts | 11 -- src/harness/unittests/typingsInstaller.ts | 2 - src/server/server.ts | 3 +- src/services/codefixes/fixUnusedIdentifier.ts | 4 +- src/services/findAllReferences.ts | 21 +--- src/services/preProcess.ts | 2 - .../reference/extendsUntypedModule.errors.txt | 4 +- .../noUnusedLocals_selfReference.errors.txt | 12 +-- .../noUnusedLocals_writeOnly.errors.txt | 16 +++ .../reference/noUnusedLocals_writeOnly.js | 22 ++++ ...oUnusedLocals_writeOnlyProperty.errors.txt | 13 +++ .../noUnusedLocals_writeOnlyProperty.js | 18 ++++ .../unusedClassesinModule1.errors.txt | 4 +- .../unusedClassesinNamespace1.errors.txt | 4 +- .../unusedClassesinNamespace2.errors.txt | 4 +- .../unusedClassesinNamespace4.errors.txt | 4 +- .../unusedClassesinNamespace5.errors.txt | 4 +- .../unusedDestructuringParameters.errors.txt | 8 +- .../unusedFunctionsinNamespaces1.errors.txt | 4 +- .../unusedFunctionsinNamespaces2.errors.txt | 4 +- .../unusedFunctionsinNamespaces3.errors.txt | 8 +- .../unusedFunctionsinNamespaces4.errors.txt | 4 +- .../unusedFunctionsinNamespaces5.errors.txt | 8 +- .../unusedFunctionsinNamespaces6.errors.txt | 4 +- .../unusedIdentifiersConsolidated1.errors.txt | 69 ++++++------ .../reference/unusedImports1.errors.txt | 4 +- .../reference/unusedImports10.errors.txt | 4 +- .../reference/unusedImports12.errors.txt | 20 ++-- .../reference/unusedImports2.errors.txt | 4 +- .../reference/unusedImports3.errors.txt | 4 +- .../reference/unusedImports4.errors.txt | 4 +- .../reference/unusedImports5.errors.txt | 4 +- .../reference/unusedImports6.errors.txt | 4 +- .../reference/unusedImports7.errors.txt | 4 +- .../reference/unusedImports8.errors.txt | 4 +- .../reference/unusedImports9.errors.txt | 4 +- .../unusedInterfaceinNamespace1.errors.txt | 4 +- .../unusedInterfaceinNamespace2.errors.txt | 4 +- .../unusedInterfaceinNamespace3.errors.txt | 4 +- .../unusedLocalsAndObjectSpread.errors.txt | 8 +- .../unusedLocalsAndObjectSpread2.errors.txt | 12 +-- .../unusedLocalsAndParameters.errors.txt | 84 +++++++-------- ...LocalsAndParametersTypeAliases2.errors.txt | 12 +-- .../unusedLocalsInMethod1.errors.txt | 4 +- .../unusedLocalsInMethod2.errors.txt | 9 +- .../unusedLocalsInMethod3.errors.txt | 9 +- ...ationWithinFunctionDeclaration1.errors.txt | 25 +++-- ...ationWithinFunctionDeclaration2.errors.txt | 28 ++--- ...rationWithinFunctionExpression1.errors.txt | 25 +++-- ...rationWithinFunctionExpression2.errors.txt | 28 ++--- ...ssionWithinFunctionDeclaration1.errors.txt | 25 +++-- ...ssionWithinFunctionDeclaration2.errors.txt | 28 ++--- ...essionWithinFunctionExpression1.errors.txt | 25 +++-- ...essionWithinFunctionExpression2.errors.txt | 28 ++--- ...sedLocalsStartingWithUnderscore.errors.txt | 4 +- .../unusedLocalsinConstructor1.errors.txt | 4 +- .../unusedLocalsinConstructor2.errors.txt | 4 +- .../reference/unusedModuleInModule.errors.txt | 4 +- ...dMultipleParameter1InContructor.errors.txt | 13 ++- ...eParameter1InFunctionExpression.errors.txt | 13 ++- ...dMultipleParameter2InContructor.errors.txt | 17 +-- ...eParameter2InFunctionExpression.errors.txt | 17 +-- ...arameters1InFunctionDeclaration.errors.txt | 13 ++- ...eParameters1InMethodDeclaration.errors.txt | 13 ++- ...arameters2InFunctionDeclaration.errors.txt | 17 +-- ...eParameters2InMethodDeclaration.errors.txt | 17 +-- .../unusedNamespaceInModule.errors.txt | 4 +- .../unusedNamespaceInNamespace.errors.txt | 4 +- .../unusedParameterProperty1.errors.txt | 9 +- .../unusedParameterProperty2.errors.txt | 9 +- .../reference/unusedParameterUsedInTypeOf.js | 4 +- .../unusedParameterUsedInTypeOf.symbols | 2 +- .../unusedParameterUsedInTypeOf.types | 5 +- .../unusedParametersInLambda1.errors.txt | 4 +- .../unusedParametersInLambda2.errors.txt | 4 +- .../unusedParametersWithUnderscore.errors.txt | 24 ++--- .../unusedParametersinConstructor1.errors.txt | 4 +- .../unusedParametersinConstructor2.errors.txt | 4 +- .../unusedParametersinConstructor3.errors.txt | 8 +- .../unusedPrivateMethodInClass1.errors.txt | 9 +- .../unusedPrivateMethodInClass2.errors.txt | 16 ++- .../unusedPrivateMethodInClass3.errors.txt | 19 +++- .../unusedPrivateMethodInClass4.errors.txt | 15 ++- .../unusedPrivateVariableInClass1.errors.txt | 4 +- .../unusedPrivateVariableInClass2.errors.txt | 8 +- .../unusedPrivateVariableInClass3.errors.txt | 8 +- .../unusedPrivateVariableInClass4.errors.txt | 6 +- .../unusedPrivateVariableInClass4.js | 4 +- .../unusedPrivateVariableInClass5.errors.txt | 6 +- .../unusedPrivateVariableInClass5.js | 4 +- .../reference/unusedSetterInClass.errors.txt | 13 +++ ...usedSingleParameterInContructor.errors.txt | 8 +- ...eParameterInFunctionDeclaration.errors.txt | 8 +- ...leParameterInFunctionExpression.errors.txt | 8 +- ...gleParameterInMethodDeclaration.errors.txt | 8 +- .../reference/unusedSwitchStatment.errors.txt | 17 +-- .../unusedTypeParameterInFunction1.errors.txt | 4 +- .../unusedTypeParameterInFunction2.errors.txt | 4 +- .../unusedTypeParameterInFunction3.errors.txt | 4 +- .../unusedTypeParameterInFunction4.errors.txt | 4 +- ...unusedTypeParameterInInterface1.errors.txt | 4 +- ...unusedTypeParameterInInterface2.errors.txt | 4 +- .../unusedTypeParameterInLambda1.errors.txt | 4 +- .../unusedTypeParameterInLambda2.errors.txt | 4 +- .../unusedTypeParameterInLambda3.errors.txt | 4 +- .../unusedTypeParameterInMethod1.errors.txt | 4 +- .../unusedTypeParameterInMethod2.errors.txt | 4 +- .../unusedTypeParameterInMethod3.errors.txt | 4 +- .../unusedTypeParameterInMethod4.errors.txt | 4 +- .../unusedTypeParameterInMethod5.errors.txt | 4 +- .../unusedTypeParameters1.errors.txt | 4 +- .../unusedTypeParameters10.errors.txt | 4 +- .../unusedTypeParameters2.errors.txt | 4 +- .../unusedTypeParameters3.errors.txt | 8 +- .../unusedTypeParameters4.errors.txt | 4 +- .../unusedTypeParameters5.errors.txt | 4 +- .../unusedTypeParameters8.errors.txt | 4 +- .../unusedVariablesinBlocks1.errors.txt | 9 +- .../unusedVariablesinBlocks2.errors.txt | 9 +- .../unusedVariablesinForLoop.errors.txt | 4 +- .../unusedVariablesinForLoop2.errors.txt | 4 +- .../unusedVariablesinForLoop3.errors.txt | 4 +- .../unusedVariablesinForLoop4.errors.txt | 4 +- .../unusedVariablesinModules1.errors.txt | 4 +- .../unusedVariablesinNamespaces1.errors.txt | 4 +- .../unusedVariablesinNamespaces2.errors.txt | 4 +- .../unusedVariablesinNamespaces3.errors.txt | 4 +- .../compiler/noUnusedLocals_writeOnly.ts | 12 +++ .../noUnusedLocals_writeOnlyProperty.ts | 8 ++ .../compiler/unusedParameterUsedInTypeOf.ts | 2 +- .../compiler/unusedPrivateVariableInClass4.ts | 2 +- .../compiler/unusedPrivateVariableInClass5.ts | 2 +- ...indAllRefsParameterPropertyDeclaration1.ts | 2 +- ...indAllRefsParameterPropertyDeclaration2.ts | 2 +- ...indAllRefsParameterPropertyDeclaration3.ts | 2 +- tests/cases/fourslash/localGetReferences.ts | 14 +-- ...referenceInParameterPropertyDeclaration.ts | 6 +- .../fourslash/referencesForClassLocal.ts | 4 +- .../fourslash/referencesForClassParameter.ts | 4 +- .../cases/fourslash/referencesForOverrides.ts | 2 +- tests/cases/fourslash/referencesForStatic.ts | 4 +- ...eferencesForStringLiteralPropertyNames4.ts | 2 +- tests/cases/fourslash/remoteGetReferences.ts | 12 +-- .../fourslash/unusedLocalsInFunction4.ts | 3 +- .../fourslash/unusedLocalsInMethodFS1.ts | 4 +- .../fourslash/unusedLocalsInMethodFS2.ts | 2 +- .../fourslash/unusedParameterInFunction2.ts | 2 +- .../fourslash/unusedParameterInFunction4.ts | 3 +- .../fourslash/unusedVariableInNamespace2.ts | 3 +- .../fourslash/unusedVariableInNamespace3.ts | 3 +- 157 files changed, 826 insertions(+), 651 deletions(-) create mode 100644 tests/baselines/reference/noUnusedLocals_writeOnly.errors.txt create mode 100644 tests/baselines/reference/noUnusedLocals_writeOnly.js create mode 100644 tests/baselines/reference/noUnusedLocals_writeOnlyProperty.errors.txt create mode 100644 tests/baselines/reference/noUnusedLocals_writeOnlyProperty.js create mode 100644 tests/baselines/reference/unusedSetterInClass.errors.txt create mode 100644 tests/cases/compiler/noUnusedLocals_writeOnly.ts create mode 100644 tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c169dcb83ca..5c6a8b59119 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -230,7 +230,7 @@ namespace ts { getSuggestionForNonexistentSymbol: (location, name, meaning) => unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning)), getBaseConstraintOfType, resolveName(name, location, meaning) { - return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); }, getJsxNamespace: () => unescapeLeadingUnderscores(getJsxNamespace()), }; @@ -865,17 +865,22 @@ namespace ts { } } - // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and - // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with - // the given name can be found. + /** + * Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and + * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with + * the given name can be found. + * + * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters. + */ function resolveName( location: Node | undefined, name: __String, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage | undefined, nameArg: __String | Identifier, + isUse: boolean, suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol { - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage); + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, getSymbol, suggestedNameNotFoundMessage); } function resolveNameHelper( @@ -884,6 +889,7 @@ namespace ts { meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: __String | Identifier, + isUse: boolean, lookup: typeof getSymbol, suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol { const originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location @@ -1114,7 +1120,7 @@ namespace ts { // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`. // If `result === lastLocation.symbol`, that means that we are somewhere inside `lastLocation` looking up a name, and resolving to `lastLocation` itself. // That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used. - if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { + if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } @@ -1267,7 +1273,7 @@ namespace ts { function checkAndReportErrorForUsingTypeAsNamespace(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { if (meaning === SymbolFlags.Namespace) { - const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); const parent = errorLocation.parent; if (symbol) { if (isQualifiedName(parent)) { @@ -1298,7 +1304,7 @@ namespace ts { error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name)); return true; } - const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & SymbolFlags.NamespaceModule)) { error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name)); return true; @@ -1309,14 +1315,14 @@ namespace ts { function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Type)) { - const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_value, unescapeLeadingUnderscores(name)); return true; } } else if (meaning & (SymbolFlags.Type & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Value)) { - const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Type, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Type, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_type, unescapeLeadingUnderscores(name)); return true; @@ -1640,7 +1646,7 @@ namespace ts { if (name.kind === SyntaxKind.Identifier) { const message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0; - symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name); + symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name, /*isUse*/ true); if (!symbol) { return undefined; } @@ -2314,7 +2320,7 @@ namespace ts { } const firstIdentifier = getFirstIdentifier(entityName); - const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { @@ -3971,7 +3977,7 @@ namespace ts { function collectLinkedAliases(node: Identifier): Node[] { let exportSymbol: Symbol; if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) { - exportSymbol = resolveName(node.parent, node.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node); + exportSymbol = resolveName(node.parent, node.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node, /*isUse*/ false); } else if (node.parent.kind === SyntaxKind.ExportSpecifier) { exportSymbol = getTargetOfExportSpecifier(node.parent, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); @@ -3993,7 +3999,7 @@ namespace ts { const internalModuleReference = (declaration).moduleReference; const firstIdentifier = getFirstIdentifier(internalModuleReference); const importSymbol = resolveName(declaration, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, - undefined, undefined); + undefined, undefined, /*isUse*/ false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -6408,7 +6414,7 @@ namespace ts { let paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & SymbolFlags.Property) && !isBindingPattern(param.name)) { - const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, undefined, undefined); + const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this") { @@ -7085,7 +7091,8 @@ namespace ts { } function getGlobalSymbol(name: __String, meaning: SymbolFlags, diagnostic: DiagnosticMessage): Symbol { - return resolveName(undefined, name, meaning, diagnostic, name); + // Don't track references for global symbols anyway, so value if `isReference` is arbitrary + return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false); } function getGlobalType(name: __String, arity: 0, reportErrors: boolean): ObjectType; @@ -10832,7 +10839,15 @@ namespace ts { function getResolvedSymbol(node: Identifier): Symbol { const links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = !nodeIsMissing(node) && resolveName(node, node.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, Diagnostics.Cannot_find_name_0, node, Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + links.resolvedSymbol = !nodeIsMissing(node) && + resolveName( + node, + node.escapedText, + SymbolFlags.Value | SymbolFlags.ExportValue, + Diagnostics.Cannot_find_name_0, + node, + !isWriteOnlyAccess(node), + Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } @@ -14428,7 +14443,7 @@ namespace ts { // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. const reactRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined; const reactNamespace = getJsxNamespace(); - const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace); + const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted @@ -14704,7 +14719,7 @@ namespace ts { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop); + markPropertyAsReferenced(prop, node); getNodeLinks(node).resolvedSymbol = prop; @@ -14804,7 +14819,7 @@ namespace ts { } function getSuggestionForNonexistentSymbol(location: Node, name: __String, meaning: SymbolFlags): __String { - const result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, (symbols, name, meaning) => { + const result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ false, (symbols, name, meaning) => { const symbol = getSymbol(symbols, name, meaning); if (symbol) { // Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function @@ -14884,11 +14899,12 @@ namespace ts { return bestCandidate; } - function markPropertyAsReferenced(prop: Symbol) { + function markPropertyAsReferenced(prop: Symbol, nodeForCheckWriteOnly: Node | undefined) { if (prop && noUnusedIdentifiers && (prop.flags & SymbolFlags.ClassMember) && - prop.valueDeclaration && hasModifier(prop.valueDeclaration, ModifierFlags.Private)) { + prop.valueDeclaration && hasModifier(prop.valueDeclaration, ModifierFlags.Private) + && !(nodeForCheckWriteOnly && isWriteOnlyAccess(nodeForCheckWriteOnly))) { if (getCheckFlags(prop) & CheckFlags.Instantiated) { getSymbolLinks(prop).target.isReferenced = true; } @@ -15153,7 +15169,6 @@ namespace ts { let argCount: number; // Apparent number of arguments we will have in this call let typeArguments: NodeArray; // Type arguments (undefined if none) let callIsIncomplete: boolean; // In incomplete call we want to be lenient when we have too few arguments - let isDecorator: boolean; let spreadArgIndex = -1; if (isJsxOpeningLikeElement(node)) { @@ -15187,7 +15202,6 @@ namespace ts { } } else if (node.kind === SyntaxKind.Decorator) { - isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } @@ -16582,7 +16596,7 @@ namespace ts { } // Make sure require is not a local function if (!isIdentifier(node.expression)) throw Debug.fail(); - const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (!resolvedRequire) { // project does not contain symbol named 'require' - assume commonjs require return true; @@ -19579,8 +19593,11 @@ namespace ts { } function markEntityNameOrEntityExpressionAsReference(typeName: EntityNameOrEntityNameExpression) { - const rootName = typeName && getFirstIdentifier(typeName); - const rootSymbol = rootName && resolveName(rootName, rootName.escapedText, (typeName.kind === SyntaxKind.Identifier ? SymbolFlags.Type : SymbolFlags.Namespace) | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (!typeName) return; + + const rootName = getFirstIdentifier(typeName); + const meaning = (typeName.kind === SyntaxKind.Identifier ? SymbolFlags.Type : SymbolFlags.Namespace) | SymbolFlags.Alias; + const rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && symbolIsValue(rootSymbol) @@ -19874,7 +19891,7 @@ namespace ts { !isParameterPropertyDeclaration(parameter) && !parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { - error(name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(local.escapedName)); + error(name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(local.escapedName)); } } else if (compilerOptions.noUnusedLocals) { @@ -19903,7 +19920,7 @@ namespace ts { } if (!isRemovedPropertyFromObjectSpread(node.kind === SyntaxKind.Identifier ? node.parent : node)) { - error(node, Diagnostics._0_is_declared_but_never_used, name); + error(node, Diagnostics._0_is_declared_but_its_value_is_never_read, name); } } @@ -19921,13 +19938,13 @@ namespace ts { for (const member of node.members) { if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) { if (!member.symbol.isReferenced && hasModifier(member, ModifierFlags.Private)) { - error(member.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(member.symbol.escapedName)); + error(member.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === SyntaxKind.Constructor) { for (const parameter of (member).parameters) { if (!parameter.symbol.isReferenced && hasModifier(parameter, ModifierFlags.Private)) { - error(parameter.name, Diagnostics.Property_0_is_declared_but_never_used, unescapeLeadingUnderscores(parameter.symbol.escapedName)); + error(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } } @@ -19948,7 +19965,7 @@ namespace ts { } for (const typeParameter of node.typeParameters) { if (!getMergedSymbol(typeParameter.symbol).isReferenced) { - error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); + error(typeParameter.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); } } } @@ -20179,7 +20196,7 @@ namespace ts { const symbol = getSymbolOfNode(node); if (symbol.flags & SymbolFlags.FunctionScopedVariable) { if (!isIdentifier(node.name)) throw Debug.fail(); - const localDeclarationSymbol = resolveName(node, node.name.escapedText, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + const localDeclarationSymbol = resolveName(node, node.name.escapedText, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & SymbolFlags.BlockScopedVariable) { @@ -20234,7 +20251,7 @@ namespace ts { else if (n.kind === SyntaxKind.Identifier) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name - const symbol = resolveName(n, (n).escapedText, SymbolFlags.Value | SymbolFlags.Alias, /*nameNotFoundMessage*/undefined, /*nameArg*/undefined); + const symbol = resolveName(n, (n).escapedText, SymbolFlags.Value | SymbolFlags.Alias, /*nameNotFoundMessage*/undefined, /*nameArg*/undefined, /*isUse*/ false); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; } @@ -20318,7 +20335,7 @@ namespace ts { const parentType = getTypeForBindingElementParent(parent); const name = node.propertyName || node.name; const property = getPropertyOfType(parentType, getTextOfPropertyName(name)); - markPropertyAsReferenced(property); + markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined); // A destructuring is never a write-only reference. if (parent.initializer && property) { checkPropertyAccessibility(parent, parent.initializer, parentType, property); } @@ -22254,7 +22271,7 @@ namespace ts { const exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) const symbol = resolveName(exportedName, exportedName.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, - /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, unescapeLeadingUnderscores(exportedName.escapedText)); } @@ -23359,7 +23376,7 @@ namespace ts { const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (isStatementWithLocals(container)) { const nodeLinks = getNodeLinks(symbol.valueDeclaration); - if (!!resolveName(container.parent, symbol.escapedName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + if (resolveName(container.parent, symbol.escapedName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -23669,7 +23686,7 @@ namespace ts { } } - return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(reference: Identifier): Declaration { @@ -23992,7 +24009,7 @@ namespace ts { return quickResult; } - let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node, lastAsync: Node, lastReadonly: Node; + let lastStatic: Node, lastDeclare: Node, lastAsync: Node, lastReadonly: Node; let flags = ModifierFlags.None; for (const modifier of node.modifiers) { if (modifier.kind !== SyntaxKind.ReadonlyKeyword) { @@ -24014,13 +24031,6 @@ namespace ts { case SyntaxKind.PrivateKeyword: const text = visibilityToString(modifierToFlag(modifier.kind)); - if (modifier.kind === SyntaxKind.ProtectedKeyword) { - lastProtected = modifier; - } - else if (modifier.kind === SyntaxKind.PrivateKeyword) { - lastPrivate = modifier; - } - if (flags & ModifierFlags.AccessibilityModifier) { return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9c0b549da50..af7f6d6c949 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3102,7 +3102,7 @@ "category": "Message", "code": 6132 }, - "'{0}' is declared but never used.": { + "'{0}' is declared but its value is never read.": { "category": "Error", "code": 6133 }, @@ -3122,7 +3122,7 @@ "category": "Error", "code": 6137 }, - "Property '{0}' is declared but never used.": { + "Property '{0}' is declared but its value is never read.": { "category": "Error", "code": 6138 }, diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 85a44e35983..90c9063c140 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -21,9 +21,6 @@ namespace ts { const compilerOptions = context.getCompilerOptions(); const languageVersion = getEmitScriptTarget(compilerOptions); - // These variables contain state that changes as we descend into the tree. - let currentSourceFile: SourceFile; - /** * Keeps track of whether expression substitution has been enabled for specific edge cases. * They are persisted between each SourceFile transformation and should not be reset. @@ -51,12 +48,8 @@ namespace ts { return node; } - currentSourceFile = node; - const visited = visitEachChild(node, visitor, context); addEmitHelpers(visited, context.readEmitHelpers()); - - currentSourceFile = undefined; return visited; } diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 20195adeef4..06ecae3a63f 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -244,7 +244,6 @@ namespace ts { const previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - let currentSourceFile: SourceFile; let renamedCatchVariables: Map; let renamedCatchVariableDeclarations: Identifier[]; @@ -300,12 +299,9 @@ namespace ts { return node; } - currentSourceFile = node; const visited = visitEachChild(node, visitor, context); addEmitHelpers(visited, context.readEmitHelpers()); - - currentSourceFile = undefined; return visited; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index d5e584c7ac5..b109b166f5c 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -100,7 +100,6 @@ namespace ts { const commandLine = parseCommandLine(args); let configFileName: string; // Configuration file name (if any) let cachedConfigFileText: string; // Cached configuration file text, used for reparsing (if any) - let configFileWatcher: FileWatcher; // Configuration file watcher let directoryWatcher: FileWatcher; // Directory watcher to monitor source file addition/removal let cachedProgram: Program; // Program cached from last compilation let rootFileNames: string[]; // Root fileNames for compilation @@ -189,7 +188,7 @@ namespace ts { return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (configFileName) { - configFileWatcher = sys.watchFile(configFileName, configFileChanged); + sys.watchFile(configFileName, configFileChanged); } if (sys.watchDirectory && configFileName) { const directory = ts.getDirectoryPath(configFileName); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 31e03672281..64d5bcaac62 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3502,6 +3502,46 @@ namespace ts { export function getCombinedLocalAndExportSymbolFlags(symbol: Symbol): SymbolFlags { return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags; } + + export function isWriteOnlyAccess(node: Node) { + return accessKind(node) === AccessKind.Write; + } + + export function isWriteAccess(node: Node) { + return accessKind(node) !== AccessKind.Read; + } + + const enum AccessKind { + /** Only reads from a variable. */ + Read, + /** Only writes to a variable without using the result. E.g.: `x++;`. */ + Write, + /** Writes to a variable and uses the result as an expression. E.g.: `f(x++);`. */ + ReadWrite + } + function accessKind(node: Node): AccessKind { + const { parent } = node; + if (!parent) return AccessKind.Read; + + switch (parent.kind) { + case SyntaxKind.PostfixUnaryExpression: + case SyntaxKind.PrefixUnaryExpression: + const { operator } = parent as PrefixUnaryExpression | PostfixUnaryExpression; + return operator === SyntaxKind.PlusPlusToken || operator === SyntaxKind.MinusMinusToken ? writeOrReadWrite() : AccessKind.Read; + case SyntaxKind.BinaryExpression: + const { left, operatorToken } = parent as BinaryExpression; + return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : AccessKind.Read; + case SyntaxKind.PropertyAccessExpression: + return (parent as PropertyAccessExpression).name !== node ? AccessKind.Read : accessKind(parent); + default: + return AccessKind.Read; + } + + function writeOrReadWrite(): AccessKind { + // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. + return parent.parent && parent.parent.kind === SyntaxKind.ExpressionStatement ? AccessKind.Write : AccessKind.ReadWrite; + } + } } namespace ts { diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index a600c7dd857..dc3aa64c6ac 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -11,19 +11,13 @@ const enum CompilerTestType { class CompilerBaselineRunner extends RunnerBase { private basePath = "tests/cases"; private testSuiteName: TestRunnerKind; - private errors: boolean; private emit: boolean; - private decl: boolean; - private output: boolean; public options: string; constructor(public testType: CompilerTestType) { super(); - this.errors = true; this.emit = true; - this.decl = true; - this.output = true; if (testType === CompilerTestType.Conformance) { this.testSuiteName = "conformance"; } @@ -214,26 +208,14 @@ class CompilerBaselineRunner extends RunnerBase { private parseOptions() { if (this.options && this.options.length > 0) { - this.errors = false; this.emit = false; - this.decl = false; - this.output = false; const opts = this.options.split(","); for (let i = 0; i < opts.length; i++) { switch (opts[i]) { - case "error": - this.errors = true; - break; case "emit": this.emit = true; break; - case "decl": - this.decl = true; - break; - case "output": - this.output = true; - break; default: throw new Error("unsupported flag"); } diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index e4b84e848c6..1545390de8d 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -55,7 +55,6 @@ namespace ts.projectSystem { let configFile: FileOrFolder; let changeModuleFile1ShapeRequest1: server.protocol.Request; let changeModuleFile1InternalRequest1: server.protocol.Request; - let changeModuleFile1ShapeRequest2: server.protocol.Request; // A compile on save affected file request using file1 let moduleFile1FileListRequest: server.protocol.Request; @@ -112,16 +111,6 @@ namespace ts.projectSystem { insertString: `var T1: number;` }); - // Change the content of file1 to `export var T: number;export function Foo() { };` - changeModuleFile1ShapeRequest2 = makeSessionRequest(CommandNames.Change, { - file: moduleFile1.path, - line: 1, - offset: 1, - endLine: 1, - endOffset: 1, - insertString: `export var T2: number;` - }); - moduleFile1FileListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path, projectFileName: configFile.path }); }); diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index de8ceb7f984..df0c1dd9095 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -366,13 +366,11 @@ namespace ts.projectSystem { }; const host = createServerHost([file1, file2]); - let enqueueIsCalled = false; const installer = new (class extends Installer { constructor() { super(host, { typesRegistry: createTypesRegistry("jquery") }); } enqueueInstallTypingsRequest(project: server.Project, typeAcquisition: TypeAcquisition, unresolvedImports: server.SortedReadonlyArray) { - enqueueIsCalled = true; super.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); } installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { diff --git a/src/server/server.ts b/src/server/server.ts index 6b6535c8cac..f031d5f0cfc 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -585,7 +585,6 @@ namespace ts.server { function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) { const watchedFiles: WatchedFile[] = []; let nextFileToCheck = 0; - let watchTimer: any; return { getModifiedTime, poll, startWatchTimer, addFile, removeFile }; function getModifiedTime(fileName: string): Date { @@ -622,7 +621,7 @@ namespace ts.server { // stat due to inconsistencies of fs.watch // and efficiency of stat on modern filesystems function startWatchTimer() { - watchTimer = setInterval(() => { + setInterval(() => { let count = 0; let nextToCheck = nextFileToCheck; let firstCheck = -1; diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 530a4543ec4..090aefbb8ca 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -2,8 +2,8 @@ namespace ts.codefix { registerCodeFix({ errorCodes: [ - Diagnostics._0_is_declared_but_never_used.code, - Diagnostics.Property_0_is_declared_but_never_used.code + Diagnostics._0_is_declared_but_its_value_is_never_read.code, + Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code ], getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index b12b0f85fda..80194c5649b 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -175,7 +175,7 @@ namespace ts.FindAllReferences { return { fileName: node.getSourceFile().fileName, textSpan: getTextSpan(node), - isWriteAccess: isWriteAccess(node), + isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node), @@ -224,7 +224,7 @@ namespace ts.FindAllReferences { const { node, isInString } = entry; const fileName = entry.node.getSourceFile().fileName; - const writeAccess = isWriteAccess(node); + const writeAccess = isWriteAccessForReference(node); const span: HighlightSpan = { textSpan: getTextSpan(node), kind: writeAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference, @@ -244,21 +244,8 @@ namespace ts.FindAllReferences { } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ - function isWriteAccess(node: Node): boolean { - if (node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node)) { - return true; - } - - const { parent } = node; - switch (parent && parent.kind) { - case SyntaxKind.PostfixUnaryExpression: - case SyntaxKind.PrefixUnaryExpression: - return true; - case SyntaxKind.BinaryExpression: - return (parent).left === node && isAssignmentOperator((parent).operatorToken.kind); - default: - return false; - } + function isWriteAccessForReference(node: Node): boolean { + return node.kind === SyntaxKind.DefaultKeyword || isAnyDeclarationName(node) || isWriteAccess(node); } } diff --git a/src/services/preProcess.ts b/src/services/preProcess.ts index 106759a3a28..8f6a468be64 100644 --- a/src/services/preProcess.ts +++ b/src/services/preProcess.ts @@ -273,13 +273,11 @@ namespace ts { // skip open bracket token = nextToken(); - let i = 0; // scan until ']' or EOF while (token !== SyntaxKind.CloseBracketToken && token !== SyntaxKind.EndOfFileToken) { // record string literals as module names if (token === SyntaxKind.StringLiteral) { recordModuleName(); - i++; } token = nextToken(); diff --git a/tests/baselines/reference/extendsUntypedModule.errors.txt b/tests/baselines/reference/extendsUntypedModule.errors.txt index 4667f16b74a..8df9e8a1c36 100644 --- a/tests/baselines/reference/extendsUntypedModule.errors.txt +++ b/tests/baselines/reference/extendsUntypedModule.errors.txt @@ -1,11 +1,11 @@ -/a.ts(2,8): error TS6133: 'Bar' is declared but never used. +/a.ts(2,8): error TS6133: 'Bar' is declared but its value is never read. ==== /a.ts (1 errors) ==== import Foo from "foo"; import Bar from "bar"; // error: unused ~~~ -!!! error TS6133: 'Bar' is declared but never used. +!!! error TS6133: 'Bar' is declared but its value is never read. export class A extends Foo { } ==== /node_modules/foo/index.js (0 errors) ==== diff --git a/tests/baselines/reference/noUnusedLocals_selfReference.errors.txt b/tests/baselines/reference/noUnusedLocals_selfReference.errors.txt index af40081e71c..e4a0d478cb4 100644 --- a/tests/baselines/reference/noUnusedLocals_selfReference.errors.txt +++ b/tests/baselines/reference/noUnusedLocals_selfReference.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/noUnusedLocals_selfReference.ts(3,10): error TS6133: 'f' is declared but never used. -tests/cases/compiler/noUnusedLocals_selfReference.ts(4,7): error TS6133: 'C' is declared but never used. -tests/cases/compiler/noUnusedLocals_selfReference.ts(7,6): error TS6133: 'E' is declared but never used. +tests/cases/compiler/noUnusedLocals_selfReference.ts(3,10): error TS6133: 'f' is declared but its value is never read. +tests/cases/compiler/noUnusedLocals_selfReference.ts(4,7): error TS6133: 'C' is declared but its value is never read. +tests/cases/compiler/noUnusedLocals_selfReference.ts(7,6): error TS6133: 'E' is declared but its value is never read. ==== tests/cases/compiler/noUnusedLocals_selfReference.ts (3 errors) ==== @@ -8,15 +8,15 @@ tests/cases/compiler/noUnusedLocals_selfReference.ts(7,6): error TS6133: 'E' is function f() { f; } ~ -!!! error TS6133: 'f' is declared but never used. +!!! error TS6133: 'f' is declared but its value is never read. class C { ~ -!!! error TS6133: 'C' is declared but never used. +!!! error TS6133: 'C' is declared but its value is never read. m() { C; } } enum E { A = 0, B = E.A } ~ -!!! error TS6133: 'E' is declared but never used. +!!! error TS6133: 'E' is declared but its value is never read. // Does not detect mutual recursion. function g() { D; } diff --git a/tests/baselines/reference/noUnusedLocals_writeOnly.errors.txt b/tests/baselines/reference/noUnusedLocals_writeOnly.errors.txt new file mode 100644 index 00000000000..355bec02eb9 --- /dev/null +++ b/tests/baselines/reference/noUnusedLocals_writeOnly.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/noUnusedLocals_writeOnly.ts(1,12): error TS6133: 'x' is declared but its value is never read. + + +==== tests/cases/compiler/noUnusedLocals_writeOnly.ts (1 errors) ==== + function f(x = 0) { + ~ +!!! error TS6133: 'x' is declared but its value is never read. + x = 1; + x++; + x /= 2; + + let y = 0; + // This is a write access to y, but not a write-*only* access. + f(y++); + } + \ No newline at end of file diff --git a/tests/baselines/reference/noUnusedLocals_writeOnly.js b/tests/baselines/reference/noUnusedLocals_writeOnly.js new file mode 100644 index 00000000000..40529f690cd --- /dev/null +++ b/tests/baselines/reference/noUnusedLocals_writeOnly.js @@ -0,0 +1,22 @@ +//// [noUnusedLocals_writeOnly.ts] +function f(x = 0) { + x = 1; + x++; + x /= 2; + + let y = 0; + // This is a write access to y, but not a write-*only* access. + f(y++); +} + + +//// [noUnusedLocals_writeOnly.js] +function f(x) { + if (x === void 0) { x = 0; } + x = 1; + x++; + x /= 2; + var y = 0; + // This is a write access to y, but not a write-*only* access. + f(y++); +} diff --git a/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.errors.txt b/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.errors.txt new file mode 100644 index 00000000000..3f947c71473 --- /dev/null +++ b/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts(2,13): error TS6133: 'x' is declared but its value is never read. + + +==== tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts (1 errors) ==== + class C { + private x; + ~ +!!! error TS6133: 'x' is declared but its value is never read. + m() { + this.x = 0; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.js b/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.js new file mode 100644 index 00000000000..1ac4efa8dde --- /dev/null +++ b/tests/baselines/reference/noUnusedLocals_writeOnlyProperty.js @@ -0,0 +1,18 @@ +//// [noUnusedLocals_writeOnlyProperty.ts] +class C { + private x; + m() { + this.x = 0; + } +} + + +//// [noUnusedLocals_writeOnlyProperty.js] +var C = /** @class */ (function () { + function C() { + } + C.prototype.m = function () { + this.x = 0; + }; + return C; +}()); diff --git a/tests/baselines/reference/unusedClassesinModule1.errors.txt b/tests/baselines/reference/unusedClassesinModule1.errors.txt index b3e8c3009cd..b7d0da8fc2d 100644 --- a/tests/baselines/reference/unusedClassesinModule1.errors.txt +++ b/tests/baselines/reference/unusedClassesinModule1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedClassesinModule1.ts(2,11): error TS6133: 'Calculator' is declared but never used. +tests/cases/compiler/unusedClassesinModule1.ts(2,11): error TS6133: 'Calculator' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinModule1.ts (1 errors) ==== module A { class Calculator { ~~~~~~~~~~ -!!! error TS6133: 'Calculator' is declared but never used. +!!! error TS6133: 'Calculator' is declared but its value is never read. public handelChar() { } } diff --git a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt index 57f3e003242..2df9f918e7d 100644 --- a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedClassesinNamespace1.ts(2,11): error TS6133: 'c1' is declared but never used. +tests/cases/compiler/unusedClassesinNamespace1.ts(2,11): error TS6133: 'c1' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinNamespace1.ts (1 errors) ==== namespace Validation { class c1 { ~~ -!!! error TS6133: 'c1' is declared but never used. +!!! error TS6133: 'c1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt index e8f9c659d0d..2425ea02e51 100644 --- a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedClassesinNamespace2.ts(2,11): error TS6133: 'c1' is declared but never used. +tests/cases/compiler/unusedClassesinNamespace2.ts(2,11): error TS6133: 'c1' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinNamespace2.ts (1 errors) ==== namespace Validation { class c1 { ~~ -!!! error TS6133: 'c1' is declared but never used. +!!! error TS6133: 'c1' is declared but its value is never read. } diff --git a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt index b2ddfe3f3f6..719689fbca3 100644 --- a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace4.ts(10,11): error TS6133: 'c3' is declared but never used. +tests/cases/compiler/unusedClassesinNamespace4.ts(10,11): error TS6133: 'c3' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinNamespace4.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/unusedClassesinNamespace4.ts(10,11): error TS6133: 'c3' is class c3 extends c1 { ~~ -!!! error TS6133: 'c3' is declared but never used. +!!! error TS6133: 'c3' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt index 29c08c9a107..7f7f5cf1b7a 100644 --- a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace5.ts(10,11): error TS6133: 'c3' is declared but never used. +tests/cases/compiler/unusedClassesinNamespace5.ts(10,11): error TS6133: 'c3' is declared but its value is never read. ==== tests/cases/compiler/unusedClassesinNamespace5.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/unusedClassesinNamespace5.ts(10,11): error TS6133: 'c3' is class c3 { ~~ -!!! error TS6133: 'c3' is declared but never used. +!!! error TS6133: 'c3' is declared but its value is never read. public x: c1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedDestructuringParameters.errors.txt b/tests/baselines/reference/unusedDestructuringParameters.errors.txt index b6814df6b7a..24a7b3838cd 100644 --- a/tests/baselines/reference/unusedDestructuringParameters.errors.txt +++ b/tests/baselines/reference/unusedDestructuringParameters.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/unusedDestructuringParameters.ts(1,13): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedDestructuringParameters.ts(3,14): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedDestructuringParameters.ts(1,13): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedDestructuringParameters.ts(3,14): error TS6133: 'a' is declared but its value is never read. ==== tests/cases/compiler/unusedDestructuringParameters.ts (2 errors) ==== const f = ([a]) => { }; ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. f([1]); const f2 = ({a}) => { }; ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. f2({ a: 10 }); const f3 = ([_]) => { }; f3([10]); \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt index 6d59137b4b7..202977c6fb7 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedFunctionsinNamespaces1.ts(2,14): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces1.ts(2,14): error TS6133: 'function1' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces1.ts (1 errors) ==== namespace Validation { function function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt index 68fffcc4f51..eec94fee215 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedFunctionsinNamespaces2.ts(2,9): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces2.ts(2,9): error TS6133: 'function1' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces2.ts (1 errors) ==== namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt index 0046d4eb116..8761ec400b1 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(2,9): error TS6133: 'function1' is declared but never used. -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(2,30): error TS6133: 'param1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(2,9): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(2,30): error TS6133: 'param1' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces3.ts (2 errors) ==== namespace Validation { var function1 = function(param1:string) { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. ~~~~~~ -!!! error TS6133: 'param1' is declared but never used. +!!! error TS6133: 'param1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt index c012f671427..feb8f8158db 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedFunctionsinNamespaces4.ts(2,9): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces4.ts(2,9): error TS6133: 'function1' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces4.ts (1 errors) ==== namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. } export function function2() { diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt index 0c7a6321922..8f7f617e559 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(9,14): error TS6133: 'function3' is declared but never used. -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(13,14): error TS6133: 'function4' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(9,14): error TS6133: 'function3' is declared but its value is never read. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(13,14): error TS6133: 'function4' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces5.ts (2 errors) ==== @@ -13,13 +13,13 @@ tests/cases/compiler/unusedFunctionsinNamespaces5.ts(13,14): error TS6133: 'func function function3() { ~~~~~~~~~ -!!! error TS6133: 'function3' is declared but never used. +!!! error TS6133: 'function3' is declared but its value is never read. function1(); } function function4() { ~~~~~~~~~ -!!! error TS6133: 'function4' is declared but never used. +!!! error TS6133: 'function4' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt index a3ab17655b2..de5f7ae4d87 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces6.ts(13,14): error TS6133: 'function4' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces6.ts(13,14): error TS6133: 'function4' is declared but its value is never read. ==== tests/cases/compiler/unusedFunctionsinNamespaces6.ts (1 errors) ==== @@ -16,7 +16,7 @@ tests/cases/compiler/unusedFunctionsinNamespaces6.ts(13,14): error TS6133: 'func function function4() { ~~~~~~~~~ -!!! error TS6133: 'function4' is declared but never used. +!!! error TS6133: 'function4' is declared but its value is never read. } diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt index 51db8356293..c327dc4b19b 100644 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -1,55 +1,58 @@ -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(5,32): error TS6133: 'unusedtypeparameter' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,13): error TS6133: 'unusedprivatevariable' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(11,17): error TS6133: 'message' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(16,20): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,13): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(24,13): error TS6133: 'unUsedPrivateFunction' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(37,11): error TS6133: 'numberRegexp' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(44,17): error TS6133: 'unUsedPrivateFunction' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(57,15): error TS6133: 'usedLocallyInterface2' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(64,11): error TS6133: 'dummy' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(67,15): error TS6133: 'unusedInterface' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(79,11): error TS6133: 'class3' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'interface5' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(5,32): error TS6133: 'unusedtypeparameter' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,13): error TS6133: 'unusedprivatevariable' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,13): error TS6133: 'greeting' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(11,17): error TS6133: 'message' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(16,20): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,13): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(24,13): error TS6133: 'unUsedPrivateFunction' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(37,11): error TS6133: 'numberRegexp' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(44,17): error TS6133: 'unUsedPrivateFunction' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(57,15): error TS6133: 'usedLocallyInterface2' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(64,11): error TS6133: 'dummy' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(67,15): error TS6133: 'unusedInterface' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(79,11): error TS6133: 'class3' is declared but its value is never read. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'interface5' is declared but its value is never read. -==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== +==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (17 errors) ==== function greeter(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } class Dummy { ~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'unusedtypeparameter' is declared but never used. +!!! error TS6133: 'unusedtypeparameter' is declared but its value is never read. private unusedprivatevariable: string; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'unusedprivatevariable' is declared but never used. +!!! error TS6133: 'unusedprivatevariable' is declared but its value is never read. private greeting: string; + ~~~~~~~~ +!!! error TS6133: 'greeting' is declared but its value is never read. public unusedpublicvariable: string; public typedvariable: usedtypeparameter; constructor(message: string) { ~~~~~~~ -!!! error TS6133: 'message' is declared but never used. +!!! error TS6133: 'message' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. this.greeting = "Dummy Message"; } public greeter(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. this.usedPrivateFunction(); } @@ -58,7 +61,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'unUsedPrivateFunction' is declared but never used. +!!! error TS6133: 'unUsedPrivateFunction' is declared but its value is never read. } } @@ -73,7 +76,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6133: 'numberRegexp' is declared but never used. +!!! error TS6133: 'numberRegexp' is declared but its value is never read. export class LettersOnlyValidator implements StringValidator { isAcceptable(s2: string) { @@ -82,7 +85,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'unUsedPrivateFunction' is declared but never used. +!!! error TS6133: 'unUsedPrivateFunction' is declared but its value is never read. } } @@ -97,7 +100,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in interface usedLocallyInterface2 { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'usedLocallyInterface2' is declared but never used. +!!! error TS6133: 'usedLocallyInterface2' is declared but its value is never read. someFunction(s1: string): void; } @@ -106,12 +109,12 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in class dummy implements usedLocallyInterface { ~~~~~ -!!! error TS6133: 'dummy' is declared but never used. +!!! error TS6133: 'dummy' is declared but its value is never read. } interface unusedInterface { ~~~~~~~~~~~~~~~ -!!! error TS6133: 'unusedInterface' is declared but never used. +!!! error TS6133: 'unusedInterface' is declared but its value is never read. } } @@ -125,7 +128,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in class class3 { ~~~~~~ -!!! error TS6133: 'class3' is declared but never used. +!!! error TS6133: 'class3' is declared but its value is never read. } export class class4 { @@ -147,6 +150,6 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(99,15): error TS6133: 'in interface interface5 { ~~~~~~~~~~ -!!! error TS6133: 'interface5' is declared but never used. +!!! error TS6133: 'interface5' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports1.errors.txt b/tests/baselines/reference/unusedImports1.errors.txt index ad5d52a861e..36963513146 100644 --- a/tests/baselines/reference/unusedImports1.errors.txt +++ b/tests/baselines/reference/unusedImports1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but never used. +tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -9,4 +9,4 @@ tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but n ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator} from "./file1" ~~~~~~~~~~ -!!! error TS6133: 'Calculator' is declared but never used. \ No newline at end of file +!!! error TS6133: 'Calculator' is declared but its value is never read. \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports10.errors.txt b/tests/baselines/reference/unusedImports10.errors.txt index 916f9f8e46d..b9688a01185 100644 --- a/tests/baselines/reference/unusedImports10.errors.txt +++ b/tests/baselines/reference/unusedImports10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedImports10.ts(9,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedImports10.ts(9,12): error TS6133: 'a' is declared but its value is never read. ==== tests/cases/compiler/unusedImports10.ts (1 errors) ==== @@ -12,5 +12,5 @@ tests/cases/compiler/unusedImports10.ts(9,12): error TS6133: 'a' is declared but module B { import a = A; ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports12.errors.txt b/tests/baselines/reference/unusedImports12.errors.txt index 7c4e581bf2f..56df4edc5e3 100644 --- a/tests/baselines/reference/unusedImports12.errors.txt +++ b/tests/baselines/reference/unusedImports12.errors.txt @@ -1,25 +1,25 @@ -tests/cases/compiler/a.ts(1,10): error TS6133: 'Member' is declared but never used. -tests/cases/compiler/a.ts(2,8): error TS6133: 'd' is declared but never used. -tests/cases/compiler/a.ts(2,23): error TS6133: 'M' is declared but never used. -tests/cases/compiler/a.ts(3,13): error TS6133: 'ns' is declared but never used. -tests/cases/compiler/a.ts(4,8): error TS6133: 'r' is declared but never used. +tests/cases/compiler/a.ts(1,10): error TS6133: 'Member' is declared but its value is never read. +tests/cases/compiler/a.ts(2,8): error TS6133: 'd' is declared but its value is never read. +tests/cases/compiler/a.ts(2,23): error TS6133: 'M' is declared but its value is never read. +tests/cases/compiler/a.ts(3,13): error TS6133: 'ns' is declared but its value is never read. +tests/cases/compiler/a.ts(4,8): error TS6133: 'r' is declared but its value is never read. ==== tests/cases/compiler/a.ts (5 errors) ==== import { Member } from './b'; ~~~~~~ -!!! error TS6133: 'Member' is declared but never used. +!!! error TS6133: 'Member' is declared but its value is never read. import d, { Member as M } from './b'; ~ -!!! error TS6133: 'd' is declared but never used. +!!! error TS6133: 'd' is declared but its value is never read. ~ -!!! error TS6133: 'M' is declared but never used. +!!! error TS6133: 'M' is declared but its value is never read. import * as ns from './b'; ~~ -!!! error TS6133: 'ns' is declared but never used. +!!! error TS6133: 'ns' is declared but its value is never read. import r = require("./b"); ~ -!!! error TS6133: 'r' is declared but never used. +!!! error TS6133: 'r' is declared but its value is never read. ==== tests/cases/compiler/b.ts (0 errors) ==== export class Member {} diff --git a/tests/baselines/reference/unusedImports2.errors.txt b/tests/baselines/reference/unusedImports2.errors.txt index 6755a432b48..c037eea2f51 100644 --- a/tests/baselines/reference/unusedImports2.errors.txt +++ b/tests/baselines/reference/unusedImports2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(2,9): error TS6133: 'test' is declared but never used. +tests/cases/compiler/file2.ts(2,9): error TS6133: 'test' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/file2.ts(2,9): error TS6133: 'test' is declared but never u import {Calculator} from "./file1" import {test} from "./file1" ~~~~ -!!! error TS6133: 'test' is declared but never used. +!!! error TS6133: 'test' is declared but its value is never read. var x = new Calculator(); x.handleChar(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports3.errors.txt b/tests/baselines/reference/unusedImports3.errors.txt index b63087466fe..5271d72cf77 100644 --- a/tests/baselines/reference/unusedImports3.errors.txt +++ b/tests/baselines/reference/unusedImports3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but never used. +tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but n ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator, test, test2} from "./file1" ~~~~~~~~~~ -!!! error TS6133: 'Calculator' is declared but never used. +!!! error TS6133: 'Calculator' is declared but its value is never read. test(); test2(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports4.errors.txt b/tests/baselines/reference/unusedImports4.errors.txt index c57bc534137..7f475e2967e 100644 --- a/tests/baselines/reference/unusedImports4.errors.txt +++ b/tests/baselines/reference/unusedImports4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,21): error TS6133: 'test' is declared but never used. +tests/cases/compiler/file2.ts(1,21): error TS6133: 'test' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,21): error TS6133: 'test' is declared but never ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator, test, test2} from "./file1" ~~~~ -!!! error TS6133: 'test' is declared but never used. +!!! error TS6133: 'test' is declared but its value is never read. var x = new Calculator(); x.handleChar(); diff --git a/tests/baselines/reference/unusedImports5.errors.txt b/tests/baselines/reference/unusedImports5.errors.txt index 10fc097237c..4b433db9b7c 100644 --- a/tests/baselines/reference/unusedImports5.errors.txt +++ b/tests/baselines/reference/unusedImports5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,27): error TS6133: 'test2' is declared but never used. +tests/cases/compiler/file2.ts(1,27): error TS6133: 'test2' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,27): error TS6133: 'test2' is declared but never ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator, test, test2} from "./file1" ~~~~~ -!!! error TS6133: 'test2' is declared but never used. +!!! error TS6133: 'test2' is declared but its value is never read. var x = new Calculator(); x.handleChar(); diff --git a/tests/baselines/reference/unusedImports6.errors.txt b/tests/baselines/reference/unusedImports6.errors.txt index ed9b9c43ee8..28b2d1a2875 100644 --- a/tests/baselines/reference/unusedImports6.errors.txt +++ b/tests/baselines/reference/unusedImports6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,8): error TS6133: 'd' is declared but never used. +tests/cases/compiler/file2.ts(1,8): error TS6133: 'd' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,8): error TS6133: 'd' is declared but never used ==== tests/cases/compiler/file2.ts (1 errors) ==== import d from "./file1" ~ -!!! error TS6133: 'd' is declared but never used. +!!! error TS6133: 'd' is declared but its value is never read. diff --git a/tests/baselines/reference/unusedImports7.errors.txt b/tests/baselines/reference/unusedImports7.errors.txt index ac3a82a7f4d..9482a2c6f47 100644 --- a/tests/baselines/reference/unusedImports7.errors.txt +++ b/tests/baselines/reference/unusedImports7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,13): error TS6133: 'n' is declared but never used. +tests/cases/compiler/file2.ts(1,13): error TS6133: 'n' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,6 +17,6 @@ tests/cases/compiler/file2.ts(1,13): error TS6133: 'n' is declared but never use ==== tests/cases/compiler/file2.ts (1 errors) ==== import * as n from "./file1" ~ -!!! error TS6133: 'n' is declared but never used. +!!! error TS6133: 'n' is declared but its value is never read. \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports8.errors.txt b/tests/baselines/reference/unusedImports8.errors.txt index 1c9d7a5ae8c..a6cbaae8ff6 100644 --- a/tests/baselines/reference/unusedImports8.errors.txt +++ b/tests/baselines/reference/unusedImports8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,50): error TS6133: 't2' is declared but never used. +tests/cases/compiler/file2.ts(1,50): error TS6133: 't2' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,50): error TS6133: 't2' is declared but never us ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator as calc, test as t1, test2 as t2} from "./file1" ~~ -!!! error TS6133: 't2' is declared but never used. +!!! error TS6133: 't2' is declared but its value is never read. var x = new calc(); x.handleChar(); diff --git a/tests/baselines/reference/unusedImports9.errors.txt b/tests/baselines/reference/unusedImports9.errors.txt index d46f0b68284..2452962b289 100644 --- a/tests/baselines/reference/unusedImports9.errors.txt +++ b/tests/baselines/reference/unusedImports9.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/file2.ts(1,8): error TS6133: 'c' is declared but never used. +tests/cases/compiler/file2.ts(1,8): error TS6133: 'c' is declared but its value is never read. ==== tests/cases/compiler/file2.ts (1 errors) ==== import c = require('./file1') ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. ==== tests/cases/compiler/file1.ts (0 errors) ==== export class Calculator { handleChar() {} diff --git a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt index eac7c6301df..613852735de 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedInterfaceinNamespace1.ts(2,15): error TS6133: 'i1' is declared but never used. +tests/cases/compiler/unusedInterfaceinNamespace1.ts(2,15): error TS6133: 'i1' is declared but its value is never read. ==== tests/cases/compiler/unusedInterfaceinNamespace1.ts (1 errors) ==== namespace Validation { interface i1 { ~~ -!!! error TS6133: 'i1' is declared but never used. +!!! error TS6133: 'i1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt index 1e8ea56ea0e..9ce75e393fe 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedInterfaceinNamespace2.ts(2,15): error TS6133: 'i1' is declared but never used. +tests/cases/compiler/unusedInterfaceinNamespace2.ts(2,15): error TS6133: 'i1' is declared but its value is never read. ==== tests/cases/compiler/unusedInterfaceinNamespace2.ts (1 errors) ==== namespace Validation { interface i1 { ~~ -!!! error TS6133: 'i1' is declared but never used. +!!! error TS6133: 'i1' is declared but its value is never read. } diff --git a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt index 519244e4c5d..b1b1cbb9b86 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace3.ts(10,15): error TS6133: 'i3' is declared but never used. +tests/cases/compiler/unusedInterfaceinNamespace3.ts(10,15): error TS6133: 'i3' is declared but its value is never read. ==== tests/cases/compiler/unusedInterfaceinNamespace3.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/unusedInterfaceinNamespace3.ts(10,15): error TS6133: 'i3' i interface i3 extends i1 { ~~ -!!! error TS6133: 'i3' is declared but never used. +!!! error TS6133: 'i3' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndObjectSpread.errors.txt b/tests/baselines/reference/unusedLocalsAndObjectSpread.errors.txt index 4dfd37f7668..c3f89f32488 100644 --- a/tests/baselines/reference/unusedLocalsAndObjectSpread.errors.txt +++ b/tests/baselines/reference/unusedLocalsAndObjectSpread.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedLocalsAndObjectSpread.ts(20,18): error TS6133: 'bar' is declared but never used. -tests/cases/compiler/unusedLocalsAndObjectSpread.ts(27,21): error TS6133: 'bar' is declared but never used. +tests/cases/compiler/unusedLocalsAndObjectSpread.ts(20,18): error TS6133: 'bar' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndObjectSpread.ts(27,21): error TS6133: 'bar' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsAndObjectSpread.ts (2 errors) ==== @@ -24,7 +24,7 @@ tests/cases/compiler/unusedLocalsAndObjectSpread.ts(27,21): error TS6133: 'bar' // 'a' is declared but never used const {a, ...bar} = foo; // bar should be unused ~~~ -!!! error TS6133: 'bar' is declared but never used. +!!! error TS6133: 'bar' is declared but its value is never read. //console.log(bar); } @@ -33,7 +33,7 @@ tests/cases/compiler/unusedLocalsAndObjectSpread.ts(27,21): error TS6133: 'bar' // '_' is declared but never used const {a: _, ...bar} = foo; // bar should be unused ~~~ -!!! error TS6133: 'bar' is declared but never used. +!!! error TS6133: 'bar' is declared but its value is never read. //console.log(bar); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt b/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt index 57d265e3b7e..2e29bf04608 100644 --- a/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt +++ b/tests/baselines/reference/unusedLocalsAndObjectSpread2.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(5,6): error TS6133: 'rest' is declared but never used. -tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(8,10): error TS6133: 'foo' is declared but never used. -tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(12,8): error TS6133: 'rest' is declared but never used. +tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(5,6): error TS6133: 'rest' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(8,10): error TS6133: 'foo' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(12,8): error TS6133: 'rest' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsAndObjectSpread2.ts (3 errors) ==== @@ -10,18 +10,18 @@ tests/cases/compiler/unusedLocalsAndObjectSpread2.ts(12,8): error TS6133: 'rest' active: _a, // here! ...rest, ~~~~ -!!! error TS6133: 'rest' is declared but never used. +!!! error TS6133: 'rest' is declared but its value is never read. } = props; function foo() { ~~~ -!!! error TS6133: 'foo' is declared but never used. +!!! error TS6133: 'foo' is declared but its value is never read. const { children, active: _a, ...rest, ~~~~ -!!! error TS6133: 'rest' is declared but never used. +!!! error TS6133: 'rest' is declared but its value is never read. } = props; } diff --git a/tests/baselines/reference/unusedLocalsAndParameters.errors.txt b/tests/baselines/reference/unusedLocalsAndParameters.errors.txt index 2416b29c216..01fcdd4f225 100644 --- a/tests/baselines/reference/unusedLocalsAndParameters.errors.txt +++ b/tests/baselines/reference/unusedLocalsAndParameters.errors.txt @@ -1,27 +1,27 @@ -tests/cases/compiler/unusedLocalsAndParameters.ts(4,12): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(9,22): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(15,5): error TS6133: 'farrow' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(15,15): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(18,7): error TS6133: 'C' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(20,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(4,12): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(9,22): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(15,5): error TS6133: 'farrow' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(15,15): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(18,7): error TS6133: 'C' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(20,12): error TS6133: 'a' is declared but its value is never read. tests/cases/compiler/unusedLocalsAndParameters.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/unusedLocalsAndParameters.ts(23,11): error TS6133: 'v' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(27,5): error TS6133: 'E' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(29,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(23,11): error TS6133: 'v' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(27,5): error TS6133: 'E' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(29,12): error TS6133: 'a' is declared but its value is never read. tests/cases/compiler/unusedLocalsAndParameters.ts(32,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/unusedLocalsAndParameters.ts(32,11): error TS6133: 'v' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(38,12): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(32,11): error TS6133: 'v' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(38,12): error TS6133: 'a' is declared but its value is never read. tests/cases/compiler/unusedLocalsAndParameters.ts(41,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/unusedLocalsAndParameters.ts(41,11): error TS6133: 'v' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(48,10): error TS6133: 'i' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(52,10): error TS6133: 'i' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(56,17): error TS6133: 'n' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(63,11): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(68,11): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(71,11): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(74,11): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(79,11): error TS6133: 'N' is declared but never used. -tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedLocalsAndParameters.ts(41,11): error TS6133: 'v' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(48,10): error TS6133: 'i' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(52,10): error TS6133: 'i' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(56,17): error TS6133: 'n' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(63,11): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(68,11): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(71,11): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(74,11): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(79,11): error TS6133: 'N' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsAndParameters.ts (24 errors) ==== @@ -30,14 +30,14 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de // function declaration paramter function f(a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } f(0); // function expression paramter var fexp = function (a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. }; fexp(0); @@ -45,42 +45,42 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de // arrow function paramter var farrow = (a) => { ~~~~~~ -!!! error TS6133: 'farrow' is declared but never used. +!!! error TS6133: 'farrow' is declared but its value is never read. ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. }; class C { ~ -!!! error TS6133: 'C' is declared but never used. +!!! error TS6133: 'C' is declared but its value is never read. // Method declaration paramter method(a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } // Accessor declaration paramter set x(v: number) { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~ -!!! error TS6133: 'v' is declared but never used. +!!! error TS6133: 'v' is declared but its value is never read. } } var E = class { ~ -!!! error TS6133: 'E' is declared but never used. +!!! error TS6133: 'E' is declared but its value is never read. // Method declaration paramter method(a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } // Accessor declaration paramter set x(v: number) { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~ -!!! error TS6133: 'v' is declared but never used. +!!! error TS6133: 'v' is declared but its value is never read. } } @@ -88,14 +88,14 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de // Object literal method declaration paramter method(a) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. }, // Accessor declaration paramter set x(v: number) { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~ -!!! error TS6133: 'v' is declared but never used. +!!! error TS6133: 'v' is declared but its value is never read. } }; @@ -104,19 +104,19 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de // in a for..in statment for (let i in o) { ~ -!!! error TS6133: 'i' is declared but never used. +!!! error TS6133: 'i' is declared but its value is never read. } // in a for..of statment for (let i of [1, 2, 3]) { ~ -!!! error TS6133: 'i' is declared but never used. +!!! error TS6133: 'i' is declared but its value is never read. } // in a for. statment for (let i = 0, n; i < 10; i++) { ~ -!!! error TS6133: 'n' is declared but never used. +!!! error TS6133: 'n' is declared but its value is never read. } // in a block @@ -125,34 +125,34 @@ tests/cases/compiler/unusedLocalsAndParameters.ts(80,9): error TS6133: 'x' is de if (condition) { const c = 0; ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. } // in try/catch/finally try { const a = 0; ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. } catch (e) { const c = 1; ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. } finally { const c = 0; ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. } // in a namespace namespace N { ~ -!!! error TS6133: 'N' is declared but never used. +!!! error TS6133: 'N' is declared but its value is never read. var x; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt index e5c6f476480..e30dc92d394 100644 --- a/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt +++ b/tests/baselines/reference/unusedLocalsAndParametersTypeAliases2.errors.txt @@ -1,21 +1,21 @@ -tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(2,6): error TS6133: 'handler1' is declared but never used. -tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(5,10): error TS6133: 'foo' is declared but never used. -tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(6,10): error TS6133: 'handler2' is declared but never used. +tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(2,6): error TS6133: 'handler1' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(5,10): error TS6133: 'foo' is declared but its value is never read. +tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(6,10): error TS6133: 'handler2' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts (3 errors) ==== // unused type handler1 = () => void; ~~~~~~~~ -!!! error TS6133: 'handler1' is declared but never used. +!!! error TS6133: 'handler1' is declared but its value is never read. function foo() { ~~~ -!!! error TS6133: 'foo' is declared but never used. +!!! error TS6133: 'foo' is declared but its value is never read. type handler2 = () => void; ~~~~~~~~ -!!! error TS6133: 'handler2' is declared but never used. +!!! error TS6133: 'handler2' is declared but its value is never read. foo(); } diff --git a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt index 8406a009324..53802457794 100644 --- a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod1.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedLocalsInMethod1.ts(3,13): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsInMethod1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedLocalsInMethod1.ts(3,13): error TS6133: 'x' is declar public function1() { var x = 10; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt index 9aaa52ceee1..2aec1afb13a 100644 --- a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedLocalsInMethod2.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedLocalsInMethod2.ts(3,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedLocalsInMethod2.ts(3,16): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsInMethod2.ts (1 errors) ==== +==== tests/cases/compiler/unusedLocalsInMethod2.ts (2 errors) ==== class greeter { public function1() { var x, y = 10; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt index 3486f9d894e..6e34814457b 100644 --- a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedLocalsInMethod3.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedLocalsInMethod3.ts(3,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedLocalsInMethod3.ts(3,16): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsInMethod3.ts (1 errors) ==== +==== tests/cases/compiler/unusedLocalsInMethod3.ts (2 errors) ==== class greeter { public function1() { var x, y; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. + ~ +!!! error TS6133: 'y' is declared but its value is never read. y = 1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt index f3ace8acc9a..da5bc7382e3 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt @@ -1,25 +1,28 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,14): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,20): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(1,34): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,20): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (5 errors) ==== +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (6 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. function maker(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt index aacf8b9889f..e5326d2c41f 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,14): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,20): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(6,21): error TS6133: 'child2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,13): error TS6133: 'unused3' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,20): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(6,21): error TS6133: 'child2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,13): error TS6133: 'unused3' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. function maker(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } function maker2(child2: string): void { ~~~~~~ -!!! error TS6133: 'child2' is declared but never used. +!!! error TS6133: 'child2' is declared but its value is never read. var unused3 = 23; ~~~~~~~ -!!! error TS6133: 'unused3' is declared but never used. +!!! error TS6133: 'unused3' is declared but its value is never read. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt index b8ebdd2ad75..ac9b5c8632c 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt @@ -1,25 +1,28 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(1,25): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,14): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,20): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(1,25): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(1,41): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,20): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (5 errors) ==== +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (6 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. function maker(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt index b405993b0f5..c709d189d17 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(1,25): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,14): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,20): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(6,21): error TS6133: 'child2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,13): error TS6133: 'unused3' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(1,25): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,14): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,20): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(6,21): error TS6133: 'child2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,13): error TS6133: 'unused3' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. function maker(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } function maker2(child2: string): void { ~~~~~~ -!!! error TS6133: 'child2' is declared but never used. +!!! error TS6133: 'child2' is declared but its value is never read. var unused3 = 23; ~~~~~~~ -!!! error TS6133: 'unused3' is declared but never used. +!!! error TS6133: 'unused3' is declared but its value is never read. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt index 094ed3d338c..b68f8dbc94c 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt @@ -1,25 +1,28 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,27): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(1,34): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,27): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (5 errors) ==== +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (6 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var maker = function (child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt index a9887731ce3..58e9c46047c 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,26): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(6,27): error TS6133: 'child2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,13): error TS6133: 'unused3' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,26): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(6,27): error TS6133: 'child2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,13): error TS6133: 'unused3' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var maker = function(child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } var maker2 = function(child2: string): void { ~~~~~~ -!!! error TS6133: 'child2' is declared but never used. +!!! error TS6133: 'child2' is declared but its value is never read. var unused3 = 23; ~~~~~~~ -!!! error TS6133: 'unused3' is declared but never used. +!!! error TS6133: 'unused3' is declared but its value is never read. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt index 3ff247c3423..35f63193f48 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt @@ -1,25 +1,28 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(1,25): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,27): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(1,25): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(1,41): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,27): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. -==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (5 errors) ==== +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (6 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var maker = function (child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt index e5097afa44b..57fb73eb6ca 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(1,25): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,9): error TS6133: 'unused' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6133: 'maker' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,27): error TS6133: 'child' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,13): error TS6133: 'unused2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(6,28): error TS6133: 'child2' is declared but never used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,13): error TS6133: 'unused3' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(1,25): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,9): error TS6133: 'unused' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6133: 'maker' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,27): error TS6133: 'child' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,13): error TS6133: 'unused2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(6,28): error TS6133: 'child2' is declared but its value is never read. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,13): error TS6133: 'unused3' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var maker = function (child: string): void { ~~~~~ -!!! error TS6133: 'maker' is declared but never used. +!!! error TS6133: 'maker' is declared but its value is never read. ~~~~~ -!!! error TS6133: 'child' is declared but never used. +!!! error TS6133: 'child' is declared but its value is never read. var unused2 = 22; ~~~~~~~ -!!! error TS6133: 'unused2' is declared but never used. +!!! error TS6133: 'unused2' is declared but its value is never read. } var maker2 = function (child2: string): void { ~~~~~~ -!!! error TS6133: 'child2' is declared but never used. +!!! error TS6133: 'child2' is declared but its value is never read. var unused3 = 23; ~~~~~~~ -!!! error TS6133: 'unused3' is declared but never used. +!!! error TS6133: 'unused3' is declared but its value is never read. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt b/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt index 32f2acfe78b..b8a0a50fea6 100644 --- a/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt +++ b/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts(6,9): error TS6133: '_' is declared but never used. +tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts(6,9): error TS6133: '_' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts(6,9): error TS6133: ' namespace M { let _; ~ -!!! error TS6133: '_' is declared but never used. +!!! error TS6133: '_' is declared but its value is never read. for (const _ of []) { } for (const _ in []) { } diff --git a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt index 4831c09f40d..b0eb68286b5 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor1.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsinConstructor1.ts(3,13): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsinConstructor1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedLocalsinConstructor1.ts(3,13): error TS6133: 'unused' constructor() { var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt index 83127b6ecd9..32fb8bfccc8 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor2.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsinConstructor2.ts(3,13): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedLocalsinConstructor2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedLocalsinConstructor2.ts(3,13): error TS6133: 'unused' constructor() { var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. var used = "dummy"; used = used + "second part"; } diff --git a/tests/baselines/reference/unusedModuleInModule.errors.txt b/tests/baselines/reference/unusedModuleInModule.errors.txt index c558e7446fe..bd8040ce590 100644 --- a/tests/baselines/reference/unusedModuleInModule.errors.txt +++ b/tests/baselines/reference/unusedModuleInModule.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedModuleInModule.ts(2,12): error TS6133: 'B' is declared but never used. +tests/cases/compiler/unusedModuleInModule.ts(2,12): error TS6133: 'B' is declared but its value is never read. ==== tests/cases/compiler/unusedModuleInModule.ts (1 errors) ==== module A { module B {} ~ -!!! error TS6133: 'B' is declared but never used. +!!! error TS6133: 'B' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt index 5c2ccfc29e0..59a5af15888 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt @@ -1,15 +1,18 @@ -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(2,17): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(2,17): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(2,33): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,13): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== +==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (3 errors) ==== class Dummy { constructor(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt index 1405f9aae2c..26bc6f2c859 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(1,21): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(1,21): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(1,37): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (2 errors) ==== +==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (3 errors) ==== var func = function(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt index 9c28c969d3a..0279c8912f0 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt @@ -1,18 +1,21 @@ -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,17): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,50): error TS6133: 'person3' is declared but never used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,17): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,33): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(2,50): error TS6133: 'person3' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,13): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (3 errors) ==== +==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (4 errors) ==== class Dummy { constructor(person: string, person2: string, person3: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. ~~~~~~~ -!!! error TS6133: 'person3' is declared but never used. +!!! error TS6133: 'person3' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt index 98bc39e16fb..a2dccf10132 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt @@ -1,16 +1,19 @@ -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,21): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,54): error TS6133: 'person3' is declared but never used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,21): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,37): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(1,54): error TS6133: 'person3' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (3 errors) ==== +==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (4 errors) ==== var func = function(person: string, person2: string, person3: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. ~~~~~~~ -!!! error TS6133: 'person3' is declared but never used. +!!! error TS6133: 'person3' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt index 38e6a8bbcd9..77dd37f96f9 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(1,34): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (2 errors) ==== +==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (3 errors) ==== function greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt index e3e75de1fbd..58cfcee24dc 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt @@ -1,15 +1,18 @@ -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(2,36): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts (2 errors) ==== +==== tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts (3 errors) ==== class Dummy { public greeter(person: string, person2: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt index 39e21691460..6f34c67054f 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt @@ -1,16 +1,19 @@ -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,51): error TS6133: 'person3' is declared but never used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,34): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(1,51): error TS6133: 'person3' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (3 errors) ==== +==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (4 errors) ==== function greeter(person: string, person2: string, person3: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. ~~~~~~~ -!!! error TS6133: 'person3' is declared but never used. +!!! error TS6133: 'person3' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt index 32496974c6b..6779fb83aec 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt @@ -1,18 +1,21 @@ -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,53): error TS6133: 'person3' is declared but never used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,36): error TS6133: 'person2' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(2,53): error TS6133: 'person3' is declared but its value is never read. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but its value is never read. -==== tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts (3 errors) ==== +==== tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts (4 errors) ==== class Dummy { public greeter(person: string, person2: string, person3: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. + ~~~~~~~ +!!! error TS6133: 'person2' is declared but its value is never read. ~~~~~~~ -!!! error TS6133: 'person3' is declared but never used. +!!! error TS6133: 'person3' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedNamespaceInModule.errors.txt b/tests/baselines/reference/unusedNamespaceInModule.errors.txt index 3d722a113ea..afc118b094a 100644 --- a/tests/baselines/reference/unusedNamespaceInModule.errors.txt +++ b/tests/baselines/reference/unusedNamespaceInModule.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedNamespaceInModule.ts(2,15): error TS6133: 'B' is declared but never used. +tests/cases/compiler/unusedNamespaceInModule.ts(2,15): error TS6133: 'B' is declared but its value is never read. ==== tests/cases/compiler/unusedNamespaceInModule.ts (1 errors) ==== module A { namespace B { } ~ -!!! error TS6133: 'B' is declared but never used. +!!! error TS6133: 'B' is declared but its value is never read. export namespace C {} } \ No newline at end of file diff --git a/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt b/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt index 1bf7d15d3c2..ff031f5af41 100644 --- a/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt +++ b/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedNamespaceInNamespace.ts(2,15): error TS6133: 'B' is declared but never used. +tests/cases/compiler/unusedNamespaceInNamespace.ts(2,15): error TS6133: 'B' is declared but its value is never read. ==== tests/cases/compiler/unusedNamespaceInNamespace.ts (1 errors) ==== namespace A { namespace B { } ~ -!!! error TS6133: 'B' is declared but never used. +!!! error TS6133: 'B' is declared but its value is never read. export namespace C {} } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterProperty1.errors.txt b/tests/baselines/reference/unusedParameterProperty1.errors.txt index fb400332c0d..ba9bb4af3ae 100644 --- a/tests/baselines/reference/unusedParameterProperty1.errors.txt +++ b/tests/baselines/reference/unusedParameterProperty1.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedParameterProperty1.ts(2,25): error TS6138: Property 'used' is declared but never used. +tests/cases/compiler/unusedParameterProperty1.ts(2,25): error TS6138: Property 'used' is declared but its value is never read. +tests/cases/compiler/unusedParameterProperty1.ts(3,13): error TS6133: 'foge' is declared but its value is never read. -==== tests/cases/compiler/unusedParameterProperty1.ts (1 errors) ==== +==== tests/cases/compiler/unusedParameterProperty1.ts (2 errors) ==== class A { constructor(private used: string) { ~~~~ -!!! error TS6138: Property 'used' is declared but never used. +!!! error TS6138: Property 'used' is declared but its value is never read. let foge = used; + ~~~~ +!!! error TS6133: 'foge' is declared but its value is never read. foge += ""; } } diff --git a/tests/baselines/reference/unusedParameterProperty2.errors.txt b/tests/baselines/reference/unusedParameterProperty2.errors.txt index 9fa8c4c79f8..853b459c772 100644 --- a/tests/baselines/reference/unusedParameterProperty2.errors.txt +++ b/tests/baselines/reference/unusedParameterProperty2.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedParameterProperty2.ts(2,25): error TS6138: Property 'used' is declared but never used. +tests/cases/compiler/unusedParameterProperty2.ts(2,25): error TS6138: Property 'used' is declared but its value is never read. +tests/cases/compiler/unusedParameterProperty2.ts(3,13): error TS6133: 'foge' is declared but its value is never read. -==== tests/cases/compiler/unusedParameterProperty2.ts (1 errors) ==== +==== tests/cases/compiler/unusedParameterProperty2.ts (2 errors) ==== class A { constructor(private used) { ~~~~ -!!! error TS6138: Property 'used' is declared but never used. +!!! error TS6138: Property 'used' is declared but its value is never read. let foge = used; + ~~~~ +!!! error TS6133: 'foge' is declared but its value is never read. foge += ""; } } diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.js b/tests/baselines/reference/unusedParameterUsedInTypeOf.js index 544057eb4d1..42639a7398e 100644 --- a/tests/baselines/reference/unusedParameterUsedInTypeOf.js +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.js @@ -1,9 +1,9 @@ //// [unusedParameterUsedInTypeOf.ts] function f1 (a: number, b: typeof a) { - b++; + return b; } //// [unusedParameterUsedInTypeOf.js] function f1(a, b) { - b++; + return b; } diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols b/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols index 9479eb8af01..c2bc4a126ef 100644 --- a/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols @@ -5,6 +5,6 @@ function f1 (a: number, b: typeof a) { >b : Symbol(b, Decl(unusedParameterUsedInTypeOf.ts, 0, 23)) >a : Symbol(a, Decl(unusedParameterUsedInTypeOf.ts, 0, 13)) - b++; + return b; >b : Symbol(b, Decl(unusedParameterUsedInTypeOf.ts, 0, 23)) } diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.types b/tests/baselines/reference/unusedParameterUsedInTypeOf.types index d8f181cc07b..8e0cef7962b 100644 --- a/tests/baselines/reference/unusedParameterUsedInTypeOf.types +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.types @@ -1,11 +1,10 @@ === tests/cases/compiler/unusedParameterUsedInTypeOf.ts === function f1 (a: number, b: typeof a) { ->f1 : (a: number, b: number) => void +>f1 : (a: number, b: number) => number >a : number >b : number >a : number - b++; ->b++ : number + return b; >b : number } diff --git a/tests/baselines/reference/unusedParametersInLambda1.errors.txt b/tests/baselines/reference/unusedParametersInLambda1.errors.txt index a5a58045c5a..94ca0e83cf9 100644 --- a/tests/baselines/reference/unusedParametersInLambda1.errors.txt +++ b/tests/baselines/reference/unusedParametersInLambda1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersInLambda1.ts(3,17): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedParametersInLambda1.ts(3,17): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersInLambda1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedParametersInLambda1.ts(3,17): error TS6133: 'X' is de public f1() { return (X) => { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. } } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersInLambda2.errors.txt b/tests/baselines/reference/unusedParametersInLambda2.errors.txt index 055e0cbeb63..16f4c3f2640 100644 --- a/tests/baselines/reference/unusedParametersInLambda2.errors.txt +++ b/tests/baselines/reference/unusedParametersInLambda2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersInLambda2.ts(3,17): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedParametersInLambda2.ts(3,17): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersInLambda2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedParametersInLambda2.ts(3,17): error TS6133: 'X' is de public f1() { return (X, Y) => { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. Y; } } diff --git a/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt b/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt index 136c3c0e367..841e8ec95fd 100644 --- a/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt +++ b/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt @@ -1,21 +1,21 @@ -tests/cases/compiler/unusedParametersWithUnderscore.ts(1,12): error TS6133: 'a' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(1,19): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(1,27): error TS6133: 'd' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(1,29): error TS6133: 'e___' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(11,16): error TS6133: 'arg' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(17,13): error TS6133: 'arg' is declared but never used. +tests/cases/compiler/unusedParametersWithUnderscore.ts(1,12): error TS6133: 'a' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(1,19): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(1,27): error TS6133: 'd' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(1,29): error TS6133: 'e___' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(11,16): error TS6133: 'arg' is declared but its value is never read. +tests/cases/compiler/unusedParametersWithUnderscore.ts(17,13): error TS6133: 'arg' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersWithUnderscore.ts (6 errors) ==== function f(a, _b, c, ___, d,e___, _f) { ~ -!!! error TS6133: 'a' is declared but never used. +!!! error TS6133: 'a' is declared but its value is never read. ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. ~ -!!! error TS6133: 'd' is declared but never used. +!!! error TS6133: 'd' is declared but its value is never read. ~~~~ -!!! error TS6133: 'e___' is declared but never used. +!!! error TS6133: 'e___' is declared but its value is never read. } @@ -27,7 +27,7 @@ tests/cases/compiler/unusedParametersWithUnderscore.ts(17,13): error TS6133: 'ar function f4(...arg) { ~~~ -!!! error TS6133: 'arg' is declared but never used. +!!! error TS6133: 'arg' is declared but its value is never read. } function f5(..._arg) { @@ -35,7 +35,7 @@ tests/cases/compiler/unusedParametersWithUnderscore.ts(17,13): error TS6133: 'ar function f6(arg?, _arg?) { ~~~ -!!! error TS6133: 'arg' is declared but never used. +!!! error TS6133: 'arg' is declared but its value is never read. } var f7 = _ => undefined; diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt index c505cc96f2f..a68bdccdc31 100644 --- a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedParametersinConstructor1.ts(2,17): error TS6133: 'param1' is declared but never used. +tests/cases/compiler/unusedParametersinConstructor1.ts(2,17): error TS6133: 'param1' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersinConstructor1.ts (1 errors) ==== class greeter { constructor(param1: string) { ~~~~~~ -!!! error TS6133: 'param1' is declared but never used. +!!! error TS6133: 'param1' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt index f1c7bf1b49a..67cf295edda 100644 --- a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedParametersinConstructor2.ts(2,17): error TS6133: 'param1' is declared but never used. +tests/cases/compiler/unusedParametersinConstructor2.ts(2,17): error TS6133: 'param1' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersinConstructor2.ts (1 errors) ==== class greeter { constructor(param1: string, param2: string) { ~~~~~~ -!!! error TS6133: 'param1' is declared but never used. +!!! error TS6133: 'param1' is declared but its value is never read. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt index 1e79539d342..ca88555f45c 100644 --- a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedParametersinConstructor3.ts(2,17): error TS6133: 'param1' is declared but never used. -tests/cases/compiler/unusedParametersinConstructor3.ts(2,49): error TS6133: 'param3' is declared but never used. +tests/cases/compiler/unusedParametersinConstructor3.ts(2,17): error TS6133: 'param1' is declared but its value is never read. +tests/cases/compiler/unusedParametersinConstructor3.ts(2,49): error TS6133: 'param3' is declared but its value is never read. ==== tests/cases/compiler/unusedParametersinConstructor3.ts (2 errors) ==== class greeter { constructor(param1: string, param2: string, param3: string) { ~~~~~~ -!!! error TS6133: 'param1' is declared but never used. +!!! error TS6133: 'param1' is declared but its value is never read. ~~~~~~ -!!! error TS6133: 'param3' is declared but never used. +!!! error TS6133: 'param3' is declared but its value is never read. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt index 7271fd48d70..110155a2734 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt @@ -1,12 +1,15 @@ -tests/cases/compiler/unusedPrivateMethodInClass1.ts(2,13): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass1.ts(2,13): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedPrivateMethodInClass1.ts (1 errors) ==== +==== tests/cases/compiler/unusedPrivateMethodInClass1.ts (2 errors) ==== class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt index ee52b95765f..16873219a6c 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt @@ -1,20 +1,26 @@ -tests/cases/compiler/unusedPrivateMethodInClass2.ts(2,13): error TS6133: 'function1' is declared but never used. -tests/cases/compiler/unusedPrivateMethodInClass2.ts(7,13): error TS6133: 'function2' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(2,13): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(7,13): error TS6133: 'function2' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedPrivateMethodInClass2.ts (2 errors) ==== +==== tests/cases/compiler/unusedPrivateMethodInClass2.ts (4 errors) ==== class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } private function2() { ~~~~~~~~~ -!!! error TS6133: 'function2' is declared but never used. +!!! error TS6133: 'function2' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt index 87bc63dd87f..492492836d0 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt @@ -1,25 +1,34 @@ -tests/cases/compiler/unusedPrivateMethodInClass3.ts(2,13): error TS6133: 'function1' is declared but never used. -tests/cases/compiler/unusedPrivateMethodInClass3.ts(7,13): error TS6133: 'function2' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(2,13): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(7,13): error TS6133: 'function2' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(13,13): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedPrivateMethodInClass3.ts (2 errors) ==== +==== tests/cases/compiler/unusedPrivateMethodInClass3.ts (5 errors) ==== class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } private function2() { ~~~~~~~~~ -!!! error TS6133: 'function2' is declared but never used. +!!! error TS6133: 'function2' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } public function3() { var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt index 8709a83374e..bcf8a5d25c7 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt @@ -1,22 +1,31 @@ -tests/cases/compiler/unusedPrivateMethodInClass4.ts(2,13): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(2,13): error TS6133: 'function1' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(8,13): error TS6133: 'y' is declared but its value is never read. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(13,13): error TS6133: 'y' is declared but its value is never read. -==== tests/cases/compiler/unusedPrivateMethodInClass4.ts (1 errors) ==== +==== tests/cases/compiler/unusedPrivateMethodInClass4.ts (4 errors) ==== class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: 'function1' is declared but never used. +!!! error TS6133: 'function1' is declared but its value is never read. var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } private function2() { var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; } public function3() { var y = 10; + ~ +!!! error TS6133: 'y' is declared but its value is never read. y++; this.function2(); } diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt index 68033811c15..08ebd8d1656 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedPrivateVariableInClass1.ts(2,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass1.ts(2,13): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass1.ts (1 errors) ==== class greeter { private x: string; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt index 922263e0c5f..d13c7f0b6b5 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedPrivateVariableInClass2.ts(2,13): error TS6133: 'x' is declared but never used. -tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,13): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(2,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,13): error TS6133: 'y' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass2.ts (2 errors) ==== class greeter { private x: string; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. private y: string; ~ -!!! error TS6133: 'y' is declared but never used. +!!! error TS6133: 'y' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt index 686b5317436..ffa32a1c2c0 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedPrivateVariableInClass3.ts(2,13): error TS6133: 'x' is declared but never used. -tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,13): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(2,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,13): error TS6133: 'y' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass3.ts (2 errors) ==== class greeter { private x: string; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. private y: string; ~ -!!! error TS6133: 'y' is declared but never used. +!!! error TS6133: 'y' is declared but its value is never read. public z: string; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt index 5586b628c50..33c3f7237af 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass4.ts(3,13): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass4.ts(3,13): error TS6133: 'y' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass4.ts (1 errors) ==== @@ -6,10 +6,10 @@ tests/cases/compiler/unusedPrivateVariableInClass4.ts(3,13): error TS6133: 'y' i private x: string; private y: string; ~ -!!! error TS6133: 'y' is declared but never used. +!!! error TS6133: 'y' is declared but its value is never read. public z: string; public method1() { - this.x = "dummy value"; + this.x; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.js b/tests/baselines/reference/unusedPrivateVariableInClass4.js index 21c910f702c..e782b0791aa 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass4.js +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.js @@ -5,7 +5,7 @@ class greeter { public z: string; public method1() { - this.x = "dummy value"; + this.x; } } @@ -14,7 +14,7 @@ var greeter = /** @class */ (function () { function greeter() { } greeter.prototype.method1 = function () { - this.x = "dummy value"; + this.x; }; return greeter; }()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt index 9379b84ce82..96c4f74f956 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass5.ts(3,13): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass5.ts(3,13): error TS6133: 'y' is declared but its value is never read. ==== tests/cases/compiler/unusedPrivateVariableInClass5.ts (1 errors) ==== @@ -6,10 +6,10 @@ tests/cases/compiler/unusedPrivateVariableInClass5.ts(3,13): error TS6133: 'y' i private x: string; private y: string; ~ -!!! error TS6133: 'y' is declared but never used. +!!! error TS6133: 'y' is declared but its value is never read. public z: string; constructor() { - this.x = "dummy value"; + this.x; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.js b/tests/baselines/reference/unusedPrivateVariableInClass5.js index a0ad7bf0021..4d000350197 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass5.js +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.js @@ -5,14 +5,14 @@ class greeter { public z: string; constructor() { - this.x = "dummy value"; + this.x; } } //// [unusedPrivateVariableInClass5.js] var greeter = /** @class */ (function () { function greeter() { - this.x = "dummy value"; + this.x; } return greeter; }()); diff --git a/tests/baselines/reference/unusedSetterInClass.errors.txt b/tests/baselines/reference/unusedSetterInClass.errors.txt new file mode 100644 index 00000000000..d7cd764b293 --- /dev/null +++ b/tests/baselines/reference/unusedSetterInClass.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedSetterInClass.ts(2,13): error TS6133: '_fullName' is declared but its value is never read. + + +==== tests/cases/compiler/unusedSetterInClass.ts (1 errors) ==== + class Employee { + private _fullName: string; + ~~~~~~~~~ +!!! error TS6133: '_fullName' is declared but its value is never read. + + set fullName(newName: string) { + this._fullName = newName; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt index c963394abca..7a8976b664d 100644 --- a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedSingleParameterInContructor.ts(2,17): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedSingleParameterInContructor.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(2,17): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedSingleParameterInContructor.ts(3,13): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedSingleParameterInContructor.ts (2 errors) ==== class Dummy { constructor(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt index 374f963802f..f02dc30f455 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(1,18): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,9): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts (2 errors) ==== function greeter(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt index 4adb424b3d4..a63003422ca 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(1,21): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(1,21): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,9): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts (2 errors) ==== var func = function(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt index 903e4d87668..717b41e4d2a 100644 --- a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but never used. -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(2,20): error TS6133: 'person' is declared but its value is never read. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,13): error TS6133: 'unused' is declared but its value is never read. ==== tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts (2 errors) ==== class Dummy { public greeter(person: string) { ~~~~~~ -!!! error TS6133: 'person' is declared but never used. +!!! error TS6133: 'person' is declared but its value is never read. var unused = 20; ~~~~~~ -!!! error TS6133: 'unused' is declared but never used. +!!! error TS6133: 'unused' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSwitchStatment.errors.txt b/tests/baselines/reference/unusedSwitchStatment.errors.txt index f47cad32eba..29dc18b5d9a 100644 --- a/tests/baselines/reference/unusedSwitchStatment.errors.txt +++ b/tests/baselines/reference/unusedSwitchStatment.errors.txt @@ -1,29 +1,30 @@ tests/cases/compiler/unusedSwitchStatment.ts(2,10): error TS2678: Type '0' is not comparable to type '1'. -tests/cases/compiler/unusedSwitchStatment.ts(3,13): error TS6133: 'x' is declared but never used. -tests/cases/compiler/unusedSwitchStatment.ts(6,15): error TS6133: 'c' is declared but never used. -tests/cases/compiler/unusedSwitchStatment.ts(9,13): error TS6133: 'z' is declared but never used. +tests/cases/compiler/unusedSwitchStatment.ts(3,13): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedSwitchStatment.ts(6,15): error TS6133: 'c' is declared but its value is never read. +tests/cases/compiler/unusedSwitchStatment.ts(9,13): error TS6133: 'z' is declared but its value is never read. tests/cases/compiler/unusedSwitchStatment.ts(14,10): error TS2678: Type '0' is not comparable to type '2'. +tests/cases/compiler/unusedSwitchStatment.ts(15,13): error TS6133: 'x' is declared but its value is never read. tests/cases/compiler/unusedSwitchStatment.ts(16,10): error TS2678: Type '1' is not comparable to type '2'. -==== tests/cases/compiler/unusedSwitchStatment.ts (6 errors) ==== +==== tests/cases/compiler/unusedSwitchStatment.ts (7 errors) ==== switch (1) { case 0: ~ !!! error TS2678: Type '0' is not comparable to type '1'. let x; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. break; case 1: const c = 1; ~ -!!! error TS6133: 'c' is declared but never used. +!!! error TS6133: 'c' is declared but its value is never read. break; default: let z = 2; ~ -!!! error TS6133: 'z' is declared but never used. +!!! error TS6133: 'z' is declared but its value is never read. } @@ -32,6 +33,8 @@ tests/cases/compiler/unusedSwitchStatment.ts(16,10): error TS2678: Type '1' is n ~ !!! error TS2678: Type '0' is not comparable to type '2'. let x; + ~ +!!! error TS6133: 'x' is declared but its value is never read. case 1: ~ !!! error TS2678: Type '1' is not comparable to type '2'. diff --git a/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt index 7ecdae21390..93af5cf16b6 100644 --- a/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameterInFunction1.ts(1,13): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameterInFunction1.ts(1,13): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInFunction1.ts (1 errors) ==== function f1() { ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt index 06926092f2b..848f242be19 100644 --- a/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameterInFunction2.ts(1,16): error TS6133: 'Y' is declared but never used. +tests/cases/compiler/unusedTypeParameterInFunction2.ts(1,16): error TS6133: 'Y' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInFunction2.ts (1 errors) ==== function f1() { ~ -!!! error TS6133: 'Y' is declared but never used. +!!! error TS6133: 'Y' is declared but its value is never read. var a: X; a; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt index 5eb2f012f5e..3acdc7b523b 100644 --- a/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameterInFunction3.ts(1,16): error TS6133: 'Y' is declared but never used. +tests/cases/compiler/unusedTypeParameterInFunction3.ts(1,16): error TS6133: 'Y' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInFunction3.ts (1 errors) ==== function f1() { ~ -!!! error TS6133: 'Y' is declared but never used. +!!! error TS6133: 'Y' is declared but its value is never read. var a: X; var b: Z; a; diff --git a/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt index 7ff8090f3c3..82eaffa100a 100644 --- a/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameterInFunction4.ts(1,13): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedTypeParameterInFunction4.ts(1,13): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInFunction4.ts (1 errors) ==== function f1() { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. var a: Y; var b: Z; a; diff --git a/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt b/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt index d1aa6fc03da..f0796d8fcd7 100644 --- a/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameterInInterface1.ts(1,15): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameterInInterface1.ts(1,15): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInInterface1.ts (1 errors) ==== interface int { ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt b/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt index c36cffdca41..1fa66c920a8 100644 --- a/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameterInInterface2.ts(1,18): error TS6133: 'U' is declared but never used. +tests/cases/compiler/unusedTypeParameterInInterface2.ts(1,18): error TS6133: 'U' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInInterface2.ts (1 errors) ==== interface int { ~ -!!! error TS6133: 'U' is declared but never used. +!!! error TS6133: 'U' is declared but its value is never read. f1(a: T): string; c: V; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt index 687e0809f97..144ee86a0f5 100644 --- a/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedTypeParameterInLambda1.ts(3,17): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameterInLambda1.ts(3,17): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInLambda1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedTypeParameterInLambda1.ts(3,17): error TS6133: 'T' is public f1() { return () => { ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. } } diff --git a/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt index bdadc908059..c185808338e 100644 --- a/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedTypeParameterInLambda2.ts(3,17): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameterInLambda2.ts(3,17): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInLambda2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedTypeParameterInLambda2.ts(3,17): error TS6133: 'T' is public f1() { return () => { ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. var a: X; a; } diff --git a/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt index 5477f611e72..8b6f98ef681 100644 --- a/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedTypeParameterInLambda3.ts(5,15): error TS6133: 'U' is declared but never used. +tests/cases/compiler/unusedTypeParameterInLambda3.ts(5,15): error TS6133: 'U' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInLambda3.ts (1 errors) ==== @@ -8,5 +8,5 @@ tests/cases/compiler/unusedTypeParameterInLambda3.ts(5,15): error TS6133: 'U' is var y: new (a:T)=>void; ~ -!!! error TS6133: 'U' is declared but never used. +!!! error TS6133: 'U' is declared but its value is never read. \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt index eab59fddec2..dcf6fda8254 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod1.ts(2,15): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod1.ts(2,15): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod1.ts (1 errors) ==== class A { public f1() { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. var a: Y; var b: Z; a; diff --git a/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt index 219d5f99e61..9e5936a2bc4 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod2.ts(2,18): error TS6133: 'Y' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod2.ts(2,18): error TS6133: 'Y' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod2.ts (1 errors) ==== class A { public f1() { ~ -!!! error TS6133: 'Y' is declared but never used. +!!! error TS6133: 'Y' is declared but its value is never read. var a: X; var b: Z; a; diff --git a/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt index f9257169897..102cd56f281 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod3.ts(2,21): error TS6133: 'Z' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod3.ts(2,21): error TS6133: 'Z' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod3.ts (1 errors) ==== class A { public f1() { ~ -!!! error TS6133: 'Z' is declared but never used. +!!! error TS6133: 'Z' is declared but its value is never read. var a: X; var b: Y; a; diff --git a/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt index ab2dbbc868e..bb121372e91 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod4.ts(2,15): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod4.ts(2,15): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod4.ts (1 errors) ==== class A { public f1() { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt index 6bc5f88407c..7afa26fd323 100644 --- a/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt +++ b/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameterInMethod5.ts(2,26): error TS6133: 'X' is declared but never used. +tests/cases/compiler/unusedTypeParameterInMethod5.ts(2,26): error TS6133: 'X' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameterInMethod5.ts (1 errors) ==== class A { public f1 = function() { ~ -!!! error TS6133: 'X' is declared but never used. +!!! error TS6133: 'X' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters1.errors.txt b/tests/baselines/reference/unusedTypeParameters1.errors.txt index 0868ebbe9be..3a6222497f0 100644 --- a/tests/baselines/reference/unusedTypeParameters1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameters1.ts(1,15): error TS6133: 'typeparameter1' is declared but never used. +tests/cases/compiler/unusedTypeParameters1.ts(1,15): error TS6133: 'typeparameter1' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters1.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6133: 'typeparameter1' is declared but never used. +!!! error TS6133: 'typeparameter1' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters10.errors.txt b/tests/baselines/reference/unusedTypeParameters10.errors.txt index 7bfd5676df3..2e76b39ab96 100644 --- a/tests/baselines/reference/unusedTypeParameters10.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters10.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameters10.ts(1,12): error TS6133: 'T' is declared but never used. +tests/cases/compiler/unusedTypeParameters10.ts(1,12): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters10.ts (1 errors) ==== type Alias = { }; ~ -!!! error TS6133: 'T' is declared but never used. +!!! error TS6133: 'T' is declared but its value is never read. type Alias2 = { x: T }; \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters2.errors.txt b/tests/baselines/reference/unusedTypeParameters2.errors.txt index 97335fc6ecf..0ce28313c75 100644 --- a/tests/baselines/reference/unusedTypeParameters2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameters2.ts(1,15): error TS6133: 'typeparameter1' is declared but never used. +tests/cases/compiler/unusedTypeParameters2.ts(1,15): error TS6133: 'typeparameter1' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters2.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6133: 'typeparameter1' is declared but never used. +!!! error TS6133: 'typeparameter1' is declared but its value is never read. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedTypeParameters3.errors.txt b/tests/baselines/reference/unusedTypeParameters3.errors.txt index 31840f2cc42..6f5797365a2 100644 --- a/tests/baselines/reference/unusedTypeParameters3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters3.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedTypeParameters3.ts(1,15): error TS6133: 'typeparameter1' is declared but never used. -tests/cases/compiler/unusedTypeParameters3.ts(1,47): error TS6133: 'typeparameter3' is declared but never used. +tests/cases/compiler/unusedTypeParameters3.ts(1,15): error TS6133: 'typeparameter1' is declared but its value is never read. +tests/cases/compiler/unusedTypeParameters3.ts(1,47): error TS6133: 'typeparameter3' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters3.ts (2 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6133: 'typeparameter1' is declared but never used. +!!! error TS6133: 'typeparameter1' is declared but its value is never read. ~~~~~~~~~~~~~~ -!!! error TS6133: 'typeparameter3' is declared but never used. +!!! error TS6133: 'typeparameter3' is declared but its value is never read. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedTypeParameters4.errors.txt b/tests/baselines/reference/unusedTypeParameters4.errors.txt index 149c764895c..3e56c270f43 100644 --- a/tests/baselines/reference/unusedTypeParameters4.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters4.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedTypeParameters4.ts(2,13): error TS6133: 'U' is declared but never used. +tests/cases/compiler/unusedTypeParameters4.ts(2,13): error TS6133: 'U' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters4.ts (1 errors) ==== var x: { new (a: T): void; ~ -!!! error TS6133: 'U' is declared but never used. +!!! error TS6133: 'U' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters5.errors.txt b/tests/baselines/reference/unusedTypeParameters5.errors.txt index ed19d33fd97..069caedf0dd 100644 --- a/tests/baselines/reference/unusedTypeParameters5.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedTypeParameters5.ts(6,16): error TS6133: 'K' is declared but never used. +tests/cases/compiler/unusedTypeParameters5.ts(6,16): error TS6133: 'K' is declared but its value is never read. ==== tests/cases/compiler/unusedTypeParameters5.ts (1 errors) ==== @@ -9,5 +9,5 @@ tests/cases/compiler/unusedTypeParameters5.ts(6,16): error TS6133: 'K' is declar var x: { new (a: T): A; ~ -!!! error TS6133: 'K' is declared but never used. +!!! error TS6133: 'K' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters8.errors.txt b/tests/baselines/reference/unusedTypeParameters8.errors.txt index 5b466a9b806..e1381ec0002 100644 --- a/tests/baselines/reference/unusedTypeParameters8.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/b.ts(1,13): error TS6133: 'T' is declared but never used. +tests/cases/compiler/b.ts(1,13): error TS6133: 'T' is declared but its value is never read. ==== tests/cases/compiler/a.ts (0 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/b.ts(1,13): error TS6133: 'T' is declared but never used. ==== tests/cases/compiler/b.ts (1 errors) ==== interface C { } ~ -!!! error TS6133: 'T' is declared but never used. \ No newline at end of file +!!! error TS6133: 'T' is declared but its value is never read. \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt b/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt index e1906041a89..1fa2e52b3f3 100644 --- a/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt +++ b/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/unusedVariablesinBlocks1.ts(2,9): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedVariablesinBlocks1.ts(2,9): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedVariablesinBlocks1.ts(4,13): error TS6133: 'x' is declared but its value is never read. -==== tests/cases/compiler/unusedVariablesinBlocks1.ts (1 errors) ==== +==== tests/cases/compiler/unusedVariablesinBlocks1.ts (2 errors) ==== function f1 () { let x = 10; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. { let x = 11; + ~ +!!! error TS6133: 'x' is declared but its value is never read. x++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt b/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt index 610b379d607..f9c83abca18 100644 --- a/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt +++ b/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt @@ -1,13 +1,16 @@ -tests/cases/compiler/unusedVariablesinBlocks2.ts(4,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedVariablesinBlocks2.ts(2,9): error TS6133: 'x' is declared but its value is never read. +tests/cases/compiler/unusedVariablesinBlocks2.ts(4,13): error TS6133: 'x' is declared but its value is never read. -==== tests/cases/compiler/unusedVariablesinBlocks2.ts (1 errors) ==== +==== tests/cases/compiler/unusedVariablesinBlocks2.ts (2 errors) ==== function f1 () { let x = 10; + ~ +!!! error TS6133: 'x' is declared but its value is never read. { let x = 11; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } x++; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop.errors.txt index 74f1450b6f7..1385f1e2327 100644 --- a/tests/baselines/reference/unusedVariablesinForLoop.errors.txt +++ b/tests/baselines/reference/unusedVariablesinForLoop.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedVariablesinForLoop.ts(2,13): error TS6133: 'i' is declared but never used. +tests/cases/compiler/unusedVariablesinForLoop.ts(2,13): error TS6133: 'i' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinForLoop.ts (1 errors) ==== function f1 () { for(var i = 0; ;) { ~ -!!! error TS6133: 'i' is declared but never used. +!!! error TS6133: 'i' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt index d42f71286a0..bdd4706854a 100644 --- a/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt +++ b/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedVariablesinForLoop2.ts(2,16): error TS6133: 'elem' is declared but never used. +tests/cases/compiler/unusedVariablesinForLoop2.ts(2,16): error TS6133: 'elem' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinForLoop2.ts (1 errors) ==== function f1 () { for (const elem in ["a", "b", "c"]) { ~~~~ -!!! error TS6133: 'elem' is declared but never used. +!!! error TS6133: 'elem' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt index ec3e96584e2..a2a9d273200 100644 --- a/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt +++ b/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedVariablesinForLoop3.ts(2,16): error TS6133: 'elem' is declared but never used. +tests/cases/compiler/unusedVariablesinForLoop3.ts(2,16): error TS6133: 'elem' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinForLoop3.ts (1 errors) ==== function f1 () { for (const elem of ["a", "b", "c"]) { ~~~~ -!!! error TS6133: 'elem' is declared but never used. +!!! error TS6133: 'elem' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt index c20a6c1ba20..df6ffe9934b 100644 --- a/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt +++ b/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinForLoop4.ts(4,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedVariablesinForLoop4.ts(4,13): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinForLoop4.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/unusedVariablesinForLoop4.ts(4,13): error TS6133: 'x' is de elem; var x = 20; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinModules1.errors.txt b/tests/baselines/reference/unusedVariablesinModules1.errors.txt index 7a8704a89ca..0421c9ff2b0 100644 --- a/tests/baselines/reference/unusedVariablesinModules1.errors.txt +++ b/tests/baselines/reference/unusedVariablesinModules1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinModules1.ts(3,5): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedVariablesinModules1.ts(3,5): error TS6133: 'x' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinModules1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedVariablesinModules1.ts(3,5): error TS6133: 'x' is dec var x: string; ~ -!!! error TS6133: 'x' is declared but never used. +!!! error TS6133: 'x' is declared but its value is never read. export var y: string; \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt index 25c06c216fb..8ba5fc3c39a 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/unusedVariablesinNamespaces1.ts(2,11): error TS6133: 'lettersRegexp' is declared but never used. +tests/cases/compiler/unusedVariablesinNamespaces1.ts(2,11): error TS6133: 'lettersRegexp' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinNamespaces1.ts (1 errors) ==== namespace Validation { const lettersRegexp = /^[A-Za-z]+$/; ~~~~~~~~~~~~~ -!!! error TS6133: 'lettersRegexp' is declared but never used. +!!! error TS6133: 'lettersRegexp' is declared but its value is never read. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt index a3af55498dc..df5fa298266 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces2.ts(3,11): error TS6133: 'numberRegexp' is declared but never used. +tests/cases/compiler/unusedVariablesinNamespaces2.ts(3,11): error TS6133: 'numberRegexp' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinNamespaces2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedVariablesinNamespaces2.ts(3,11): error TS6133: 'numbe const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6133: 'numberRegexp' is declared but never used. +!!! error TS6133: 'numberRegexp' is declared but its value is never read. export class LettersOnlyValidator { isAcceptable(s2: string) { diff --git a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt index 64d94a86ade..b1c7644019a 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces3.ts(3,11): error TS6133: 'numberRegexp' is declared but never used. +tests/cases/compiler/unusedVariablesinNamespaces3.ts(3,11): error TS6133: 'numberRegexp' is declared but its value is never read. ==== tests/cases/compiler/unusedVariablesinNamespaces3.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedVariablesinNamespaces3.ts(3,11): error TS6133: 'numbe const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6133: 'numberRegexp' is declared but never used. +!!! error TS6133: 'numberRegexp' is declared but its value is never read. export const anotherUnusedVariable = "Dummy value"; export class LettersOnlyValidator { diff --git a/tests/cases/compiler/noUnusedLocals_writeOnly.ts b/tests/cases/compiler/noUnusedLocals_writeOnly.ts new file mode 100644 index 00000000000..228a7e0b6b0 --- /dev/null +++ b/tests/cases/compiler/noUnusedLocals_writeOnly.ts @@ -0,0 +1,12 @@ +// @noUnusedLocals: true +// @noUnusedParameters: true + +function f(x = 0) { + x = 1; + x++; + x /= 2; + + let y = 0; + // This is a write access to y, but not a write-*only* access. + f(y++); +} diff --git a/tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts b/tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts new file mode 100644 index 00000000000..84e005afd54 --- /dev/null +++ b/tests/cases/compiler/noUnusedLocals_writeOnlyProperty.ts @@ -0,0 +1,8 @@ +// @noUnusedLocals: true + +class C { + private x; + m() { + this.x = 0; + } +} diff --git a/tests/cases/compiler/unusedParameterUsedInTypeOf.ts b/tests/cases/compiler/unusedParameterUsedInTypeOf.ts index b69b2412314..f1cf83d56c4 100644 --- a/tests/cases/compiler/unusedParameterUsedInTypeOf.ts +++ b/tests/cases/compiler/unusedParameterUsedInTypeOf.ts @@ -3,5 +3,5 @@ //@noUnusedParameters:true function f1 (a: number, b: typeof a) { - b++; + return b; } \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass4.ts b/tests/cases/compiler/unusedPrivateVariableInClass4.ts index 23598d5a491..e737d9ac477 100644 --- a/tests/cases/compiler/unusedPrivateVariableInClass4.ts +++ b/tests/cases/compiler/unusedPrivateVariableInClass4.ts @@ -7,6 +7,6 @@ class greeter { public z: string; public method1() { - this.x = "dummy value"; + this.x; } } \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass5.ts b/tests/cases/compiler/unusedPrivateVariableInClass5.ts index 51e64afca1d..4234f16bdbc 100644 --- a/tests/cases/compiler/unusedPrivateVariableInClass5.ts +++ b/tests/cases/compiler/unusedPrivateVariableInClass5.ts @@ -7,6 +7,6 @@ class greeter { public z: string; constructor() { - this.x = "dummy value"; + this.x; } } \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts index fa1254118a1..89bb40b6830 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts @@ -3,7 +3,7 @@ //// class Foo { //// constructor(private [|{| "isWriteAccess": true, "isDefinition": true |}privateParam|]: number) { //// let localPrivate = [|privateParam|]; -//// this.[|privateParam|] += 10; +//// this.[|{| "isWriteAccess": true |}privateParam|] += 10; //// } //// } diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts index 45d814f909e..519ca74c5c4 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts @@ -3,7 +3,7 @@ //// class Foo { //// constructor(public [|{| "isWriteAccess": true, "isDefinition": true |}publicParam|]: number) { //// let localPublic = [|publicParam|]; -//// this.[|publicParam|] += 10; +//// this.[|{| "isWriteAccess": true |}publicParam|] += 10; //// } //// } diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts index 3520fecb8ad..7addc2ba7a0 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts @@ -3,7 +3,7 @@ //// class Foo { //// constructor(protected [|{| "isWriteAccess": true, "isDefinition": true |}protectedParam|]: number) { //// let localProtected = [|protectedParam|]; -//// this.[|protectedParam|] += 10; +//// this.[|{| "isWriteAccess": true |}protectedParam|] += 10; //// } //// } diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index 4648471648a..a434a6b0820 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -14,10 +14,10 @@ //// constructor (public [|{| "isWriteAccess": true, "isDefinition": true |}clsParam|]: number) { //// //Increments //// [|{| "isWriteAccess": true |}globalVar|]++; -//// this.[|clsVar|]++; -//// fooCls.[|clsSVar|]++; +//// this.[|{| "isWriteAccess": true |}clsVar|]++; +//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; //// // References to a class parameter. -//// this.[|clsParam|]++; +//// this.[|{| "isWriteAccess": true |}clsParam|]++; //// modTest.modVar++; //// } ////} @@ -28,7 +28,7 @@ //// var [|{| "isWriteAccess": true, "isDefinition": true |}fnVar|] = 1; //// //// //Increments -//// fooCls.[|clsSVar|]++; +//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; //// [|{| "isWriteAccess": true |}globalVar|]++; //// modTest.modVar++; //// [|{| "isWriteAccess": true |}fnVar|]++; @@ -43,7 +43,7 @@ //// //// //Increments //// [|{| "isWriteAccess": true |}globalVar|]++; -//// fooCls.[|clsSVar|]++; +//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; //// modVar++; //// //// class testCls { @@ -55,7 +55,7 @@ //// //// //Increments //// [|{| "isWriteAccess": true |}globalVar|]++; -//// fooCls.[|clsSVar|]++; +//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; //// modVar++; //// } //// @@ -74,7 +74,7 @@ ////[|foo|]([|globalVar|]); //// //////Increments -////fooCls.[|clsSVar|]++; +////fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; ////modTest.modVar++; ////[|{| "isWriteAccess": true |}globalVar|] = [|globalVar|] + [|globalVar|]; //// diff --git a/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts b/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts index 79bf6172863..63494352ff4 100644 --- a/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts +++ b/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts @@ -7,13 +7,13 @@ //// protected [|{| "isWriteAccess": true, "isDefinition": true, "type": "boolean" |}protectedParam|]: boolean) { //// //// let localPrivate = [|privateParam|]; -//// this.[|privateParam|] += 10; +//// this.[|{| "isWriteAccess": true |}privateParam|] += 10; //// //// let localPublic = [|publicParam|]; -//// this.[|publicParam|] += " Hello!"; +//// this.[|{| "isWriteAccess": true |}publicParam|] += " Hello!"; //// //// let localProtected = [|protectedParam|]; -//// this.[|protectedParam|] = false; +//// this.[|{| "isWriteAccess": true |}protectedParam|] = false; //// } //// } diff --git a/tests/cases/fourslash/referencesForClassLocal.ts b/tests/cases/fourslash/referencesForClassLocal.ts index 4108c060a39..9e2576413f2 100644 --- a/tests/cases/fourslash/referencesForClassLocal.ts +++ b/tests/cases/fourslash/referencesForClassLocal.ts @@ -8,11 +8,11 @@ //// private [|{| "isWriteAccess": true, "isDefinition": true |}n|] = 0; //// //// public bar() { -//// this.[|n|] = 9; +//// this.[|{| "isWriteAccess": true |}n|] = 9; //// } //// //// constructor() { -//// this.[|n|] = 4; +//// this.[|{| "isWriteAccess": true |}n|] = 4; //// } //// //// public bar2() { diff --git a/tests/cases/fourslash/referencesForClassParameter.ts b/tests/cases/fourslash/referencesForClassParameter.ts index e1a33dc5ac4..24eb9e5496e 100644 --- a/tests/cases/fourslash/referencesForClassParameter.ts +++ b/tests/cases/fourslash/referencesForClassParameter.ts @@ -11,13 +11,13 @@ //// } //// //// public f(p) { -//// this.[|p|] = p; +//// this.[|{| "isWriteAccess": true |}p|] = p; //// } //// ////} //// ////var n = new foo(undefined); -////n.[|p|] = null; +////n.[|{| "isWriteAccess": true |}p|] = null; const ranges = test.ranges(); const [r0, r1, r2] = ranges; diff --git a/tests/cases/fourslash/referencesForOverrides.ts b/tests/cases/fourslash/referencesForOverrides.ts index 5ce6bc5ed04..a3cfffa8bd4 100644 --- a/tests/cases/fourslash/referencesForOverrides.ts +++ b/tests/cases/fourslash/referencesForOverrides.ts @@ -70,7 +70,7 @@ //// w.[|icfoo|](); //// //// var z = new Test.BarBlah(); -//// z.[|field|] = ""; +//// z.[|{| "isWriteAccess": true |}field|] = ""; //// z.[|method|](); //// } ////} diff --git a/tests/cases/fourslash/referencesForStatic.ts b/tests/cases/fourslash/referencesForStatic.ts index 17c33daac32..1c82d2fde6c 100644 --- a/tests/cases/fourslash/referencesForStatic.ts +++ b/tests/cases/fourslash/referencesForStatic.ts @@ -9,7 +9,7 @@ //// static [|{| "isWriteAccess": true, "isDefinition": true |}n|] = ''; //// //// public bar() { -//// foo.[|n|] = "'"; +//// foo.[|{| "isWriteAccess": true |}n|] = "'"; //// if(foo.[|n|]) { //// var x = foo.[|n|]; //// } @@ -19,7 +19,7 @@ ////class foo2 { //// private x = foo.[|n|]; //// constructor() { -//// foo.[|n|] = x; +//// foo.[|{| "isWriteAccess": true |}n|] = x; //// } //// //// function b(n) { diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts index 4293435de1d..c289a17c91c 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts @@ -2,7 +2,7 @@ ////var x = { "[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|]": 0 } ////x["[|someProperty|]"] = 3; -////x.[|someProperty|] = 5; +////x.[|{| "isWriteAccess": true |}someProperty|] = 5; const ranges = test.ranges(); const [r0, r1, r2] = ranges; diff --git a/tests/cases/fourslash/remoteGetReferences.ts b/tests/cases/fourslash/remoteGetReferences.ts index 292864f9ed4..a09e3fb3b01 100644 --- a/tests/cases/fourslash/remoteGetReferences.ts +++ b/tests/cases/fourslash/remoteGetReferences.ts @@ -93,7 +93,7 @@ ////remotefoo([|remoteglobalVar|]); //// //////Increments -////[|remotefooCls|].[|remoteclsSVar|]++; +////[|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; ////remotemodTest.remotemodVar++; ////[|{| "isWriteAccess": true |}remoteglobalVar|] = [|remoteglobalVar|] + [|remoteglobalVar|]; //// @@ -129,8 +129,8 @@ //// constructor(public remoteclsParam: number) { //// //Increments //// [|{| "isWriteAccess": true |}remoteglobalVar|]++; -//// this.[|remoteclsVar|]++; -//// [|remotefooCls|].[|remoteclsSVar|]++; +//// this.[|{| "isWriteAccess": true |}remoteclsVar|]++; +//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; //// this.remoteclsParam++; //// remotemodTest.remotemodVar++; //// } @@ -141,7 +141,7 @@ //// var remotefnVar = 1; //// //// //Increments -//// [|remotefooCls|].[|remoteclsSVar|]++; +//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; //// [|{| "isWriteAccess": true |}remoteglobalVar|]++; //// remotemodTest.remotemodVar++; //// remotefnVar++; @@ -156,7 +156,7 @@ //// //// //Increments //// [|{| "isWriteAccess": true |}remoteglobalVar|]++; -//// [|remotefooCls|].[|remoteclsSVar|]++; +//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; //// remotemodVar++; //// //// class remotetestCls { @@ -168,7 +168,7 @@ //// //// //Increments //// [|{| "isWriteAccess": true |}remoteglobalVar|]++; -//// [|remotefooCls|].[|remoteclsSVar|]++; +//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++; //// remotemodVar++; //// } //// diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts index a458d6d824c..62d128ea9e7 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction4.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts @@ -3,8 +3,7 @@ // @noUnusedLocals: true ////function greeter() { //// [| var x,y = 0,z = 1; |] -//// y++; -//// z++; +//// use(y, z); ////} verify.rangeAfterCodeFix("var y = 0,z = 1;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts index dc73ab86663..ecfb7455276 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts @@ -4,8 +4,8 @@ // @noUnusedParameters: true ////class greeter { //// public function1() { -//// [| var /*0*/x,/*1*/ y = 10; |] -//// y++; +//// [| var /*0*/x,/*1*/ y = 10; |] +//// use(y); //// } ////} diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts index 012bf87a222..d06e803bf7f 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts @@ -5,7 +5,7 @@ ////class greeter { //// public function1() { //// [| var x, y; |] -//// y = 1; +//// use(y); //// } ////} diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts index 81e73450622..6d1a772b0a8 100644 --- a/tests/cases/fourslash/unusedParameterInFunction2.ts +++ b/tests/cases/fourslash/unusedParameterInFunction2.ts @@ -2,7 +2,7 @@ // @noUnusedParameters: true ////function [|greeter(x,y)|] { -//// x++; +//// use(x); ////} verify.rangeAfterCodeFix("greeter(x)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts index 4ea96b3bd18..e3ee2585384 100644 --- a/tests/cases/fourslash/unusedParameterInFunction4.ts +++ b/tests/cases/fourslash/unusedParameterInFunction4.ts @@ -2,8 +2,7 @@ // @noUnusedParameters: true ////[|function greeter(x,y,z) |] { -//// x++; -//// z++; +//// use(x, z); ////} verify.rangeAfterCodeFix("function greeter(x,z)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts index 992c229014a..61fc3ec137c 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace2.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts @@ -4,8 +4,7 @@ ////namespace greeter { //// [|let a = "dummy entry", b, c = 0;|] //// export function function1() { -//// a = "dummy"; -//// c++; +//// use(a, c); //// } ////} diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts index 0039036b2f8..7d2f3d251f3 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace3.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts @@ -4,8 +4,7 @@ ////namespace greeter { //// [|let a = "dummy entry", b, c = 0;|] //// export function function1() { -//// a = "dummy"; -//// b = 0; +//// use(a, b); //// } ////} From d762f55199ec652520b6a695f3957f9ed4da881b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 09:23:57 -0700 Subject: [PATCH 138/216] Fix:Instantiate javascript constructor signatures getSignatureInstantation takes a parameter that tells whether the signature comes from Javascript and therefore is allowed to pass fewer than the required number of type arguments. (Defaults are chosen if this is the case.) Previously, getInstantiatedConstructorsForTypeArguments forgot to provide this argument, and constructors with insufficient type arguments would cause a crash because getSignatureInstantiation would not know to fill in the missing type arguments. --- src/compiler/checker.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c169dcb83ca..2375d52a6e9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4902,7 +4902,7 @@ namespace ts { function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray, location: Node): Signature[] { const signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); - return sameMap(signatures, sig => some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig); + return sameMap(signatures, sig => some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, isInJavaScriptFile(location)) : sig); } /** @@ -5498,7 +5498,7 @@ namespace ts { const minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); const typeParamCount = length(baseSig.typeParameters); if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { - const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); + const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -6361,11 +6361,10 @@ namespace ts { * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, location?: Node) { + function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript?: boolean) { const numTypeParameters = length(typeParameters); if (numTypeParameters) { const numTypeArguments = length(typeArguments); - const isJavaScript = isInJavaScriptFile(location); if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; @@ -6623,8 +6622,8 @@ namespace ts { return anyType; } - function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); + function getSignatureInstantiation(signature: Signature, typeArguments: Type[], isJavascript?: boolean): Signature { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); const instantiations = signature.instantiations || (signature.instantiations = createMap()); const id = getTypeListId(typeArguments); let instantiation = instantiations.get(id); @@ -6813,7 +6812,8 @@ namespace ts { if (typeParameters) { const numTypeArguments = length(node.typeArguments); const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (!isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { + const isJavascript = isInJavaScriptFile(node); + if (!isJavascript && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? Diagnostics.Generic_type_0_requires_1_type_argument_s @@ -6826,7 +6826,7 @@ namespace ts { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, node)); + const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJavascript)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { From 014f7ba8280d0cfa3936ebacb018c4b6d2407d91 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 09:26:20 -0700 Subject: [PATCH 139/216] Test:javascript signature instantiation w/insufficient type args --- ...ssingTypeArgsOnJSConstructCalls.errors.txt | 48 +++++++++++++++++++ ...fillInMissingTypeArgsOnJSConstructCalls.ts | 27 +++++++++++ 2 files changed, 75 insertions(+) create mode 100644 tests/baselines/reference/fillInMissingTypeArgsOnJSConstructCalls.errors.txt create mode 100644 tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts diff --git a/tests/baselines/reference/fillInMissingTypeArgsOnJSConstructCalls.errors.txt b/tests/baselines/reference/fillInMissingTypeArgsOnJSConstructCalls.errors.txt new file mode 100644 index 00000000000..966e3e35613 --- /dev/null +++ b/tests/baselines/reference/fillInMissingTypeArgsOnJSConstructCalls.errors.txt @@ -0,0 +1,48 @@ +tests/cases/compiler/BaseB.js(2,24): error TS8004: 'type parameter declarations' can only be used in a .ts file. +tests/cases/compiler/BaseB.js(2,25): error TS1005: ',' expected. +tests/cases/compiler/BaseB.js(3,14): error TS2304: Cannot find name 'Class'. +tests/cases/compiler/BaseB.js(3,14): error TS8010: 'types' can only be used in a .ts file. +tests/cases/compiler/BaseB.js(4,25): error TS2304: Cannot find name 'Class'. +tests/cases/compiler/BaseB.js(4,25): error TS8010: 'types' can only be used in a .ts file. +tests/cases/compiler/SubB.js(3,41): error TS8011: 'type arguments' can only be used in a .ts file. + + +==== tests/cases/compiler/BaseA.js (0 errors) ==== + // regression test for #18254 + export default class BaseA { + } +==== tests/cases/compiler/SubA.js (0 errors) ==== + import BaseA from './BaseA'; + export default class SubA extends BaseA { + } +==== tests/cases/compiler/BaseB.js (6 errors) ==== + import BaseA from './BaseA'; + export default class B { + ~~~~~~~~ +!!! error TS8004: 'type parameter declarations' can only be used in a .ts file. + ~ +!!! error TS1005: ',' expected. + _AClass: Class; + ~~~~~ +!!! error TS2304: Cannot find name 'Class'. + ~~~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + constructor(AClass: Class) { + ~~~~~ +!!! error TS2304: Cannot find name 'Class'. + ~~~~~~~~ +!!! error TS8010: 'types' can only be used in a .ts file. + this._AClass = AClass; + } + } +==== tests/cases/compiler/SubB.js (1 errors) ==== + import SubA from './SubA'; + import BaseB from './BaseB'; + export default class SubB extends BaseB { + ~~~~ +!!! error TS8011: 'type arguments' can only be used in a .ts file. + constructor() { + super(SubA); + } + } + \ No newline at end of file diff --git a/tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts b/tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts new file mode 100644 index 00000000000..8ef0f903189 --- /dev/null +++ b/tests/cases/compiler/fillInMissingTypeArgsOnJSConstructCalls.ts @@ -0,0 +1,27 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// regression test for #18254 +// @Filename: BaseA.js +export default class BaseA { +} +// @Filename: SubA.js +import BaseA from './BaseA'; +export default class SubA extends BaseA { +} +// @Filename: BaseB.js +import BaseA from './BaseA'; +export default class B { + _AClass: Class; + constructor(AClass: Class) { + this._AClass = AClass; + } +} +// @Filename: SubB.js +import SubA from './SubA'; +import BaseB from './BaseB'; +export default class SubB extends BaseB { + constructor() { + super(SubA); + } +} From 5d51a42030bce430b3bed523da9520f97287d82f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 10:26:11 -0700 Subject: [PATCH 140/216] Use createMissingNode for sentinel node --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6d6b757f6e9..8912480d541 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3028,7 +3028,7 @@ namespace ts { if (inParameter && requireEqualsToken) { // = is required when speculatively parsing arrow function parameters, // so return a fake initializer as a signal that the equals token was missing - const result = createNode(SyntaxKind.Identifier, scanner.getStartPos()) as Identifier; + const result = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics._0_expected, "=") as Identifier; result.escapedText = "= not found" as __String; return result; } From a1d1a2219b7d16a262af9eb52eaa242bc46ef657 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 10:44:11 -0700 Subject: [PATCH 141/216] Make isJavascript parameters required This is a bit wordy, but will probably prevent bugs similar to #18254 in the future. --- src/compiler/checker.ts | 27 ++++++++++++++++----------- src/compiler/utilities.ts | 4 ++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2375d52a6e9..0ee3d549d48 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6361,7 +6361,7 @@ namespace ts { * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript?: boolean) { + function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript: boolean) { const numTypeParameters = length(typeParameters); if (numTypeParameters) { const numTypeArguments = length(typeArguments); @@ -6622,7 +6622,7 @@ namespace ts { return anyType; } - function getSignatureInstantiation(signature: Signature, typeArguments: Type[], isJavascript?: boolean): Signature { + function getSignatureInstantiation(signature: Signature, typeArguments: Type[], isJavascript: boolean): Signature { typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); const instantiations = signature.instantiations || (signature.instantiations = createMap()); const id = getTypeListId(typeArguments); @@ -6661,7 +6661,10 @@ namespace ts { // where different generations of the same type parameter are in scope). This leads to a lot of new type // identities, and potentially a lot of work comparing those identities, so here we create an instantiation // that uses the original type identities for all unconstrained type parameters. - return getSignatureInstantiation(signature, map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp)); + return getSignatureInstantiation( + signature, + map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp), + isInJavaScriptFile(signature.declaration)); } function getOrCreateTypeFromSignature(signature: Signature): ObjectType { @@ -6843,7 +6846,7 @@ namespace ts { const id = getTypeListId(typeArguments); let instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), isInJavaScriptFile(symbol.valueDeclaration))))); } return instantiation; } @@ -13999,8 +14002,9 @@ namespace ts { const instantiatedSignatures = []; for (const signature of signatures) { if (signature.typeParameters) { - const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + const isJavascript = isInJavaScriptFile(node); + const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0, isJavascript); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); } else { instantiatedSignatures.push(signature); @@ -15257,7 +15261,7 @@ namespace ts { if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), InferencePriority.ReturnType); } - return getSignatureInstantiation(signature, getInferredTypes(context)); + return getSignatureInstantiation(signature, getInferredTypes(context), isInJavaScriptFile(contextualSignature.declaration)); } function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: ReadonlyArray, excludeArgument: boolean[], context: InferenceContext): Type[] { @@ -15292,7 +15296,7 @@ namespace ts { // Above, the type of the 'value' parameter is inferred to be 'A'. const contextualSignature = getSingleCallSignature(instantiatedType); const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) : + getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, isInJavaScriptFile(node))) : instantiatedType; const inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -16008,8 +16012,9 @@ namespace ts { candidate = originalCandidate; if (candidate.typeParameters) { let typeArgumentTypes: Type[]; + const isJavascript = isInJavaScriptFile(candidate.declaration); if (typeArguments) { - typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); + typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript); if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)) { candidateForTypeArgumentError = originalCandidate; break; @@ -16018,7 +16023,7 @@ namespace ts { else { typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript); } if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { candidateForArgumentError = candidate; @@ -18782,7 +18787,7 @@ namespace ts { const constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); + typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, isInJavaScriptFile(typeArgumentNodes[i])); mapper = createTypeMapper(typeParameters, typeArguments); } const typeArgument = typeArguments[i]; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ee450344827..7eaf99c68e2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1325,11 +1325,11 @@ namespace ts { return isInJavaScriptFile(file); } - export function isInJavaScriptFile(node: Node): boolean { + export function isInJavaScriptFile(node: Node | undefined): boolean { return node && !!(node.flags & NodeFlags.JavaScriptFile); } - export function isInJSDoc(node: Node): boolean { + export function isInJSDoc(node: Node | undefined): boolean { return node && !!(node.flags & NodeFlags.JSDoc); } From c64beb90dfb513cbc24ed4a4a52b242196f0c2a3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Sep 2017 11:52:10 -0700 Subject: [PATCH 142/216] Remove intersections of object and nullable types from union types --- src/compiler/checker.ts | 20 ++++++++++++++++++-- src/compiler/types.ts | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 379bc3377d2..bdebfcef47a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7289,6 +7289,22 @@ namespace ts { return binarySearchTypes(types, type) >= 0; } + // Return true if the given intersection type contains (a) more than one unit type or (b) an object + // type and a nullable type (null or undefined). + function isEmptyIntersectionType(type: IntersectionType) { + let combined: TypeFlags = 0; + for (const t of type.types) { + if (t.flags & TypeFlags.Unit && combined & TypeFlags.Unit) { + return true; + } + combined |= t.flags; + if (combined & TypeFlags.Nullable && combined & (TypeFlags.Object | TypeFlags.NonPrimitive)) { + return true; + } + } + return false; + } + function addTypeToUnion(typeSet: TypeSet, type: Type) { const flags = type.flags; if (flags & TypeFlags.Union) { @@ -7302,7 +7318,7 @@ namespace ts { if (flags & TypeFlags.Null) typeSet.containsNull = true; if (!(flags & TypeFlags.ContainsWideningType)) typeSet.containsNonWideningType = true; } - else if (!(flags & TypeFlags.Never || flags & TypeFlags.Intersection && every((type).types, isUnitType))) { + else if (!(flags & TypeFlags.Never || flags & TypeFlags.Intersection && isEmptyIntersectionType(type))) { // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it @@ -10041,7 +10057,7 @@ namespace ts { } function isUnitType(type: Type): boolean { - return (type.flags & (TypeFlags.Literal | TypeFlags.Undefined | TypeFlags.Null)) !== 0; + return !!(type.flags & TypeFlags.Unit); } function isLiteralType(type: Type): boolean { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 55baf9763c2..efae0b50784 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3217,6 +3217,7 @@ namespace ts { /* @internal */ Nullable = Undefined | Null, Literal = StringLiteral | NumberLiteral | BooleanLiteral, + Unit = Literal | Nullable, StringOrNumberLiteral = StringLiteral | NumberLiteral, /* @internal */ DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, From 0ac942f7ab89ccbe42af987425237f3a271b32a3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Sep 2017 11:52:21 -0700 Subject: [PATCH 143/216] Update test --- tests/cases/compiler/restUnion2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/compiler/restUnion2.ts b/tests/cases/compiler/restUnion2.ts index 83d94e03a73..21f912cb2fb 100644 --- a/tests/cases/compiler/restUnion2.ts +++ b/tests/cases/compiler/restUnion2.ts @@ -14,6 +14,6 @@ declare const nullAndUndefinedUnion: null | undefined; var rest4: { }; var {...rest4 } = nullAndUndefinedUnion; -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined; var rest5: { n: number, s: string }; var {...rest5 } = unionWithIntersection; \ No newline at end of file From b20d631ba235ae176d12fe95006535b637357e01 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Sep 2017 11:52:51 -0700 Subject: [PATCH 144/216] Accept new baselines --- tests/baselines/reference/restUnion2.js | 2 +- tests/baselines/reference/restUnion2.symbols | 2 +- tests/baselines/reference/restUnion2.types | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/restUnion2.js b/tests/baselines/reference/restUnion2.js index 71f4b06cfef..382b7bb2bc9 100644 --- a/tests/baselines/reference/restUnion2.js +++ b/tests/baselines/reference/restUnion2.js @@ -13,7 +13,7 @@ declare const nullAndUndefinedUnion: null | undefined; var rest4: { }; var {...rest4 } = nullAndUndefinedUnion; -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined; var rest5: { n: number, s: string }; var {...rest5 } = unionWithIntersection; diff --git a/tests/baselines/reference/restUnion2.symbols b/tests/baselines/reference/restUnion2.symbols index 54ac47f0694..2728285f5ef 100644 --- a/tests/baselines/reference/restUnion2.symbols +++ b/tests/baselines/reference/restUnion2.symbols @@ -35,7 +35,7 @@ var {...rest4 } = nullAndUndefinedUnion; >rest4 : Symbol(rest4, Decl(restUnion2.ts, 11, 3), Decl(restUnion2.ts, 12, 5)) >nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(restUnion2.ts, 10, 13)) -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined; >unionWithIntersection : Symbol(unionWithIntersection, Decl(restUnion2.ts, 14, 13)) >n : Symbol(n, Decl(restUnion2.ts, 14, 39)) >s : Symbol(s, Decl(restUnion2.ts, 14, 55)) diff --git a/tests/baselines/reference/restUnion2.types b/tests/baselines/reference/restUnion2.types index 03c8d577e66..029192a9ac4 100644 --- a/tests/baselines/reference/restUnion2.types +++ b/tests/baselines/reference/restUnion2.types @@ -37,11 +37,10 @@ var {...rest4 } = nullAndUndefinedUnion; >rest4 : {} >nullAndUndefinedUnion : null | undefined -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; ->unionWithIntersection : ({ n: number; } & { s: string; } & undefined) | null +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined; +>unionWithIntersection : { n: number; } & { s: string; } & undefined >n : number >s : string ->null : null var rest5: { n: number, s: string }; >rest5 : { n: number; s: string; } @@ -50,5 +49,5 @@ var rest5: { n: number, s: string }; var {...rest5 } = unionWithIntersection; >rest5 : { n: number; s: string; } ->unionWithIntersection : ({ n: number; } & { s: string; } & undefined) | null +>unionWithIntersection : { n: number; } & { s: string; } & undefined From 34576c2521b3cc12b88e73fde33b100220110013 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 8 Sep 2017 18:37:15 -0700 Subject: [PATCH 145/216] Call getShorthandAssignmentValueSymbol rather than getSymbolAtLocation ...for shorthand property assignment names when collecting usages. --- src/harness/unittests/extractMethods.ts | 19 ++++++ src/services/refactors/extractMethod.ts | 6 +- .../extractMethod/extractMethod29.ts | 62 +++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod29.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index c836698aeb4..bfd7519449d 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -709,6 +709,25 @@ function M3() { }`); } M3() { } constructor() { } +}`); + // Shorthand property names + testExtractMethod("extractMethod29", + `interface UnaryExpression { + kind: "Unary"; + operator: string; + operand: any; +} + +function parseUnaryExpression(operator: string): UnaryExpression { + [#|return { + kind: "Unary", + operator, + operand: parsePrimaryExpression(), + };|] +} + +function parsePrimaryExpression(): any { + throw "Not implemented"; }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 7b5e1e40c7e..5749c2b71d5 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -1161,7 +1161,11 @@ namespace ts.refactor.extractMethod { } function recordUsagebySymbol(identifier: Identifier, usage: Usage, isTypeName: boolean) { - const symbol = checker.getSymbolAtLocation(identifier); + // If the identifier is both a property name and its value, we're only interested in its value + // (since the name is a declaration and will be included in the extracted range). + const symbol = identifier.parent && isShorthandPropertyAssignment(identifier.parent) && identifier.parent.name === identifier + ? checker.getShorthandAssignmentValueSymbol(identifier.parent) + : checker.getSymbolAtLocation(identifier); if (!symbol) { // cannot find symbol - do nothing return undefined; diff --git a/tests/baselines/reference/extractMethod/extractMethod29.ts b/tests/baselines/reference/extractMethod/extractMethod29.ts new file mode 100644 index 00000000000..aa7004d254e --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod29.ts @@ -0,0 +1,62 @@ +// ==ORIGINAL== +interface UnaryExpression { + kind: "Unary"; + operator: string; + operand: any; +} + +function parseUnaryExpression(operator: string): UnaryExpression { + return { + kind: "Unary", + operator, + operand: parsePrimaryExpression(), + }; +} + +function parsePrimaryExpression(): any { + throw "Not implemented"; +} +// ==SCOPE::inner function in function 'parseUnaryExpression'== +interface UnaryExpression { + kind: "Unary"; + operator: string; + operand: any; +} + +function parseUnaryExpression(operator: string): UnaryExpression { + return /*RENAME*/newFunction(); + + function newFunction() { + return { + kind: "Unary", + operator, + operand: parsePrimaryExpression(), + }; + } +} + +function parsePrimaryExpression(): any { + throw "Not implemented"; +} +// ==SCOPE::function in global scope== +interface UnaryExpression { + kind: "Unary"; + operator: string; + operand: any; +} + +function parseUnaryExpression(operator: string): UnaryExpression { + return /*RENAME*/newFunction(operator); +} + +function newFunction(operator: string) { + return { + kind: "Unary", + operator, + operand: parsePrimaryExpression(), + }; +} + +function parsePrimaryExpression(): any { + throw "Not implemented"; +} \ No newline at end of file From 255951c270b10627b3dfcef0aa55a25a0fd0a7d1 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 12 Sep 2017 16:51:13 -0700 Subject: [PATCH 146/216] Stop preventing extraction when a type parameter wouldn't bind ...correctly in a containing scope. It's not an issue because we'll just declare a corresponding type parameter on the extracted function and pass the original as a type argument. Fixes #18142 --- src/harness/unittests/extractMethods.ts | 5 +++++ src/services/refactors/extractMethod.ts | 6 +++++- .../extractMethod/extractMethod30.ts | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod30.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index bfd7519449d..86ee5354a5c 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -728,6 +728,11 @@ function parseUnaryExpression(operator: string): UnaryExpression { function parsePrimaryExpression(): any { throw "Not implemented"; +}`); + // Type parameter as declared type + testExtractMethod("extractMethod30", + `function F() { + [#|let t: T;|] }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 5749c2b71d5..eed49524656 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -1222,7 +1222,11 @@ namespace ts.refactor.extractMethod { substitutionsPerScope[i].set(symbolId, substitution); } else if (isTypeName) { - errorsPerScope[i].push(createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument + // so there's no problem. + if (!(symbol.flags & SymbolFlags.TypeParameter)) { + errorsPerScope[i].push(createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } } else { usagesPerScope[i].usages.set(identifier.text as string, { usage, symbol, node: identifier }); diff --git a/tests/baselines/reference/extractMethod/extractMethod30.ts b/tests/baselines/reference/extractMethod/extractMethod30.ts new file mode 100644 index 00000000000..67dc1208abc --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod30.ts @@ -0,0 +1,19 @@ +// ==ORIGINAL== +function F() { + let t: T; +} +// ==SCOPE::inner function in function 'F'== +function F() { + /*RENAME*/newFunction(); + + function newFunction() { + let t: T; + } +} +// ==SCOPE::function in global scope== +function F() { + /*RENAME*/newFunction(); +} +function newFunction() { + let t: T; +} From e2d94a2922a605fa14f6ae3864595d084d362540 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 13 Sep 2017 12:50:41 -0700 Subject: [PATCH 147/216] Only introduce return properties at the top level ...not in nested functions. --- src/harness/unittests/extractMethods.ts | 27 +++++++++++ src/services/refactors/extractMethod.ts | 9 +++- .../extractMethod/extractMethod31.ts | 45 ++++++++++++++++++ .../extractMethod/extractMethod32.ts | 46 +++++++++++++++++++ 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod31.ts create mode 100644 tests/baselines/reference/extractMethod/extractMethod32.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 86ee5354a5c..956ceb78e02 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -733,6 +733,33 @@ function parsePrimaryExpression(): any { testExtractMethod("extractMethod30", `function F() { [#|let t: T;|] +}`); + // Return in nested function + testExtractMethod("extractMethod31", + `namespace N { + + export const value = 1; + + () => { + var f: () => number; + [#|f = function (): number { + return value; + }|] + } +}`); + // Return in nested class + testExtractMethod("extractMethod32", + `namespace N { + + export const value = 1; + + () => { + [#|var c = class { + M() { + return value; + } + }|] + } }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index eed49524656..2410ce8cee5 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -855,6 +855,7 @@ namespace ts.refactor.extractMethod { return { body: createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; } let returnValueProperty: string; + let ignoreReturns = false; const statements = createNodeArray(isBlock(body) ? body.statements.slice(0) : [isStatement(body) ? body : createReturn(body)]); // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions if (writes || substitutions.size) { @@ -877,7 +878,7 @@ namespace ts.refactor.extractMethod { } function visitor(node: Node): VisitResult { - if (node.kind === SyntaxKind.ReturnStatement && writes) { + if (!ignoreReturns && node.kind === SyntaxKind.ReturnStatement && writes) { const assignments: ObjectLiteralElementLike[] = getPropertyAssignmentsForWrites(writes); if ((node).expression) { if (!returnValueProperty) { @@ -893,8 +894,12 @@ namespace ts.refactor.extractMethod { } } else { + const oldIgnoreReturns = ignoreReturns; + ignoreReturns = ignoreReturns || isFunctionLike(node) || isClassLike(node); const substitution = substitutions.get(getNodeId(node).toString()); - return substitution || visitEachChild(node, visitor, nullTransformationContext); + const result = substitution || visitEachChild(node, visitor, nullTransformationContext); + ignoreReturns = oldIgnoreReturns; + return result; } } } diff --git a/tests/baselines/reference/extractMethod/extractMethod31.ts b/tests/baselines/reference/extractMethod/extractMethod31.ts new file mode 100644 index 00000000000..754814dcc26 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod31.ts @@ -0,0 +1,45 @@ +// ==ORIGINAL== +namespace N { + + export const value = 1; + + () => { + var f: () => number; + f = function (): number { + return value; + } + } +} +// ==SCOPE::function in namespace 'N'== +namespace N { + + export const value = 1; + + () => { + var f: () => number; + f = /*RENAME*/newFunction(f); + } + + function newFunction(f: () => number) { + f = function(): number { + return value; + }; + return f; + } +} +// ==SCOPE::function in global scope== +namespace N { + + export const value = 1; + + () => { + var f: () => number; + f = /*RENAME*/newFunction(f); + } +} +function newFunction(f: () => number) { + f = function(): number { + return N.value; + }; + return f; +} diff --git a/tests/baselines/reference/extractMethod/extractMethod32.ts b/tests/baselines/reference/extractMethod/extractMethod32.ts new file mode 100644 index 00000000000..b9b870a08fa --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod32.ts @@ -0,0 +1,46 @@ +// ==ORIGINAL== +namespace N { + + export const value = 1; + + () => { + var c = class { + M() { + return value; + } + } + } +} +// ==SCOPE::function in namespace 'N'== +namespace N { + + export const value = 1; + + () => { + /*RENAME*/newFunction(); + } + + function newFunction() { + var c = class { + M() { + return value; + } + }; + } +} +// ==SCOPE::function in global scope== +namespace N { + + export const value = 1; + + () => { + /*RENAME*/newFunction(); + } +} +function newFunction() { + var c = class { + M() { + return N.value; + } + }; +} From 60f1d4573d8166fc369887ca4b96bf04d2d5b782 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 14:04:14 -0700 Subject: [PATCH 148/216] Allow booleans in spread types Special-case types produced by `bool && expr` with the type `false | T`. This spreads `Partial` instead of `false | T`. --- src/compiler/checker.ts | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5c6a8b59119..287311e6433 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7832,12 +7832,25 @@ namespace ts { return left; } if (left.flags & TypeFlags.Union) { - return mapType(left, t => getSpreadType(t, right)); + // if the union is `false | T` make all the properties of T optional + const wl = getPartialTypeFromFalseUnion(left as UnionType); + if (wl) { + left = wl; + } + else { + return mapType(left, t => getSpreadType(t, right)); + } } if (right.flags & TypeFlags.Union) { - return mapType(right, t => getSpreadType(left, t)); + const wr = getPartialTypeFromFalseUnion(right as UnionType); + if (wr) { + right = wr; + } + else { + return mapType(right, t => getSpreadType(left, t)); + } } - if (right.flags & TypeFlags.NonPrimitive) { + if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike)) { return emptyObjectType; } @@ -7908,6 +7921,29 @@ namespace ts { return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); } + function getPartialTypeFromFalseUnion(type: UnionType): Type | undefined { + if (type.types.length === 2) { + const i = type.types.indexOf(falseType); + if (i > -1) { + const members = createSymbolTable(); + const other = type.types[i === 0 ? 1 : 0]; + for (const prop of getPropertiesOfType(other)) { + if (prop.flags & SymbolFlags.Optional) { + members.set(prop.escapedName, prop); + } + else { + const result = createSymbol(prop.flags | SymbolFlags.Optional, prop.escapedName); + result.type = getUnionType([getTypeOfSymbol(prop), undefinedType]); + result.declarations = prop.declarations; + result.syntheticOrigin = prop; + members.set(prop.escapedName, result); + } + } + return createAnonymousType(undefined, members, emptyArray, emptyArray, getIndexInfoOfType(other, IndexKind.String), getIndexInfoOfType(other, IndexKind.Number)); + } + } + } + function createLiteralType(flags: TypeFlags, value: string | number, symbol: Symbol) { const type = createType(flags); type.symbol = symbol; @@ -13749,7 +13785,7 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { - return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined | TypeFlags.NonPrimitive) || + return !!(type.flags & (TypeFlags.Any | TypeFlags.Nullable | TypeFlags.NonPrimitive | TypeFlags.BooleanLike) || type.flags & TypeFlags.Object && !isGenericMappedType(type) || type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } From 9cddd1aca2de5eec903b2cbdb5d812ab68e2ef94 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 14:06:15 -0700 Subject: [PATCH 149/216] Update spread tests for booleans in spread types --- tests/baselines/reference/objectSpread.js | 65 +++--- .../baselines/reference/objectSpread.symbols | 201 ++++++++++-------- tests/baselines/reference/objectSpread.types | 80 ++++--- .../reference/objectSpreadNegative.errors.txt | 26 +-- .../reference/objectSpreadNegative.js | 6 - .../conformance/types/spread/objectSpread.ts | 38 ++-- .../types/spread/objectSpreadNegative.ts | 3 - 7 files changed, 236 insertions(+), 183 deletions(-) diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index e05837c32d5..11b904a4806 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -38,6 +38,13 @@ getter.a = 12; // functions result in { } let spreadFunc = { ...(function () { }) }; +// boolean && T results in Partial +function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { + return { ...b && { x: 1, y: 2 } }; +} +// other booleans result in { } +let spreadBool = { ... true } + // any results in any let anything: any; let spreadAny = { ...anything }; @@ -60,21 +67,23 @@ let changeTypeBoth: { a: string, b: number } = { ...o, ...swap }; // optional -let definiteBoolean: { sn: boolean }; -let definiteString: { sn: string }; -let optionalString: { sn?: string }; -let optionalNumber: { sn?: number }; -let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; -let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; -let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; +function container( + definiteBoolean: { sn: boolean }, + definiteString: { sn: string }, + optionalString: { sn?: string }, + optionalNumber: { sn?: number }) { + let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; + let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; + let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; -// computed property -let computedFirst: { a: number, b: string, "before everything": number } = - { ['before everything']: 12, ...o, b: 'yes' } -let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = - { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } -let computedAfter: { a: number, b: string, "at the end": number } = - { ...o, b: 'yeah', ['at the end']: 14 } + // computed property + let computedFirst: { a: number, b: string, "before everything": number } = + { ['before everything']: 12, ...o, b: 'yes' } + let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = + { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } + let computedAfter: { a: number, b: string, "at the end": number } = + { ...o, b: 'yeah', ['at the end']: 14 } +} // shortcut syntax let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } @@ -114,6 +123,12 @@ var getter = __assign({}, op, { c: 7 }); getter.a = 12; // functions result in { } var spreadFunc = __assign({}, (function () { })); +// boolean && T results in Partial +function conditionalSpread(b) { + return __assign({}, b && { x: 1, y: 2 }); +} +// other booleans result in { } +var spreadBool = __assign({}, true); // any results in any var anything; var spreadAny = __assign({}, anything); @@ -135,20 +150,18 @@ var changeTypeAfter = __assign({}, o, { a: 'wrong type?' }); var changeTypeBefore = __assign({ a: 'wrong type?' }, o); var changeTypeBoth = __assign({}, o, swap); // optional -var definiteBoolean; -var definiteString; -var optionalString; -var optionalNumber; -var optionalUnionStops = __assign({}, definiteBoolean, definiteString, optionalNumber); -var optionalUnionDuplicates = __assign({}, definiteBoolean, definiteString, optionalString, optionalNumber); -var allOptional = __assign({}, optionalString, optionalNumber); -// computed property -var computedFirst = __assign((_a = {}, _a['before everything'] = 12, _a), o, { b: 'yes' }); -var computedMiddle = __assign({}, o, (_b = {}, _b['in the middle'] = 13, _b.b = 'maybe?', _b), o2); -var computedAfter = __assign({}, o, (_c = { b: 'yeah' }, _c['at the end'] = 14, _c)); +function container(definiteBoolean, definiteString, optionalString, optionalNumber) { + var optionalUnionStops = __assign({}, definiteBoolean, definiteString, optionalNumber); + var optionalUnionDuplicates = __assign({}, definiteBoolean, definiteString, optionalString, optionalNumber); + var allOptional = __assign({}, optionalString, optionalNumber); + // computed property + var computedFirst = __assign((_a = {}, _a['before everything'] = 12, _a), o, { b: 'yes' }); + var computedMiddle = __assign({}, o, (_b = {}, _b['in the middle'] = 13, _b.b = 'maybe?', _b), o2); + var computedAfter = __assign({}, o, (_c = { b: 'yeah' }, _c['at the end'] = 14, _c)); + var _a, _b, _c; +} // shortcut syntax var a = 12; var shortCutted = __assign({}, o, { a: a }); // non primitive var spreadNonPrimitive = __assign({}, {}); -var _a, _b, _c; diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 1ec2520e166..0c5e8a4c5a8 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -169,154 +169,173 @@ getter.a = 12; let spreadFunc = { ...(function () { }) }; >spreadFunc : Symbol(spreadFunc, Decl(objectSpread.ts, 37, 3)) +// boolean && T results in Partial +function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { +>conditionalSpread : Symbol(conditionalSpread, Decl(objectSpread.ts, 37, 42)) +>b : Symbol(b, Decl(objectSpread.ts, 40, 27)) +>x : Symbol(x, Decl(objectSpread.ts, 40, 42)) +>y : Symbol(y, Decl(objectSpread.ts, 40, 66)) + + return { ...b && { x: 1, y: 2 } }; +>b : Symbol(b, Decl(objectSpread.ts, 40, 27)) +>x : Symbol(x, Decl(objectSpread.ts, 41, 22)) +>y : Symbol(y, Decl(objectSpread.ts, 41, 28)) +} +// other booleans result in { } +let spreadBool = { ... true } +>spreadBool : Symbol(spreadBool, Decl(objectSpread.ts, 44, 3)) + // any results in any let anything: any; ->anything : Symbol(anything, Decl(objectSpread.ts, 40, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 47, 3)) let spreadAny = { ...anything }; ->spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 41, 3)) ->anything : Symbol(anything, Decl(objectSpread.ts, 40, 3)) +>spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 48, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 47, 3)) // methods are not enumerable class C { p = 1; m() { } } ->C : Symbol(C, Decl(objectSpread.ts, 41, 32)) ->p : Symbol(C.p, Decl(objectSpread.ts, 44, 9)) ->m : Symbol(C.m, Decl(objectSpread.ts, 44, 16)) +>C : Symbol(C, Decl(objectSpread.ts, 48, 32)) +>p : Symbol(C.p, Decl(objectSpread.ts, 51, 9)) +>m : Symbol(C.m, Decl(objectSpread.ts, 51, 16)) let c: C = new C() ->c : Symbol(c, Decl(objectSpread.ts, 45, 3)) ->C : Symbol(C, Decl(objectSpread.ts, 41, 32)) ->C : Symbol(C, Decl(objectSpread.ts, 41, 32)) +>c : Symbol(c, Decl(objectSpread.ts, 52, 3)) +>C : Symbol(C, Decl(objectSpread.ts, 48, 32)) +>C : Symbol(C, Decl(objectSpread.ts, 48, 32)) let spreadC: { p: number } = { ...c } ->spreadC : Symbol(spreadC, Decl(objectSpread.ts, 46, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 46, 14)) ->c : Symbol(c, Decl(objectSpread.ts, 45, 3)) +>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 53, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 53, 14)) +>c : Symbol(c, Decl(objectSpread.ts, 52, 3)) // own methods are enumerable let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }; ->cplus : Symbol(cplus, Decl(objectSpread.ts, 49, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 49, 12)) ->plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) ->c : Symbol(c, Decl(objectSpread.ts, 45, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 49, 48)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 56, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 56, 12)) +>plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) +>c : Symbol(c, Decl(objectSpread.ts, 52, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 56, 48)) cplus.plus(); ->cplus.plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) ->cplus : Symbol(cplus, Decl(objectSpread.ts, 49, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 49, 23)) +>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 56, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) // new field's type conflicting with existing field is OK let changeTypeAfter: { a: string, b: string } = ->changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 53, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 53, 22)) ->b : Symbol(b, Decl(objectSpread.ts, 53, 33)) +>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 60, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 60, 22)) +>b : Symbol(b, Decl(objectSpread.ts, 60, 33)) { ...o, a: 'wrong type?' } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 54, 11)) +>a : Symbol(a, Decl(objectSpread.ts, 61, 11)) let changeTypeBefore: { a: number, b: string } = ->changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 55, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 55, 23)) ->b : Symbol(b, Decl(objectSpread.ts, 55, 34)) +>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 62, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 62, 23)) +>b : Symbol(b, Decl(objectSpread.ts, 62, 34)) { a: 'wrong type?', ...o }; ->a : Symbol(a, Decl(objectSpread.ts, 56, 5)) +>a : Symbol(a, Decl(objectSpread.ts, 63, 5)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) let changeTypeBoth: { a: string, b: number } = ->changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 57, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 57, 21)) ->b : Symbol(b, Decl(objectSpread.ts, 57, 32)) +>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 64, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 64, 21)) +>b : Symbol(b, Decl(objectSpread.ts, 64, 32)) { ...o, ...swap }; >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) >swap : Symbol(swap, Decl(objectSpread.ts, 2, 3)) // optional -let definiteBoolean: { sn: boolean }; ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 61, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 61, 22)) +function container( +>container : Symbol(container, Decl(objectSpread.ts, 65, 22)) -let definiteString: { sn: string }; ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 62, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 62, 21)) + definiteBoolean: { sn: boolean }, +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) +>sn : Symbol(sn, Decl(objectSpread.ts, 69, 22)) -let optionalString: { sn?: string }; ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 63, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 63, 21)) + definiteString: { sn: string }, +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) +>sn : Symbol(sn, Decl(objectSpread.ts, 70, 21)) -let optionalNumber: { sn?: number }; ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 64, 21)) + optionalString: { sn?: string }, +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) +>sn : Symbol(sn, Decl(objectSpread.ts, 71, 21)) -let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; ->optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 65, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 65, 25)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 61, 3)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 62, 3)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) + optionalNumber: { sn?: number }) { +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) +>sn : Symbol(sn, Decl(objectSpread.ts, 72, 21)) -let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; ->optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 66, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 66, 30)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 61, 3)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 62, 3)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 63, 3)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) + let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; +>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 73, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 73, 29)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) -let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; ->allOptional : Symbol(allOptional, Decl(objectSpread.ts, 67, 3)) ->sn : Symbol(sn, Decl(objectSpread.ts, 67, 18)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 63, 3)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 64, 3)) + let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; +>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 74, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 74, 34)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) -// computed property -let computedFirst: { a: number, b: string, "before everything": number } = ->computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 70, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 70, 20)) ->b : Symbol(b, Decl(objectSpread.ts, 70, 31)) + let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; +>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 75, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 75, 22)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) - { ['before everything']: 12, ...o, b: 'yes' } ->'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 71, 5)) + // computed property + let computedFirst: { a: number, b: string, "before everything": number } = +>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 78, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 78, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 78, 35)) + + { ['before everything']: 12, ...o, b: 'yes' } +>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 79, 9)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 71, 38)) +>b : Symbol(b, Decl(objectSpread.ts, 79, 42)) -let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = ->computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 72, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 72, 21)) ->b : Symbol(b, Decl(objectSpread.ts, 72, 32)) ->c : Symbol(c, Decl(objectSpread.ts, 72, 43)) + let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = +>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 80, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 80, 25)) +>b : Symbol(b, Decl(objectSpread.ts, 80, 36)) +>c : Symbol(c, Decl(objectSpread.ts, 80, 47)) - { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } + { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 73, 11)) ->b : Symbol(b, Decl(objectSpread.ts, 73, 34)) +>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 81, 15)) +>b : Symbol(b, Decl(objectSpread.ts, 81, 38)) >o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) -let computedAfter: { a: number, b: string, "at the end": number } = ->computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 74, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 74, 20)) ->b : Symbol(b, Decl(objectSpread.ts, 74, 31)) + let computedAfter: { a: number, b: string, "at the end": number } = +>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 82, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 82, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 82, 35)) - { ...o, b: 'yeah', ['at the end']: 14 } + { ...o, b: 'yeah', ['at the end']: 14 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 75, 11)) ->'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 75, 22)) - +>b : Symbol(b, Decl(objectSpread.ts, 83, 15)) +>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 83, 26)) +} // shortcut syntax let a = 12; ->a : Symbol(a, Decl(objectSpread.ts, 77, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 86, 3)) let shortCutted: { a: number, b: string } = { ...o, a } ->shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 78, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 78, 18)) ->b : Symbol(b, Decl(objectSpread.ts, 78, 29)) +>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 87, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 87, 18)) +>b : Symbol(b, Decl(objectSpread.ts, 87, 29)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 78, 51)) +>a : Symbol(a, Decl(objectSpread.ts, 87, 51)) // non primitive let spreadNonPrimitive = { ...{}}; ->spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 80, 3)) +>spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 89, 3)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index 7bac35119ed..d696ed9ac7c 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -230,6 +230,29 @@ let spreadFunc = { ...(function () { }) }; >(function () { }) : () => void >function () { } : () => void +// boolean && T results in Partial +function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { +>conditionalSpread : (b: boolean) => { x?: number | undefined; y?: number | undefined; } +>b : boolean +>x : number | undefined +>y : number | undefined + + return { ...b && { x: 1, y: 2 } }; +>{ ...b && { x: 1, y: 2 } } : { x?: number | undefined; y?: number | undefined; } +>b && { x: 1, y: 2 } : false | { x: number; y: number; } +>b : boolean +>{ x: 1, y: 2 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>2 : 2 +} +// other booleans result in { } +let spreadBool = { ... true } +>spreadBool : {} +>{ ... true } : {} +>true : true + // any results in any let anything: any; >anything : any @@ -312,53 +335,56 @@ let changeTypeBoth: { a: string, b: number } = >swap : { a: string; b: number; } // optional -let definiteBoolean: { sn: boolean }; +function container( +>container : (definiteBoolean: { sn: boolean; }, definiteString: { sn: string; }, optionalString: { sn?: string | undefined; }, optionalNumber: { sn?: number | undefined; }) => void + + definiteBoolean: { sn: boolean }, >definiteBoolean : { sn: boolean; } >sn : boolean -let definiteString: { sn: string }; + definiteString: { sn: string }, >definiteString : { sn: string; } >sn : string -let optionalString: { sn?: string }; ->optionalString : { sn?: string; } ->sn : string + optionalString: { sn?: string }, +>optionalString : { sn?: string | undefined; } +>sn : string | undefined -let optionalNumber: { sn?: number }; ->optionalNumber : { sn?: number; } ->sn : number + optionalNumber: { sn?: number }) { +>optionalNumber : { sn?: number | undefined; } +>sn : number | undefined -let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; + let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; >optionalUnionStops : { sn: string | number | boolean; } >sn : string | number | boolean >{ ...definiteBoolean, ...definiteString, ...optionalNumber } : { sn: string | number; } >definiteBoolean : { sn: boolean; } >definiteString : { sn: string; } ->optionalNumber : { sn?: number; } +>optionalNumber : { sn?: number | undefined; } -let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; + let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; >optionalUnionDuplicates : { sn: string | number; } >sn : string | number >{ ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber } : { sn: string | number; } >definiteBoolean : { sn: boolean; } >definiteString : { sn: string; } ->optionalString : { sn?: string; } ->optionalNumber : { sn?: number; } +>optionalString : { sn?: string | undefined; } +>optionalNumber : { sn?: number | undefined; } -let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; ->allOptional : { sn?: string | number; } ->sn : string | number ->{ ...optionalString, ...optionalNumber } : { sn?: string | number; } ->optionalString : { sn?: string; } ->optionalNumber : { sn?: number; } + let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; +>allOptional : { sn?: string | number | undefined; } +>sn : string | number | undefined +>{ ...optionalString, ...optionalNumber } : { sn?: string | number | undefined; } +>optionalString : { sn?: string | undefined; } +>optionalNumber : { sn?: number | undefined; } -// computed property -let computedFirst: { a: number, b: string, "before everything": number } = + // computed property + let computedFirst: { a: number, b: string, "before everything": number } = >computedFirst : { a: number; b: string; "before everything": number; } >a : number >b : string - { ['before everything']: 12, ...o, b: 'yes' } + { ['before everything']: 12, ...o, b: 'yes' } >{ ['before everything']: 12, ...o, b: 'yes' } : { b: string; a: number; ['before everything']: number; } >'before everything' : "before everything" >12 : 12 @@ -366,13 +392,13 @@ let computedFirst: { a: number, b: string, "before everything": number } = >b : string >'yes' : "yes" -let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = + let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = >computedMiddle : { a: number; b: string; c: boolean; "in the middle": number; } >a : number >b : string >c : boolean - { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } + { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } >{ ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } : { b: string; c: boolean; ['in the middle']: number; a: number; } >o : { a: number; b: string; } >'in the middle' : "in the middle" @@ -381,19 +407,19 @@ let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number >'maybe?' : "maybe?" >o2 : { b: string; c: boolean; } -let computedAfter: { a: number, b: string, "at the end": number } = + let computedAfter: { a: number, b: string, "at the end": number } = >computedAfter : { a: number; b: string; "at the end": number; } >a : number >b : string - { ...o, b: 'yeah', ['at the end']: 14 } + { ...o, b: 'yeah', ['at the end']: 14 } >{ ...o, b: 'yeah', ['at the end']: 14 } : { b: string; ['at the end']: number; a: number; } >o : { a: number; b: string; } >b : string >'yeah' : "yeah" >'at the end' : "at the end" >14 : 14 - +} // shortcut syntax let a = 12; >a : number diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index a9381a0dcb1..14eba9d6f2a 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -9,23 +9,22 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,36): error TS230 tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,53): error TS2300: Duplicate identifier 'b'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(32,19): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,19): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(35,20): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,19): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(42,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(46,12): error TS2339: Property 'b' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(57,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(39,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,12): error TS2339: Property 'b' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(49,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(54,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,14): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(64,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(75,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(81,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(83,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (19 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (18 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -78,11 +77,6 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(83,7): error TS2322 let spreadSum = { ...1 + 1 }; ~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. - spreadSum.toFixed(); // error, no methods from number - let spreadBool = { ...false }; - ~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - spreadBool.valueOf(); // error, what were you thinking? let spreadStr = { ...'foo' }; ~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index aab8ffc4e91..6e82a19acbc 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -32,9 +32,6 @@ let duplicatedSpread = { ...o, ...o } // primitives are not allowed let spreadNum = { ...12 }; let spreadSum = { ...1 + 1 }; -spreadSum.toFixed(); // error, no methods from number -let spreadBool = { ...false }; -spreadBool.valueOf(); // error, what were you thinking? let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either @@ -124,9 +121,6 @@ var duplicatedSpread = __assign({}, o, o); // primitives are not allowed var spreadNum = __assign({}, 12); var spreadSum = __assign({}, 1 + 1); -spreadSum.toFixed(); // error, no methods from number -var spreadBool = __assign({}, false); -spreadBool.valueOf(); // error, what were you thinking? var spreadStr = __assign({}, 'foo'); spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either diff --git a/tests/cases/conformance/types/spread/objectSpread.ts b/tests/cases/conformance/types/spread/objectSpread.ts index 59b93bdd9e4..378c5558fc5 100644 --- a/tests/cases/conformance/types/spread/objectSpread.ts +++ b/tests/cases/conformance/types/spread/objectSpread.ts @@ -1,3 +1,4 @@ +// @strictNullChecks: true // @target: es5 let o = { a: 1, b: 'no' } let o2 = { b: 'yes', c: true } @@ -38,6 +39,13 @@ getter.a = 12; // functions result in { } let spreadFunc = { ...(function () { }) }; +// boolean && T results in Partial +function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { + return { ...b && { x: 1, y: 2 } }; +} +// other booleans result in { } +let spreadBool = { ... true } + // any results in any let anything: any; let spreadAny = { ...anything }; @@ -60,21 +68,23 @@ let changeTypeBoth: { a: string, b: number } = { ...o, ...swap }; // optional -let definiteBoolean: { sn: boolean }; -let definiteString: { sn: string }; -let optionalString: { sn?: string }; -let optionalNumber: { sn?: number }; -let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; -let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; -let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; +function container( + definiteBoolean: { sn: boolean }, + definiteString: { sn: string }, + optionalString: { sn?: string }, + optionalNumber: { sn?: number }) { + let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; + let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; + let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; -// computed property -let computedFirst: { a: number, b: string, "before everything": number } = - { ['before everything']: 12, ...o, b: 'yes' } -let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = - { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } -let computedAfter: { a: number, b: string, "at the end": number } = - { ...o, b: 'yeah', ['at the end']: 14 } + // computed property + let computedFirst: { a: number, b: string, "before everything": number } = + { ['before everything']: 12, ...o, b: 'yes' } + let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = + { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } + let computedAfter: { a: number, b: string, "at the end": number } = + { ...o, b: 'yeah', ['at the end']: 14 } +} // shortcut syntax let a = 12; let shortCutted: { a: number, b: string } = { ...o, a } diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index fced7706c96..beb9ff265b4 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -32,9 +32,6 @@ let duplicatedSpread = { ...o, ...o } // primitives are not allowed let spreadNum = { ...12 }; let spreadSum = { ...1 + 1 }; -spreadSum.toFixed(); // error, no methods from number -let spreadBool = { ...false }; -spreadBool.valueOf(); // error, what were you thinking? let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either From d951c14052b077cef3b8d1d6ef83c89f766c6d47 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 14:56:15 -0700 Subject: [PATCH 150/216] Allow all possibly falsy types in spreads And update tests to reflect that --- src/compiler/checker.ts | 10 +- tests/baselines/reference/objectSpread.js | 34 ++- .../baselines/reference/objectSpread.symbols | 230 +++++++++++------- tests/baselines/reference/objectSpread.types | 86 ++++++- .../reference/objectSpreadNegative.errors.txt | 17 +- .../objectSpreadNegativeParse.errors.txt | 5 +- .../conformance/types/spread/objectSpread.ts | 20 +- 7 files changed, 296 insertions(+), 106 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 287311e6433..ff796879071 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7850,7 +7850,7 @@ namespace ts { return mapType(right, t => getSpreadType(left, t)); } } - if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike)) { + if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike)) { return emptyObjectType; } @@ -7923,7 +7923,11 @@ namespace ts { function getPartialTypeFromFalseUnion(type: UnionType): Type | undefined { if (type.types.length === 2) { - const i = type.types.indexOf(falseType); + // getFalsyFlagsOfTypes + // getTypeFacts + const i = Math.max(type.types.indexOf(falseType), + type.types.indexOf(zeroType), + type.types.indexOf(emptyStringType)); if (i > -1) { const members = createSymbolTable(); const other = type.types[i === 0 ? 1 : 0]; @@ -13785,7 +13789,7 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { - return !!(type.flags & (TypeFlags.Any | TypeFlags.Nullable | TypeFlags.NonPrimitive | TypeFlags.BooleanLike) || + return !!(type.flags & (TypeFlags.Any | TypeFlags.PossiblyFalsy | TypeFlags.NonPrimitive) || type.flags & TypeFlags.Object && !isGenericMappedType(type) || type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index 11b904a4806..7eab2da265f 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -39,9 +39,27 @@ getter.a = 12; let spreadFunc = { ...(function () { }) }; // boolean && T results in Partial -function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { +function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { return { ...b && { x: 1, y: 2 } }; } +function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { + let o = { x: 12, y: 13 } + o = { + ...o, + ...nt && { x: nt } + } + let o2 = { ...nt && { x: nt }} + return o; +} +function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { + let o = { x: 'hi', y: 13 } + o = { + ...o, + ...st && { x: st } + } + let o2 = { ...st && { x: st }} + return o; +} // other booleans result in { } let spreadBool = { ... true } @@ -124,9 +142,21 @@ getter.a = 12; // functions result in { } var spreadFunc = __assign({}, (function () { })); // boolean && T results in Partial -function conditionalSpread(b) { +function conditionalSpreadBoolean(b) { return __assign({}, b && { x: 1, y: 2 }); } +function conditionalSpreadNumber(nt) { + var o = { x: 12, y: 13 }; + o = __assign({}, o, nt && { x: nt }); + var o2 = __assign({}, nt && { x: nt }); + return o; +} +function conditionalSpreadString(st) { + var o = { x: 'hi', y: 13 }; + o = __assign({}, o, st && { x: st }); + var o2 = __assign({}, st && { x: st }); + return o; +} // other booleans result in { } var spreadBool = __assign({}, true); // any results in any diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 0c5e8a4c5a8..9f257870a0b 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -170,81 +170,143 @@ let spreadFunc = { ...(function () { }) }; >spreadFunc : Symbol(spreadFunc, Decl(objectSpread.ts, 37, 3)) // boolean && T results in Partial -function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { ->conditionalSpread : Symbol(conditionalSpread, Decl(objectSpread.ts, 37, 42)) ->b : Symbol(b, Decl(objectSpread.ts, 40, 27)) ->x : Symbol(x, Decl(objectSpread.ts, 40, 42)) ->y : Symbol(y, Decl(objectSpread.ts, 40, 66)) +function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { +>conditionalSpreadBoolean : Symbol(conditionalSpreadBoolean, Decl(objectSpread.ts, 37, 42)) +>b : Symbol(b, Decl(objectSpread.ts, 40, 34)) +>x : Symbol(x, Decl(objectSpread.ts, 40, 49)) +>y : Symbol(y, Decl(objectSpread.ts, 40, 73)) return { ...b && { x: 1, y: 2 } }; ->b : Symbol(b, Decl(objectSpread.ts, 40, 27)) +>b : Symbol(b, Decl(objectSpread.ts, 40, 34)) >x : Symbol(x, Decl(objectSpread.ts, 41, 22)) >y : Symbol(y, Decl(objectSpread.ts, 41, 28)) } +function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { +>conditionalSpreadNumber : Symbol(conditionalSpreadNumber, Decl(objectSpread.ts, 42, 1)) +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 43, 47)) +>y : Symbol(y, Decl(objectSpread.ts, 43, 71)) + + let o = { x: 12, y: 13 } +>o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 44, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 44, 20)) + + o = { +>o : Symbol(o, Decl(objectSpread.ts, 44, 7)) + + ...o, +>o : Symbol(o, Decl(objectSpread.ts, 44, 7)) + + ...nt && { x: nt } +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 47, 18)) +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) + } + let o2 = { ...nt && { x: nt }} +>o2 : Symbol(o2, Decl(objectSpread.ts, 49, 7)) +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 49, 25)) +>nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) + + return o; +>o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +} +function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { +>conditionalSpreadString : Symbol(conditionalSpreadString, Decl(objectSpread.ts, 51, 1)) +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 52, 47)) +>y : Symbol(y, Decl(objectSpread.ts, 52, 71)) + + let o = { x: 'hi', y: 13 } +>o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 53, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 53, 22)) + + o = { +>o : Symbol(o, Decl(objectSpread.ts, 53, 7)) + + ...o, +>o : Symbol(o, Decl(objectSpread.ts, 53, 7)) + + ...st && { x: st } +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 56, 18)) +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) + } + let o2 = { ...st && { x: st }} +>o2 : Symbol(o2, Decl(objectSpread.ts, 58, 7)) +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 58, 25)) +>st : Symbol(st, Decl(objectSpread.ts, 52, 33)) + + return o; +>o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +} // other booleans result in { } let spreadBool = { ... true } ->spreadBool : Symbol(spreadBool, Decl(objectSpread.ts, 44, 3)) +>spreadBool : Symbol(spreadBool, Decl(objectSpread.ts, 62, 3)) // any results in any let anything: any; ->anything : Symbol(anything, Decl(objectSpread.ts, 47, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 65, 3)) let spreadAny = { ...anything }; ->spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 48, 3)) ->anything : Symbol(anything, Decl(objectSpread.ts, 47, 3)) +>spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 66, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 65, 3)) // methods are not enumerable class C { p = 1; m() { } } ->C : Symbol(C, Decl(objectSpread.ts, 48, 32)) ->p : Symbol(C.p, Decl(objectSpread.ts, 51, 9)) ->m : Symbol(C.m, Decl(objectSpread.ts, 51, 16)) +>C : Symbol(C, Decl(objectSpread.ts, 66, 32)) +>p : Symbol(C.p, Decl(objectSpread.ts, 69, 9)) +>m : Symbol(C.m, Decl(objectSpread.ts, 69, 16)) let c: C = new C() ->c : Symbol(c, Decl(objectSpread.ts, 52, 3)) ->C : Symbol(C, Decl(objectSpread.ts, 48, 32)) ->C : Symbol(C, Decl(objectSpread.ts, 48, 32)) +>c : Symbol(c, Decl(objectSpread.ts, 70, 3)) +>C : Symbol(C, Decl(objectSpread.ts, 66, 32)) +>C : Symbol(C, Decl(objectSpread.ts, 66, 32)) let spreadC: { p: number } = { ...c } ->spreadC : Symbol(spreadC, Decl(objectSpread.ts, 53, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 53, 14)) ->c : Symbol(c, Decl(objectSpread.ts, 52, 3)) +>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 71, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 71, 14)) +>c : Symbol(c, Decl(objectSpread.ts, 70, 3)) // own methods are enumerable let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }; ->cplus : Symbol(cplus, Decl(objectSpread.ts, 56, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 56, 12)) ->plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) ->c : Symbol(c, Decl(objectSpread.ts, 52, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 56, 48)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 74, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 74, 12)) +>plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) +>c : Symbol(c, Decl(objectSpread.ts, 70, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 74, 48)) cplus.plus(); ->cplus.plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) ->cplus : Symbol(cplus, Decl(objectSpread.ts, 56, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 56, 23)) +>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 74, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) // new field's type conflicting with existing field is OK let changeTypeAfter: { a: string, b: string } = ->changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 60, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 60, 22)) ->b : Symbol(b, Decl(objectSpread.ts, 60, 33)) +>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 78, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 78, 22)) +>b : Symbol(b, Decl(objectSpread.ts, 78, 33)) { ...o, a: 'wrong type?' } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 61, 11)) +>a : Symbol(a, Decl(objectSpread.ts, 79, 11)) let changeTypeBefore: { a: number, b: string } = ->changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 62, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 62, 23)) ->b : Symbol(b, Decl(objectSpread.ts, 62, 34)) +>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 80, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 80, 23)) +>b : Symbol(b, Decl(objectSpread.ts, 80, 34)) { a: 'wrong type?', ...o }; ->a : Symbol(a, Decl(objectSpread.ts, 63, 5)) +>a : Symbol(a, Decl(objectSpread.ts, 81, 5)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) let changeTypeBoth: { a: string, b: number } = ->changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 64, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 64, 21)) ->b : Symbol(b, Decl(objectSpread.ts, 64, 32)) +>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 82, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 82, 21)) +>b : Symbol(b, Decl(objectSpread.ts, 82, 32)) { ...o, ...swap }; >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) @@ -252,90 +314,90 @@ let changeTypeBoth: { a: string, b: number } = // optional function container( ->container : Symbol(container, Decl(objectSpread.ts, 65, 22)) +>container : Symbol(container, Decl(objectSpread.ts, 83, 22)) definiteBoolean: { sn: boolean }, ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) ->sn : Symbol(sn, Decl(objectSpread.ts, 69, 22)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) +>sn : Symbol(sn, Decl(objectSpread.ts, 87, 22)) definiteString: { sn: string }, ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) ->sn : Symbol(sn, Decl(objectSpread.ts, 70, 21)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) +>sn : Symbol(sn, Decl(objectSpread.ts, 88, 21)) optionalString: { sn?: string }, ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) ->sn : Symbol(sn, Decl(objectSpread.ts, 71, 21)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) +>sn : Symbol(sn, Decl(objectSpread.ts, 89, 21)) optionalNumber: { sn?: number }) { ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) ->sn : Symbol(sn, Decl(objectSpread.ts, 72, 21)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) +>sn : Symbol(sn, Decl(objectSpread.ts, 90, 21)) let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; ->optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 73, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 73, 29)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) +>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 91, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 91, 29)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; ->optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 74, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 74, 34)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 68, 19)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 69, 37)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) +>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 92, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 92, 34)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; ->allOptional : Symbol(allOptional, Decl(objectSpread.ts, 75, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 75, 22)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 70, 35)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 71, 36)) +>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 93, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 93, 22)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) // computed property let computedFirst: { a: number, b: string, "before everything": number } = ->computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 78, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 78, 24)) ->b : Symbol(b, Decl(objectSpread.ts, 78, 35)) +>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 96, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 96, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 96, 35)) { ['before everything']: 12, ...o, b: 'yes' } ->'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 79, 9)) +>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 97, 9)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 79, 42)) +>b : Symbol(b, Decl(objectSpread.ts, 97, 42)) let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = ->computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 80, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 80, 25)) ->b : Symbol(b, Decl(objectSpread.ts, 80, 36)) ->c : Symbol(c, Decl(objectSpread.ts, 80, 47)) +>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 98, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 98, 25)) +>b : Symbol(b, Decl(objectSpread.ts, 98, 36)) +>c : Symbol(c, Decl(objectSpread.ts, 98, 47)) { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 81, 15)) ->b : Symbol(b, Decl(objectSpread.ts, 81, 38)) +>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 99, 15)) +>b : Symbol(b, Decl(objectSpread.ts, 99, 38)) >o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) let computedAfter: { a: number, b: string, "at the end": number } = ->computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 82, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 82, 24)) ->b : Symbol(b, Decl(objectSpread.ts, 82, 35)) +>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 100, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 100, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 100, 35)) { ...o, b: 'yeah', ['at the end']: 14 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 83, 15)) ->'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 83, 26)) +>b : Symbol(b, Decl(objectSpread.ts, 101, 15)) +>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 101, 26)) } // shortcut syntax let a = 12; ->a : Symbol(a, Decl(objectSpread.ts, 86, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 104, 3)) let shortCutted: { a: number, b: string } = { ...o, a } ->shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 87, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 87, 18)) ->b : Symbol(b, Decl(objectSpread.ts, 87, 29)) +>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 105, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 105, 18)) +>b : Symbol(b, Decl(objectSpread.ts, 105, 29)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 87, 51)) +>a : Symbol(a, Decl(objectSpread.ts, 105, 51)) // non primitive let spreadNonPrimitive = { ...{}}; ->spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 89, 3)) +>spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 107, 3)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index d696ed9ac7c..10d8af02440 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -231,8 +231,8 @@ let spreadFunc = { ...(function () { }) }; >function () { } : () => void // boolean && T results in Partial -function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { ->conditionalSpread : (b: boolean) => { x?: number | undefined; y?: number | undefined; } +function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { +>conditionalSpreadBoolean : (b: boolean) => { x?: number | undefined; y?: number | undefined; } >b : boolean >x : number | undefined >y : number | undefined @@ -247,6 +247,88 @@ function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | >y : number >2 : 2 } +function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { +>conditionalSpreadNumber : (nt: number) => { x?: number | undefined; y: number; } +>nt : number +>x : number | undefined +>y : number + + let o = { x: 12, y: 13 } +>o : { x: number; y: number; } +>{ x: 12, y: 13 } : { x: number; y: number; } +>x : number +>12 : 12 +>y : number +>13 : 13 + + o = { +>o = { ...o, ...nt && { x: nt } } : { x: number; y: number; } +>o : { x: number; y: number; } +>{ ...o, ...nt && { x: nt } } : { x: number; y: number; } + + ...o, +>o : { x: number; y: number; } + + ...nt && { x: nt } +>nt && { x: nt } : 0 | { x: number; } +>nt : number +>{ x: nt } : { x: number; } +>x : number +>nt : number + } + let o2 = { ...nt && { x: nt }} +>o2 : { x?: number | undefined; } +>{ ...nt && { x: nt }} : { x?: number | undefined; } +>nt && { x: nt } : 0 | { x: number; } +>nt : number +>{ x: nt } : { x: number; } +>x : number +>nt : number + + return o; +>o : { x: number; y: number; } +} +function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { +>conditionalSpreadString : (st: string) => { x?: string | undefined; y: number; } +>st : string +>x : string | undefined +>y : number + + let o = { x: 'hi', y: 13 } +>o : { x: string; y: number; } +>{ x: 'hi', y: 13 } : { x: string; y: number; } +>x : string +>'hi' : "hi" +>y : number +>13 : 13 + + o = { +>o = { ...o, ...st && { x: st } } : { x: string; y: number; } +>o : { x: string; y: number; } +>{ ...o, ...st && { x: st } } : { x: string; y: number; } + + ...o, +>o : { x: string; y: number; } + + ...st && { x: st } +>st && { x: st } : "" | { x: string; } +>st : string +>{ x: st } : { x: string; } +>x : string +>st : string + } + let o2 = { ...st && { x: st }} +>o2 : { x?: string | undefined; } +>{ ...st && { x: st }} : { x?: string | undefined; } +>st && { x: st } : "" | { x: string; } +>st : string +>{ x: st } : { x: string; } +>x : string +>st : string + + return o; +>o : { x: string; y: number; } +} // other booleans result in { } let spreadBool = { ... true } >spreadBool : {} diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 14eba9d6f2a..305c149841b 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -7,9 +7,8 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(25,1): error TS2322 Property 's' is missing in type '{ b: boolean; }'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,36): error TS2300: Duplicate identifier 'b'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,53): error TS2300: Duplicate identifier 'b'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(32,19): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,19): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(35,11): error TS2339: Property 'length' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(36,11): error TS2339: Property 'charAt' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(39,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,12): error TS2339: Property 'b' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(49,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. @@ -24,7 +23,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322 Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (18 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (17 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -72,16 +71,14 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322 // primitives are not allowed let spreadNum = { ...12 }; - ~~~~~ -!!! error TS2698: Spread types may only be created from object types. let spreadSum = { ...1 + 1 }; - ~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. let spreadStr = { ...'foo' }; - ~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. spreadStr.length; // error, no 'length' + ~~~~~~ +!!! error TS2339: Property 'length' does not exist on type '{}'. spreadStr.charAt(1); // error, no methods either + ~~~~~~ +!!! error TS2339: Property 'charAt' does not exist on type '{}'. // functions are skipped let spreadFunc = { ...function () { } } spreadFunc(); // error, no call signature diff --git a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt index b37200c4f02..41651fb1d1c 100644 --- a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt +++ b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt @@ -1,6 +1,5 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,15): error TS2304: Cannot find name 'o'. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,18): error TS1109: Expression expected. -tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,12): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,15): error TS1109: Expression expected. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,16): error TS2304: Cannot find name 'o'. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(3,15): error TS2304: Cannot find name 'matchMedia'. @@ -10,15 +9,13 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,16): error T tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error TS1005: ',' expected. -==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (10 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (9 errors) ==== let o7 = { ...o? }; ~ !!! error TS2304: Cannot find name 'o'. ~ !!! error TS1109: Expression expected. let o8 = { ...*o }; - ~~~~~ -!!! error TS2698: Spread types may only be created from object types. ~ !!! error TS1109: Expression expected. ~ diff --git a/tests/cases/conformance/types/spread/objectSpread.ts b/tests/cases/conformance/types/spread/objectSpread.ts index 378c5558fc5..566c9eb0384 100644 --- a/tests/cases/conformance/types/spread/objectSpread.ts +++ b/tests/cases/conformance/types/spread/objectSpread.ts @@ -40,9 +40,27 @@ getter.a = 12; let spreadFunc = { ...(function () { }) }; // boolean && T results in Partial -function conditionalSpread(b: boolean) : { x?: number | undefined, y?: number | undefined } { +function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { return { ...b && { x: 1, y: 2 } }; } +function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { + let o = { x: 12, y: 13 } + o = { + ...o, + ...nt && { x: nt } + } + let o2 = { ...nt && { x: nt }} + return o; +} +function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { + let o = { x: 'hi', y: 13 } + o = { + ...o, + ...st && { x: st } + } + let o2 = { ...st && { x: st }} + return o; +} // other booleans result in { } let spreadBool = { ... true } From fbdb14833ad2865bec8a8df173bafbcef04f2910 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 14:58:35 -0700 Subject: [PATCH 151/216] Improve naming of getPartialTypeFromFalsyUnion --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ff796879071..e4696363ebb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7833,7 +7833,7 @@ namespace ts { } if (left.flags & TypeFlags.Union) { // if the union is `false | T` make all the properties of T optional - const wl = getPartialTypeFromFalseUnion(left as UnionType); + const wl = getPartialTypeFromFalsyUnion(left as UnionType); if (wl) { left = wl; } @@ -7842,7 +7842,7 @@ namespace ts { } } if (right.flags & TypeFlags.Union) { - const wr = getPartialTypeFromFalseUnion(right as UnionType); + const wr = getPartialTypeFromFalsyUnion(right as UnionType); if (wr) { right = wr; } @@ -7921,7 +7921,7 @@ namespace ts { return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); } - function getPartialTypeFromFalseUnion(type: UnionType): Type | undefined { + function getPartialTypeFromFalsyUnion(type: UnionType): Type | undefined { if (type.types.length === 2) { // getFalsyFlagsOfTypes // getTypeFacts From d2e2faad5c9e48af39d2775063e1d599c8083113 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 13 Sep 2017 15:13:34 -0700 Subject: [PATCH 152/216] Update tests and baselines --- .../reference/objectSpreadNegative.errors.txt | 26 ++++---- .../reference/objectSpreadNegative.js | 8 +-- .../restInvalidArgumentType.errors.txt | 63 +++---------------- .../reference/restInvalidArgumentType.js | 46 +------------- .../spreadInvalidArgumentType.errors.txt | 62 +++--------------- .../reference/spreadInvalidArgumentType.js | 45 +------------ .../cases/compiler/restInvalidArgumentType.ts | 25 +------- .../compiler/spreadInvalidArgumentType.ts | 24 +------ .../types/spread/objectSpreadNegative.ts | 4 +- 9 files changed, 41 insertions(+), 262 deletions(-) diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 305c149841b..39639af545e 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -7,20 +7,20 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(25,1): error TS2322 Property 's' is missing in type '{ b: boolean; }'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,36): error TS2300: Duplicate identifier 'b'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,53): error TS2300: Duplicate identifier 'b'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(35,11): error TS2339: Property 'length' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(36,11): error TS2339: Property 'charAt' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(39,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,12): error TS2339: Property 'b' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(49,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(54,11): error TS2339: Property 'a' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(75,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,11): error TS2339: Property 'length' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,11): error TS2339: Property 'charAt' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(41,12): error TS2339: Property 'b' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(47,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(56,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(73,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. + Object literal may only specify known properties, and 'extra' does not exist in type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(76,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. - Object literal may only specify known properties, and 'extra' does not exist in type 'A'. ==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (17 errors) ==== @@ -69,9 +69,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(80,7): error TS2322 !!! error TS2300: Duplicate identifier 'b'. let duplicatedSpread = { ...o, ...o } - // primitives are not allowed - let spreadNum = { ...12 }; - let spreadSum = { ...1 + 1 }; + // primitives are skipped let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' ~~~~~~ diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index 6e82a19acbc..41502dc028d 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -29,9 +29,7 @@ spread = b; // error, missing 's' let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' } let duplicatedSpread = { ...o, ...o } -// primitives are not allowed -let spreadNum = { ...12 }; -let spreadSum = { ...1 + 1 }; +// primitives are skipped let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either @@ -118,9 +116,7 @@ spread = b; // error, missing 's' // literal repeats are not allowed, but spread repeats are fine var duplicated = __assign({ b: 'bad' }, o, { b: 'bad' }, o2, { b: 'bad' }); var duplicatedSpread = __assign({}, o, o); -// primitives are not allowed -var spreadNum = __assign({}, 12); -var spreadSum = __assign({}, 1 + 1); +// primitives are skipped var spreadStr = __assign({}, 'foo'); spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either diff --git a/tests/baselines/reference/restInvalidArgumentType.errors.txt b/tests/baselines/reference/restInvalidArgumentType.errors.txt index fff2c7b3563..44577d5a24e 100644 --- a/tests/baselines/reference/restInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/restInvalidArgumentType.errors.txt @@ -1,22 +1,13 @@ -tests/cases/compiler/restInvalidArgumentType.ts(31,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(33,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(35,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(36,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(38,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(41,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(42,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(44,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(45,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(47,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(48,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(55,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(56,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(18,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(20,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(22,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(23,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(25,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(28,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types may only be created from object types. -==== tests/cases/compiler/restInvalidArgumentType.ts (14 errors) ==== - enum E { v1, v2 }; - +==== tests/cases/compiler/restInvalidArgumentType.ts (7 errors) ==== function f(p1: T, p2: T[]) { var t: T; @@ -27,24 +18,13 @@ tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; - var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var {...r1} = p1; // Error, generic type paramterre ~~ !!! error TS2700: Rest types may only be created from object types. @@ -68,37 +48,14 @@ tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types var {...r8} = union_generic; // Error, union with generic type parameter ~~ !!! error TS2700: Rest types may only be created from object types. - var {...r9} = union_primitive; // Error, union with generic type parameter - ~~ -!!! error TS2700: Rest types may only be created from object types. var {...r10} = intersection_generic; // Error, intersection with generic type parameter ~~~ !!! error TS2700: Rest types may only be created from object types. - var {...r11} = intersection_premitive; // Error, intersection with generic type parameter - ~~~ -!!! error TS2700: Rest types may only be created from object types. - - var {...r12} = num; // Error - ~~~ -!!! error TS2700: Rest types may only be created from object types. - var {...r13} = str; // Error - ~~~ -!!! error TS2700: Rest types may only be created from object types. var {...r14} = u; // OK var {...r15} = n; // OK var {...r16} = a; // OK - - var {...r17} = literal_string; // Error - ~~~ -!!! error TS2700: Rest types may only be created from object types. - var {...r18} = literal_number; // Error - ~~~ -!!! error TS2700: Rest types may only be created from object types. - - var {...r19} = e; // Error, enum - ~~~ -!!! error TS2700: Rest types may only be created from object types. - } \ No newline at end of file + } + \ No newline at end of file diff --git a/tests/baselines/reference/restInvalidArgumentType.js b/tests/baselines/reference/restInvalidArgumentType.js index 48e4e11e805..81bcfb63a17 100644 --- a/tests/baselines/reference/restInvalidArgumentType.js +++ b/tests/baselines/reference/restInvalidArgumentType.js @@ -1,6 +1,4 @@ //// [restInvalidArgumentType.ts] -enum E { v1, v2 }; - function f(p1: T, p2: T[]) { var t: T; @@ -11,24 +9,13 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; - var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var {...r1} = p1; // Error, generic type paramterre var {...r2} = p2; // OK var {...r3} = t; // Error, generic type paramter @@ -40,24 +27,15 @@ function f(p1: T, p2: T[]) { var {...r7} = mapped; // OK, non-generic mapped type var {...r8} = union_generic; // Error, union with generic type parameter - var {...r9} = union_primitive; // Error, union with generic type parameter var {...r10} = intersection_generic; // Error, intersection with generic type parameter - var {...r11} = intersection_premitive; // Error, intersection with generic type parameter - - var {...r12} = num; // Error - var {...r13} = str; // Error var {...r14} = u; // OK var {...r15} = n; // OK var {...r16} = a; // OK - - var {...r17} = literal_string; // Error - var {...r18} = literal_number; // Error - - var {...r19} = e; // Error, enum -} +} + //// [restInvalidArgumentType.js] var __rest = (this && this.__rest) || function (s, e) { @@ -69,12 +47,6 @@ var __rest = (this && this.__rest) || function (s, e) { t[p[i]] = s[p[i]]; return t; }; -var E; -(function (E) { - E[E["v1"] = 0] = "v1"; - E[E["v2"] = 1] = "v2"; -})(E || (E = {})); -; function f(p1, p2) { var t; var i; @@ -82,17 +54,10 @@ function f(p1, p2) { var mapped_generic; var mapped; var union_generic; - var union_primitive; var intersection_generic; - var intersection_premitive; - var num; - var str; var u; var n; var a; - var literal_string; - var literal_number; - var e; var r1 = __rest(p1, []); // Error, generic type paramterre var r2 = __rest(p2, []); // OK var r3 = __rest(t, []); // Error, generic type paramter @@ -101,15 +66,8 @@ function f(p1, p2) { var r6 = __rest(mapped_generic, []); // Error, generic mapped object type var r7 = __rest(mapped, []); // OK, non-generic mapped type var r8 = __rest(union_generic, []); // Error, union with generic type parameter - var r9 = __rest(union_primitive, []); // Error, union with generic type parameter var r10 = __rest(intersection_generic, []); // Error, intersection with generic type parameter - var r11 = __rest(intersection_premitive, []); // Error, intersection with generic type parameter - var r12 = __rest(num, []); // Error - var r13 = __rest(str, []); // Error var r14 = __rest(u, []); // OK var r15 = __rest(n, []); // OK var r16 = __rest(a, []); // OK - var r17 = __rest(literal_string, []); // Error - var r18 = __rest(literal_number, []); // Error - var r19 = __rest(e, []); // Error, enum } diff --git a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt index 5088390f9ee..5b48e24ad0d 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt @@ -1,22 +1,13 @@ -tests/cases/compiler/spreadInvalidArgumentType.ts(31,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(33,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(35,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(36,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(38,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(41,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(42,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(44,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(45,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(47,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(48,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(55,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(56,17): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(58,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(19,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(21,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(23,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(24,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(26,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(29,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread types may only be created from object types. -==== tests/cases/compiler/spreadInvalidArgumentType.ts (14 errors) ==== - enum E { v1, v2 }; - +==== tests/cases/compiler/spreadInvalidArgumentType.ts (7 errors) ==== function f(p1: T, p2: T[]) { var t: T; @@ -27,24 +18,14 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(58,17): error TS2698: Spread t var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var o1 = { ...p1 }; // Error, generic type paramterre ~~~~~ !!! error TS2698: Spread types may only be created from object types. @@ -68,37 +49,14 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(58,17): error TS2698: Spread t var o8 = { ...union_generic }; // Error, union with generic type parameter ~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. - var o9 = { ...union_primitive }; // Error, union with generic type parameter - ~~~~~~~~~~~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. - var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - - var o12 = { ...num }; // Error - ~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - var o13 = { ...str }; // Error - ~~~~~~ -!!! error TS2698: Spread types may only be created from object types. var o14 = { ...u }; // OK var o15 = { ...n }; // OK var o16 = { ...a }; // OK - - var o17 = { ...literal_string }; // Error - ~~~~~~~~~~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - var o18 = { ...literal_number }; // Error - ~~~~~~~~~~~~~~~~~ -!!! error TS2698: Spread types may only be created from object types. - - var o19 = { ...e }; // Error, enum - ~~~~ -!!! error TS2698: Spread types may only be created from object types. - } \ No newline at end of file + } + \ No newline at end of file diff --git a/tests/baselines/reference/spreadInvalidArgumentType.js b/tests/baselines/reference/spreadInvalidArgumentType.js index 26f958f224d..aa42419e59a 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.js +++ b/tests/baselines/reference/spreadInvalidArgumentType.js @@ -1,6 +1,4 @@ //// [spreadInvalidArgumentType.ts] -enum E { v1, v2 }; - function f(p1: T, p2: T[]) { var t: T; @@ -11,24 +9,14 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var o1 = { ...p1 }; // Error, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // Error, generic type paramter @@ -40,24 +28,15 @@ function f(p1: T, p2: T[]) { var o7 = { ...mapped }; // OK, non-generic mapped type var o8 = { ...union_generic }; // Error, union with generic type parameter - var o9 = { ...union_primitive }; // Error, union with generic type parameter var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter - var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter - - var o12 = { ...num }; // Error - var o13 = { ...str }; // Error var o14 = { ...u }; // OK var o15 = { ...n }; // OK var o16 = { ...a }; // OK - - var o17 = { ...literal_string }; // Error - var o18 = { ...literal_number }; // Error - - var o19 = { ...e }; // Error, enum -} +} + //// [spreadInvalidArgumentType.js] var __assign = (this && this.__assign) || Object.assign || function(t) { @@ -68,12 +47,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { } return t; }; -var E; -(function (E) { - E[E["v1"] = 0] = "v1"; - E[E["v2"] = 1] = "v2"; -})(E || (E = {})); -; function f(p1, p2) { var t; var i; @@ -81,17 +54,10 @@ function f(p1, p2) { var mapped_generic; var mapped; var union_generic; - var union_primitive; var intersection_generic; - var intersection_premitive; - var num; - var str; var u; var n; var a; - var literal_string; - var literal_number; - var e; var o1 = __assign({}, p1); // Error, generic type paramterre var o2 = __assign({}, p2); // OK var o3 = __assign({}, t); // Error, generic type paramter @@ -100,15 +66,8 @@ function f(p1, p2) { var o6 = __assign({}, mapped_generic); // Error, generic mapped object type var o7 = __assign({}, mapped); // OK, non-generic mapped type var o8 = __assign({}, union_generic); // Error, union with generic type parameter - var o9 = __assign({}, union_primitive); // Error, union with generic type parameter var o10 = __assign({}, intersection_generic); // Error, intersection with generic type parameter - var o11 = __assign({}, intersection_premitive); // Error, intersection with generic type parameter - var o12 = __assign({}, num); // Error - var o13 = __assign({}, str); // Error var o14 = __assign({}, u); // OK var o15 = __assign({}, n); // OK var o16 = __assign({}, a); // OK - var o17 = __assign({}, literal_string); // Error - var o18 = __assign({}, literal_number); // Error - var o19 = __assign({}, e); // Error, enum } diff --git a/tests/cases/compiler/restInvalidArgumentType.ts b/tests/cases/compiler/restInvalidArgumentType.ts index 488f546e231..2d50903328f 100644 --- a/tests/cases/compiler/restInvalidArgumentType.ts +++ b/tests/cases/compiler/restInvalidArgumentType.ts @@ -1,5 +1,3 @@ -enum E { v1, v2 }; - function f(p1: T, p2: T[]) { var t: T; @@ -10,24 +8,13 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; - var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var {...r1} = p1; // Error, generic type paramterre var {...r2} = p2; // OK var {...r3} = t; // Error, generic type paramter @@ -39,21 +26,11 @@ function f(p1: T, p2: T[]) { var {...r7} = mapped; // OK, non-generic mapped type var {...r8} = union_generic; // Error, union with generic type parameter - var {...r9} = union_primitive; // Error, union with generic type parameter var {...r10} = intersection_generic; // Error, intersection with generic type parameter - var {...r11} = intersection_premitive; // Error, intersection with generic type parameter - - var {...r12} = num; // Error - var {...r13} = str; // Error var {...r14} = u; // OK var {...r15} = n; // OK var {...r16} = a; // OK - - var {...r17} = literal_string; // Error - var {...r18} = literal_number; // Error - - var {...r19} = e; // Error, enum -} \ No newline at end of file +} diff --git a/tests/cases/compiler/spreadInvalidArgumentType.ts b/tests/cases/compiler/spreadInvalidArgumentType.ts index 2ac6aa921f4..bf7365e8ab0 100644 --- a/tests/cases/compiler/spreadInvalidArgumentType.ts +++ b/tests/cases/compiler/spreadInvalidArgumentType.ts @@ -1,5 +1,3 @@ -enum E { v1, v2 }; - function f(p1: T, p2: T[]) { var t: T; @@ -10,24 +8,14 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; - var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; - var intersection_premitive: { a: number } | string; - - var num: number; - var str: number; var u: undefined; var n: null; var a: any; - var literal_string: "string"; - var literal_number: 42; - - var e: E; - var o1 = { ...p1 }; // Error, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // Error, generic type paramter @@ -39,21 +27,11 @@ function f(p1: T, p2: T[]) { var o7 = { ...mapped }; // OK, non-generic mapped type var o8 = { ...union_generic }; // Error, union with generic type parameter - var o9 = { ...union_primitive }; // Error, union with generic type parameter var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter - var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter - - var o12 = { ...num }; // Error - var o13 = { ...str }; // Error var o14 = { ...u }; // OK var o15 = { ...n }; // OK var o16 = { ...a }; // OK - - var o17 = { ...literal_string }; // Error - var o18 = { ...literal_number }; // Error - - var o19 = { ...e }; // Error, enum -} \ No newline at end of file +} diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index beb9ff265b4..8fe9174f759 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -29,9 +29,7 @@ spread = b; // error, missing 's' let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' } let duplicatedSpread = { ...o, ...o } -// primitives are not allowed -let spreadNum = { ...12 }; -let spreadSum = { ...1 + 1 }; +// primitives are skipped let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either From ae1752e10d65c5401be051e90ed452415a69c3a8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 13 Sep 2017 15:16:03 -0700 Subject: [PATCH 153/216] Actually be able to run RWC tests in parallel (#18453) --- src/harness/runner.ts | 4 ++-- src/harness/rwcRunner.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 4653e440f11..6e1f91b21af 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -216,8 +216,8 @@ if (taskConfigsFolder) { for (let i = 0; i < workerCount; i++) { const config = workerConfigs[i]; - // use last worker to run unit tests - config.runUnitTests = i === workerCount - 1; + // use last worker to run unit tests if we're not just running a single specific runner + config.runUnitTests = runners.length !== 1 && i === workerCount - 1; Harness.IO.writeFile(ts.combinePaths(taskConfigsFolder, `task-config${i}.json`), JSON.stringify(workerConfigs[i])); } } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index cddb9b19d4a..b3ef80b2a31 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -263,7 +263,7 @@ class RWCRunner extends RunnerBase { */ public initializeTests(): void { // Read in and evaluate the test list - const testList = this.enumerateTestFiles(); + const testList = this.tests && this.tests.length ? this.tests : this.enumerateTestFiles(); for (let i = 0; i < testList.length; i++) { this.runTest(testList[i]); } From 3bd4c4f847c2dbabc75c1356bc6d112fd02f9537 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 29 Aug 2017 10:22:36 -0700 Subject: [PATCH 154/216] Properly report external filenames --- src/compiler/core.ts | 2 +- src/server/editorServices.ts | 5 +++-- src/server/project.ts | 9 +++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f94ac9a75c5..63c7fdd1076 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1659,7 +1659,7 @@ namespace ts { } export function isRootedDiskPath(path: string) { - return getRootLength(path) !== 0; + return path && getRootLength(path) !== 0; } export function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 22a025ae68f..1958c7e5d20 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1191,7 +1191,8 @@ namespace ts.server { projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); - + this.addFilesToProjectAndUpdateGraph(project, project.getExternalFiles(), fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); + project.watchConfigFile(project => this.onConfigChangedForConfiguredProject(project)); if (!sizeLimitExceeded) { this.watchConfigDirectoryForProject(project, projectOptions); @@ -1210,7 +1211,7 @@ namespace ts.server { } } - private addFilesToProjectAndUpdateGraph(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray): void { + private addFilesToProjectAndUpdateGraph(project: ConfiguredProject | ExternalProject, files: ReadonlyArray, propertyReader: FilePropertyReader, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray): void { let errors: Diagnostic[]; for (const f of files) { const rootFileName = propertyReader.getFileName(f); diff --git a/src/server/project.ts b/src/server/project.ts index 4fb5ef78d75..d588bae88ae 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -747,7 +747,8 @@ namespace ts.server { } // compute and return the difference const lastReportedFileNames = this.lastReportedFileNames; - const currentFiles = arrayToSet(this.getFileNames()); + const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f)); + const currentFiles = arrayToSet(this.getFileNames().concat(externalFiles)); const added: string[] = []; const removed: string[] = []; @@ -770,7 +771,8 @@ namespace ts.server { else { // unknown version - return everything const projectFileNames = this.getFileNames(); - this.lastReportedFileNames = arrayToSet(projectFileNames); + const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f)); + this.lastReportedFileNames = arrayToSet(projectFileNames.concat(externalFiles)); this.lastReportedVersion = this.projectStructureVersion; return { info, files: projectFileNames, projectErrors: this.getGlobalProjectErrors() }; } @@ -1085,6 +1087,9 @@ namespace ts.server { } catch (e) { this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`); + if (e.stack) { + this.projectService.logger.info(e.stack); + } } })); } From f28d80d7d48549ad8a5e0e48c3d74c44c93ebc25 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 13 Sep 2017 15:40:10 -0700 Subject: [PATCH 155/216] Support '// @ts-ignore' comments in .ts files --- src/compiler/program.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 00e933d680a..93437259d61 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1158,9 +1158,7 @@ namespace ts { const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); const diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - return isSourceFileJavaScript(sourceFile) - ? filter(diagnostics, shouldReportDiagnostic) - : diagnostics; + return filter(diagnostics, shouldReportDiagnostic); }); } From 9046fcb65831ba9edb1dc8ef657ba094547b5671 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Wed, 13 Sep 2017 16:09:18 -0700 Subject: [PATCH 156/216] Add files as one batch to preserve errors --- src/server/editorServices.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 1958c7e5d20..7474efebe54 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1190,9 +1190,9 @@ namespace ts.server { /*languageServiceEnabled*/ !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); - this.addFilesToProjectAndUpdateGraph(project, project.getExternalFiles(), fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); - + const filesToAdd = projectOptions.files.concat(project.getExternalFiles()); + this.addFilesToProjectAndUpdateGraph(project, filesToAdd, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); + project.watchConfigFile(project => this.onConfigChangedForConfiguredProject(project)); if (!sizeLimitExceeded) { this.watchConfigDirectoryForProject(project, projectOptions); From cf53743bd696de5b3a3eff71a13b799c8e390ea7 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 07:59:53 -0700 Subject: [PATCH 157/216] In `isInPropertyInitializer`, don't bail out at a `PropertyAssignment` (#18449) --- src/compiler/checker.ts | 16 +++++++++++++++- ...reDeclaration_propertyAssignment.errors.txt | 11 +++++++++++ .../useBeforeDeclaration_propertyAssignment.js | 18 ++++++++++++++++++ .../useBeforeDeclaration_propertyAssignment.ts | 4 ++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/useBeforeDeclaration_propertyAssignment.errors.txt create mode 100644 tests/baselines/reference/useBeforeDeclaration_propertyAssignment.js create mode 100644 tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5c6a8b59119..1fae08328b3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14753,7 +14753,7 @@ namespace ts { return; } - if (findAncestor(node, node => node.kind === SyntaxKind.PropertyDeclaration ? true : isExpression(node) ? false : "quit") && + if (isInPropertyInitializer(node) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !isPropertyDeclaredInAncestorClass(prop)) { error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, unescapeLeadingUnderscores(right.escapedText)); @@ -14766,6 +14766,20 @@ namespace ts { } } + function isInPropertyInitializer(node: Node): boolean { + return !!findAncestor(node, node => { + switch (node.kind) { + case SyntaxKind.PropertyDeclaration: + return true; + case SyntaxKind.PropertyAssignment: + // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. + return false; + default: + return isPartOfExpression(node) ? false : "quit"; + } + }); + } + /** * It's possible that "prop.valueDeclaration" is a local declaration, but the property was also declared in a superclass. * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. diff --git a/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.errors.txt b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.errors.txt new file mode 100644 index 00000000000..f237fd07c80 --- /dev/null +++ b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts(2,27): error TS2448: Block-scoped variable 'b' used before its declaration. + + +==== tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts (1 errors) ==== + export class C { + public a = { b: this.b }; + ~ +!!! error TS2448: Block-scoped variable 'b' used before its declaration. + private b = 0; + } + \ No newline at end of file diff --git a/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.js b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.js new file mode 100644 index 00000000000..e34604e0a4e --- /dev/null +++ b/tests/baselines/reference/useBeforeDeclaration_propertyAssignment.js @@ -0,0 +1,18 @@ +//// [useBeforeDeclaration_propertyAssignment.ts] +export class C { + public a = { b: this.b }; + private b = 0; +} + + +//// [useBeforeDeclaration_propertyAssignment.js] +"use strict"; +exports.__esModule = true; +var C = /** @class */ (function () { + function C() { + this.a = { b: this.b }; + this.b = 0; + } + return C; +}()); +exports.C = C; diff --git a/tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts b/tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts new file mode 100644 index 00000000000..bdd84473c57 --- /dev/null +++ b/tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts @@ -0,0 +1,4 @@ +export class C { + public a = { b: this.b }; + private b = 0; +} From d96dfeb708bfec850031a85cc197dfd5732bd52a Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 08:23:50 -0700 Subject: [PATCH 158/216] Don't normalize whitespace in fourslash tests (#18447) * Don't normalize whitespace in fourslash tests * Only render whitespace when the diff is text-only --- src/harness/fourslash.ts | 93 +++++++++---------- src/harness/harness.ts | 3 +- src/harness/harnessLanguageService.ts | 2 +- src/server/client.ts | 3 +- src/server/protocol.ts | 1 + src/server/session.ts | 2 +- src/services/services.ts | 2 +- src/services/textChanges.ts | 6 +- .../fourslash/codeFixAddMissingMember5.ts | 3 +- .../fourslash/codeFixAddMissingMember7.ts | 3 +- .../cases/fourslash/codeFixSuperAfterThis.ts | 5 +- tests/cases/fourslash/codeFixSuperCall.ts | 3 +- tests/cases/fourslash/extract-method14.ts | 2 +- .../fourslash/formatConflictDiff3Marker1.ts | 18 ++-- .../cases/fourslash/formatConflictMarker1.ts | 14 +-- .../fourslash/importNameCodeFixReExport.ts | 5 +- 16 files changed, 82 insertions(+), 83 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d89a4677ef9..fb5e9e0354e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -22,10 +22,6 @@ namespace FourSlash { ts.disableIncrementalParsing = false; - function normalizeNewLines(s: string) { - return s.replace(/\r\n/g, "\n"); - } - // Represents a parsed source file with metadata export interface FourSlashFile { // The contents of the file (with markers, etc stripped out) @@ -364,7 +360,7 @@ namespace FourSlash { baseIndentSize: 0, indentSize: 4, tabSize: 4, - newLineCharacter: Harness.IO.newLine(), + newLineCharacter: "\n", convertTabsToSpaces: true, indentStyle: ts.IndentStyle.Smart, insertSpaceAfterCommaDelimiter: true, @@ -1603,7 +1599,7 @@ namespace FourSlash { } } - public printCurrentFileState(makeWhitespaceVisible: boolean, makeCaretVisible: boolean) { + public printCurrentFileState(showWhitespace: boolean, makeCaretVisible: boolean) { for (const file of this.testData.files) { const active = (this.activeFile === file); Harness.IO.log(`=== Script (${file.fileName}) ${(active ? "(active, cursor at |)" : "")} ===`); @@ -1611,8 +1607,8 @@ namespace FourSlash { if (active) { content = content.substr(0, this.currentCaretPosition) + (makeCaretVisible ? "|" : "") + content.substr(this.currentCaretPosition); } - if (makeWhitespaceVisible) { - content = TestState.makeWhitespaceVisible(content); + if (showWhitespace) { + content = makeWhitespaceVisible(content); } Harness.IO.log(content); } @@ -2128,10 +2124,8 @@ namespace FourSlash { public verifyCurrentFileContent(text: string) { const actual = this.getFileContent(this.activeFile.fileName); - if (normalizeNewLines(actual) !== normalizeNewLines(text)) { - throw new Error("verifyCurrentFileContent\n" + - "\tExpected: \"" + TestState.makeWhitespaceVisible(text) + "\"\n" + - "\t Actual: \"" + TestState.makeWhitespaceVisible(actual) + "\""); + if (actual !== text) { + throw new Error(`verifyCurrentFileContent failed:\n${showTextDiff(text, actual)}`); } } @@ -2305,11 +2299,11 @@ namespace FourSlash { const actualText = this.rangeText(ranges[0]); const result = includeWhiteSpace - ? normalizeNewLines(actualText) === normalizeNewLines(expectedText) + ? actualText === expectedText : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText); if (!result) { - this.raiseError(`Actual text doesn't match expected text. Actual:\n'${actualText}'\nExpected:\n'${expectedText}'`); + this.raiseError(`Actual range text doesn't match expected text.\n${showTextDiff(expectedText, actualText)}`); } } @@ -2403,15 +2397,19 @@ namespace FourSlash { const originalContent = scriptInfo.content; for (const codeFix of codeFixes) { this.applyEdits(codeFix.changes[0].fileName, codeFix.changes[0].textChanges, /*isFormattingEdit*/ false); - actualTextArray.push(this.normalizeNewlines(this.rangeText(ranges[0]))); + let text = this.rangeText(ranges[0]); + // TODO:GH#18445 (remove this line to see errors in many `importNameCodeFix` tests) + text = text.replace(/\r\n/g, "\n"); + actualTextArray.push(text); scriptInfo.updateContent(originalContent); } - const sortedExpectedArray = ts.map(expectedTextArray, str => this.normalizeNewlines(str)).sort(); + const sortedExpectedArray = expectedTextArray.sort(); const sortedActualArray = actualTextArray.sort(); - if (!ts.arrayIsEqualTo(sortedExpectedArray, sortedActualArray)) { - this.raiseError( - `Actual text array doesn't match expected text array. \nActual: \n'${sortedActualArray.join("\n\n")}'\n---\nExpected: \n'${sortedExpectedArray.join("\n\n")}'`); - } + ts.zipWith(sortedExpectedArray, sortedActualArray, (expected, actual, index) => { + if (expected !== actual) { + this.raiseError(`Import fix at index ${index} doesn't match.\n${showTextDiff(expected, actual)}`); + } + }); } public verifyDocCommentTemplate(expected: ts.TextInsertion | undefined) { @@ -2431,7 +2429,7 @@ namespace FourSlash { } if (actual.newText !== expected.newText) { - this.raiseError(`${name} failed - expected insertion:\n"${this.clarifyNewlines(expected.newText)}"\nactual insertion:\n"${this.clarifyNewlines(actual.newText)}"`); + this.raiseError(`${name} failed for expected insertion.\n${showTextDiff(expected.newText, actual.newText)}`); } if (actual.caretOffset !== expected.caretOffset) { @@ -2440,17 +2438,6 @@ namespace FourSlash { } } - private clarifyNewlines(str: string) { - return str.replace(/\r?\n/g, lineEnding => { - const representation = lineEnding === "\r\n" ? "CRLF" : "LF"; - return "# - " + representation + lineEnding; - }); - } - - private normalizeNewlines(str: string) { - return str.replace(/\r?\n/g, "\n"); - } - public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) { const openBraceMap = ts.createMapFromTemplate({ @@ -2878,8 +2865,8 @@ namespace FourSlash { } const actualContent = this.getFileContent(this.activeFile.fileName); - if (this.normalizeNewlines(actualContent) !== this.normalizeNewlines(expectedContent)) { - this.raiseError(`verifyFileAfterApplyingRefactors failed: expected:\n${expectedContent}\nactual:\n${actualContent}`); + if (actualContent !== expectedContent) { + this.raiseError(`verifyFileAfterApplyingRefactors failed:\n${showTextDiff(expectedContent, actualContent)}`); } } @@ -3014,10 +3001,6 @@ namespace FourSlash { } } - private static makeWhitespaceVisible(text: string) { - return text.replace(/ /g, "\u00B7").replace(/\r/g, "\u00B6").replace(/\n/g, "\u2193\n").replace(/\t/g, "\u2192\ "); - } - public setCancelled(numberOfCalls: number): void { this.cancellationToken.setCancelled(numberOfCalls); } @@ -3319,12 +3302,7 @@ ${code} let column = 1; const flush = (lastSafeCharIndex: number) => { - if (lastSafeCharIndex === undefined) { - output = output + content.substr(lastNormalCharPosition); - } - else { - output = output + content.substr(lastNormalCharPosition, lastSafeCharIndex - lastNormalCharPosition); - } + output = output + content.substr(lastNormalCharPosition, lastSafeCharIndex === undefined ? undefined : lastSafeCharIndex - lastNormalCharPosition); }; if (content.length > 0) { @@ -3511,6 +3489,27 @@ ${code} function toArray(x: T | T[]): T[] { return ts.isArray(x) ? x : [x]; } + + function makeWhitespaceVisible(text: string) { + return text.replace(/ /g, "\u00B7").replace(/\r/g, "\u00B6").replace(/\n/g, "\u2193\n").replace(/\t/g, "\u2192\ "); + } + + function showTextDiff(expected: string, actual: string): string { + // Only show whitespace if the difference is whitespace-only. + if (differOnlyByWhitespace(expected, actual)) { + expected = makeWhitespaceVisible(expected); + actual = makeWhitespaceVisible(actual); + } + return `Expected:\n${expected}\nActual:${actual}`; + } + + function differOnlyByWhitespace(a: string, b: string) { + return stripWhitespace(a) === stripWhitespace(b); + } + + function stripWhitespace(s: string): string { + return s.replace(/\s/g, ""); + } } namespace FourSlashInterface { @@ -4143,15 +4142,15 @@ namespace FourSlashInterface { } public printCurrentFileState() { - this.state.printCurrentFileState(/*makeWhitespaceVisible*/ false, /*makeCaretVisible*/ true); + this.state.printCurrentFileState(/*showWhitespace*/ false, /*makeCaretVisible*/ true); } public printCurrentFileStateWithWhitespace() { - this.state.printCurrentFileState(/*makeWhitespaceVisible*/ true, /*makeCaretVisible*/ true); + this.state.printCurrentFileState(/*showWhitespace*/ true, /*makeCaretVisible*/ true); } public printCurrentFileStateWithoutCaret() { - this.state.printCurrentFileState(/*makeWhitespaceVisible*/ false, /*makeCaretVisible*/ false); + this.state.printCurrentFileState(/*showWhitespace*/ false, /*makeCaretVisible*/ false); } public printCurrentQuickInfo() { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 2fc1aac2d83..8344be36753 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -500,7 +500,8 @@ namespace Harness { export let IO: IO; // harness always uses one kind of new line - const harnessNewLine = "\r\n"; + // But note that `parseTestData` in `fourslash.ts` uses "\n" + export const harnessNewLine = "\r\n"; // Root for file paths that are stored in a virtual file system export const virtualFileSystemRoot = "/"; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 78da05570d8..23bc08108c7 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -130,7 +130,7 @@ namespace Harness.LanguageService { } public getNewLine(): string { - return "\r\n"; + return harnessNewLine; } public getFilenames(): string[] { diff --git a/src/server/client.ts b/src/server/client.ts index 0ffac42dae4..9e472a83e2b 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -573,7 +573,7 @@ namespace ts.server { getEditsForRefactor( fileName: string, - _formatOptions: FormatCodeSettings, + formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo { @@ -581,6 +581,7 @@ namespace ts.server { const args = this.createFileLocationOrRangeRequestArgs(positionOrRange, fileName) as protocol.GetEditsForRefactorRequestArgs; args.refactor = refactorName; args.action = actionName; + args.formatOptions = formatOptions; const request = this.processRequest(CommandNames.GetEditsForRefactor, args); const response = this.processResponse(request); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 3fdbd8fd7f7..1740f8ae0ba 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -494,6 +494,7 @@ namespace ts.server.protocol { refactor: string; /* The 'name' property from the refactoring action */ action: string; + formatOptions: FormatCodeSettings, }; diff --git a/src/server/session.ts b/src/server/session.ts index 0b3038a408d..2d773d6f467 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1488,7 +1488,7 @@ namespace ts.server { const result = project.getLanguageService().getEditsForRefactor( file, - this.projectService.getFormatCodeOptions(), + convertFormatOptions(args.formatOptions), position || textRange, args.refactor, args.action diff --git a/src/services/services.ts b/src/services/services.ts index 197f76b607f..bdd0eb41e4f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2019,7 +2019,7 @@ namespace ts { startPosition, endPosition, program: getProgram(), - newLineCharacter: host.getNewLine(), + newLineCharacter: formatOptions ? formatOptions.newLineCharacter : host.getNewLine(), rulesProvider: getRuleProvider(formatOptions), cancellationToken }; diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 42c1d1e9a4f..f3ad7df1607 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -184,16 +184,12 @@ namespace ts.textChanges { return s; } - function getNewlineKind(context: { newLineCharacter: string }) { - return context.newLineCharacter === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed; - } - export class ChangeTracker { private changes: Change[] = []; private readonly newLineCharacter: string; public static fromContext(context: RefactorContext | CodeFixContext) { - return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + return new ChangeTracker(context.newLineCharacter === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed, context.rulesProvider); } constructor( diff --git a/tests/cases/fourslash/codeFixAddMissingMember5.ts b/tests/cases/fourslash/codeFixAddMissingMember5.ts index db893cb61d3..44b11c5141b 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember5.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember5.ts @@ -17,5 +17,4 @@ verify.currentFileContentIs(`class C { ()=>{ this.foo === 10 }; } } -C.foo = undefined; -`); \ No newline at end of file +C.foo = undefined;` + "\r\n"); // TODO: GH#18445 diff --git a/tests/cases/fourslash/codeFixAddMissingMember7.ts b/tests/cases/fourslash/codeFixAddMissingMember7.ts index 8ac7f2b5aff..7690023815c 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember7.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember7.ts @@ -13,5 +13,4 @@ verify.getAndApplyCodeFix(/*errorCode*/ undefined, /*index*/ 2) verify.currentFileContentIs(`class C { static p = ()=>{ this.foo === 10 }; } -C.foo = undefined; -`); +C.foo = undefined;` + "\r\n"); // TODO: GH#18445 diff --git a/tests/cases/fourslash/codeFixSuperAfterThis.ts b/tests/cases/fourslash/codeFixSuperAfterThis.ts index 55b44b07881..a4db2c909fd 100644 --- a/tests/cases/fourslash/codeFixSuperAfterThis.ts +++ b/tests/cases/fourslash/codeFixSuperAfterThis.ts @@ -9,7 +9,8 @@ //// super(); //// |]} ////} +// TODO: GH#18445 verify.rangeAfterCodeFix(` - super(); + super();\r this.a = 12; - `, /*includeWhiteSpace*/ true); \ No newline at end of file + `, /*includeWhiteSpace*/ true); diff --git a/tests/cases/fourslash/codeFixSuperCall.ts b/tests/cases/fourslash/codeFixSuperCall.ts index f7584050a15..28f7d34a2bd 100644 --- a/tests/cases/fourslash/codeFixSuperCall.ts +++ b/tests/cases/fourslash/codeFixSuperCall.ts @@ -6,6 +6,7 @@ //// constructor() {[| //// |]} ////} +// TODO: GH#18445 verify.rangeAfterCodeFix(` - super(); + super();\r `, /*includeWhitespace*/ true); diff --git a/tests/cases/fourslash/extract-method14.ts b/tests/cases/fourslash/extract-method14.ts index 27a561743c6..e2b58a36450 100644 --- a/tests/cases/fourslash/extract-method14.ts +++ b/tests/cases/fourslash/extract-method14.ts @@ -19,7 +19,7 @@ edit.applyRefactor({ `function foo() { var i = 10; var __return: any; - ({ __return, i } = n/*RENAME*/ewFunction(i)); + ({ __return, i } = /*RENAME*/newFunction(i)); return __return; } function newFunction(i) { diff --git a/tests/cases/fourslash/formatConflictDiff3Marker1.ts b/tests/cases/fourslash/formatConflictDiff3Marker1.ts index f6492a6f60c..188fe5b0dd2 100644 --- a/tests/cases/fourslash/formatConflictDiff3Marker1.ts +++ b/tests/cases/fourslash/formatConflictDiff3Marker1.ts @@ -11,12 +11,12 @@ ////} format.document(); -verify.currentFileContentIs("class C {\r\n\ -<<<<<<< HEAD\r\n\ - v = 1;\r\n\ -||||||| merged common ancestors\r\n\ -v = 3;\r\n\ -=======\r\n\ -v = 2;\r\n\ ->>>>>>> Branch - a\r\n\ -}"); \ No newline at end of file +verify.currentFileContentIs(`class C { +<<<<<<< HEAD + v = 1; +||||||| merged common ancestors +v = 3; +======= +v = 2; +>>>>>>> Branch - a +}`); diff --git a/tests/cases/fourslash/formatConflictMarker1.ts b/tests/cases/fourslash/formatConflictMarker1.ts index c0e2dbc4f69..413206dc893 100644 --- a/tests/cases/fourslash/formatConflictMarker1.ts +++ b/tests/cases/fourslash/formatConflictMarker1.ts @@ -9,10 +9,10 @@ ////} format.document(); -verify.currentFileContentIs("class C {\r\n\ -<<<<<<< HEAD\r\n\ - v = 1;\r\n\ -=======\r\n\ -v = 2;\r\n\ ->>>>>>> Branch - a\r\n\ -}"); \ No newline at end of file +verify.currentFileContentIs(`class C { +<<<<<<< HEAD + v = 1; +======= +v = 2; +>>>>>>> Branch - a +}`); diff --git a/tests/cases/fourslash/importNameCodeFixReExport.ts b/tests/cases/fourslash/importNameCodeFixReExport.ts index c77d32cc458..eb1c1a91343 100644 --- a/tests/cases/fourslash/importNameCodeFixReExport.ts +++ b/tests/cases/fourslash/importNameCodeFixReExport.ts @@ -10,7 +10,8 @@ ////x;|] goTo.file("/b.ts"); -verify.rangeAfterCodeFix(`import { x } from "./a"; - +// TODO:GH#18445 +verify.rangeAfterCodeFix(`import { x } from "./a";\r +\r export { x } from "./a"; x;`, /*includeWhiteSpace*/ true); From 76eab54ab7b73027651cc4551346476e7e0f1443 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 14 Sep 2017 11:11:54 -0700 Subject: [PATCH 159/216] Add error for using generalized expressions with export assignments in ambient contexts (#18444) --- src/compiler/checker.ts | 4 ++ src/compiler/diagnosticMessages.json | 4 ++ .../ambientExportDefaultErrors.errors.txt | 41 +++++++++++++++++++ .../reference/ambientExportDefaultErrors.js | 39 ++++++++++++++++++ .../baselines/reference/es5-commonjs7.symbols | 4 +- tests/baselines/reference/es5-commonjs7.types | 4 +- tests/baselines/reference/typeAliasExport.js | 2 +- .../reference/typeAliasExport.symbols | 4 +- .../baselines/reference/typeAliasExport.types | 4 +- .../compiler/ambientExportDefaultErrors.ts | 27 ++++++++++++ tests/cases/compiler/es5-commonjs7.ts | 2 +- tests/cases/compiler/typeAliasExport.ts | 2 +- 12 files changed, 130 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/ambientExportDefaultErrors.errors.txt create mode 100644 tests/baselines/reference/ambientExportDefaultErrors.js create mode 100644 tests/cases/compiler/ambientExportDefaultErrors.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index eb662cbd382..1957ebf23bb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22345,6 +22345,10 @@ namespace ts { checkExternalModuleExports(container); + if (isInAmbientContext(node) && !isEntityNameExpression(node.expression)) { + grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); + } + if (node.isExportEquals && !isInAmbientContext(node)) { if (modulekind >= ModuleKind.ES2015) { // export assignment is not supported in es6 modules diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index af7f6d6c949..8a76ddcda9a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2212,6 +2212,10 @@ "category": "Error", "code": 2713 }, + "The expression of an export assignment must be an identifier or qualified name in an ambient context.": { + "category": "Error", + "code": 2714 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/ambientExportDefaultErrors.errors.txt b/tests/baselines/reference/ambientExportDefaultErrors.errors.txt new file mode 100644 index 00000000000..246ff5147b2 --- /dev/null +++ b/tests/baselines/reference/ambientExportDefaultErrors.errors.txt @@ -0,0 +1,41 @@ +tests/cases/compiler/foo.d.ts(1,16): error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. +tests/cases/compiler/foo2.d.ts(1,10): error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. +tests/cases/compiler/indirection.d.ts(3,20): error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. +tests/cases/compiler/indirection2.d.ts(3,14): error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + + +==== tests/cases/compiler/consumer.ts (0 errors) ==== + /// + /// + import "indirect"; + import "foo"; + import "indirect2"; + import "foo2"; +==== tests/cases/compiler/foo.d.ts (1 errors) ==== + export default 2 + 2; + ~~~~~ +!!! error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + export as namespace Foo; + +==== tests/cases/compiler/foo2.d.ts (1 errors) ==== + export = 2 + 2; + ~~~~~ +!!! error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + export as namespace Foo2; + +==== tests/cases/compiler/indirection.d.ts (1 errors) ==== + /// + declare module "indirect" { + export default typeof Foo.default; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + } + +==== tests/cases/compiler/indirection2.d.ts (1 errors) ==== + /// + declare module "indirect2" { + export = typeof Foo2; + ~~~~~~~~~~~ +!!! error TS2714: The expression of an export assignment must be an identifier or qualified name in an ambient context. + } + \ No newline at end of file diff --git a/tests/baselines/reference/ambientExportDefaultErrors.js b/tests/baselines/reference/ambientExportDefaultErrors.js new file mode 100644 index 00000000000..3d8d2bf65f9 --- /dev/null +++ b/tests/baselines/reference/ambientExportDefaultErrors.js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/ambientExportDefaultErrors.ts] //// + +//// [foo.d.ts] +export default 2 + 2; +export as namespace Foo; + +//// [foo2.d.ts] +export = 2 + 2; +export as namespace Foo2; + +//// [indirection.d.ts] +/// +declare module "indirect" { + export default typeof Foo.default; +} + +//// [indirection2.d.ts] +/// +declare module "indirect2" { + export = typeof Foo2; +} + +//// [consumer.ts] +/// +/// +import "indirect"; +import "foo"; +import "indirect2"; +import "foo2"; + +//// [consumer.js] +"use strict"; +exports.__esModule = true; +/// +/// +require("indirect"); +require("foo"); +require("indirect2"); +require("foo2"); diff --git a/tests/baselines/reference/es5-commonjs7.symbols b/tests/baselines/reference/es5-commonjs7.symbols index 0ac992e7db9..ed8247a6878 100644 --- a/tests/baselines/reference/es5-commonjs7.symbols +++ b/tests/baselines/reference/es5-commonjs7.symbols @@ -1,5 +1,7 @@ === tests/cases/compiler/test.d.ts === -export default "test"; +export default undefined; +>undefined : Symbol(default) + export var __esModule; >__esModule : Symbol(__esModule, Decl(test.d.ts, 1, 10)) diff --git a/tests/baselines/reference/es5-commonjs7.types b/tests/baselines/reference/es5-commonjs7.types index 60d9f9b6c62..5b6c3f1e816 100644 --- a/tests/baselines/reference/es5-commonjs7.types +++ b/tests/baselines/reference/es5-commonjs7.types @@ -1,5 +1,7 @@ === tests/cases/compiler/test.d.ts === -export default "test"; +export default undefined; +>undefined : undefined + export var __esModule; >__esModule : any diff --git a/tests/baselines/reference/typeAliasExport.js b/tests/baselines/reference/typeAliasExport.js index fa864f571ea..dca14cea38e 100644 --- a/tests/baselines/reference/typeAliasExport.js +++ b/tests/baselines/reference/typeAliasExport.js @@ -1,6 +1,6 @@ //// [typeAliasExport.ts] declare module "a" { - export default 0 + export default undefined export var a; export type a = typeof a; } diff --git a/tests/baselines/reference/typeAliasExport.symbols b/tests/baselines/reference/typeAliasExport.symbols index 1f580b03011..e019ca7a10b 100644 --- a/tests/baselines/reference/typeAliasExport.symbols +++ b/tests/baselines/reference/typeAliasExport.symbols @@ -1,6 +1,8 @@ === tests/cases/compiler/typeAliasExport.ts === declare module "a" { - export default 0 + export default undefined +>undefined : Symbol(default) + export var a; >a : Symbol(a, Decl(typeAliasExport.ts, 2, 12), Decl(typeAliasExport.ts, 2, 15)) diff --git a/tests/baselines/reference/typeAliasExport.types b/tests/baselines/reference/typeAliasExport.types index afa26073061..e9a7b92c3e7 100644 --- a/tests/baselines/reference/typeAliasExport.types +++ b/tests/baselines/reference/typeAliasExport.types @@ -1,6 +1,8 @@ === tests/cases/compiler/typeAliasExport.ts === declare module "a" { - export default 0 + export default undefined +>undefined : undefined + export var a; >a : any diff --git a/tests/cases/compiler/ambientExportDefaultErrors.ts b/tests/cases/compiler/ambientExportDefaultErrors.ts new file mode 100644 index 00000000000..589af41333a --- /dev/null +++ b/tests/cases/compiler/ambientExportDefaultErrors.ts @@ -0,0 +1,27 @@ +// @filename: foo.d.ts +export default 2 + 2; +export as namespace Foo; + +// @filename: foo2.d.ts +export = 2 + 2; +export as namespace Foo2; + +// @filename: indirection.d.ts +/// +declare module "indirect" { + export default typeof Foo.default; +} + +// @filename: indirection2.d.ts +/// +declare module "indirect2" { + export = typeof Foo2; +} + +// @filename: consumer.ts +/// +/// +import "indirect"; +import "foo"; +import "indirect2"; +import "foo2"; \ No newline at end of file diff --git a/tests/cases/compiler/es5-commonjs7.ts b/tests/cases/compiler/es5-commonjs7.ts index 384feb22638..0ad10c1822d 100644 --- a/tests/cases/compiler/es5-commonjs7.ts +++ b/tests/cases/compiler/es5-commonjs7.ts @@ -4,5 +4,5 @@ // @module: commonjs // @filename: test.d.ts -export default "test"; +export default undefined; export var __esModule; diff --git a/tests/cases/compiler/typeAliasExport.ts b/tests/cases/compiler/typeAliasExport.ts index 706b731f0ab..914deba40b5 100644 --- a/tests/cases/compiler/typeAliasExport.ts +++ b/tests/cases/compiler/typeAliasExport.ts @@ -1,5 +1,5 @@ declare module "a" { - export default 0 + export default undefined export var a; export type a = typeof a; } \ No newline at end of file From 6e512a495f235fed8d1a0a10b619e181c2ef2a5c Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 11:16:21 -0700 Subject: [PATCH 160/216] extractMethod: Don't try to extract an ExpressionStatement consisting of a single token (#18450) * extractMethod: Don't try to extract an ExpressionStatement consisting of a single token * Move to unit test --- src/harness/unittests/extractMethods.ts | 2 ++ src/services/refactors/extractMethod.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 5cab0289d67..ca77af61c75 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -410,6 +410,8 @@ function test(x: number) { "Statement or expression expected." ]); + testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single token."]); + testExtractMethod("extractMethod1", `namespace A { let x = 1; diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 4c24d22a2f3..9ea3d9d11bd 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -231,7 +231,7 @@ namespace ts.refactor.extractMethod { } function checkRootNode(node: Node): Diagnostic[] | undefined { - if (isToken(node)) { + if (isToken(isExpressionStatement(node) ? node.expression : node)) { return [createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; From 18653a5c5d31e08973520bcbf65d81872ac56923 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 14 Sep 2017 11:18:48 -0700 Subject: [PATCH 161/216] Use removeDefinitelyFalsyTypes for building partial type --- src/compiler/checker.ts | 13 ++-- tests/baselines/reference/spreadUnion2.js | 10 +-- .../baselines/reference/spreadUnion2.symbols | 24 ++++--- tests/baselines/reference/spreadUnion2.types | 66 +++++++++---------- .../reference/spreadUnion3.errors.txt | 12 ++-- .../conformance/types/spread/spreadUnion2.ts | 10 +-- 6 files changed, 63 insertions(+), 72 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c8b0100a02e..a7c98f657dc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7923,15 +7923,10 @@ namespace ts { function getPartialTypeFromFalsyUnion(type: UnionType): Type | undefined { if (type.types.length === 2) { - // getFalsyFlagsOfTypes - // getTypeFacts - const i = Math.max(type.types.indexOf(falseType), - type.types.indexOf(zeroType), - type.types.indexOf(emptyStringType)); - if (i > -1) { + const truthy = removeDefinitelyFalsyTypes(type); + if (truthy !== type) { const members = createSymbolTable(); - const other = type.types[i === 0 ? 1 : 0]; - for (const prop of getPropertiesOfType(other)) { + for (const prop of getPropertiesOfType(truthy)) { if (prop.flags & SymbolFlags.Optional) { members.set(prop.escapedName, prop); } @@ -7943,7 +7938,7 @@ namespace ts { members.set(prop.escapedName, result); } } - return createAnonymousType(undefined, members, emptyArray, emptyArray, getIndexInfoOfType(other, IndexKind.String), getIndexInfoOfType(other, IndexKind.Number)); + return createAnonymousType(undefined, members, emptyArray, emptyArray, getIndexInfoOfType(truthy, IndexKind.String), getIndexInfoOfType(truthy, IndexKind.Number)); } } } diff --git a/tests/baselines/reference/spreadUnion2.js b/tests/baselines/reference/spreadUnion2.js index 6e49770617a..48b12731817 100644 --- a/tests/baselines/reference/spreadUnion2.js +++ b/tests/baselines/reference/spreadUnion2.js @@ -3,20 +3,20 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; declare const nullAndUndefinedUnion: null | undefined; -var o1: {} | { a: number }; +var o1: { a?: number | undefined }; var o1 = { ...undefinedUnion }; -var o2: {} | { b: number }; +var o2: { b?: number | undefined }; var o2 = { ...nullUnion }; -var o3: {} | { b: number } | { a: number } | { a: number, b: number }; +var o3: { a?: number | undefined, b?: number | undefined }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; -var o4: {} | { a: number }; +var o4: { a?: number | undefined }; var o4 = { ...undefinedUnion, ...undefinedUnion }; -var o5: {} | { b: number }; +var o5: { b?: number | undefined }; var o5 = { ...nullUnion, ...nullUnion }; var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; diff --git a/tests/baselines/reference/spreadUnion2.symbols b/tests/baselines/reference/spreadUnion2.symbols index c4d1f19b6d9..841bce12e42 100644 --- a/tests/baselines/reference/spreadUnion2.symbols +++ b/tests/baselines/reference/spreadUnion2.symbols @@ -10,28 +10,26 @@ declare const nullUnion: { b: number } | null; declare const nullAndUndefinedUnion: null | undefined; >nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) -var o1: {} | { a: number }; +var o1: { a?: number | undefined }; >o1 : Symbol(o1, Decl(spreadUnion2.ts, 4, 3), Decl(spreadUnion2.ts, 5, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 4, 14)) +>a : Symbol(a, Decl(spreadUnion2.ts, 4, 9)) var o1 = { ...undefinedUnion }; >o1 : Symbol(o1, Decl(spreadUnion2.ts, 4, 3), Decl(spreadUnion2.ts, 5, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o2: {} | { b: number }; +var o2: { b?: number | undefined }; >o2 : Symbol(o2, Decl(spreadUnion2.ts, 7, 3), Decl(spreadUnion2.ts, 8, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 7, 14)) +>b : Symbol(b, Decl(spreadUnion2.ts, 7, 9)) var o2 = { ...nullUnion }; >o2 : Symbol(o2, Decl(spreadUnion2.ts, 7, 3), Decl(spreadUnion2.ts, 8, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) -var o3: {} | { b: number } | { a: number } | { a: number, b: number }; +var o3: { a?: number | undefined, b?: number | undefined }; >o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 10, 14)) ->a : Symbol(a, Decl(spreadUnion2.ts, 10, 30)) ->a : Symbol(a, Decl(spreadUnion2.ts, 10, 46)) ->b : Symbol(b, Decl(spreadUnion2.ts, 10, 57)) +>a : Symbol(a, Decl(spreadUnion2.ts, 10, 9)) +>b : Symbol(b, Decl(spreadUnion2.ts, 10, 33)) var o3 = { ...undefinedUnion, ...nullUnion }; >o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) @@ -43,18 +41,18 @@ var o3 = { ...nullUnion, ...undefinedUnion }; >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o4: {} | { a: number }; +var o4: { a?: number | undefined }; >o4 : Symbol(o4, Decl(spreadUnion2.ts, 14, 3), Decl(spreadUnion2.ts, 15, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 14, 14)) +>a : Symbol(a, Decl(spreadUnion2.ts, 14, 9)) var o4 = { ...undefinedUnion, ...undefinedUnion }; >o4 : Symbol(o4, Decl(spreadUnion2.ts, 14, 3), Decl(spreadUnion2.ts, 15, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o5: {} | { b: number }; +var o5: { b?: number | undefined }; >o5 : Symbol(o5, Decl(spreadUnion2.ts, 17, 3), Decl(spreadUnion2.ts, 18, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 17, 14)) +>b : Symbol(b, Decl(spreadUnion2.ts, 17, 9)) var o5 = { ...nullUnion, ...nullUnion }; >o5 : Symbol(o5, Decl(spreadUnion2.ts, 17, 3), Decl(spreadUnion2.ts, 18, 3)) diff --git a/tests/baselines/reference/spreadUnion2.types b/tests/baselines/reference/spreadUnion2.types index ea3364f296b..50f79cc7745 100644 --- a/tests/baselines/reference/spreadUnion2.types +++ b/tests/baselines/reference/spreadUnion2.types @@ -12,71 +12,69 @@ declare const nullAndUndefinedUnion: null | undefined; >nullAndUndefinedUnion : null | undefined >null : null -var o1: {} | { a: number }; ->o1 : {} | { a: number; } ->a : number +var o1: { a?: number | undefined }; +>o1 : { a?: number | undefined; } +>a : number | undefined var o1 = { ...undefinedUnion }; ->o1 : {} | { a: number; } ->{ ...undefinedUnion } : {} | { a: number; } +>o1 : { a?: number | undefined; } +>{ ...undefinedUnion } : { a?: number | undefined; } >undefinedUnion : { a: number; } | undefined -var o2: {} | { b: number }; ->o2 : {} | { b: number; } ->b : number +var o2: { b?: number | undefined }; +>o2 : { b?: number | undefined; } +>b : number | undefined var o2 = { ...nullUnion }; ->o2 : {} | { b: number; } ->{ ...nullUnion } : {} | { b: number; } +>o2 : { b?: number | undefined; } +>{ ...nullUnion } : { b?: number | undefined; } >nullUnion : { b: number; } | null -var o3: {} | { b: number } | { a: number } | { a: number, b: number }; ->o3 : {} | { b: number; } | { a: number; } | { a: number; b: number; } ->b : number ->a : number ->a : number ->b : number +var o3: { a?: number | undefined, b?: number | undefined }; +>o3 : { a?: number | undefined; b?: number | undefined; } +>a : number | undefined +>b : number | undefined var o3 = { ...undefinedUnion, ...nullUnion }; ->o3 : {} | { b: number; } | { a: number; } | { a: number; b: number; } ->{ ...undefinedUnion, ...nullUnion } : {} | { b: number; } | { a: number; } | { b: number; a: number; } +>o3 : { a?: number | undefined; b?: number | undefined; } +>{ ...undefinedUnion, ...nullUnion } : { b?: number | undefined; a?: number | undefined; } >undefinedUnion : { a: number; } | undefined >nullUnion : { b: number; } | null var o3 = { ...nullUnion, ...undefinedUnion }; ->o3 : {} | { b: number; } | { a: number; } | { a: number; b: number; } ->{ ...nullUnion, ...undefinedUnion } : {} | { a: number; } | { b: number; } | { a: number; b: number; } +>o3 : { a?: number | undefined; b?: number | undefined; } +>{ ...nullUnion, ...undefinedUnion } : { a?: number | undefined; b?: number | undefined; } >nullUnion : { b: number; } | null >undefinedUnion : { a: number; } | undefined -var o4: {} | { a: number }; ->o4 : {} | { a: number; } ->a : number +var o4: { a?: number | undefined }; +>o4 : { a?: number | undefined; } +>a : number | undefined var o4 = { ...undefinedUnion, ...undefinedUnion }; ->o4 : {} | { a: number; } ->{ ...undefinedUnion, ...undefinedUnion } : {} | { a: number; } | { a: number; } | { a: number; } +>o4 : { a?: number | undefined; } +>{ ...undefinedUnion, ...undefinedUnion } : { a?: number | undefined; } >undefinedUnion : { a: number; } | undefined >undefinedUnion : { a: number; } | undefined -var o5: {} | { b: number }; ->o5 : {} | { b: number; } ->b : number +var o5: { b?: number | undefined }; +>o5 : { b?: number | undefined; } +>b : number | undefined var o5 = { ...nullUnion, ...nullUnion }; ->o5 : {} | { b: number; } ->{ ...nullUnion, ...nullUnion } : {} | { b: number; } | { b: number; } | { b: number; } +>o5 : { b?: number | undefined; } +>{ ...nullUnion, ...nullUnion } : { b?: number | undefined; } >nullUnion : { b: number; } | null >nullUnion : { b: number; } | null var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; ->o6 : {} | {} | {} | {} ->{ ...nullAndUndefinedUnion, ...nullAndUndefinedUnion } : {} | {} | {} | {} +>o6 : {} +>{ ...nullAndUndefinedUnion, ...nullAndUndefinedUnion } : {} >nullAndUndefinedUnion : null | undefined >nullAndUndefinedUnion : null | undefined var o7 = { ...nullAndUndefinedUnion }; ->o7 : {} | {} ->{ ...nullAndUndefinedUnion } : {} | {} +>o7 : {} +>{ ...nullAndUndefinedUnion } : {} >nullAndUndefinedUnion : null | undefined diff --git a/tests/baselines/reference/spreadUnion3.errors.txt b/tests/baselines/reference/spreadUnion3.errors.txt index 5f5b620685c..f3fa2da7597 100644 --- a/tests/baselines/reference/spreadUnion3.errors.txt +++ b/tests/baselines/reference/spreadUnion3.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'. - Type '{ y: number; }' is not assignable to type '{ y: string; }'. - Types of property 'y' are incompatible. +tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ y: string | number; }' is not assignable to type '{ y: string; }'. + Types of property 'y' are incompatible. + Type 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. Property 'a' does not exist on type '{}'. @@ -10,9 +10,9 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Proper function f(x: { y: string } | undefined): { y: string } { return { y: 123, ...x } // y: string | number ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'. -!!! error TS2322: Type '{ y: number; }' is not assignable to type '{ y: string; }'. -!!! error TS2322: Types of property 'y' are incompatible. +!!! error TS2322: Type '{ y: string | number; }' is not assignable to type '{ y: string; }'. +!!! error TS2322: Types of property 'y' are incompatible. +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. } f(undefined) diff --git a/tests/cases/conformance/types/spread/spreadUnion2.ts b/tests/cases/conformance/types/spread/spreadUnion2.ts index e2f72879915..17abdd4006a 100644 --- a/tests/cases/conformance/types/spread/spreadUnion2.ts +++ b/tests/cases/conformance/types/spread/spreadUnion2.ts @@ -4,20 +4,20 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; declare const nullAndUndefinedUnion: null | undefined; -var o1: {} | { a: number }; +var o1: { a?: number | undefined }; var o1 = { ...undefinedUnion }; -var o2: {} | { b: number }; +var o2: { b?: number | undefined }; var o2 = { ...nullUnion }; -var o3: {} | { b: number } | { a: number } | { a: number, b: number }; +var o3: { a?: number | undefined, b?: number | undefined }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; -var o4: {} | { a: number }; +var o4: { a?: number | undefined }; var o4 = { ...undefinedUnion, ...undefinedUnion }; -var o5: {} | { b: number }; +var o5: { b?: number | undefined }; var o5 = { ...nullUnion, ...nullUnion }; var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; From e91af7d30dcc44942ef2afbb2483d28532c2c5b3 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 11:19:54 -0700 Subject: [PATCH 162/216] Allow template string with no substitutions to be used as a string literal type (#18452) --- src/compiler/factory.ts | 4 ++-- src/compiler/parser.ts | 14 ++++---------- src/compiler/types.ts | 2 +- .../noSubstitutionTemplateStringLiteralTypes.js | 6 ++++++ ...oSubstitutionTemplateStringLiteralTypes.symbols | 4 ++++ .../noSubstitutionTemplateStringLiteralTypes.types | 6 ++++++ .../noSubstitutionTemplateStringLiteralTypes.ts | 1 + 7 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.js create mode 100644 tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.symbols create mode 100644 tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.types create mode 100644 tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 0369be30076..7252a9f0c1d 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -773,13 +773,13 @@ namespace ts { : node; } - export function createLiteralTypeNode(literal: Expression) { + export function createLiteralTypeNode(literal: LiteralTypeNode["literal"]) { const node = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; node.literal = literal; return node; } - export function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression) { + export function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]) { return node.literal !== literal ? updateNode(createLiteralTypeNode(literal), node) : node; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 63f1696832b..275e83cfac2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2621,16 +2621,9 @@ namespace ts { unaryMinusExpression.operator = SyntaxKind.MinusToken; nextToken(); } - let expression: UnaryExpression; - switch (token()) { - case SyntaxKind.StringLiteral: - case SyntaxKind.NumericLiteral: - expression = parseLiteralLikeNode(token()) as LiteralExpression; - break; - case SyntaxKind.TrueKeyword: - case SyntaxKind.FalseKeyword: - expression = parseTokenNode(); - } + let expression: BooleanLiteral | LiteralExpression | PrefixUnaryExpression = token() === SyntaxKind.TrueKeyword || token() === SyntaxKind.FalseKeyword + ? parseTokenNode() + : parseLiteralLikeNode(token()) as LiteralExpression; if (negative) { unaryMinusExpression.operand = expression; finishNode(unaryMinusExpression); @@ -2666,6 +2659,7 @@ namespace ts { return parseJSDocNodeWithType(SyntaxKind.JSDocVariadicType); case SyntaxKind.ExclamationToken: return parseJSDocNodeWithType(SyntaxKind.JSDocNonNullableType); + case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: case SyntaxKind.TrueKeyword: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7c073b45dfb..64cd32e0a0b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1049,7 +1049,7 @@ namespace ts { export interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; - literal: Expression; + literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } export interface StringLiteral extends LiteralExpression { diff --git a/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.js b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.js new file mode 100644 index 00000000000..0c702a113b1 --- /dev/null +++ b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.js @@ -0,0 +1,6 @@ +//// [noSubstitutionTemplateStringLiteralTypes.ts] +const x: `foo` = "foo"; + + +//// [noSubstitutionTemplateStringLiteralTypes.js] +var x = "foo"; diff --git a/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.symbols b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.symbols new file mode 100644 index 00000000000..c5ee4025663 --- /dev/null +++ b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts === +const x: `foo` = "foo"; +>x : Symbol(x, Decl(noSubstitutionTemplateStringLiteralTypes.ts, 0, 5)) + diff --git a/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.types b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.types new file mode 100644 index 00000000000..2274e703ddc --- /dev/null +++ b/tests/baselines/reference/noSubstitutionTemplateStringLiteralTypes.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts === +const x: `foo` = "foo"; +>x : "foo" +>`foo` : "foo" +>"foo" : "foo" + diff --git a/tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts b/tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts new file mode 100644 index 00000000000..994262c5b10 --- /dev/null +++ b/tests/cases/compiler/noSubstitutionTemplateStringLiteralTypes.ts @@ -0,0 +1 @@ +const x: `foo` = "foo"; From 3062c6309b58ccaad26df200f30f55dfe0cbb11e Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:36:29 -0700 Subject: [PATCH 163/216] Simplify some code in `getSymbolAtLocation` (#18470) --- src/compiler/checker.ts | 16 +++--- src/compiler/utilities.ts | 103 ++++++++++++++++++++------------------ 2 files changed, 62 insertions(+), 57 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1957ebf23bb..7835a5e3e72 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7996,7 +7996,7 @@ namespace ts { return unknownType; } - function getTypeFromThisTypeNode(node: TypeNode): Type { + function getTypeFromThisTypeNode(node: ThisExpression | ThisTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { links.resolvedType = getThisType(node); @@ -8030,7 +8030,7 @@ namespace ts { return node.flags & NodeFlags.JavaScriptFile ? anyType : nonPrimitiveType; case SyntaxKind.ThisType: case SyntaxKind.ThisKeyword: - return getTypeFromThisTypeNode(node); + return getTypeFromThisTypeNode(node as ThisExpression | ThisTypeNode); case SyntaxKind.LiteralType: return getTypeFromLiteralTypeNode(node); case SyntaxKind.TypeReference: @@ -23065,14 +23065,16 @@ namespace ts { return sig.thisParameter; } } + if (isInExpressionContext(node)) { + return checkExpression(node as Expression).symbol; + } // falls through - case SyntaxKind.SuperKeyword: - const type = isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); - return type.symbol; - case SyntaxKind.ThisType: - return getTypeFromTypeNode(node).symbol; + return getTypeFromThisTypeNode(node as ThisExpression | ThisTypeNode).symbol; + + case SyntaxKind.SuperKeyword: + return checkExpression(node as Expression).symbol; case SyntaxKind.ConstructorKeyword: // constructor keyword for an overload, should take us to the definition if it exist diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 64d5bcaac62..47cf2038f03 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1253,57 +1253,60 @@ namespace ts { case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: case SyntaxKind.ThisKeyword: - const parent = node.parent; - switch (parent.kind) { - case SyntaxKind.VariableDeclaration: - case SyntaxKind.Parameter: - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.EnumMember: - case SyntaxKind.PropertyAssignment: - case SyntaxKind.BindingElement: - return (parent).initializer === node; - case SyntaxKind.ExpressionStatement: - case SyntaxKind.IfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.ReturnStatement: - case SyntaxKind.WithStatement: - case SyntaxKind.SwitchStatement: - case SyntaxKind.CaseClause: - case SyntaxKind.ThrowStatement: - return (parent).expression === node; - case SyntaxKind.ForStatement: - const forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || - forStatement.condition === node || - forStatement.incrementor === node; - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - const forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || - forInStatement.expression === node; - case SyntaxKind.TypeAssertionExpression: - case SyntaxKind.AsExpression: - return node === (parent).expression; - case SyntaxKind.TemplateSpan: - return node === (parent).expression; - case SyntaxKind.ComputedPropertyName: - return node === (parent).expression; - case SyntaxKind.Decorator: - case SyntaxKind.JsxExpression: - case SyntaxKind.JsxSpreadAttribute: - case SyntaxKind.SpreadAssignment: - return true; - case SyntaxKind.ExpressionWithTypeArguments: - return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - default: - if (isPartOfExpression(parent)) { - return true; - } - } + return isInExpressionContext(node); + default: + return false; + } + } + + export function isInExpressionContext(node: Node): boolean { + const parent = node.parent; + switch (parent.kind) { + case SyntaxKind.VariableDeclaration: + case SyntaxKind.Parameter: + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + case SyntaxKind.EnumMember: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.BindingElement: + return (parent).initializer === node; + case SyntaxKind.ExpressionStatement: + case SyntaxKind.IfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + case SyntaxKind.ReturnStatement: + case SyntaxKind.WithStatement: + case SyntaxKind.SwitchStatement: + case SyntaxKind.CaseClause: + case SyntaxKind.ThrowStatement: + return (parent).expression === node; + case SyntaxKind.ForStatement: + const forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || + forStatement.condition === node || + forStatement.incrementor === node; + case SyntaxKind.ForInStatement: + case SyntaxKind.ForOfStatement: + const forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) || + forInStatement.expression === node; + case SyntaxKind.TypeAssertionExpression: + case SyntaxKind.AsExpression: + return node === (parent).expression; + case SyntaxKind.TemplateSpan: + return node === (parent).expression; + case SyntaxKind.ComputedPropertyName: + return node === (parent).expression; + case SyntaxKind.Decorator: + case SyntaxKind.JsxExpression: + case SyntaxKind.JsxSpreadAttribute: + case SyntaxKind.SpreadAssignment: + return true; + case SyntaxKind.ExpressionWithTypeArguments: + return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + return isPartOfExpression(parent); } - return false; } export function isExternalModuleImportEqualsDeclaration(node: Node) { From d1e2242ee4e7b3224b1c129868cd0947449186c7 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:36:55 -0700 Subject: [PATCH 164/216] Allow to access `exports` from inside a commonjs module (#17745) * Allow to access `exports` from inside a commonjs module * Don't contextually type `this` in `exports.f = function() { ... }` * Update test --- src/compiler/checker.ts | 26 ++++++- .../reference/commonjsAccessExports.symbols | 30 ++++++++ .../reference/commonjsAccessExports.types | 39 ++++++++++ ...ileCompilationExternalPackageError.symbols | 1 + ...sFileCompilationExternalPackageError.types | 6 +- .../reference/moduleExportAlias.symbols | 27 +++++++ .../reference/moduleExportAlias.types | 76 +++++++++---------- ...solution_explicitNodeModulesImport.symbols | 1 + ...Resolution_explicitNodeModulesImport.types | 6 +- .../typeFromParamTagForFunction.symbols | 2 + .../typeFromParamTagForFunction.types | 12 +-- .../untypedModuleImport_allowJs.symbols | 1 + .../untypedModuleImport_allowJs.types | 6 +- tests/cases/compiler/commonjsAccessExports.ts | 18 +++++ 14 files changed, 194 insertions(+), 57 deletions(-) create mode 100644 tests/baselines/reference/commonjsAccessExports.symbols create mode 100644 tests/baselines/reference/commonjsAccessExports.types create mode 100644 tests/cases/compiler/commonjsAccessExports.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7835a5e3e72..5a8ecc2e83d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1125,6 +1125,13 @@ namespace ts { } if (!result) { + if (lastLocation) { + Debug.assert(lastLocation.kind === SyntaxKind.SourceFile); + if ((lastLocation as SourceFile).commonJsModuleIndicator && name === "exports") { + return lastLocation.symbol; + } + } + result = lookup(globals, name, meaning); } @@ -12885,7 +12892,8 @@ namespace ts { } } } - if (noImplicitThis || isInJavaScriptFile(func)) { + const inJs = isInJavaScriptFile(func); + if (noImplicitThis || inJs) { const containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { // We have an object literal method. Check if the containing object literal has a contextual type @@ -12912,10 +12920,20 @@ namespace ts { } // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. - if (func.parent.kind === SyntaxKind.BinaryExpression && (func.parent).operatorToken.kind === SyntaxKind.EqualsToken) { - const target = (func.parent).left; + const { parent } = func; + if (parent.kind === SyntaxKind.BinaryExpression && (parent).operatorToken.kind === SyntaxKind.EqualsToken) { + const target = (parent).left; if (target.kind === SyntaxKind.PropertyAccessExpression || target.kind === SyntaxKind.ElementAccessExpression) { - return checkExpressionCached((target).expression); + const { expression } = target as PropertyAccessExpression | ElementAccessExpression; + // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` + if (inJs && isIdentifier(expression)) { + const sourceFile = getSourceFileOfNode(parent); + if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) { + return undefined; + } + } + + return checkExpressionCached(expression); } } } diff --git a/tests/baselines/reference/commonjsAccessExports.symbols b/tests/baselines/reference/commonjsAccessExports.symbols new file mode 100644 index 00000000000..dce61803408 --- /dev/null +++ b/tests/baselines/reference/commonjsAccessExports.symbols @@ -0,0 +1,30 @@ +=== /a.js === +exports.x = 0; +>exports.x : Symbol(x, Decl(a.js, 0, 0)) +>exports : Symbol(x, Decl(a.js, 0, 0)) +>x : Symbol(x, Decl(a.js, 0, 0)) + +exports.x; +>exports.x : Symbol(x, Decl(a.js, 0, 0)) +>exports : Symbol("/a", Decl(a.js, 0, 0)) +>x : Symbol(x, Decl(a.js, 0, 0)) + +// Works nested +{ + // 'exports' does not provide a contextual type to a function-class + exports.Cls = function() { +>exports.Cls : Symbol(Cls, Decl(a.js, 4, 1)) +>exports : Symbol(Cls, Decl(a.js, 4, 1)) +>Cls : Symbol(Cls, Decl(a.js, 4, 1)) + + this.x = 0; +>x : Symbol((Anonymous function).x, Decl(a.js, 6, 30)) + } +} + +const instance = new exports.Cls(); +>instance : Symbol(instance, Decl(a.js, 11, 5)) +>exports.Cls : Symbol(Cls, Decl(a.js, 4, 1)) +>exports : Symbol("/a", Decl(a.js, 0, 0)) +>Cls : Symbol(Cls, Decl(a.js, 4, 1)) + diff --git a/tests/baselines/reference/commonjsAccessExports.types b/tests/baselines/reference/commonjsAccessExports.types new file mode 100644 index 00000000000..61d57d4b2cc --- /dev/null +++ b/tests/baselines/reference/commonjsAccessExports.types @@ -0,0 +1,39 @@ +=== /a.js === +exports.x = 0; +>exports.x = 0 : 0 +>exports.x : number +>exports : typeof "/a" +>x : number +>0 : 0 + +exports.x; +>exports.x : number +>exports : typeof "/a" +>x : number + +// Works nested +{ + // 'exports' does not provide a contextual type to a function-class + exports.Cls = function() { +>exports.Cls = function() { this.x = 0; } : () => void +>exports.Cls : () => void +>exports : typeof "/a" +>Cls : () => void +>function() { this.x = 0; } : () => void + + this.x = 0; +>this.x = 0 : 0 +>this.x : any +>this : any +>x : any +>0 : 0 + } +} + +const instance = new exports.Cls(); +>instance : { x: number; } +>new exports.Cls() : { x: number; } +>exports.Cls : () => void +>exports : typeof "/a" +>Cls : () => void + diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols b/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols index 7663b2fcedf..ed03884c653 100644 --- a/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols +++ b/tests/baselines/reference/jsFileCompilationExternalPackageError.symbols @@ -17,6 +17,7 @@ var a = 10; === tests/cases/compiler/node_modules/c.js === exports.a = 10; +>exports.a : Symbol(a, Decl(c.js, 0, 0)) >exports : Symbol(a, Decl(c.js, 0, 0)) >a : Symbol(a, Decl(c.js, 0, 0)) diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.types b/tests/baselines/reference/jsFileCompilationExternalPackageError.types index c41a24fcffd..82418aeeb28 100644 --- a/tests/baselines/reference/jsFileCompilationExternalPackageError.types +++ b/tests/baselines/reference/jsFileCompilationExternalPackageError.types @@ -21,9 +21,9 @@ var a = 10; === tests/cases/compiler/node_modules/c.js === exports.a = 10; >exports.a = 10 : 10 ->exports.a : any ->exports : any ->a : any +>exports.a : number +>exports : typeof "tests/cases/compiler/node_modules/c" +>a : number >10 : 10 c = 10; diff --git a/tests/baselines/reference/moduleExportAlias.symbols b/tests/baselines/reference/moduleExportAlias.symbols index ed480a0033c..9e2e0e554d2 100644 --- a/tests/baselines/reference/moduleExportAlias.symbols +++ b/tests/baselines/reference/moduleExportAlias.symbols @@ -106,11 +106,15 @@ b.func20; === tests/cases/conformance/salsa/b.js === var exportsAlias = exports; >exportsAlias : Symbol(exportsAlias, Decl(b.js, 0, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) exportsAlias.func1 = function () { }; +>exportsAlias.func1 : Symbol(func1, Decl(b.js, 0, 27)) >exportsAlias : Symbol(exportsAlias, Decl(b.js, 0, 3)) +>func1 : Symbol(func1, Decl(b.js, 0, 27)) exports.func2 = function () { }; +>exports.func2 : Symbol(func2, Decl(b.js, 1, 37)) >exports : Symbol(func2, Decl(b.js, 1, 37)) >func2 : Symbol(func2, Decl(b.js, 1, 37)) @@ -126,15 +130,19 @@ module.exports.func4 = function () { }; var multipleDeclarationAlias1 = exports = module.exports; >multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias1.func5 = function () { }; >multipleDeclarationAlias1 : Symbol(multipleDeclarationAlias1, Decl(b.js, 8, 3)) var multipleDeclarationAlias2 = module.exports = exports; >multipleDeclarationAlias2 : Symbol(multipleDeclarationAlias2, Decl(b.js, 11, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias2.func6 = function () { }; +>multipleDeclarationAlias2.func6 : Symbol(func6, Decl(b.js, 11, 57)) >multipleDeclarationAlias2 : Symbol(multipleDeclarationAlias2, Decl(b.js, 11, 3)) +>func6 : Symbol(func6, Decl(b.js, 11, 57)) var someOtherVariable; >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) @@ -142,9 +150,12 @@ var someOtherVariable; var multipleDeclarationAlias3 = someOtherVariable = exports; >multipleDeclarationAlias3 : Symbol(multipleDeclarationAlias3, Decl(b.js, 15, 3)) >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias3.func7 = function () { }; +>multipleDeclarationAlias3.func7 : Symbol(func7, Decl(b.js, 15, 60)) >multipleDeclarationAlias3 : Symbol(multipleDeclarationAlias3, Decl(b.js, 15, 3)) +>func7 : Symbol(func7, Decl(b.js, 15, 60)) var multipleDeclarationAlias4 = someOtherVariable = module.exports; >multipleDeclarationAlias4 : Symbol(multipleDeclarationAlias4, Decl(b.js, 18, 3)) @@ -155,20 +166,24 @@ multipleDeclarationAlias4.func8 = function () { }; var multipleDeclarationAlias5 = module.exports = exports = {}; >multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias5.func9 = function () { }; >multipleDeclarationAlias5 : Symbol(multipleDeclarationAlias5, Decl(b.js, 21, 3)) var multipleDeclarationAlias6 = exports = module.exports = {}; >multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) multipleDeclarationAlias6.func10 = function () { }; >multipleDeclarationAlias6 : Symbol(multipleDeclarationAlias6, Decl(b.js, 24, 3)) exports = module.exports = someOtherVariable = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) exports.func11 = function () { }; +>exports.func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) >exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) >func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) @@ -177,9 +192,11 @@ module.exports.func12 = function () { }; >func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) exports = module.exports = someOtherVariable = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) >someOtherVariable : Symbol(someOtherVariable, Decl(b.js, 14, 3)) exports.func11 = function () { }; +>exports.func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) >exports : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) >func11 : Symbol(func11, Decl(b.js, 27, 50), Decl(b.js, 31, 50)) @@ -188,7 +205,10 @@ module.exports.func12 = function () { }; >func12 : Symbol(func12, Decl(b.js, 28, 33), Decl(b.js, 32, 33)) exports = module.exports = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) + exports.func13 = function () { }; +>exports.func13 : Symbol(func13, Decl(b.js, 35, 30)) >exports : Symbol(func13, Decl(b.js, 35, 30)) >func13 : Symbol(func13, Decl(b.js, 35, 30)) @@ -197,7 +217,10 @@ module.exports.func14 = function () { }; >func14 : Symbol(func14, Decl(b.js, 36, 33)) exports = module.exports = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) + exports.func15 = function () { }; +>exports.func15 : Symbol(func15, Decl(b.js, 39, 30)) >exports : Symbol(func15, Decl(b.js, 39, 30)) >func15 : Symbol(func15, Decl(b.js, 39, 30)) @@ -206,7 +229,10 @@ module.exports.func16 = function () { }; >func16 : Symbol(func16, Decl(b.js, 40, 33)) module.exports = exports = {}; +>exports : Symbol("tests/cases/conformance/salsa/b", Decl(b.js, 0, 0)) + exports.func17 = function () { }; +>exports.func17 : Symbol(func17, Decl(b.js, 43, 30)) >exports : Symbol(func17, Decl(b.js, 43, 30)) >func17 : Symbol(func17, Decl(b.js, 43, 30)) @@ -216,6 +242,7 @@ module.exports.func18 = function () { }; module.exports = {}; exports.func19 = function () { }; +>exports.func19 : Symbol(func19, Decl(b.js, 47, 20)) >exports : Symbol(func19, Decl(b.js, 47, 20)) >func19 : Symbol(func19, Decl(b.js, 47, 20)) diff --git a/tests/baselines/reference/moduleExportAlias.types b/tests/baselines/reference/moduleExportAlias.types index ccf8e5d7a24..b1eedf8c2ab 100644 --- a/tests/baselines/reference/moduleExportAlias.types +++ b/tests/baselines/reference/moduleExportAlias.types @@ -105,21 +105,21 @@ b.func20; === tests/cases/conformance/salsa/b.js === var exportsAlias = exports; ->exportsAlias : any ->exports : any +>exportsAlias : typeof "tests/cases/conformance/salsa/b" +>exports : typeof "tests/cases/conformance/salsa/b" exportsAlias.func1 = function () { }; >exportsAlias.func1 = function () { } : () => void ->exportsAlias.func1 : any ->exportsAlias : any ->func1 : any +>exportsAlias.func1 : () => void +>exportsAlias : typeof "tests/cases/conformance/salsa/b" +>func1 : () => void >function () { } : () => void exports.func2 = function () { }; >exports.func2 = function () { } : () => void ->exports.func2 : any ->exports : any ->func2 : any +>exports.func2 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func2 : () => void >function () { } : () => void var moduleExportsAlias = module.exports; @@ -160,34 +160,34 @@ multipleDeclarationAlias1.func5 = function () { }; >function () { } : () => void var multipleDeclarationAlias2 = module.exports = exports; ->multipleDeclarationAlias2 : any ->module.exports = exports : any +>multipleDeclarationAlias2 : typeof "tests/cases/conformance/salsa/b" +>module.exports = exports : typeof "tests/cases/conformance/salsa/b" >module.exports : any >module : any >exports : any ->exports : any +>exports : typeof "tests/cases/conformance/salsa/b" multipleDeclarationAlias2.func6 = function () { }; >multipleDeclarationAlias2.func6 = function () { } : () => void ->multipleDeclarationAlias2.func6 : any ->multipleDeclarationAlias2 : any ->func6 : any +>multipleDeclarationAlias2.func6 : () => void +>multipleDeclarationAlias2 : typeof "tests/cases/conformance/salsa/b" +>func6 : () => void >function () { } : () => void var someOtherVariable; >someOtherVariable : any var multipleDeclarationAlias3 = someOtherVariable = exports; ->multipleDeclarationAlias3 : any ->someOtherVariable = exports : any +>multipleDeclarationAlias3 : typeof "tests/cases/conformance/salsa/b" +>someOtherVariable = exports : typeof "tests/cases/conformance/salsa/b" >someOtherVariable : any ->exports : any +>exports : typeof "tests/cases/conformance/salsa/b" multipleDeclarationAlias3.func7 = function () { }; >multipleDeclarationAlias3.func7 = function () { } : () => void ->multipleDeclarationAlias3.func7 : any ->multipleDeclarationAlias3 : any ->func7 : any +>multipleDeclarationAlias3.func7 : () => void +>multipleDeclarationAlias3 : typeof "tests/cases/conformance/salsa/b" +>func7 : () => void >function () { } : () => void var multipleDeclarationAlias4 = someOtherVariable = module.exports; @@ -252,9 +252,9 @@ exports = module.exports = someOtherVariable = {}; exports.func11 = function () { }; >exports.func11 = function () { } : () => void ->exports.func11 : any ->exports : any ->func11 : any +>exports.func11 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func11 : () => void >function () { } : () => void module.exports.func12 = function () { }; @@ -279,9 +279,9 @@ exports = module.exports = someOtherVariable = {}; exports.func11 = function () { }; >exports.func11 = function () { } : () => void ->exports.func11 : any ->exports : any ->func11 : any +>exports.func11 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func11 : () => void >function () { } : () => void module.exports.func12 = function () { }; @@ -304,9 +304,9 @@ exports = module.exports = {}; exports.func13 = function () { }; >exports.func13 = function () { } : () => void ->exports.func13 : any ->exports : any ->func13 : any +>exports.func13 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func13 : () => void >function () { } : () => void module.exports.func14 = function () { }; @@ -329,9 +329,9 @@ exports = module.exports = {}; exports.func15 = function () { }; >exports.func15 = function () { } : () => void ->exports.func15 : any ->exports : any ->func15 : any +>exports.func15 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func15 : () => void >function () { } : () => void module.exports.func16 = function () { }; @@ -354,9 +354,9 @@ module.exports = exports = {}; exports.func17 = function () { }; >exports.func17 = function () { } : () => void ->exports.func17 : any ->exports : any ->func17 : any +>exports.func17 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func17 : () => void >function () { } : () => void module.exports.func18 = function () { }; @@ -377,9 +377,9 @@ module.exports = {}; exports.func19 = function () { }; >exports.func19 = function () { } : () => void ->exports.func19 : any ->exports : any ->func19 : any +>exports.func19 : () => void +>exports : typeof "tests/cases/conformance/salsa/b" +>func19 : () => void >function () { } : () => void module.exports.func20 = function () { }; diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols index b635ba2c7c7..b091b2d4ab2 100644 --- a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.symbols @@ -4,6 +4,7 @@ import { x } from "../node_modules/foo"; === /node_modules/foo/index.js === exports.x = 0; +>exports.x : Symbol(x, Decl(index.js, 0, 0)) >exports : Symbol(x, Decl(index.js, 0, 0)) >x : Symbol(x, Decl(index.js, 0, 0)) diff --git a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types index ca7541d2140..fe7d74c914c 100644 --- a/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types +++ b/tests/baselines/reference/moduleResolution_explicitNodeModulesImport.types @@ -5,8 +5,8 @@ import { x } from "../node_modules/foo"; === /node_modules/foo/index.js === exports.x = 0; >exports.x = 0 : 0 ->exports.x : any ->exports : any ->x : any +>exports.x : number +>exports : typeof "/node_modules/foo/index" +>x : number >0 : 0 diff --git a/tests/baselines/reference/typeFromParamTagForFunction.symbols b/tests/baselines/reference/typeFromParamTagForFunction.symbols index 0df0dfdc206..5bacb93cc7a 100644 --- a/tests/baselines/reference/typeFromParamTagForFunction.symbols +++ b/tests/baselines/reference/typeFromParamTagForFunction.symbols @@ -9,6 +9,7 @@ declare var module: any, exports: any; === tests/cases/conformance/salsa/a-ext.js === exports.A = function () { +>exports.A : Symbol(A, Decl(a-ext.js, 0, 0)) >exports : Symbol(A, Decl(a-ext.js, 0, 0)) >A : Symbol(A, Decl(a-ext.js, 0, 0)) @@ -33,6 +34,7 @@ function a(p) { p.x; } === tests/cases/conformance/salsa/b-ext.js === exports.B = class { +>exports.B : Symbol(B, Decl(b-ext.js, 0, 0)) >exports : Symbol(B, Decl(b-ext.js, 0, 0)) >B : Symbol(B, Decl(b-ext.js, 0, 0)) diff --git a/tests/baselines/reference/typeFromParamTagForFunction.types b/tests/baselines/reference/typeFromParamTagForFunction.types index c1e16ddb33d..98bd1682455 100644 --- a/tests/baselines/reference/typeFromParamTagForFunction.types +++ b/tests/baselines/reference/typeFromParamTagForFunction.types @@ -10,9 +10,9 @@ declare var module: any, exports: any; === tests/cases/conformance/salsa/a-ext.js === exports.A = function () { >exports.A = function () { this.x = 1;} : () => void ->exports.A : any ->exports : any ->A : any +>exports.A : () => void +>exports : typeof "tests/cases/conformance/salsa/a-ext" +>A : () => void >function () { this.x = 1;} : () => void this.x = 1; @@ -42,9 +42,9 @@ function a(p) { p.x; } === tests/cases/conformance/salsa/b-ext.js === exports.B = class { >exports.B = class { constructor() { this.x = 1; }} : typeof (Anonymous class) ->exports.B : any ->exports : any ->B : any +>exports.B : typeof (Anonymous class) +>exports : typeof "tests/cases/conformance/salsa/b-ext" +>B : typeof (Anonymous class) >class { constructor() { this.x = 1; }} : typeof (Anonymous class) constructor() { diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.symbols b/tests/baselines/reference/untypedModuleImport_allowJs.symbols index d660e811630..1076590e009 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.symbols +++ b/tests/baselines/reference/untypedModuleImport_allowJs.symbols @@ -11,6 +11,7 @@ foo.bar(); // Same as untypedModuleImport.ts but with --allowJs, so the package will actually be typed. exports.default = { bar() { return 0; } } +>exports.default : Symbol(default, Decl(index.js, 0, 0)) >exports : Symbol(default, Decl(index.js, 0, 0)) >default : Symbol(default, Decl(index.js, 0, 0)) >bar : Symbol(bar, Decl(index.js, 2, 19)) diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.types b/tests/baselines/reference/untypedModuleImport_allowJs.types index 108ba60ccb3..2a854ce9d23 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.types +++ b/tests/baselines/reference/untypedModuleImport_allowJs.types @@ -13,9 +13,9 @@ foo.bar(); exports.default = { bar() { return 0; } } >exports.default = { bar() { return 0; } } : { [x: string]: any; bar(): number; } ->exports.default : any ->exports : any ->default : any +>exports.default : { [x: string]: any; bar(): number; } +>exports : typeof "/node_modules/foo/index" +>default : { [x: string]: any; bar(): number; } >{ bar() { return 0; } } : { [x: string]: any; bar(): number; } >bar : () => number >0 : 0 diff --git a/tests/cases/compiler/commonjsAccessExports.ts b/tests/cases/compiler/commonjsAccessExports.ts new file mode 100644 index 00000000000..961be3f5a23 --- /dev/null +++ b/tests/cases/compiler/commonjsAccessExports.ts @@ -0,0 +1,18 @@ +// @module: commonjs +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @Filename: /a.js +exports.x = 0; +exports.x; + +// Works nested +{ + // 'exports' does not provide a contextual type to a function-class + exports.Cls = function() { + this.x = 0; + } +} + +const instance = new exports.Cls(); From 89eb06e47534a962902928161836ed959ed9d3b1 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:37:38 -0700 Subject: [PATCH 165/216] For completions of union, exclude types with methods (#18124) For completions of union, exclude arrays --- src/compiler/checker.ts | 29 +++++++++---------- src/compiler/types.ts | 3 +- src/services/completions.ts | 18 +++++++++++- .../cases/fourslash/completionListOfUnion.ts | 2 +- tests/cases/fourslash/completionsUnion.ts | 8 +++++ 5 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 tests/cases/fourslash/completionsUnion.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5a8ecc2e83d..25fff43bab7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -225,7 +225,8 @@ namespace ts { return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); }, getApparentType, - getAllPossiblePropertiesOfType, + isArrayLikeType, + getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: (node, type) => unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)), getSuggestionForNonexistentSymbol: (location, name, meaning) => unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning)), getBaseConstraintOfType, @@ -5925,25 +5926,21 @@ namespace ts { getPropertiesOfObjectType(type); } - function getAllPossiblePropertiesOfType(type: Type): Symbol[] { - if (type.flags & TypeFlags.Union) { - const props = createSymbolTable(); - for (const memberType of (type as UnionType).types) { - if (memberType.flags & TypeFlags.Primitive) { - continue; - } + function getAllPossiblePropertiesOfTypes(types: Type[]): Symbol[] { + const unionType = getUnionType(types); + if (!(unionType.flags & TypeFlags.Union)) { + return getPropertiesOfType(unionType); + } - for (const { escapedName } of getPropertiesOfType(memberType)) { - if (!props.has(escapedName)) { - props.set(escapedName, createUnionOrIntersectionProperty(type as UnionType, escapedName)); - } + const props = createSymbolTable(); + for (const memberType of types) { + for (const { escapedName } of getPropertiesOfType(memberType)) { + if (!props.has(escapedName)) { + props.set(escapedName, createUnionOrIntersectionProperty(unionType as UnionType, escapedName)); } } - return arrayFrom(props.values()); - } - else { - return getPropertiesOfType(type); } + return arrayFrom(props.values()); } function getConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 64cd32e0a0b..66a31864f56 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2703,7 +2703,8 @@ namespace ts { * So for `{ a } | { b }`, this will include both `a` and `b`. * Does not include properties of primitive types. */ - /* @internal */ getAllPossiblePropertiesOfType(type: Type): Symbol[]; + /* @internal */ isArrayLikeType(type: Type): boolean; + /* @internal */ getAllPossiblePropertiesOfTypes(type: ReadonlyArray): Symbol[]; /* @internal */ resolveName(name: string, location: Node, meaning: SymbolFlags): Symbol | undefined; /* @internal */ getJsxNamespace(): string; } diff --git a/src/services/completions.ts b/src/services/completions.ts index 15a20798508..e271ef12104 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -978,7 +978,7 @@ namespace ts.Completions { isNewIdentifierLocation = true; const typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return false; - typeMembers = typeChecker.getAllPossiblePropertiesOfType(typeForObject); + typeMembers = getPropertiesForCompletion(typeForObject, typeChecker); existingMembers = (objectLikeContainer).properties; } else { @@ -1766,4 +1766,20 @@ namespace ts.Completions { return node.parent; } } + + /** + * Gets all properties on a type, but if that type is a union of several types, + * tries to only include those types which declare properties, not methods. + * This ensures that we don't try providing completions for all the methods on e.g. Array. + */ + function getPropertiesForCompletion(type: Type, checker: TypeChecker): Symbol[] { + if (!(type.flags & TypeFlags.Union)) { + return checker.getPropertiesOfType(type); + } + + const { types } = type as UnionType; + const filteredTypes = types.filter(memberType => !(memberType.flags & TypeFlags.Primitive || checker.isArrayLikeType(memberType))); + // If there are no property-only types, just provide completions for every type as usual. + return checker.getAllPossiblePropertiesOfTypes(filteredTypes); + } } diff --git a/tests/cases/fourslash/completionListOfUnion.ts b/tests/cases/fourslash/completionListOfUnion.ts index 5ffaf89e5b3..c323c83d054 100644 --- a/tests/cases/fourslash/completionListOfUnion.ts +++ b/tests/cases/fourslash/completionListOfUnion.ts @@ -16,5 +16,5 @@ verify.completionListContains("b", "(property) b: number | boolean"); verify.completionListContains("c", "(property) c: string"); goTo.marker("f"); -verify.completionListContains("a", "(property) a: number"); +verify.completionListContains("a", "(property) I.a: number"); // Also contains array members diff --git a/tests/cases/fourslash/completionsUnion.ts b/tests/cases/fourslash/completionsUnion.ts new file mode 100644 index 00000000000..ed449936680 --- /dev/null +++ b/tests/cases/fourslash/completionsUnion.ts @@ -0,0 +1,8 @@ +/// + +////interface I { x: number; } +////interface Many extends ReadonlyArray { extra: number; } +////const x: I | I[] | Many = { /**/ }; + +// We specifically filter out any array-like types. +verify.completionsAt("", ["x"]); From 8dc66e4665e6aa7c3c822e066bb1c59e72fa7591 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:38:17 -0700 Subject: [PATCH 166/216] Cleanup navTo (#18150) --- src/services/navigateTo.ts | 286 ++++++++++++++++----------------- src/services/patternMatcher.ts | 4 +- 2 files changed, 144 insertions(+), 146 deletions(-) diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index ec7b011456f..7fa177b6a30 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -21,185 +21,183 @@ namespace ts.NavigateTo { } forEachEntry(sourceFile.getNamedDeclarations(), (declarations, name) => { - if (declarations) { - // First do a quick check to see if the name of the declaration matches the - // last portion of the (possibly) dotted name they're searching for. - let matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); - - if (!matches) { - return; // continue to next named declarations - } - - for (const declaration of declarations) { - // It was a match! If the pattern has dots in it, then also see if the - // declaration container matches as well. - if (patternMatcher.patternContainsDots) { - const containers = getContainers(declaration); - if (!containers) { - return true; // Break out of named declarations and go to the next source file. - } - - matches = patternMatcher.getMatches(containers, name); - - if (!matches) { - return; // continue to next named declarations - } - } - - const fileName = sourceFile.fileName; - const matchKind = bestMatchKind(matches); - rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration }); - } - } + getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, rawItems); }); } - // Remove imports when the imported declaration is already in the list and has the same name. - rawItems = filter(rawItems, item => { - const decl = item.declaration; - if (decl.kind === SyntaxKind.ImportClause || decl.kind === SyntaxKind.ImportSpecifier || decl.kind === SyntaxKind.ImportEqualsDeclaration) { - const importer = checker.getSymbolAtLocation((decl as NamedDeclaration).name); - const imported = checker.getAliasedSymbol(importer); - return importer.escapedName !== imported.escapedName; - } - else { - return true; - } - }); - rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { rawItems = rawItems.slice(0, maxResultCount); } + return rawItems.map(createNavigateToItem); + } - const items = map(rawItems, createNavigateToItem); + function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: ReadonlyArray, checker: TypeChecker, fileName: string, rawItems: Push): void { + // First do a quick check to see if the name of the declaration matches the + // last portion of the (possibly) dotted name they're searching for. + const matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); - return items; + if (!matches) { + return; // continue to next named declarations + } - function allMatchesAreCaseSensitive(matches: PatternMatch[]): boolean { - Debug.assert(matches.length > 0); + for (const declaration of declarations) { + if (!shouldKeepItem(declaration, checker)) { + continue; + } - // This is a case sensitive match, only if all the submatches were case sensitive. - for (const match of matches) { - if (!match.isCaseSensitive) { + // It was a match! If the pattern has dots in it, then also see if the + // declaration container matches as well. + let containerMatches = matches; + if (patternMatcher.patternContainsDots) { + containerMatches = patternMatcher.getMatches(getContainers(declaration), name); + if (!containerMatches) { + continue; + } + } + + const matchKind = bestMatchKind(containerMatches); + const isCaseSensitive = allMatchesAreCaseSensitive(containerMatches); + rawItems.push({ name, fileName, matchKind, isCaseSensitive, declaration }); + } + } + + function shouldKeepItem(declaration: Declaration, checker: ts.TypeChecker): boolean { + switch (declaration.kind) { + case SyntaxKind.ImportClause: + case SyntaxKind.ImportSpecifier: + case SyntaxKind.ImportEqualsDeclaration: + const importer = checker.getSymbolAtLocation((declaration as ImportClause | ImportSpecifier | ImportEqualsDeclaration).name); + const imported = checker.getAliasedSymbol(importer); + return importer.escapedName !== imported.escapedName; + default: + return true; + } + } + + function allMatchesAreCaseSensitive(matches: ReadonlyArray): boolean { + Debug.assert(matches.length > 0); + + // This is a case sensitive match, only if all the submatches were case sensitive. + for (const match of matches) { + if (!match.isCaseSensitive) { + return false; + } + } + + return true; + } + + function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]): boolean { + if (declaration) { + const name = getNameOfDeclaration(declaration); + if (name) { + const text = getTextOfIdentifierOrLiteral(name as (Identifier | LiteralExpression)); + if (text !== undefined) { + containers.unshift(text); + } + else if (name.kind === SyntaxKind.ComputedPropertyName) { + return tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ true); + } + else { + // Don't know how to add this. return false; } } + } + return true; + } + + // Only added the names of computed properties if they're simple dotted expressions, like: + // + // [X.Y.Z]() { } + function tryAddComputedPropertyName(expression: Expression, containers: string[], includeLastPortion: boolean): boolean { + const text = getTextOfIdentifierOrLiteral(expression as LiteralExpression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); + } return true; } - function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]) { - if (declaration) { - const name = getNameOfDeclaration(declaration); - if (name) { - const text = getTextOfIdentifierOrLiteral(name as (Identifier | LiteralExpression)); - if (text !== undefined) { - containers.unshift(text); - } - else if (name.kind === SyntaxKind.ComputedPropertyName) { - return tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ true); - } - else { - // Don't know how to add this. - return false; - } - } + if (expression.kind === SyntaxKind.PropertyAccessExpression) { + const propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); } - return true; + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion*/ true); } - // Only added the names of computed properties if they're simple dotted expressions, like: - // - // [X.Y.Z]() { } - function tryAddComputedPropertyName(expression: Expression, containers: string[], includeLastPortion: boolean): boolean { - const text = getTextOfIdentifierOrLiteral(expression as LiteralExpression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); - } - return true; + return false; + } + + function getContainers(declaration: Declaration): string[] { + const containers: string[] = []; + + // First, if we started with a computed property name, then add all but the last + // portion into the container array. + const name = getNameOfDeclaration(declaration); + if (name.kind === SyntaxKind.ComputedPropertyName) { + if (!tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ false)) { + return undefined; } - - if (expression.kind === SyntaxKind.PropertyAccessExpression) { - const propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); - } - - return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion*/ true); - } - - return false; } - function getContainers(declaration: Declaration) { - const containers: string[] = []; + // Now, walk up our containers, adding all their names to the container array. + declaration = getContainerNode(declaration); - // First, if we started with a computed property name, then add all but the last - // portion into the container array. - const name = getNameOfDeclaration(declaration); - if (name.kind === SyntaxKind.ComputedPropertyName) { - if (!tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ false)) { - return undefined; - } + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; } - // Now, walk up our containers, adding all their names to the container array. declaration = getContainerNode(declaration); + } - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { - return undefined; - } + return containers; + } - declaration = getContainerNode(declaration); + function bestMatchKind(matches: ReadonlyArray): PatternMatchKind { + Debug.assert(matches.length > 0); + let bestMatchKind = PatternMatchKind.camelCase; + + for (const match of matches) { + const kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; } - - return containers; } - function bestMatchKind(matches: PatternMatch[]) { - Debug.assert(matches.length > 0); - let bestMatchKind = PatternMatchKind.camelCase; + return bestMatchKind; + } - for (const match of matches) { - const kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; - } - } + function compareNavigateToItems(i1: RawNavigateToItem, i2: RawNavigateToItem): number { + // TODO(cyrusn): get the gamut of comparisons that VS already uses here. + // Right now we just sort by kind first, and then by name of the item. + // We first sort case insensitively. So "Aaa" will come before "bar". + // Then we sort case sensitively, so "aaa" will come before "Aaa". + return i1.matchKind - i2.matchKind || + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); + } - return bestMatchKind; - } - - function compareNavigateToItems(i1: RawNavigateToItem, i2: RawNavigateToItem) { - // TODO(cyrusn): get the gamut of comparisons that VS already uses here. - // Right now we just sort by kind first, and then by name of the item. - // We first sort case insensitively. So "Aaa" will come before "bar". - // Then we sort case sensitively, so "aaa" will come before "Aaa". - return i1.matchKind - i2.matchKind || - ts.compareStringsCaseInsensitive(i1.name, i2.name) || - ts.compareStrings(i1.name, i2.name); - } - - function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem { - const declaration = rawItem.declaration; - const container = getContainerNode(declaration); - const containerName = container && getNameOfDeclaration(container); - return { - name: rawItem.name, - kind: getNodeKind(declaration), - kindModifiers: getNodeModifiers(declaration), - matchKind: PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: createTextSpanFromNode(declaration), - // TODO(jfreeman): What should be the containerName when the container has a computed name? - containerName: containerName ? (containerName).text : "", - containerKind: containerName ? getNodeKind(container) : ScriptElementKind.unknown - }; - } + function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem { + const declaration = rawItem.declaration; + const container = getContainerNode(declaration); + const containerName = container && getNameOfDeclaration(container); + return { + name: rawItem.name, + kind: getNodeKind(declaration), + kindModifiers: getNodeModifiers(declaration), + matchKind: PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: createTextSpanFromNode(declaration), + // TODO(jfreeman): What should be the containerName when the container has a computed name? + containerName: containerName ? (containerName).text : "", + containerKind: containerName ? getNodeKind(container) : ScriptElementKind.unknown + }; } } diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index 396e53810ce..04f9d906d35 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -47,7 +47,7 @@ namespace ts { // Fully checks a candidate, with an dotted container, against the search pattern. // The candidate must match the last part of the search pattern, and the dotted container // must match the preceding segments of the pattern. - getMatches(candidateContainers: string[], candidate: string): PatternMatch[]; + getMatches(candidateContainers: string[], candidate: string): PatternMatch[] | undefined; // Whether or not the pattern contained dots or not. Clients can use this to determine // If they should call getMatches, or if getMatchesForLastSegmentOfPattern is sufficient. @@ -139,7 +139,7 @@ namespace ts { return matchSegment(candidate, lastOrUndefined(dotSeparatedSegments)); } - function getMatches(candidateContainers: string[], candidate: string): PatternMatch[] { + function getMatches(candidateContainers: string[], candidate: string): PatternMatch[] | undefined { if (skipMatch(candidate)) { return undefined; } From 0de1b2301ebeccc4ce4c85ca8110bf4ffcb41b05 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 12:38:48 -0700 Subject: [PATCH 167/216] Cleanup getDiagnosticsForProject (#18151) --- src/server/session.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/server/session.ts b/src/server/session.ts index 2d773d6f467..e6ba78b81c9 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1609,7 +1609,10 @@ namespace ts.server { } // No need to analyze lib.d.ts - let fileNamesInProject = fileNames.filter(value => value.indexOf("lib.d.ts") < 0); + const fileNamesInProject = fileNames.filter(value => value.indexOf("lib.d.ts") < 0); + if (fileNamesInProject.length === 0) { + return; + } // Sort the file name list to make the recently touched files come first const highPriorityFiles: NormalizedPath[] = []; @@ -1625,7 +1628,7 @@ namespace ts.server { else { const info = this.projectService.getScriptInfo(fileNameInProject); if (!info.isScriptOpen()) { - if (fileNameInProject.indexOf(Extension.Dts) > 0) { + if (fileExtensionIs(fileNameInProject, Extension.Dts)) { veryLowPriorityFiles.push(fileNameInProject); } else { @@ -1638,14 +1641,11 @@ namespace ts.server { } } - fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); - - if (fileNamesInProject.length > 0) { - const checkList = fileNamesInProject.map(fileName => ({ fileName, project })); - // Project level error analysis runs on background files too, therefore - // doesn't require the file to be opened - this.updateErrorCheck(next, checkList, delay, /*requireOpen*/ false); - } + const sortedFiles = [...highPriorityFiles, ...mediumPriorityFiles, ...lowPriorityFiles, ...veryLowPriorityFiles]; + const checkList = sortedFiles.map(fileName => ({ fileName, project })); + // Project level error analysis runs on background files too, therefore + // doesn't require the file to be opened + this.updateErrorCheck(next, checkList, delay, /*requireOpen*/ false); } getCanonicalFileName(fileName: string) { From 1ab67c0f222f79e4e380febcd7bd8988aa3c92d5 Mon Sep 17 00:00:00 2001 From: Armando Aguirre Date: Thu, 14 Sep 2017 12:48:04 -0700 Subject: [PATCH 168/216] Fixed sourceFiles type error --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 9cb7d6638b9..90f9acd82ea 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1543,7 +1543,7 @@ namespace ts { } } else { - sourceFiles = program.getSourceFiles(); + sourceFiles = program.getSourceFiles().slice(); } return FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); From 66abcb9166bce8a897389d56b7760139fe77f665 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 13:03:12 -0700 Subject: [PATCH 169/216] Handle undefined `symbol.declarations` in `cloneSymbol` (#18474) --- src/compiler/checker.ts | 2 +- .../mergedClassWithNamespacePrototype.errors.txt | 15 +++++++++++++++ .../mergedClassWithNamespacePrototype.js | 14 ++++++++++++++ .../compiler/mergedClassWithNamespacePrototype.ts | 9 +++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt create mode 100644 tests/baselines/reference/mergedClassWithNamespacePrototype.js create mode 100644 tests/cases/compiler/mergedClassWithNamespacePrototype.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 25fff43bab7..28c9fb25af9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -578,7 +578,7 @@ namespace ts { function cloneSymbol(symbol: Symbol): Symbol { const result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations.slice(0); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; diff --git a/tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt b/tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt new file mode 100644 index 00000000000..5c1d4ec5026 --- /dev/null +++ b/tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt @@ -0,0 +1,15 @@ +/b.ts(2,15): error TS2300: Duplicate identifier 'prototype'. + + +==== /a.d.ts (0 errors) ==== + declare class Foo {} + +==== /b.ts (1 errors) ==== + declare namespace Foo { + namespace prototype { + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + function f(): void; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/mergedClassWithNamespacePrototype.js b/tests/baselines/reference/mergedClassWithNamespacePrototype.js new file mode 100644 index 00000000000..fbacd3b8baa --- /dev/null +++ b/tests/baselines/reference/mergedClassWithNamespacePrototype.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/mergedClassWithNamespacePrototype.ts] //// + +//// [a.d.ts] +declare class Foo {} + +//// [b.ts] +declare namespace Foo { + namespace prototype { + function f(): void; + } +} + + +//// [b.js] diff --git a/tests/cases/compiler/mergedClassWithNamespacePrototype.ts b/tests/cases/compiler/mergedClassWithNamespacePrototype.ts new file mode 100644 index 00000000000..e4b086ffd27 --- /dev/null +++ b/tests/cases/compiler/mergedClassWithNamespacePrototype.ts @@ -0,0 +1,9 @@ +// @Filename: /a.d.ts +declare class Foo {} + +// @Filename: /b.ts +declare namespace Foo { + namespace prototype { + function f(): void; + } +} From 0747b33038878f011dbad9ff53cdcdc9285d5213 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 14:30:50 -0700 Subject: [PATCH 170/216] Fixes to emit / format for codeFix (#18484) --- src/compiler/emitter.ts | 6 +++++ src/harness/fourslash.ts | 2 +- src/services/formatting/rules.ts | 5 ++-- .../fourslash/convertFunctionToEs6Class3.ts | 4 +-- ...nvertFunctionToEs6Class_emptySwitchCase.ts | 25 +++++++++++++++++++ ...ToEs6Class_objectLiteralInArrowFunction.ts | 21 ++++++++++++++++ 6 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts create mode 100644 tests/cases/fourslash/convertFunctionToEs6Class_objectLiteralInArrowFunction.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 8788e0c02f4..2c6eef3672f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2417,6 +2417,12 @@ namespace ts { const isEmpty = isUndefined || start >= children.length || count === 0; if (isEmpty && format & ListFormat.OptionalIfEmpty) { + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } return; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index fb5e9e0354e..64e25e0eb9a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3500,7 +3500,7 @@ ${code} expected = makeWhitespaceVisible(expected); actual = makeWhitespaceVisible(actual); } - return `Expected:\n${expected}\nActual:${actual}`; + return `Expected:\n${expected}\nActual:\n${actual}`; } function differOnlyByWhitespace(a: string, b: string) { diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 07c2804ee83..d41d9dfbfd8 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -755,9 +755,8 @@ namespace ts.formatting { return true; case SyntaxKind.Block: { const blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== SyntaxKind.ArrowFunction && - blockParent.kind !== SyntaxKind.FunctionExpression - ) { + // In a codefix scenario, we can't rely on parents being set. So just always return true. + if (!blockParent || blockParent.kind !== SyntaxKind.ArrowFunction && blockParent.kind !== SyntaxKind.FunctionExpression) { return true; } } diff --git a/tests/cases/fourslash/convertFunctionToEs6Class3.ts b/tests/cases/fourslash/convertFunctionToEs6Class3.ts index bb48ffadec2..fec4dd8edfa 100644 --- a/tests/cases/fourslash/convertFunctionToEs6Class3.ts +++ b/tests/cases/fourslash/convertFunctionToEs6Class3.ts @@ -2,14 +2,14 @@ // @allowNonTsExtensions: true // @Filename: test123.js -//// [|var bar = 10, /*1*/foo = function() { }; +//// var bar = 10, /*1*/foo = function() { }; //// /*2*/foo.prototype.instanceMethod1 = function() { return "this is name"; }; //// /*3*/foo.prototype.instanceMethod2 = () => { return "this is name"; }; //// /*4*/foo.prototype.instanceProp1 = "hello"; //// /*5*/foo.prototype.instanceProp2 = undefined; //// /*6*/foo.staticProp = "world"; //// /*7*/foo.staticMethod1 = function() { return "this is static name"; }; -//// /*8*/foo.staticMethod2 = () => "this is static name";|] +//// /*8*/foo.staticMethod2 = () => "this is static name"; ['1', '2', '3', '4', '5', '6', '7', '8'].forEach(m => verify.applicableRefactorAvailableAtMarker(m)); diff --git a/tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts b/tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts new file mode 100644 index 00000000000..90bd48784ce --- /dev/null +++ b/tests/cases/fourslash/convertFunctionToEs6Class_emptySwitchCase.ts @@ -0,0 +1,25 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: /a.js +////function /**/MyClass() { +////} +////MyClass.prototype.f = function(x) { +//// switch (x) { +//// case 0: +//// } +////} + +verify.applicableRefactorAvailableAtMarker(""); +verify.fileAfterApplyingRefactorAtMarker("", +`class MyClass { + constructor() { + } + f(x) { + switch (x) { + case 0: + } + } +} +`, +'Convert to ES2015 class', 'convert'); diff --git a/tests/cases/fourslash/convertFunctionToEs6Class_objectLiteralInArrowFunction.ts b/tests/cases/fourslash/convertFunctionToEs6Class_objectLiteralInArrowFunction.ts new file mode 100644 index 00000000000..0bbbf4e0024 --- /dev/null +++ b/tests/cases/fourslash/convertFunctionToEs6Class_objectLiteralInArrowFunction.ts @@ -0,0 +1,21 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: /a.js +////function /**/MyClass() { +////} +////MyClass.prototype.foo = function() { +//// ({ bar: () => { } }) +////} + +verify.applicableRefactorAvailableAtMarker(""); +verify.fileAfterApplyingRefactorAtMarker("", +`class MyClass { + constructor() { + } + foo() { + ({ bar: () => { } }); + } +} +`, +'Convert to ES2015 class', 'convert'); From e1ede37ec7ff3b9be794432ada0b470cca82c647 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 14 Sep 2017 14:41:56 -0700 Subject: [PATCH 171/216] Add name to amd definition in umd module if present (#18479) --- src/compiler/transformers/module/module.ts | 3 +++ tests/baselines/reference/umdNamedAmdMode.js | 19 +++++++++++++++++++ .../reference/umdNamedAmdMode.symbols | 5 +++++ .../baselines/reference/umdNamedAmdMode.types | 6 ++++++ tests/cases/compiler/umdNamedAmdMode.ts | 4 ++++ 5 files changed, 37 insertions(+) create mode 100644 tests/baselines/reference/umdNamedAmdMode.js create mode 100644 tests/baselines/reference/umdNamedAmdMode.symbols create mode 100644 tests/baselines/reference/umdNamedAmdMode.types create mode 100644 tests/cases/compiler/umdNamedAmdMode.ts diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 493f5a43a1f..08c1fccfe16 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -200,6 +200,7 @@ namespace ts { */ function transformUMDModule(node: SourceFile) { const { aliasedModuleNames, unaliasedModuleNames, importAliasNames } = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false); + const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions); const umdHeader = createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -260,6 +261,8 @@ namespace ts { createIdentifier("define"), /*typeArguments*/ undefined, [ + // Add the module name (if provided). + ...(moduleName ? [moduleName] : []), createArrayLiteral([ createLiteral("require"), createLiteral("exports"), diff --git a/tests/baselines/reference/umdNamedAmdMode.js b/tests/baselines/reference/umdNamedAmdMode.js new file mode 100644 index 00000000000..eff0384b575 --- /dev/null +++ b/tests/baselines/reference/umdNamedAmdMode.js @@ -0,0 +1,19 @@ +//// [main.ts] +/// +export const a = 1; + +//// [main.js] +(function (factory) { + if (typeof module === "object" && typeof module.exports === "object") { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; + } + else if (typeof define === "function" && define.amd) { + define("a", ["require", "exports"], factory); + } +})(function (require, exports) { + "use strict"; + exports.__esModule = true; + /// + exports.a = 1; +}); diff --git a/tests/baselines/reference/umdNamedAmdMode.symbols b/tests/baselines/reference/umdNamedAmdMode.symbols new file mode 100644 index 00000000000..73ad766e50b --- /dev/null +++ b/tests/baselines/reference/umdNamedAmdMode.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/main.ts === +/// +export const a = 1; +>a : Symbol(a, Decl(main.ts, 1, 12)) + diff --git a/tests/baselines/reference/umdNamedAmdMode.types b/tests/baselines/reference/umdNamedAmdMode.types new file mode 100644 index 00000000000..f8f2d131fc2 --- /dev/null +++ b/tests/baselines/reference/umdNamedAmdMode.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/main.ts === +/// +export const a = 1; +>a : 1 +>1 : 1 + diff --git a/tests/cases/compiler/umdNamedAmdMode.ts b/tests/cases/compiler/umdNamedAmdMode.ts new file mode 100644 index 00000000000..d18e1427443 --- /dev/null +++ b/tests/cases/compiler/umdNamedAmdMode.ts @@ -0,0 +1,4 @@ +// @module: umd +// @filename: main.ts +/// +export const a = 1; \ No newline at end of file From c522f379b20b2be70873ca6b61dd8be7be1c76bf Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 14 Sep 2017 15:02:32 -0700 Subject: [PATCH 172/216] Update assertion: symbol in union type may be a Function (#18483) --- src/services/symbolDisplay.ts | 3 ++- .../cases/fourslash/quickInfoUnionOfNamespaces.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/quickInfoUnionOfNamespaces.ts diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 05c451cc3f3..ad8e7ddf975 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -61,7 +61,8 @@ namespace ts.SymbolDisplay { if (rootSymbolFlags & (SymbolFlags.PropertyOrAccessor | SymbolFlags.Variable)) { return ScriptElementKind.memberVariableElement; } - Debug.assert(!!(rootSymbolFlags & SymbolFlags.Method)); + // May be a Function if this was from `typeof N` with `namespace N { function f();. }`. + Debug.assert(!!(rootSymbolFlags & (SymbolFlags.Method | SymbolFlags.Function))); }); if (!unionPropertyKind) { // If this was union of all methods, diff --git a/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts b/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts new file mode 100644 index 00000000000..9b2431092e7 --- /dev/null +++ b/tests/cases/fourslash/quickInfoUnionOfNamespaces.ts @@ -0,0 +1,15 @@ +// See GH#18461 + +/// + +////declare const x: typeof A | typeof B; +////x./**/f; +//// +////namespace A { +//// export function f() {} +////} +////namespace B { +//// export function f() {} +////} + +verify.quickInfoAt("", "(method) f(): void"); From d1c4754b37fb49e3f3d9f73dcc8fc6810a1e081e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 14 Sep 2017 15:42:06 -0700 Subject: [PATCH 173/216] Better-scheduled parallel tests (#18462) * Out with the old... * Brave new world * Throttle console output * Batches test messages on large inputs initially * Move parallel runner code into seperate files --- Gulpfile.ts | 31 +-- Jakefile.js | 40 ++-- scripts/mocha-none-reporter.js | 26 --- scripts/mocha-parallel.js | 405 --------------------------------- src/harness/parallel/host.ts | 376 ++++++++++++++++++++++++++++++ src/harness/parallel/shared.ts | 14 ++ src/harness/parallel/worker.ts | 123 ++++++++++ src/harness/runner.ts | 224 +++++++++--------- src/harness/tsconfig.json | 3 + 9 files changed, 650 insertions(+), 592 deletions(-) delete mode 100644 scripts/mocha-none-reporter.js delete mode 100644 scripts/mocha-parallel.js create mode 100644 src/harness/parallel/host.ts create mode 100644 src/harness/parallel/shared.ts create mode 100644 src/harness/parallel/worker.ts diff --git a/Gulpfile.ts b/Gulpfile.ts index a3db20dfd8a..676d07ec570 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -31,8 +31,6 @@ import merge2 = require("merge2"); import * as os from "os"; import fold = require("travis-fold"); const gulp = helpMaker(originalGulp); -const mochaParallel = require("./scripts/mocha-parallel.js"); -const {runTestsInParallel} = mochaParallel; Error.stackTraceLimit = 1000; @@ -668,26 +666,9 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: } else { // run task to load all tests and partition them between workers - const args = []; - args.push("-R", "min"); - if (colors) { - args.push("--colors"); - } - else { - args.push("--no-colors"); - } - args.push(run); setNodeEnvToDevelopment(); - runTestsInParallel(taskConfigsFolder, run, { testTimeout, noColors: colors === " --no-colors " }, function(err) { - // last worker clean everything and runs linter in case if there were no errors - del(taskConfigsFolder).then(() => { - if (!err) { - lintThenFinish(); - } - else { - finish(err); - } - }); + exec(host, [run], lintThenFinish, function(e, status) { + finish(e, status); }); } }); @@ -711,7 +692,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: function finish(error?: any, errorStatus?: number) { restoreSavedNodeEnv(); - deleteTemporaryProjectOutput().then(() => { + deleteTestConfig().then(deleteTemporaryProjectOutput).then(() => { if (error !== undefined || errorStatus !== undefined) { failWithStatus(error, errorStatus); } @@ -720,6 +701,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: } }); } + + function deleteTestConfig() { + return del("test.config"); + } } gulp.task("runtests-parallel", "Runs all the tests in parallel using the built run.js file. Optional arguments are: --t[ests]=category1|category2|... --d[ebug]=true.", ["build-rules", "tests"], (done) => { @@ -836,7 +821,7 @@ function cleanTestDirs(done: (e?: any) => void) { // used to pass data from jake command line directly to run.js function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) { - const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder }); + const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder, noColor: !cmdLineOptions["colors"] }); console.log("Running tests with config: " + testConfigContents); fs.writeFileSync("test.config", testConfigContents); } diff --git a/Jakefile.js b/Jakefile.js index ad853238111..39e9e8a0421 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1,11 +1,11 @@ // This file contains the build logic for the public repo +// @ts-check var fs = require("fs"); var os = require("os"); var path = require("path"); var child_process = require("child_process"); var fold = require("travis-fold"); -var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel; var ts = require("./lib/typescript"); @@ -38,7 +38,7 @@ else if (process.env.PATH !== undefined) { function filesFromConfig(configPath) { var configText = fs.readFileSync(configPath).toString(); - var config = ts.parseConfigFileTextToJson(configPath, configText, /*stripComments*/ true); + var config = ts.parseConfigFileTextToJson(configPath, configText); if (config.error) { throw new Error(diagnosticsToString([config.error])); } @@ -104,6 +104,9 @@ var harnessCoreSources = [ "loggedIO.ts", "rwcRunner.ts", "test262Runner.ts", + "./parallel/shared.ts", + "./parallel/host.ts", + "./parallel/worker.ts", "runner.ts" ].map(function (f) { return path.join(harnessDirectory, f); @@ -596,7 +599,7 @@ file(typesMapOutputPath, function() { var content = fs.readFileSync(path.join(serverDirectory, 'typesMap.json')); // Validate that it's valid JSON try { - JSON.parse(content); + JSON.parse(content.toString()); } catch (e) { console.log("Parse error in typesMap.json: " + e); } @@ -740,7 +743,7 @@ desc("Builds the test infrastructure using the built compiler"); task("tests", ["local", run].concat(libraryTargets)); function exec(cmd, completeHandler, errorHandler) { - var ex = jake.createExec([cmd], { windowsVerbatimArguments: true }); + var ex = jake.createExec([cmd], { windowsVerbatimArguments: true, interactive: true }); // Add listeners for output and error ex.addListener("stdout", function (output) { process.stdout.write(output); @@ -783,13 +786,14 @@ function cleanTestDirs() { } // used to pass data from jake command line directly to run.js -function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit) { +function writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors) { var testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light: light, workerCount: workerCount, taskConfigsFolder: taskConfigsFolder, - stackTraceLimit: stackTraceLimit + stackTraceLimit: stackTraceLimit, + noColor: !colors }); fs.writeFileSync('test.config', testConfigContents); } @@ -831,7 +835,7 @@ function runConsoleTests(defaultReporter, runInParallel) { } if (tests || light || taskConfigsFolder) { - writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit); + writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit, colors); } if (tests && tests.toLocaleLowerCase() === "rwc") { @@ -894,19 +898,15 @@ function runConsoleTests(defaultReporter, runInParallel) { var savedNodeEnv = process.env.NODE_ENV; process.env.NODE_ENV = "development"; var startTime = mark(); - runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: !colors }, function (err) { + exec(host + " " + run, function () { process.env.NODE_ENV = savedNodeEnv; measure(startTime); - // last worker clean everything and runs linter in case if there were no errors - deleteTemporaryProjectOutput(); - jake.rmRf(taskConfigsFolder); - if (err) { - fail(err); - } - else { - runLinter(); - complete(); - } + runLinter(); + finish(); + }, function (e, status) { + process.env.NODE_ENV = savedNodeEnv; + measure(startTime); + finish(status); }); } @@ -969,8 +969,8 @@ desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is task("runtests-browser", ["browserify", nodeServerOutFile], function () { cleanTestDirs(); host = "node"; - browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE"); - tests = process.env.test || process.env.tests || process.env.t; + var browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE"); + var tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; var testConfigFile = 'test.config'; if (fs.existsSync(testConfigFile)) { diff --git a/scripts/mocha-none-reporter.js b/scripts/mocha-none-reporter.js deleted file mode 100644 index 5787b0c042e..00000000000 --- a/scripts/mocha-none-reporter.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Module dependencies. - */ - -var Base = require('mocha').reporters.Base; - -/** - * Expose `None`. - */ - -exports = module.exports = None; - -/** - * Initialize a new `None` test reporter. - * - * @api public - * @param {Runner} runner - */ -function None(runner) { - Base.call(this); -} - -/** - * Inherit from `Base.prototype`. - */ -None.prototype.__proto__ = Base.prototype; diff --git a/scripts/mocha-parallel.js b/scripts/mocha-parallel.js deleted file mode 100644 index 6a54c018e9a..00000000000 --- a/scripts/mocha-parallel.js +++ /dev/null @@ -1,405 +0,0 @@ -var tty = require("tty") - , readline = require("readline") - , fs = require("fs") - , path = require("path") - , child_process = require("child_process") - , os = require("os") - , mocha = require("mocha") - , Base = mocha.reporters.Base - , color = Base.color - , cursor = Base.cursor - , ms = require("mocha/lib/ms"); - -var isatty = tty.isatty(1) && tty.isatty(2); -var tapRangePattern = /^(\d+)\.\.(\d+)(?:$|\r\n?|\n)/; -var tapTestPattern = /^(not\sok|ok)\s+(\d+)\s+(?:-\s+)?(.*)$/; -var tapCommentPattern = /^#(?: (tests|pass|fail) (\d+)$)?/; - -exports.runTestsInParallel = runTestsInParallel; -exports.ProgressBars = ProgressBars; - -function runTestsInParallel(taskConfigsFolder, run, options, cb) { - if (options === undefined) options = { }; - - return discoverTests(run, options, function (error) { - if (error) { - return cb(error); - } - - return runTests(taskConfigsFolder, run, options, cb); - }); -} - -function discoverTests(run, options, cb) { - console.log("Discovering tests..."); - - var cmd = "mocha -R " + require.resolve("./mocha-none-reporter.js") + " " + run; - var p = spawnProcess(cmd); - p.on("exit", function (status) { - if (status) { - cb(new Error("Process exited with code " + status)); - } - else { - cb(); - } - }); -} - -function runTests(taskConfigsFolder, run, options, cb) { - var configFiles = fs.readdirSync(taskConfigsFolder); - var numPartitions = configFiles.length; - if (numPartitions <= 0) { - cb(); - return; - } - - console.log("Running tests on " + numPartitions + " threads..."); - - var partitions = Array(numPartitions); - var progressBars = new ProgressBars(); - progressBars.enable(); - - var counter = numPartitions; - configFiles.forEach(runTestsInPartition); - - function runTestsInPartition(file, index) { - var partition = { - file: path.join(taskConfigsFolder, file), - tests: 0, - passed: 0, - failed: 0, - completed: 0, - current: undefined, - start: undefined, - end: undefined, - catastrophicError: "", - failures: [] - }; - partitions[index] = partition; - - // Set up the progress bar. - updateProgress(0); - - // Start the background process. - var cmd = "mocha -t " + (options.testTimeout || 20000) + " -R tap --no-colors " + run + " --config='" + partition.file + "'"; - var p = spawnProcess(cmd); - var rl = readline.createInterface({ - input: p.stdout, - terminal: false - }); - - var rlError = readline.createInterface({ - input: p.stderr, - terminal: false - }); - - rl.on("line", onmessage); - rlError.on("line", onErrorMessage); - p.on("exit", onexit) - - function onErrorMessage(line) { - partition.catastrophicError += line + os.EOL; - } - - function onmessage(line) { - if (partition.start === undefined) { - partition.start = Date.now(); - } - - var rangeMatch = tapRangePattern.exec(line); - if (rangeMatch) { - partition.tests = parseInt(rangeMatch[2]); - return; - } - - var testMatch = tapTestPattern.exec(line); - if (testMatch) { - var test = { - result: testMatch[1], - id: parseInt(testMatch[2]), - name: testMatch[3], - output: [] - }; - - partition.current = test; - partition.completed++; - - if (test.result === "ok") { - partition.passed++; - } - else { - partition.failed++; - partition.failures.push(test); - } - - var progress = partition.completed / partition.tests; - if (progress < 1) { - updateProgress(progress); - } - - return; - } - - var commentMatch = tapCommentPattern.exec(line); - if (commentMatch) { - switch (commentMatch[1]) { - case "tests": - partition.current = undefined; - partition.tests = parseInt(commentMatch[2]); - break; - - case "pass": - partition.passed = parseInt(commentMatch[2]); - break; - - case "fail": - partition.failed = parseInt(commentMatch[2]); - break; - } - - return; - } - - if (partition.current) { - partition.current.output.push(line); - } - } - - function onexit(code) { - if (partition.end === undefined) { - partition.end = Date.now(); - } - - partition.duration = partition.end - partition.start; - var isPartitionFail = partition.failed || code !== 0; - var summaryColor = isPartitionFail ? "fail" : "green"; - var summarySymbol = isPartitionFail ? Base.symbols.err : Base.symbols.ok; - - var summaryTests = (isPartitionFail ? partition.passed + "/" + partition.tests : partition.passed) + " passing"; - var summaryDuration = "(" + ms(partition.duration) + ")"; - var savedUseColors = Base.useColors; - Base.useColors = !options.noColors; - - var summary = color(summaryColor, summarySymbol + " " + summaryTests) + " " + color("light", summaryDuration); - Base.useColors = savedUseColors; - - updateProgress(1, summary); - - signal(); - } - - function updateProgress(percentComplete, title) { - var progressColor = "pending"; - if (partition.failed) { - progressColor = "fail"; - } - - progressBars.update( - index, - percentComplete, - progressColor, - title - ); - } - } - - function signal() { - counter--; - - if (counter <= 0) { - var reporter = new Base(), - stats = reporter.stats, - failures = reporter.failures; - - var duration = 0; - var catastrophicError = ""; - for (var i = 0; i < numPartitions; i++) { - var partition = partitions[i]; - stats.passes += partition.passed; - stats.failures += partition.failed; - stats.tests += partition.tests; - duration += partition.duration; - if (partition.catastrophicError !== "") { - // Partition is written out to a temporary file as a JSON object. - // Below is an example of how the partition JSON object looks like - // { - // "light":false, - // "tasks":[ - // { - // "runner":"compiler", - // "files":["tests/cases/compiler/es6ImportNamedImportParsingError.ts"] - // } - // ], - // "runUnitTests":false - // } - var jsonText = fs.readFileSync(partition.file); - var configObj = JSON.parse(jsonText); - if (configObj.tasks && configObj.tasks[0]) { - catastrophicError += "Error from one or more of these files: " + configObj.tasks[0].files + os.EOL; - catastrophicError += partition.catastrophicError; - catastrophicError += os.EOL; - } - } - for (var j = 0; j < partition.failures.length; j++) { - var failure = partition.failures[j]; - failures.push(makeMochaTest(failure)); - } - } - - stats.duration = duration; - progressBars.disable(); - - if (options.noColors) { - var savedUseColors = Base.useColors; - Base.useColors = false; - reporter.epilogue(); - Base.useColors = savedUseColors; - } - else { - reporter.epilogue(); - } - - if (catastrophicError !== "") { - return cb(new Error(catastrophicError)); - } - if (stats.failures) { - return cb(new Error("Test failures reported: " + stats.failures)); - } - else { - return cb(); - } - } - } - - function makeMochaTest(test) { - return { - fullTitle: function() { - return test.name; - }, - err: { - message: test.output[0], - stack: test.output.join(os.EOL) - } - }; - } -} - -var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter; -if (process.env.path !== undefined) { - process.env.path = nodeModulesPathPrefix + process.env.path; -} else if (process.env.PATH !== undefined) { - process.env.PATH = nodeModulesPathPrefix + process.env.PATH; -} - -function spawnProcess(cmd, options) { - var shell = process.platform === "win32" ? "cmd" : "/bin/sh"; - var prefix = process.platform === "win32" ? "/c" : "-c"; - return child_process.spawn(shell, [prefix, cmd], { windowsVerbatimArguments: true }); -} - -function ProgressBars(options) { - if (!options) options = {}; - var open = options.open || '['; - var close = options.close || ']'; - var complete = options.complete || '▬'; - var incomplete = options.incomplete || Base.symbols.dot; - var maxWidth = Math.floor(Base.window.width * .30) - open.length - close.length - 2; - var width = minMax(options.width || maxWidth, 10, maxWidth); - this._options = { - open: open, - complete: complete, - incomplete: incomplete, - close: close, - width: width - }; - - this._progressBars = []; - this._lineCount = 0; - this._enabled = false; -} -ProgressBars.prototype = { - enable: function () { - if (!this._enabled) { - process.stdout.write(os.EOL); - this._enabled = true; - } - }, - disable: function () { - if (this._enabled) { - process.stdout.write(os.EOL); - this._enabled = false; - } - }, - update: function (index, percentComplete, color, title) { - percentComplete = minMax(percentComplete, 0, 1); - - var progressBar = this._progressBars[index] || (this._progressBars[index] = { }); - var width = this._options.width; - var n = Math.floor(width * percentComplete); - var i = width - n; - if (n === progressBar.lastN && title === progressBar.title && color === progressBar.progressColor) { - return; - } - - progressBar.lastN = n; - progressBar.title = title; - progressBar.progressColor = color; - - var progress = " "; - progress += this._color('progress', this._options.open); - progress += this._color(color, fill(this._options.complete, n)); - progress += this._color('progress', fill(this._options.incomplete, i)); - progress += this._color('progress', this._options.close); - - if (title) { - progress += this._color('progress', ' ' + title); - } - - if (progressBar.text !== progress) { - progressBar.text = progress; - this._render(index); - } - }, - _render: function (index) { - if (!this._enabled || !isatty) { - return; - } - - cursor.hide(); - readline.moveCursor(process.stdout, -process.stdout.columns, -this._lineCount); - var lineCount = 0; - var numProgressBars = this._progressBars.length; - for (var i = 0; i < numProgressBars; i++) { - if (i === index) { - readline.clearLine(process.stdout, 1); - process.stdout.write(this._progressBars[i].text + os.EOL); - } - else { - readline.moveCursor(process.stdout, -process.stdout.columns, +1); - } - - lineCount++; - } - - this._lineCount = lineCount; - cursor.show(); - }, - _color: function (type, text) { - return type && !this._options.noColors ? color(type, text) : text; - } -}; - -function fill(ch, size) { - var s = ""; - while (s.length < size) { - s += ch; - } - - return s.length > size ? s.substr(0, size) : s; -} - -function minMax(value, min, max) { - if (value < min) return min; - if (value > max) return max; - return value; -} \ No newline at end of file diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts new file mode 100644 index 00000000000..58e794bbc7d --- /dev/null +++ b/src/harness/parallel/host.ts @@ -0,0 +1,376 @@ +// tslint:disable-next-line +var describe: Mocha.IContextDefinition; // If launched without mocha for parallel mode, we still need a global describe visible to satisfy the parsing of the unit tests +// tslint:disable-next-line +var it: Mocha.ITestDefinition; +namespace Harness.Parallel.Host { + + interface ChildProcessPartial { + send(message: any, callback?: (error: Error) => void): boolean; + on(event: "error", listener: (err: Error) => void): this; + on(event: "exit", listener: (code: number, signal: string) => void): this; + on(event: "message", listener: (message: any) => void): this; + disconnect(): void; + } + + interface ProgressBarsOptions { + open: string; + close: string; + complete: string; + incomplete: string; + width: number; + noColors: boolean; + } + interface ProgressBar { + lastN?: number; + title?: string; + progressColor?: string; + text?: string; + } + + export function start() { + console.log("Discovering tests..."); + const discoverStart = +(new Date()); + const { statSync }: { statSync(path: string): { size: number }; } = require("fs"); + const tasks: { runner: TestRunnerKind, file: string, size: number }[] = []; + let totalSize = 0; + for (const runner of runners) { + const files = runner.enumerateTestFiles(); + for (const file of files) { + const size = statSync(file).size; + tasks.push({ runner: runner.kind(), file, size }); + totalSize += size; + } + } + tasks.sort((a, b) => a.size - b.size); + const batchSize = (totalSize / workerCount) * 0.9; + console.log(`Discovered ${tasks.length} test files in ${+(new Date()) - discoverStart}ms.`); + console.log(`Starting to run tests using ${workerCount} threads...`); + const { fork }: { fork(modulePath: string, args?: string[], options?: {}): ChildProcessPartial; } = require("child_process"); + + const totalFiles = tasks.length; + let passingFiles = 0; + let failingFiles = 0; + let errorResults: ErrorInfo[] = []; + let totalPassing = 0; + const startTime = Date.now(); + + const progressBars = new ProgressBars({ noColors }); + const progressUpdateInterval = 1 / progressBars._options.width; + let nextProgress = progressUpdateInterval; + + const workers: ChildProcessPartial[] = []; + for (let i = 0; i < workerCount; i++) { + // TODO: Just send the config over the IPC channel or in the command line arguments + const config: TestConfig = { light: Harness.lightMode, listenForWork: true, runUnitTests: runners.length === 1 ? false : i === workerCount - 1 }; + const configPath = ts.combinePaths(taskConfigsFolder, `task-config${i}.json`); + Harness.IO.writeFile(configPath, JSON.stringify(config)); + const child = fork(__filename, [`--config="${configPath}"`]); + child.on("error", err => { + child.disconnect(); + console.error("Unexpected error in child process:"); + console.error(err); + return process.exit(2); + }); + child.on("exit", (code, _signal) => { + if (code !== 0) { + console.error("Test worker process exited with nonzero exit code!"); + return process.exit(2); + } + }); + child.on("message", (data: ParallelClientMessage) => { + switch (data.type) { + case "error": { + child.disconnect(); + console.error(`Test worker encounted unexpected error and was forced to close: + Message: ${data.payload.error} + Stack: ${data.payload.stack}`); + return process.exit(2); + } + case "progress": + case "result": { + totalPassing += data.payload.passing; + if (data.payload.errors.length) { + errorResults = errorResults.concat(data.payload.errors); + failingFiles++; + } + else { + passingFiles++; + } + + const progress = (failingFiles + passingFiles) / totalFiles; + if (progress >= nextProgress) { + while (nextProgress < progress) { + nextProgress += progressUpdateInterval; + } + updateProgress(progress, errorResults.length ? `${errorResults.length} failing` : `${totalPassing} passing`, errorResults.length ? "fail" : undefined); + } + + if (failingFiles + passingFiles === totalFiles) { + // Done. Finished every task and collected results. + child.send({ type: "close" }); + child.disconnect(); + return outputFinalResult(); + } + if (tasks.length === 0) { + // No more tasks to distribute + child.send({ type: "close" }); + child.disconnect(); + return; + } + if (data.type === "result") { + child.send({ type: "test", payload: tasks.pop() }); + } + } + } + }); + workers.push(child); + } + + // It's only really worth doing an initial batching if there are a ton of files to go through + if (totalFiles > 1000) { + console.log("Batching initial test lists..."); + const batches: { runner: TestRunnerKind, file: string, size: number }[][] = new Array(workerCount); + const doneBatching = new Array(workerCount); + batcher: while (true) { + for (let i = 0; i < workerCount; i++) { + if (tasks.length === 0) { + // TODO: This indicates a particularly suboptimal packing + break batcher; + } + if (doneBatching[i]) { + continue; + } + if (!batches[i]) { + batches[i] = []; + } + const total = batches[i].reduce((p, c) => p + c.size, 0); + if (total >= batchSize && !doneBatching[i]) { + doneBatching[i] = true; + continue; + } + batches[i].push(tasks.pop()); + } + for (let j = 0; j < workerCount; j++) { + if (!doneBatching[j]) { + continue; + } + } + break; + } + console.log(`Batched into ${workerCount} groups with approximate total file sizes of ${Math.floor(batchSize)} bytes in each group.`); + for (const worker of workers) { + const action: ParallelBatchMessage = { type: "batch", payload: batches.pop() }; + if (!action.payload[0]) { + throw new Error(`Tried to send invalid message ${action}`); + } + worker.send(action); + } + } + else { + for (let i = 0; i < workerCount; i++) { + workers[i].send({ type: "test", payload: tasks.pop() }); + } + } + + progressBars.enable(); + updateProgress(0); + let duration: number; + + const ms = require("mocha/lib/ms"); + function completeBar() { + const isPartitionFail = failingFiles !== 0; + const summaryColor = isPartitionFail ? "fail" : "green"; + const summarySymbol = isPartitionFail ? Base.symbols.err : Base.symbols.ok; + + const summaryTests = (isPartitionFail ? totalPassing + "/" + (errorResults.length + totalPassing) : totalPassing) + " passing"; + const summaryDuration = "(" + ms(duration) + ")"; + const savedUseColors = Base.useColors; + Base.useColors = !noColors; + + const summary = color(summaryColor, summarySymbol + " " + summaryTests) + " " + color("light", summaryDuration); + Base.useColors = savedUseColors; + + updateProgress(1, summary); + } + + function updateProgress(percentComplete: number, title?: string, titleColor?: string) { + let progressColor = "pending"; + if (failingFiles) { + progressColor = "fail"; + } + + progressBars.update( + 0, + percentComplete, + progressColor, + title, + titleColor + ); + } + + function outputFinalResult() { + duration = Date.now() - startTime; + completeBar(); + progressBars.disable(); + + const reporter = new Base(); + const stats = reporter.stats; + const failures = reporter.failures; + stats.passes = totalPassing; + stats.failures = errorResults.length; + stats.tests = totalPassing + errorResults.length; + stats.duration = duration; + for (let j = 0; j < errorResults.length; j++) { + const failure = errorResults[j]; + failures.push(makeMochaTest(failure)); + } + if (noColors) { + const savedUseColors = Base.useColors; + Base.useColors = false; + reporter.epilogue(); + Base.useColors = savedUseColors; + } + else { + reporter.epilogue(); + } + + process.exit(errorResults.length); + } + + function makeMochaTest(test: ErrorInfo) { + return { + fullTitle: () => { + return test.name; + }, + err: { + message: test.error, + stack: test.stack + } + }; + } + + describe = ts.noop as any; // Disable unit tests + + return; + } + + const Mocha = require("mocha"); + const Base = Mocha.reporters.Base; + const color = Base.color; + const cursor = Base.cursor; + const readline = require("readline"); + const os = require("os"); + const tty: { isatty(x: number): boolean } = require("tty"); + const isatty = tty.isatty(1) && tty.isatty(2); + class ProgressBars { + public readonly _options: Readonly; + private _enabled: boolean; + private _lineCount: number; + private _progressBars: ProgressBar[]; + constructor(options?: Partial) { + if (!options) options = {}; + const open = options.open || "["; + const close = options.close || "]"; + const complete = options.complete || "▬"; + const incomplete = options.incomplete || Base.symbols.dot; + const maxWidth = Base.window.width - open.length - close.length - 30; + const width = minMax(options.width || maxWidth, 10, maxWidth); + this._options = { + open, + complete, + incomplete, + close, + width, + noColors: options.noColors || false + }; + + this._progressBars = []; + this._lineCount = 0; + this._enabled = false; + } + enable() { + if (!this._enabled) { + process.stdout.write(os.EOL); + this._enabled = true; + } + } + disable() { + if (this._enabled) { + process.stdout.write(os.EOL); + this._enabled = false; + } + } + update(index: number, percentComplete: number, color: string, title: string, titleColor?: string) { + percentComplete = minMax(percentComplete, 0, 1); + + const progressBar = this._progressBars[index] || (this._progressBars[index] = { }); + const width = this._options.width; + const n = Math.floor(width * percentComplete); + const i = width - n; + if (n === progressBar.lastN && title === progressBar.title && color === progressBar.progressColor) { + return; + } + + progressBar.lastN = n; + progressBar.title = title; + progressBar.progressColor = color; + + let progress = " "; + progress += this._color("progress", this._options.open); + progress += this._color(color, fill(this._options.complete, n)); + progress += this._color("progress", fill(this._options.incomplete, i)); + progress += this._color("progress", this._options.close); + + if (title) { + progress += this._color(titleColor || "progress", " " + title); + } + + if (progressBar.text !== progress) { + progressBar.text = progress; + this._render(index); + } + } + private _render(index: number) { + if (!this._enabled || !isatty) { + return; + } + + cursor.hide(); + readline.moveCursor(process.stdout, -process.stdout.columns, -this._lineCount); + let lineCount = 0; + const numProgressBars = this._progressBars.length; + for (let i = 0; i < numProgressBars; i++) { + if (i === index) { + readline.clearLine(process.stdout, 1); + process.stdout.write(this._progressBars[i].text + os.EOL); + } + else { + readline.moveCursor(process.stdout, -process.stdout.columns, +1); + } + + lineCount++; + } + + this._lineCount = lineCount; + cursor.show(); + } + private _color(type: string, text: string) { + return type && !this._options.noColors ? color(type, text) : text; + } + } + + function fill(ch: string, size: number) { + let s = ""; + while (s.length < size) { + s += ch; + } + + return s.length > size ? s.substr(0, size) : s; + } + + function minMax(value: number, min: number, max: number) { + if (value < min) return min; + if (value > max) return max; + return value; + } +} \ No newline at end of file diff --git a/src/harness/parallel/shared.ts b/src/harness/parallel/shared.ts new file mode 100644 index 00000000000..ebfe3278849 --- /dev/null +++ b/src/harness/parallel/shared.ts @@ -0,0 +1,14 @@ +/// +/// +namespace Harness.Parallel { + export type ParallelTestMessage = { type: "test", payload: { runner: TestRunnerKind, file: string } } | never; + export type ParallelBatchMessage = { type: "batch", payload: ParallelTestMessage["payload"][] } | never; + export type ParallelCloseMessage = { type: "close" } | never; + export type ParallelHostMessage = ParallelTestMessage | ParallelCloseMessage | ParallelBatchMessage; + + export type ParallelErrorMessage = { type: "error", payload: { error: string, stack: string } } | never; + export type ErrorInfo = ParallelErrorMessage["payload"] & { name: string }; + export type ParallelResultMessage = { type: "result", payload: { passing: number, errors: ErrorInfo[] } } | never; + export type ParallelBatchProgressMessage = { type: "progress", payload: ParallelResultMessage["payload"] } | never; + export type ParallelClientMessage = ParallelErrorMessage | ParallelResultMessage | ParallelBatchProgressMessage; +} \ No newline at end of file diff --git a/src/harness/parallel/worker.ts b/src/harness/parallel/worker.ts new file mode 100644 index 00000000000..34f89d37f13 --- /dev/null +++ b/src/harness/parallel/worker.ts @@ -0,0 +1,123 @@ +namespace Harness.Parallel.Worker { + let errors: ErrorInfo[] = []; + let passing = 0; + function resetShimHarnessAndExecute(runner: RunnerBase) { + errors = []; + passing = 0; + runner.initializeTests(); + return { errors, passing }; + } + + function shimMochaHarness() { + (global as any).before = undefined; + (global as any).after = undefined; + (global as any).beforeEach = undefined; + let beforeEachFunc: Function; + describe = ((_name, callback) => { + const fakeContext: Mocha.ISuiteCallbackContext = { + retries() { return this; }, + slow() { return this; }, + timeout() { return this; }, + }; + (before as any) = (cb: Function) => cb(); + let afterFunc: Function; + (after as any) = (cb: Function) => afterFunc = cb; + const savedBeforeEach = beforeEachFunc; + (beforeEach as any) = (cb: Function) => beforeEachFunc = cb; + callback.call(fakeContext); + afterFunc && afterFunc(); + afterFunc = undefined; + beforeEachFunc = savedBeforeEach; + }) as Mocha.IContextDefinition; + it = ((name, callback) => { + const fakeContext: Mocha.ITestCallbackContext = { + skip() { return this; }, + timeout() { return this; }, + retries() { return this; }, + slow() { return this; }, + }; + // TODO: If we ever start using async test completions, polyfill the `done` parameter/promise return handling + if (beforeEachFunc) { + try { + beforeEachFunc(); + } + catch (error) { + errors.push({ error: error.message, stack: error.stack, name }); + return; + } + } + try { + callback.call(fakeContext); + } + catch (error) { + errors.push({ error: error.message, stack: error.stack, name }); + return; + } + passing++; + }) as Mocha.ITestDefinition; + } + + export function start() { + let initialized = false; + const runners = ts.createMap(); + process.on("message", (data: ParallelHostMessage) => { + if (!initialized) { + initialized = true; + shimMochaHarness(); + } + switch (data.type) { + case "test": + const { runner, file } = data.payload; + if (!runner) { + console.error(data); + } + const message: ParallelResultMessage = { type: "result", payload: handleTest(runner, file) }; + process.send(message); + break; + case "close": + process.exit(0); + break; + case "batch": { + const items = data.payload; + for (let i = 0; i < items.length; i++) { + const { runner, file } = items[i]; + if (!runner) { + console.error(data); + } + let message: ParallelBatchProgressMessage | ParallelResultMessage; + const payload = handleTest(runner, file); + if (i === (items.length - 1)) { + message = { type: "result", payload }; + } + else { + message = { type: "progress", payload }; + } + process.send(message); + } + break; + } + } + }); + process.on("uncaughtException", error => { + const message: ParallelErrorMessage = { type: "error", payload: { error: error.message, stack: error.stack } }; + process.send(message); + }); + if (!runUnitTests) { + // ensure unit tests do not get run + describe = ts.noop as any; + } + else { + initialized = true; + shimMochaHarness(); + } + + function handleTest(runner: TestRunnerKind, file: string) { + if (!runners.has(runner)) { + runners.set(runner, createRunner(runner)); + } + const instance = runners.get(runner); + instance.tests = [file]; + return resetShimHarnessAndExecute(instance); + } + } +} \ No newline at end of file diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 6e1f91b21af..0b361e7fc9e 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -19,6 +19,7 @@ /// /// /// +/// let runners: RunnerBase[] = []; let iterations = 1; @@ -59,6 +60,7 @@ function createRunner(kind: TestRunnerKind): RunnerBase { case "test262": return new Test262BaselineRunner(); } + ts.Debug.fail(`Unknown runner kind ${kind}`); } if (Harness.IO.tryEnableSourceMapsForHost && /^development$/i.test(Harness.IO.getEnvironmentVariable("NODE_ENV"))) { @@ -81,15 +83,17 @@ let testConfigContent = let taskConfigsFolder: string; let workerCount: number; let runUnitTests = true; +let noColors = false; interface TestConfig { light?: boolean; taskConfigsFolder?: string; + listenForWork?: boolean; workerCount?: number; stackTraceLimit?: number | "full"; - tasks?: TaskSet[]; test?: string[]; runUnitTests?: boolean; + noColors?: boolean; } interface TaskSet { @@ -97,138 +101,122 @@ interface TaskSet { files: string[]; } -if (testConfigContent !== "") { - const testConfig = JSON.parse(testConfigContent); - if (testConfig.light) { - Harness.lightMode = true; - } - if (testConfig.taskConfigsFolder) { - taskConfigsFolder = testConfig.taskConfigsFolder; - } - if (testConfig.runUnitTests !== undefined) { - runUnitTests = testConfig.runUnitTests; - } - if (testConfig.workerCount) { - workerCount = testConfig.workerCount; - } - if (testConfig.tasks) { - for (const taskSet of testConfig.tasks) { - const runner = createRunner(taskSet.runner); - for (const file of taskSet.files) { - runner.addTest(file); - } - runners.push(runner); +function handleTestConfig() { + if (testConfigContent !== "") { + const testConfig = JSON.parse(testConfigContent); + if (testConfig.light) { + Harness.lightMode = true; } - } - - if (testConfig.stackTraceLimit === "full") { - (Error).stackTraceLimit = Infinity; - } - else if ((+testConfig.stackTraceLimit | 0) > 0) { - (Error).stackTraceLimit = testConfig.stackTraceLimit; - } - - if (testConfig.test && testConfig.test.length > 0) { - for (const option of testConfig.test) { - if (!option) { - continue; - } - - switch (option) { - case "compiler": - runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); - runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); - runners.push(new ProjectRunner()); - break; - case "conformance": - runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); - break; - case "project": - runners.push(new ProjectRunner()); - break; - case "fourslash": - runners.push(new FourSlashRunner(FourSlashTestType.Native)); - break; - case "fourslash-shims": - runners.push(new FourSlashRunner(FourSlashTestType.Shims)); - break; - case "fourslash-shims-pp": - runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); - break; - case "fourslash-server": - runners.push(new FourSlashRunner(FourSlashTestType.Server)); - break; - case "fourslash-generated": - runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native)); - break; - case "rwc": - runners.push(new RWCRunner()); - break; - case "test262": - runners.push(new Test262BaselineRunner()); - break; - } + if (testConfig.runUnitTests !== undefined) { + runUnitTests = testConfig.runUnitTests; + } + if (testConfig.workerCount) { + workerCount = +testConfig.workerCount; + } + if (testConfig.taskConfigsFolder) { + taskConfigsFolder = testConfig.taskConfigsFolder; + } + if (testConfig.noColors !== undefined) { + noColors = testConfig.noColors; } - } -} -if (runners.length === 0) { - // compiler - runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); - runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); + if (testConfig.stackTraceLimit === "full") { + (Error).stackTraceLimit = Infinity; + } + else if ((+testConfig.stackTraceLimit | 0) > 0) { + (Error).stackTraceLimit = testConfig.stackTraceLimit; + } + if (testConfig.listenForWork) { + return true; + } - // TODO: project tests don't work in the browser yet - if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) { - runners.push(new ProjectRunner()); - } + if (testConfig.test && testConfig.test.length > 0) { + for (const option of testConfig.test) { + if (!option) { + continue; + } - // language services - runners.push(new FourSlashRunner(FourSlashTestType.Native)); - runners.push(new FourSlashRunner(FourSlashTestType.Shims)); - runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); - runners.push(new FourSlashRunner(FourSlashTestType.Server)); - // runners.push(new GeneratedFourslashRunner()); -} - -if (taskConfigsFolder) { - // this instance of mocha should only partition work but not run actual tests - runUnitTests = false; - const workerConfigs: TestConfig[] = []; - for (let i = 0; i < workerCount; i++) { - // pass light mode settings to workers - workerConfigs.push({ light: Harness.lightMode, tasks: [] }); - } - - for (const runner of runners) { - const files = runner.enumerateTestFiles(); - const chunkSize = Math.floor(files.length / workerCount) + 1; // add extra 1 to prevent missing tests due to rounding - for (let i = 0; i < workerCount; i++) { - const startPos = i * chunkSize; - const len = Math.min(chunkSize, files.length - startPos); - if (len > 0) { - workerConfigs[i].tasks.push({ - runner: runner.kind(), - files: files.slice(startPos, startPos + len) - }); + switch (option) { + case "compiler": + runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); + runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); + runners.push(new ProjectRunner()); + break; + case "conformance": + runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); + break; + case "project": + runners.push(new ProjectRunner()); + break; + case "fourslash": + runners.push(new FourSlashRunner(FourSlashTestType.Native)); + break; + case "fourslash-shims": + runners.push(new FourSlashRunner(FourSlashTestType.Shims)); + break; + case "fourslash-shims-pp": + runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); + break; + case "fourslash-server": + runners.push(new FourSlashRunner(FourSlashTestType.Server)); + break; + case "fourslash-generated": + runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native)); + break; + case "rwc": + runners.push(new RWCRunner()); + break; + case "test262": + runners.push(new Test262BaselineRunner()); + break; + } } } } - for (let i = 0; i < workerCount; i++) { - const config = workerConfigs[i]; - // use last worker to run unit tests if we're not just running a single specific runner - config.runUnitTests = runners.length !== 1 && i === workerCount - 1; - Harness.IO.writeFile(ts.combinePaths(taskConfigsFolder, `task-config${i}.json`), JSON.stringify(workerConfigs[i])); + if (runners.length === 0) { + // compiler + runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); + runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); + + // TODO: project tests don"t work in the browser yet + if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) { + runners.push(new ProjectRunner()); + } + + // language services + runners.push(new FourSlashRunner(FourSlashTestType.Native)); + runners.push(new FourSlashRunner(FourSlashTestType.Shims)); + runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess)); + runners.push(new FourSlashRunner(FourSlashTestType.Server)); + // runners.push(new GeneratedFourslashRunner()); } } -else { + +function beginTests() { if (ts.Debug.isDebugging) { ts.Debug.enableDebugInfo(); } runTests(runners); + + if (!runUnitTests) { + // patch `describe` to skip unit tests + describe = ts.noop as any; + } } -if (!runUnitTests) { - // patch `describe` to skip unit tests - describe = ts.noop as any; + +function startTestEnvironment() { + const isWorker = handleTestConfig(); + if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) { + if (isWorker) { + return Harness.Parallel.Worker.start(); + } + else if (taskConfigsFolder && workerCount && workerCount > 1) { + return Harness.Parallel.Host.start(); + } + } + beginTests(); } + +startTestEnvironment(); diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index bd7c9bc2ffa..c6e78138638 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -92,6 +92,9 @@ "loggedIO.ts", "rwcRunner.ts", "test262Runner.ts", + "./parallel/shared.ts", + "./parallel/host.ts", + "./parallel/worker.ts", "runner.ts", "../server/protocol.ts", "../server/session.ts", From f3411d4361300081151db3ba51fe706bfa97c347 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 14 Sep 2017 15:35:47 -0700 Subject: [PATCH 174/216] Only decrement activeRequestCount on SetTypings responses InvalidateCache responses are triggered by file watchers, rather than by requests. --- src/server/server.ts | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index f031d5f0cfc..fe83e879433 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -433,23 +433,25 @@ namespace ts.server { return; } - if (this.activeRequestCount > 0) { - this.activeRequestCount--; - } - else { - Debug.fail("Received too many responses"); - } - - while (this.requestQueue.length > 0) { - const queuedRequest = this.requestQueue.shift(); - if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { - this.requestMap.delete(queuedRequest.operationId); - this.scheduleRequest(queuedRequest); - break; + if (response.kind === ActionSet) { + if (this.activeRequestCount > 0) { + this.activeRequestCount--; + } + else { + Debug.fail("Received too many responses"); } - if (this.logger.hasLevel(LogLevel.verbose)) { - this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); + while (this.requestQueue.length > 0) { + const queuedRequest = this.requestQueue.shift(); + if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { + this.requestMap.delete(queuedRequest.operationId); + this.scheduleRequest(queuedRequest); + break; + } + + if (this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); + } } } From fd4a8d1516e5e5ae8c0c8b7f47ed4191a1799e68 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 14 Sep 2017 16:22:14 -0700 Subject: [PATCH 175/216] Let the RWC harness iterate over files instead of building one big file (#18416) * Let the RWC harness iterate over files instead of building one big file * Handle duplicated-only-in-case outputs better in the type baseliner * Always lowercase output names * Move common code into helper function * Always write .delete for missing files even if there were errors --- Jakefile.js | 6 +- src/harness/harness.ts | 196 +++++++++++++++++++++++++++++++-------- src/harness/rwcRunner.ts | 30 +++--- 3 files changed, 177 insertions(+), 55 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 39e9e8a0421..6fd2f549015 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -769,15 +769,16 @@ function exec(cmd, completeHandler, errorHandler) { ex.run(); } +const del = require("del"); function cleanTestDirs() { // Clean the local baselines directory if (fs.existsSync(localBaseline)) { - jake.rmRf(localBaseline); + del.sync(localBaseline); } // Clean the local Rwc baselines directory if (fs.existsSync(localRwcBaseline)) { - jake.rmRf(localRwcBaseline); + del.sync(localRwcBaseline); } jake.mkdirP(localRwcBaseline); @@ -1042,6 +1043,7 @@ function acceptBaseline(sourceFolder, targetFolder) { if (fs.existsSync(target)) { fs.unlinkSync(target); } + jake.mkdirP(path.dirname(target)); fs.renameSync(path.join(sourceFolder, filename), target); } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 8344be36753..7a6c061c6d4 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1291,11 +1291,25 @@ namespace Harness { } export function getErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray, pretty?: boolean) { + let outputLines = ""; + const gen = iterateErrorBaseline(inputFiles, diagnostics, pretty); + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { + const [, content] = value; + outputLines += content; + } + return outputLines; + } + + export const diagnosticSummaryMarker = "__diagnosticSummary"; + export const globalErrorsMarker = "__globalErrors"; + export function *iterateErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray, pretty?: boolean): IterableIterator<[string, string, number]> { diagnostics = diagnostics.slice().sort(ts.compareDiagnostics); let outputLines = ""; // Count up all errors that were found in files other than lib.d.ts so we don't miss any let totalErrorsReportedInNonLibraryFiles = 0; + let errorsReported = 0; + let firstLine = true; function newLine() { if (firstLine) { @@ -1314,6 +1328,7 @@ namespace Harness { .filter(s => s.length > 0) .map(s => "!!! " + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s); errLines.forEach(e => outputLines += (newLine() + e)); + errorsReported++; // do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics // if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers) @@ -1325,12 +1340,18 @@ namespace Harness { } } + yield [diagnosticSummaryMarker, minimalDiagnosticsToString(diagnostics, pretty) + Harness.IO.newLine() + Harness.IO.newLine(), diagnostics.length]; + // Report global errors const globalErrors = diagnostics.filter(err => !err.file); globalErrors.forEach(outputErrorText); + yield [globalErrorsMarker, outputLines, errorsReported]; + outputLines = ""; + errorsReported = 0; // 'merge' the lines of each input file with any errors associated with it - inputFiles.filter(f => f.content !== undefined).forEach(inputFile => { + const dupeCase = ts.createMap(); + for (const inputFile of inputFiles.filter(f => f.content !== undefined)) { // Filter down to the errors in the file const fileErrors = diagnostics.filter(e => { const errFn = e.file; @@ -1396,7 +1417,10 @@ namespace Harness { // Verify we didn't miss any errors in this file assert.equal(markedErrorCount, fileErrors.length, "count of errors in " + inputFile.unitName); - }); + yield [checkDuplicatedFileName(inputFile.unitName, dupeCase), outputLines, errorsReported]; + outputLines = ""; + errorsReported = 0; + } const numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => { return diagnostic.file && (isDefaultLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName)); @@ -1409,9 +1433,6 @@ namespace Harness { // Verify we didn't miss any errors in total assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors"); - - return minimalDiagnosticsToString(diagnostics, pretty) + - Harness.IO.newLine() + Harness.IO.newLine() + outputLines; } export function doErrorBaseline(baselinePath: string, inputFiles: TestFile[], errors: ts.Diagnostic[], pretty?: boolean) { @@ -1425,7 +1446,7 @@ namespace Harness { }); } - export function doTypeAndSymbolBaseline(baselinePath: string, result: CompilerResult, allFiles: {unitName: string, content: string}[], opts?: Harness.Baseline.BaselineOptions) { + export function doTypeAndSymbolBaseline(baselinePath: string, result: CompilerResult, allFiles: {unitName: string, content: string}[], opts?: Harness.Baseline.BaselineOptions, multifile?: boolean) { if (result.errors.length !== 0) { return; } @@ -1486,24 +1507,42 @@ namespace Harness { return; function checkBaseLines(isSymbolBaseLine: boolean) { - const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); - const fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; - // When calling this function from rwc-runner, the baselinePath will have no extension. // As rwc test- file is stored in json which ".json" will get stripped off. // When calling this function from compiler-runner, the baselinePath will then has either ".ts" or ".tsx" extension const outputFileName = ts.endsWith(baselinePath, ts.Extension.Ts) || ts.endsWith(baselinePath, ts.Extension.Tsx) ? - baselinePath.replace(/\.tsx?/, fullExtension) : baselinePath.concat(fullExtension); - Harness.Baseline.runBaseline(outputFileName, () => fullBaseLine, opts); + baselinePath.replace(/\.tsx?/, "") : baselinePath; + + if (!multifile) { + const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); + Harness.Baseline.runBaseline(outputFileName + fullExtension, () => fullBaseLine, opts); + } + else { + Harness.Baseline.runMultifileBaseline(outputFileName, fullExtension, () => { + return iterateBaseLine(fullResults, isSymbolBaseLine); + }, opts); + } } function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { - const typeLines: string[] = []; - const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; + let result = ""; + const gen = iterateBaseLine(typeWriterResults, isSymbolBaseline); + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { + const [, content] = value; + result += content; + } + return result; + } - allFiles.forEach(file => { + function *iterateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): IterableIterator<[string, string]> { + let typeLines = ""; + const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; + const dupeCase = ts.createMap(); + + for (const file of allFiles) { const codeLines = file.content.split("\n"); + const key = file.unitName; typeWriterResults.get(file.unitName).forEach(result => { if (isSymbolBaseline && !result.symbol) { return; @@ -1511,42 +1550,42 @@ namespace Harness { const typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; const formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; - if (!typeMap[file.unitName]) { - typeMap[file.unitName] = {}; + if (!typeMap[key]) { + typeMap[key] = {}; } let typeInfo = [formattedLine]; - const existingTypeInfo = typeMap[file.unitName][result.line]; + const existingTypeInfo = typeMap[key][result.line]; if (existingTypeInfo) { typeInfo = existingTypeInfo.concat(typeInfo); } - typeMap[file.unitName][result.line] = typeInfo; + typeMap[key][result.line] = typeInfo; }); - typeLines.push("=== " + file.unitName + " ===\r\n"); + typeLines += "=== " + file.unitName + " ===\r\n"; for (let i = 0; i < codeLines.length; i++) { const currentCodeLine = codeLines[i]; - typeLines.push(currentCodeLine + "\r\n"); - if (typeMap[file.unitName]) { - const typeInfo = typeMap[file.unitName][i]; + typeLines += currentCodeLine + "\r\n"; + if (typeMap[key]) { + const typeInfo = typeMap[key][i]; if (typeInfo) { typeInfo.forEach(ty => { - typeLines.push(">" + ty + "\r\n"); + typeLines += ">" + ty + "\r\n"; }); if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === "")) { } else { - typeLines.push("\r\n"); + typeLines += "\r\n"; } } } else { - typeLines.push("No type information for this code."); + typeLines += "No type information for this code."; } } - }); - - return typeLines.join(""); + yield [checkDuplicatedFileName(file.unitName, dupeCase), typeLines]; + typeLines = ""; + } } } @@ -1642,24 +1681,29 @@ namespace Harness { } export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { - // Collect, test, and sort the fileNames - outputFiles.sort((a, b) => ts.compareStrings(cleanName(a.fileName), cleanName(b.fileName))); - + const gen = iterateOutputs(outputFiles); // Emit them let result = ""; - for (const outputFile of outputFiles) { + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { // Some extra spacing if this isn't the first file if (result.length) { result += "\r\n\r\n"; } - // FileName header + content - result += "/*====== " + outputFile.fileName + " ======*/\r\n"; - - result += outputFile.code; + const [, content] = value; + result += content; } - return result; + } + + export function *iterateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): IterableIterator<[string, string]> { + // Collect, test, and sort the fileNames + outputFiles.sort((a, b) => ts.compareStrings(cleanName(a.fileName), cleanName(b.fileName))); + const dupeCase = ts.createMap(); + // Yield them + for (const outputFile of outputFiles) { + yield [checkDuplicatedFileName(outputFile.fileName, dupeCase), "/*====== " + outputFile.fileName + " ======*/\r\n" + outputFile.code]; + } function cleanName(fn: string) { const lastSlash = ts.normalizeSlashes(fn).lastIndexOf("/"); @@ -1667,6 +1711,24 @@ namespace Harness { } } + function checkDuplicatedFileName(resultName: string, dupeCase: ts.Map): string { + resultName = sanitizeTestFilePath(resultName); + if (dupeCase.has(resultName)) { + // A different baseline filename should be manufactured if the names differ only in case, for windows compat + const count = 1 + dupeCase.get(resultName); + dupeCase.set(resultName, count); + resultName = `${resultName}.dupe${count}`; + } + else { + dupeCase.set(resultName, 0); + } + return resultName; + } + + function sanitizeTestFilePath(name: string) { + return ts.normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/").toLowerCase(); + } + // This does not need to exist strictly speaking, but many tests will need to be updated if it's removed export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) { // NEWTODO: Re-implement 'compileString' @@ -2004,6 +2066,66 @@ namespace Harness { const comparison = compareToBaseline(actual, relativeFileName, opts); writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName); } + + export function runMultifileBaseline(relativeFileBase: string, extension: string, generateContent: () => IterableIterator<[string, string, number]> | IterableIterator<[string, string]>, opts?: BaselineOptions, referencedExtensions?: string[]): void { + const gen = generateContent(); + const writtenFiles = ts.createMap(); + const canonicalize = ts.createGetCanonicalFileName(/*caseSensitive*/ false); // This is done so tests work on windows _and_ linux + /* tslint:disable-next-line:no-null-keyword */ + const errors: Error[] = []; + if (gen !== null) { + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { + const [name, content, count] = value as [string, string, number | undefined]; + if (count === 0) continue; // Allow error reporter to skip writing files without errors + const relativeFileName = ts.combinePaths(relativeFileBase, name) + extension; + const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); + const actual = content; + const comparison = compareToBaseline(actual, relativeFileName, opts); + try { + writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName); + } + catch (e) { + errors.push(e); + } + const path = ts.toPath(relativeFileName, "", canonicalize); + writtenFiles.set(path, true); + } + } + + const referenceDir = referencePath(relativeFileBase, opts && opts.Baselinefolder, opts && opts.Subfolder); + let existing = Harness.IO.readDirectory(referenceDir, referencedExtensions || [extension]); + if (extension === ".ts" || referencedExtensions && referencedExtensions.indexOf(".ts") > -1 && referencedExtensions.indexOf(".d.ts") === -1) { + // special-case and filter .d.ts out of .ts results + existing = existing.filter(f => !ts.endsWith(f, ".d.ts")); + } + const missing: string[] = []; + for (const name of existing) { + const localCopy = name.substring(referenceDir.length - relativeFileBase.length); + const path = ts.toPath(localCopy, "", canonicalize); + if (!writtenFiles.has(path)) { + missing.push(localCopy); + } + } + if (missing.length) { + for (const file of missing) { + IO.writeFile(localPath(file + ".delete", opts && opts.Baselinefolder, opts && opts.Subfolder), ""); + } + } + + if (errors.length || missing.length) { + let errorMsg = ""; + if (errors.length) { + errorMsg += `The baseline for ${relativeFileBase} has changed:${"\n " + errors.map(e => e.message).join("\n ")}`; + } + if (errors.length && missing.length) { + errorMsg += "\n"; + } + if (missing.length) { + errorMsg += `Baseline missing files:${"\n " + missing.join("\n ") + "\n"}Written:${"\n " + ts.arrayFrom(writtenFiles.keys()).join("\n ")}`; + } + throw new Error(errorMsg); + } + } } export function isDefaultLibraryFile(filePath: string): boolean { diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index b3ef80b2a31..1f398118c06 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -170,29 +170,29 @@ namespace RWC { it("has the expected emitted code", () => { - Harness.Baseline.runBaseline(`${baseName}.output.js`, () => { - return Harness.Compiler.collateOutputs(compilerResult.files); - }, baselineOpts); + Harness.Baseline.runMultifileBaseline(baseName, "", () => { + return Harness.Compiler.iterateOutputs(compilerResult.files); + }, baselineOpts, [".js", ".jsx"]); }); it("has the expected declaration file content", () => { - Harness.Baseline.runBaseline(`${baseName}.d.ts`, () => { + Harness.Baseline.runMultifileBaseline(baseName, "", () => { if (!compilerResult.declFilesCode.length) { return null; } - return Harness.Compiler.collateOutputs(compilerResult.declFilesCode); - }, baselineOpts); + return Harness.Compiler.iterateOutputs(compilerResult.declFilesCode); + }, baselineOpts, [".d.ts"]); }); it("has the expected source maps", () => { - Harness.Baseline.runBaseline(`${baseName}.map`, () => { + Harness.Baseline.runMultifileBaseline(baseName, "", () => { if (!compilerResult.sourceMaps.length) { return null; } - return Harness.Compiler.collateOutputs(compilerResult.sourceMaps); - }, baselineOpts); + return Harness.Compiler.iterateOutputs(compilerResult.sourceMaps); + }, baselineOpts, [".map"]); }); /*it("has correct source map record", () => { @@ -204,14 +204,14 @@ namespace RWC { });*/ it("has the expected errors", () => { - Harness.Baseline.runBaseline(`${baseName}.errors.txt`, () => { + Harness.Baseline.runMultifileBaseline(baseName, ".errors.txt", () => { if (compilerResult.errors.length === 0) { return null; } // Do not include the library in the baselines to avoid noise const baselineFiles = tsconfigFiles.concat(inputFiles, otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName)); const errors = compilerResult.errors.filter(e => !e.file || !Harness.isDefaultLibraryFile(e.file.fileName)); - return Harness.Compiler.getErrorBaseline(baselineFiles, errors); + return Harness.Compiler.iterateErrorBaseline(baselineFiles, errors); }, baselineOpts); }); @@ -220,14 +220,14 @@ namespace RWC { Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles .concat(otherFiles) .filter(file => !!compilerResult.program.getSourceFile(file.unitName)) - .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts); + .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts, /*multifile*/ true); }); // Ideally, a generated declaration file will have no errors. But we allow generated // declaration file errors as part of the baseline. it("has the expected errors in generated declaration files", () => { if (compilerOptions.declaration && !compilerResult.errors.length) { - Harness.Baseline.runBaseline(`${baseName}.dts.errors.txt`, () => { + Harness.Baseline.runMultifileBaseline(baseName, ".dts.errors.txt", () => { if (compilerResult.errors.length === 0) { return null; } @@ -239,9 +239,7 @@ namespace RWC { compilerResult = undefined; const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles(declContext); - return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + - Harness.IO.newLine() + Harness.IO.newLine() + - Harness.Compiler.getErrorBaseline(tsconfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); + return Harness.Compiler.iterateErrorBaseline(tsconfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); }, baselineOpts); } }); From 0b76e43977d21267350b3f4834604b816bba6382 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 15 Sep 2017 07:21:38 -0700 Subject: [PATCH 176/216] Make formatOptions optional in GetEditsForRefactorRequestArgs --- src/server/protocol.ts | 2 +- src/server/session.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 1740f8ae0ba..44862c738cc 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -494,7 +494,7 @@ namespace ts.server.protocol { refactor: string; /* The 'name' property from the refactoring action */ action: string; - formatOptions: FormatCodeSettings, + formatOptions?: FormatCodeSettings, }; diff --git a/src/server/session.ts b/src/server/session.ts index e6ba78b81c9..02eb76eeae8 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1488,7 +1488,7 @@ namespace ts.server { const result = project.getLanguageService().getEditsForRefactor( file, - convertFormatOptions(args.formatOptions), + args.formatOptions ? convertFormatOptions(args.formatOptions) : this.projectService.getFormatCodeOptions(), position || textRange, args.refactor, args.action From 95594e3ef3fe525bf8d61e6c15b24b951394d817 Mon Sep 17 00:00:00 2001 From: Vakhurin Sergey Date: Fri, 15 Sep 2017 19:12:35 +0300 Subject: [PATCH 177/216] Fixed formatting for multiline initialization of object and class members (#18494) --- src/services/formatting/smartIndenter.ts | 2 ++ tests/cases/fourslash/formattingOnClasses.ts | 8 +++++++- tests/cases/fourslash/formattingOnInvalidCodes.ts | 6 +++--- tests/cases/fourslash/formattingOnObjectLiteral.ts | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 4de2e5765e5..4943c566e0b 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -505,6 +505,8 @@ namespace ts.formatting { case SyntaxKind.NamedImports: case SyntaxKind.ExportSpecifier: case SyntaxKind.ImportSpecifier: + case SyntaxKind.PropertyAssignment: + case SyntaxKind.PropertyDeclaration: return true; } return false; diff --git a/tests/cases/fourslash/formattingOnClasses.ts b/tests/cases/fourslash/formattingOnClasses.ts index 0c259dae2ec..7371ea8c66b 100644 --- a/tests/cases/fourslash/formattingOnClasses.ts +++ b/tests/cases/fourslash/formattingOnClasses.ts @@ -79,7 +79,9 @@ /////*62*/ } /////*63*/ protected bar ( ) { } /////*64*/ protected static bar2 ( ) { } -/////*65*/} +/////*65*/ private pv4 : number = +/////*66*/ {}; +/////*END*/} format.document(); goTo.marker("1"); verify.currentLineContentIs("class a {"); @@ -210,4 +212,8 @@ verify.currentLineContentIs(" protected bar() { }"); goTo.marker("64"); verify.currentLineContentIs(" protected static bar2() { }"); goTo.marker("65"); +verify.currentLineContentIs(" private pv4: number ="); +goTo.marker("66"); +verify.currentLineContentIs(" {};"); +goTo.marker("END"); verify.currentLineContentIs("}"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingOnInvalidCodes.ts b/tests/cases/fourslash/formattingOnInvalidCodes.ts index c5d71020249..d4bc0f8c879 100644 --- a/tests/cases/fourslash/formattingOnInvalidCodes.ts +++ b/tests/cases/fourslash/formattingOnInvalidCodes.ts @@ -238,7 +238,7 @@ verify.currentLineContentIs(" {"); goTo.marker("69"); verify.currentLineContentIs(" 'student':"); goTo.marker("70"); -verify.currentLineContentIs(" { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }"); +verify.currentLineContentIs(" { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }"); goTo.marker("71"); verify.currentLineContentIs(" },"); goTo.marker("72"); @@ -246,7 +246,7 @@ verify.currentLineContentIs(" {"); goTo.marker("73"); verify.currentLineContentIs(" 'student':"); goTo.marker("74"); -verify.currentLineContentIs(" { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' }"); +verify.currentLineContentIs(" { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' }"); goTo.marker("75"); verify.currentLineContentIs(" },"); goTo.marker("76"); @@ -254,7 +254,7 @@ verify.currentLineContentIs(" {"); goTo.marker("77"); verify.currentLineContentIs(" 'student':"); goTo.marker("78"); -verify.currentLineContentIs(" { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' }"); +verify.currentLineContentIs(" { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' }"); goTo.marker("79"); verify.currentLineContentIs(" }"); goTo.marker("80"); diff --git a/tests/cases/fourslash/formattingOnObjectLiteral.ts b/tests/cases/fourslash/formattingOnObjectLiteral.ts index 5b8d5f9cb52..7b302d55378 100644 --- a/tests/cases/fourslash/formattingOnObjectLiteral.ts +++ b/tests/cases/fourslash/formattingOnObjectLiteral.ts @@ -72,11 +72,11 @@ verify.currentLineContentIs("var x2 = {"); goTo.marker("21"); verify.currentLineContentIs(" foo:"); goTo.marker("22"); -verify.currentLineContentIs(" 3,"); +verify.currentLineContentIs(" 3,"); goTo.marker("23"); verify.currentLineContentIs(" 'bar':"); goTo.marker("24"); -verify.currentLineContentIs(" { a: 1, b: 2 }"); +verify.currentLineContentIs(" { a: 1, b: 2 }"); goTo.marker("25"); verify.currentLineContentIs("};"); goTo.marker("26"); From 9c6f65175b281438fe5ac935262bb4e3ba5f3c73 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 15 Sep 2017 10:05:14 -0700 Subject: [PATCH 178/216] Refactor truthy-spread-union creation for performance Only create properties once, only if needed, and don't create an intermediate anonymous type. The code is also inlined with the rest of `getSpreadType`. --- src/compiler/checker.ts | 62 +++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a7c98f657dc..2dbf8b9253f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7822,6 +7822,7 @@ namespace ts { * and right = the new element to be spread. */ function getSpreadType(left: Type, right: Type): Type { + let truthyRight: Type; if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) { return anyType; } @@ -7832,25 +7833,18 @@ namespace ts { return left; } if (left.flags & TypeFlags.Union) { - // if the union is `false | T` make all the properties of T optional - const wl = getPartialTypeFromFalsyUnion(left as UnionType); - if (wl) { - left = wl; - } - else { - return mapType(left, t => getSpreadType(t, right)); - } + return mapType(left, t => getSpreadType(t, right)); } if (right.flags & TypeFlags.Union) { - const wr = getPartialTypeFromFalsyUnion(right as UnionType); - if (wr) { - right = wr; - } - else { + truthyRight = getTruthyTypeFromFalsyUnion(right as UnionType); + if (!truthyRight || truthyRight.flags & TypeFlags.Union) { return mapType(right, t => getSpreadType(left, t)); } + else { + right = truthyRight; + } } - if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike)) { + if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.EnumLike)) { return emptyObjectType; } @@ -7875,9 +7869,10 @@ namespace ts { skippedPrivateMembers.set(rightProp.escapedName, true); } else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { - members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); + members.set(rightProp.escapedName, getSymbolOfSpreadProperty(rightProp, !!truthyRight)); } } + for (const leftProp of getPropertiesOfType(left)) { if (leftProp.flags & SymbolFlags.SetAccessor && !(leftProp.flags & SymbolFlags.GetAccessor) || skippedPrivateMembers.has(leftProp.escapedName) @@ -7899,19 +7894,22 @@ namespace ts { } } else { - members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); + members.set(leftProp.escapedName, getSymbolOfSpreadProperty(leftProp, /*makeOptional*/ false)); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } - function getNonReadonlySymbol(prop: Symbol) { - if (!isReadonlySymbol(prop)) { + function getSymbolOfSpreadProperty(prop: Symbol, makeOptional: boolean) { + if (!isReadonlySymbol(prop) && (!makeOptional || prop.flags & SymbolFlags.Optional)) { return prop; } - const flags = SymbolFlags.Property | (prop.flags & SymbolFlags.Optional); + const flags = SymbolFlags.Property | (makeOptional ? SymbolFlags.Optional : prop.flags & SymbolFlags.Optional); const result = createSymbol(flags, prop.escapedName); result.type = getTypeOfSymbol(prop); + if (makeOptional) { + result.type = getUnionType([result.type, undefinedType]); + } result.declarations = prop.declarations; result.syntheticOrigin = prop; return result; @@ -7921,25 +7919,10 @@ namespace ts { return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); } - function getPartialTypeFromFalsyUnion(type: UnionType): Type | undefined { - if (type.types.length === 2) { - const truthy = removeDefinitelyFalsyTypes(type); - if (truthy !== type) { - const members = createSymbolTable(); - for (const prop of getPropertiesOfType(truthy)) { - if (prop.flags & SymbolFlags.Optional) { - members.set(prop.escapedName, prop); - } - else { - const result = createSymbol(prop.flags | SymbolFlags.Optional, prop.escapedName); - result.type = getUnionType([getTypeOfSymbol(prop), undefinedType]); - result.declarations = prop.declarations; - result.syntheticOrigin = prop; - members.set(prop.escapedName, result); - } - } - return createAnonymousType(undefined, members, emptyArray, emptyArray, getIndexInfoOfType(truthy, IndexKind.String), getIndexInfoOfType(truthy, IndexKind.Number)); - } + function getTruthyTypeFromFalsyUnion(type: UnionType): Type | undefined { + const truthy = removeDefinitelyFalsyTypes(type); + if (truthy !== type) { + return truthy; } } @@ -13784,7 +13767,8 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { - return !!(type.flags & (TypeFlags.Any | TypeFlags.PossiblyFalsy | TypeFlags.NonPrimitive) || + return !!(type.flags & (TypeFlags.Any | TypeFlags.NonPrimitive) || + getFalsyFlags(type) & TypeFlags.DefinitelyFalsy && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & TypeFlags.Object && !isGenericMappedType(type) || type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } From f97d5fa11d594762b4863d297a72ec4d038e4e99 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 15 Sep 2017 10:06:58 -0700 Subject: [PATCH 179/216] Update tests with improved spread-falsy-union rules --- tests/baselines/reference/objectSpread.js | 42 ++- .../baselines/reference/objectSpread.symbols | 299 ++++++++++-------- tests/baselines/reference/objectSpread.types | 114 +++++-- .../reference/objectSpreadNegative.errors.txt | 49 ++- .../reference/objectSpreadNegative.js | 16 +- .../objectSpreadNegativeParse.errors.txt | 5 +- .../restInvalidArgumentType.errors.txt | 65 +++- .../reference/restInvalidArgumentType.js | 48 ++- tests/baselines/reference/restUnion2.js | 14 +- tests/baselines/reference/restUnion2.symbols | 25 -- tests/baselines/reference/restUnion2.types | 27 -- .../baselines/reference/restUnion3.errors.txt | 17 + tests/baselines/reference/restUnion3.js | 25 ++ .../spreadInvalidArgumentType.errors.txt | 72 ++++- .../reference/spreadInvalidArgumentType.js | 53 +++- tests/baselines/reference/spreadUnion2.js | 5 - .../baselines/reference/spreadUnion2.symbols | 45 +-- tests/baselines/reference/spreadUnion2.types | 14 - .../reference/spreadUnion3.errors.txt | 23 +- tests/baselines/reference/spreadUnion3.js | 7 + .../cases/compiler/restInvalidArgumentType.ts | 24 +- tests/cases/compiler/restUnion2.ts | 9 - tests/cases/compiler/restUnion3.ts | 8 + .../compiler/spreadInvalidArgumentType.ts | 29 +- .../conformance/types/spread/objectSpread.ts | 28 +- .../types/spread/objectSpreadNegative.ts | 8 +- .../conformance/types/spread/spreadUnion2.ts | 3 - .../conformance/types/spread/spreadUnion3.ts | 5 + 28 files changed, 707 insertions(+), 372 deletions(-) create mode 100644 tests/baselines/reference/restUnion3.errors.txt create mode 100644 tests/baselines/reference/restUnion3.js create mode 100644 tests/cases/compiler/restUnion3.ts diff --git a/tests/baselines/reference/objectSpread.js b/tests/baselines/reference/objectSpread.js index 7eab2da265f..eea39c8e773 100644 --- a/tests/baselines/reference/objectSpread.js +++ b/tests/baselines/reference/objectSpread.js @@ -38,12 +38,26 @@ getter.a = 12; // functions result in { } let spreadFunc = { ...(function () { }) }; -// boolean && T results in Partial -function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { - return { ...b && { x: 1, y: 2 } }; +type Header = { head: string, body: string, authToken: string } +function from16326(this: { header: Header }, header: Header, authToken: string): Header { + return { + ...this.header, + ...header, + ...authToken && { authToken } + } } -function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { +// boolean && T results in Partial +function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { let o = { x: 12, y: 13 } + o = { + ...o, + ...b && { x: 14 } + } + let o2 = { ...b && { x: 21 }} + return o; +} +function conditionalSpreadNumber(nt: number): { x: number, y: number } { + let o = { x: 15, y: 16 } o = { ...o, ...nt && { x: nt } @@ -51,8 +65,8 @@ function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: numbe let o2 = { ...nt && { x: nt }} return o; } -function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { - let o = { x: 'hi', y: 13 } +function conditionalSpreadString(st: string): { x: string, y: number } { + let o = { x: 'hi', y: 17 } o = { ...o, ...st && { x: st } @@ -60,8 +74,6 @@ function conditionalSpreadString(st: string): { x?: string | undefined, y: numbe let o2 = { ...st && { x: st }} return o; } -// other booleans result in { } -let spreadBool = { ... true } // any results in any let anything: any; @@ -141,24 +153,28 @@ var getter = __assign({}, op, { c: 7 }); getter.a = 12; // functions result in { } var spreadFunc = __assign({}, (function () { })); +function from16326(header, authToken) { + return __assign({}, this.header, header, authToken && { authToken: authToken }); +} // boolean && T results in Partial function conditionalSpreadBoolean(b) { - return __assign({}, b && { x: 1, y: 2 }); + var o = { x: 12, y: 13 }; + o = __assign({}, o, b && { x: 14 }); + var o2 = __assign({}, b && { x: 21 }); + return o; } function conditionalSpreadNumber(nt) { - var o = { x: 12, y: 13 }; + var o = { x: 15, y: 16 }; o = __assign({}, o, nt && { x: nt }); var o2 = __assign({}, nt && { x: nt }); return o; } function conditionalSpreadString(st) { - var o = { x: 'hi', y: 13 }; + var o = { x: 'hi', y: 17 }; o = __assign({}, o, st && { x: st }); var o2 = __assign({}, st && { x: st }); return o; } -// other booleans result in { } -var spreadBool = __assign({}, true); // any results in any var anything; var spreadAny = __assign({}, anything); diff --git a/tests/baselines/reference/objectSpread.symbols b/tests/baselines/reference/objectSpread.symbols index 9f257870a0b..0cb15d4ea7a 100644 --- a/tests/baselines/reference/objectSpread.symbols +++ b/tests/baselines/reference/objectSpread.symbols @@ -169,144 +169,189 @@ getter.a = 12; let spreadFunc = { ...(function () { }) }; >spreadFunc : Symbol(spreadFunc, Decl(objectSpread.ts, 37, 3)) -// boolean && T results in Partial -function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { ->conditionalSpreadBoolean : Symbol(conditionalSpreadBoolean, Decl(objectSpread.ts, 37, 42)) ->b : Symbol(b, Decl(objectSpread.ts, 40, 34)) ->x : Symbol(x, Decl(objectSpread.ts, 40, 49)) ->y : Symbol(y, Decl(objectSpread.ts, 40, 73)) +type Header = { head: string, body: string, authToken: string } +>Header : Symbol(Header, Decl(objectSpread.ts, 37, 42)) +>head : Symbol(head, Decl(objectSpread.ts, 39, 15)) +>body : Symbol(body, Decl(objectSpread.ts, 39, 29)) +>authToken : Symbol(authToken, Decl(objectSpread.ts, 39, 43)) - return { ...b && { x: 1, y: 2 } }; ->b : Symbol(b, Decl(objectSpread.ts, 40, 34)) ->x : Symbol(x, Decl(objectSpread.ts, 41, 22)) ->y : Symbol(y, Decl(objectSpread.ts, 41, 28)) +function from16326(this: { header: Header }, header: Header, authToken: string): Header { +>from16326 : Symbol(from16326, Decl(objectSpread.ts, 39, 63)) +>this : Symbol(this, Decl(objectSpread.ts, 40, 19)) +>header : Symbol(header, Decl(objectSpread.ts, 40, 26)) +>Header : Symbol(Header, Decl(objectSpread.ts, 37, 42)) +>header : Symbol(header, Decl(objectSpread.ts, 40, 44)) +>Header : Symbol(Header, Decl(objectSpread.ts, 37, 42)) +>authToken : Symbol(authToken, Decl(objectSpread.ts, 40, 60)) +>Header : Symbol(Header, Decl(objectSpread.ts, 37, 42)) + + return { + ...this.header, +>this.header : Symbol(header, Decl(objectSpread.ts, 40, 26)) +>this : Symbol(this, Decl(objectSpread.ts, 40, 19)) +>header : Symbol(header, Decl(objectSpread.ts, 40, 26)) + + ...header, +>header : Symbol(header, Decl(objectSpread.ts, 40, 44)) + + ...authToken && { authToken } +>authToken : Symbol(authToken, Decl(objectSpread.ts, 40, 60)) +>authToken : Symbol(authToken, Decl(objectSpread.ts, 44, 25)) + } } -function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { ->conditionalSpreadNumber : Symbol(conditionalSpreadNumber, Decl(objectSpread.ts, 42, 1)) ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 43, 47)) ->y : Symbol(y, Decl(objectSpread.ts, 43, 71)) +// boolean && T results in Partial +function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { +>conditionalSpreadBoolean : Symbol(conditionalSpreadBoolean, Decl(objectSpread.ts, 46, 1)) +>b : Symbol(b, Decl(objectSpread.ts, 48, 34)) +>x : Symbol(x, Decl(objectSpread.ts, 48, 49)) +>y : Symbol(y, Decl(objectSpread.ts, 48, 60)) let o = { x: 12, y: 13 } ->o : Symbol(o, Decl(objectSpread.ts, 44, 7)) ->x : Symbol(x, Decl(objectSpread.ts, 44, 13)) ->y : Symbol(y, Decl(objectSpread.ts, 44, 20)) +>o : Symbol(o, Decl(objectSpread.ts, 49, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 49, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 49, 20)) o = { ->o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 49, 7)) ...o, ->o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 49, 7)) + + ...b && { x: 14 } +>b : Symbol(b, Decl(objectSpread.ts, 48, 34)) +>x : Symbol(x, Decl(objectSpread.ts, 52, 17)) + } + let o2 = { ...b && { x: 21 }} +>o2 : Symbol(o2, Decl(objectSpread.ts, 54, 7)) +>b : Symbol(b, Decl(objectSpread.ts, 48, 34)) +>x : Symbol(x, Decl(objectSpread.ts, 54, 24)) + + return o; +>o : Symbol(o, Decl(objectSpread.ts, 49, 7)) +} +function conditionalSpreadNumber(nt: number): { x: number, y: number } { +>conditionalSpreadNumber : Symbol(conditionalSpreadNumber, Decl(objectSpread.ts, 56, 1)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 57, 47)) +>y : Symbol(y, Decl(objectSpread.ts, 57, 58)) + + let o = { x: 15, y: 16 } +>o : Symbol(o, Decl(objectSpread.ts, 58, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 58, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 58, 20)) + + o = { +>o : Symbol(o, Decl(objectSpread.ts, 58, 7)) + + ...o, +>o : Symbol(o, Decl(objectSpread.ts, 58, 7)) ...nt && { x: nt } ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 47, 18)) ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 61, 18)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) } let o2 = { ...nt && { x: nt }} ->o2 : Symbol(o2, Decl(objectSpread.ts, 49, 7)) ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 49, 25)) ->nt : Symbol(nt, Decl(objectSpread.ts, 43, 33)) +>o2 : Symbol(o2, Decl(objectSpread.ts, 63, 7)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 63, 25)) +>nt : Symbol(nt, Decl(objectSpread.ts, 57, 33)) return o; ->o : Symbol(o, Decl(objectSpread.ts, 44, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 58, 7)) } -function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { ->conditionalSpreadString : Symbol(conditionalSpreadString, Decl(objectSpread.ts, 51, 1)) ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 52, 47)) ->y : Symbol(y, Decl(objectSpread.ts, 52, 71)) +function conditionalSpreadString(st: string): { x: string, y: number } { +>conditionalSpreadString : Symbol(conditionalSpreadString, Decl(objectSpread.ts, 65, 1)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 66, 47)) +>y : Symbol(y, Decl(objectSpread.ts, 66, 58)) - let o = { x: 'hi', y: 13 } ->o : Symbol(o, Decl(objectSpread.ts, 53, 7)) ->x : Symbol(x, Decl(objectSpread.ts, 53, 13)) ->y : Symbol(y, Decl(objectSpread.ts, 53, 22)) + let o = { x: 'hi', y: 17 } +>o : Symbol(o, Decl(objectSpread.ts, 67, 7)) +>x : Symbol(x, Decl(objectSpread.ts, 67, 13)) +>y : Symbol(y, Decl(objectSpread.ts, 67, 22)) o = { ->o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 67, 7)) ...o, ->o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 67, 7)) ...st && { x: st } ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 56, 18)) ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 70, 18)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) } let o2 = { ...st && { x: st }} ->o2 : Symbol(o2, Decl(objectSpread.ts, 58, 7)) ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) ->x : Symbol(x, Decl(objectSpread.ts, 58, 25)) ->st : Symbol(st, Decl(objectSpread.ts, 52, 33)) +>o2 : Symbol(o2, Decl(objectSpread.ts, 72, 7)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) +>x : Symbol(x, Decl(objectSpread.ts, 72, 25)) +>st : Symbol(st, Decl(objectSpread.ts, 66, 33)) return o; ->o : Symbol(o, Decl(objectSpread.ts, 53, 7)) +>o : Symbol(o, Decl(objectSpread.ts, 67, 7)) } -// other booleans result in { } -let spreadBool = { ... true } ->spreadBool : Symbol(spreadBool, Decl(objectSpread.ts, 62, 3)) // any results in any let anything: any; ->anything : Symbol(anything, Decl(objectSpread.ts, 65, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 77, 3)) let spreadAny = { ...anything }; ->spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 66, 3)) ->anything : Symbol(anything, Decl(objectSpread.ts, 65, 3)) +>spreadAny : Symbol(spreadAny, Decl(objectSpread.ts, 78, 3)) +>anything : Symbol(anything, Decl(objectSpread.ts, 77, 3)) // methods are not enumerable class C { p = 1; m() { } } ->C : Symbol(C, Decl(objectSpread.ts, 66, 32)) ->p : Symbol(C.p, Decl(objectSpread.ts, 69, 9)) ->m : Symbol(C.m, Decl(objectSpread.ts, 69, 16)) +>C : Symbol(C, Decl(objectSpread.ts, 78, 32)) +>p : Symbol(C.p, Decl(objectSpread.ts, 81, 9)) +>m : Symbol(C.m, Decl(objectSpread.ts, 81, 16)) let c: C = new C() ->c : Symbol(c, Decl(objectSpread.ts, 70, 3)) ->C : Symbol(C, Decl(objectSpread.ts, 66, 32)) ->C : Symbol(C, Decl(objectSpread.ts, 66, 32)) +>c : Symbol(c, Decl(objectSpread.ts, 82, 3)) +>C : Symbol(C, Decl(objectSpread.ts, 78, 32)) +>C : Symbol(C, Decl(objectSpread.ts, 78, 32)) let spreadC: { p: number } = { ...c } ->spreadC : Symbol(spreadC, Decl(objectSpread.ts, 71, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 71, 14)) ->c : Symbol(c, Decl(objectSpread.ts, 70, 3)) +>spreadC : Symbol(spreadC, Decl(objectSpread.ts, 83, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 83, 14)) +>c : Symbol(c, Decl(objectSpread.ts, 82, 3)) // own methods are enumerable let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }; ->cplus : Symbol(cplus, Decl(objectSpread.ts, 74, 3)) ->p : Symbol(p, Decl(objectSpread.ts, 74, 12)) ->plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) ->c : Symbol(c, Decl(objectSpread.ts, 70, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 74, 48)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 86, 3)) +>p : Symbol(p, Decl(objectSpread.ts, 86, 12)) +>plus : Symbol(plus, Decl(objectSpread.ts, 86, 23)) +>c : Symbol(c, Decl(objectSpread.ts, 82, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 86, 48)) cplus.plus(); ->cplus.plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) ->cplus : Symbol(cplus, Decl(objectSpread.ts, 74, 3)) ->plus : Symbol(plus, Decl(objectSpread.ts, 74, 23)) +>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 86, 23)) +>cplus : Symbol(cplus, Decl(objectSpread.ts, 86, 3)) +>plus : Symbol(plus, Decl(objectSpread.ts, 86, 23)) // new field's type conflicting with existing field is OK let changeTypeAfter: { a: string, b: string } = ->changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 78, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 78, 22)) ->b : Symbol(b, Decl(objectSpread.ts, 78, 33)) +>changeTypeAfter : Symbol(changeTypeAfter, Decl(objectSpread.ts, 90, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 90, 22)) +>b : Symbol(b, Decl(objectSpread.ts, 90, 33)) { ...o, a: 'wrong type?' } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 79, 11)) +>a : Symbol(a, Decl(objectSpread.ts, 91, 11)) let changeTypeBefore: { a: number, b: string } = ->changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 80, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 80, 23)) ->b : Symbol(b, Decl(objectSpread.ts, 80, 34)) +>changeTypeBefore : Symbol(changeTypeBefore, Decl(objectSpread.ts, 92, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 92, 23)) +>b : Symbol(b, Decl(objectSpread.ts, 92, 34)) { a: 'wrong type?', ...o }; ->a : Symbol(a, Decl(objectSpread.ts, 81, 5)) +>a : Symbol(a, Decl(objectSpread.ts, 93, 5)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) let changeTypeBoth: { a: string, b: number } = ->changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 82, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 82, 21)) ->b : Symbol(b, Decl(objectSpread.ts, 82, 32)) +>changeTypeBoth : Symbol(changeTypeBoth, Decl(objectSpread.ts, 94, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 94, 21)) +>b : Symbol(b, Decl(objectSpread.ts, 94, 32)) { ...o, ...swap }; >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) @@ -314,90 +359,90 @@ let changeTypeBoth: { a: string, b: number } = // optional function container( ->container : Symbol(container, Decl(objectSpread.ts, 83, 22)) +>container : Symbol(container, Decl(objectSpread.ts, 95, 22)) definiteBoolean: { sn: boolean }, ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) ->sn : Symbol(sn, Decl(objectSpread.ts, 87, 22)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 98, 19)) +>sn : Symbol(sn, Decl(objectSpread.ts, 99, 22)) definiteString: { sn: string }, ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) ->sn : Symbol(sn, Decl(objectSpread.ts, 88, 21)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 99, 37)) +>sn : Symbol(sn, Decl(objectSpread.ts, 100, 21)) optionalString: { sn?: string }, ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) ->sn : Symbol(sn, Decl(objectSpread.ts, 89, 21)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 100, 35)) +>sn : Symbol(sn, Decl(objectSpread.ts, 101, 21)) optionalNumber: { sn?: number }) { ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) ->sn : Symbol(sn, Decl(objectSpread.ts, 90, 21)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 101, 36)) +>sn : Symbol(sn, Decl(objectSpread.ts, 102, 21)) let optionalUnionStops: { sn: string | number | boolean } = { ...definiteBoolean, ...definiteString, ...optionalNumber }; ->optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 91, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 91, 29)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) +>optionalUnionStops : Symbol(optionalUnionStops, Decl(objectSpread.ts, 103, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 103, 29)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 98, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 99, 37)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 101, 36)) let optionalUnionDuplicates: { sn: string | number } = { ...definiteBoolean, ...definiteString, ...optionalString, ...optionalNumber }; ->optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 92, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 92, 34)) ->definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 86, 19)) ->definiteString : Symbol(definiteString, Decl(objectSpread.ts, 87, 37)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) +>optionalUnionDuplicates : Symbol(optionalUnionDuplicates, Decl(objectSpread.ts, 104, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 104, 34)) +>definiteBoolean : Symbol(definiteBoolean, Decl(objectSpread.ts, 98, 19)) +>definiteString : Symbol(definiteString, Decl(objectSpread.ts, 99, 37)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 100, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 101, 36)) let allOptional: { sn?: string | number } = { ...optionalString, ...optionalNumber }; ->allOptional : Symbol(allOptional, Decl(objectSpread.ts, 93, 7)) ->sn : Symbol(sn, Decl(objectSpread.ts, 93, 22)) ->optionalString : Symbol(optionalString, Decl(objectSpread.ts, 88, 35)) ->optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 89, 36)) +>allOptional : Symbol(allOptional, Decl(objectSpread.ts, 105, 7)) +>sn : Symbol(sn, Decl(objectSpread.ts, 105, 22)) +>optionalString : Symbol(optionalString, Decl(objectSpread.ts, 100, 35)) +>optionalNumber : Symbol(optionalNumber, Decl(objectSpread.ts, 101, 36)) // computed property let computedFirst: { a: number, b: string, "before everything": number } = ->computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 96, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 96, 24)) ->b : Symbol(b, Decl(objectSpread.ts, 96, 35)) +>computedFirst : Symbol(computedFirst, Decl(objectSpread.ts, 108, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 108, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 108, 35)) { ['before everything']: 12, ...o, b: 'yes' } ->'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 97, 9)) +>'before everything' : Symbol(['before everything'], Decl(objectSpread.ts, 109, 9)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 97, 42)) +>b : Symbol(b, Decl(objectSpread.ts, 109, 42)) let computedMiddle: { a: number, b: string, c: boolean, "in the middle": number } = ->computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 98, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 98, 25)) ->b : Symbol(b, Decl(objectSpread.ts, 98, 36)) ->c : Symbol(c, Decl(objectSpread.ts, 98, 47)) +>computedMiddle : Symbol(computedMiddle, Decl(objectSpread.ts, 110, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 110, 25)) +>b : Symbol(b, Decl(objectSpread.ts, 110, 36)) +>c : Symbol(c, Decl(objectSpread.ts, 110, 47)) { ...o, ['in the middle']: 13, b: 'maybe?', ...o2 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 99, 15)) ->b : Symbol(b, Decl(objectSpread.ts, 99, 38)) +>'in the middle' : Symbol(['in the middle'], Decl(objectSpread.ts, 111, 15)) +>b : Symbol(b, Decl(objectSpread.ts, 111, 38)) >o2 : Symbol(o2, Decl(objectSpread.ts, 1, 3)) let computedAfter: { a: number, b: string, "at the end": number } = ->computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 100, 7)) ->a : Symbol(a, Decl(objectSpread.ts, 100, 24)) ->b : Symbol(b, Decl(objectSpread.ts, 100, 35)) +>computedAfter : Symbol(computedAfter, Decl(objectSpread.ts, 112, 7)) +>a : Symbol(a, Decl(objectSpread.ts, 112, 24)) +>b : Symbol(b, Decl(objectSpread.ts, 112, 35)) { ...o, b: 'yeah', ['at the end']: 14 } >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->b : Symbol(b, Decl(objectSpread.ts, 101, 15)) ->'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 101, 26)) +>b : Symbol(b, Decl(objectSpread.ts, 113, 15)) +>'at the end' : Symbol(['at the end'], Decl(objectSpread.ts, 113, 26)) } // shortcut syntax let a = 12; ->a : Symbol(a, Decl(objectSpread.ts, 104, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 116, 3)) let shortCutted: { a: number, b: string } = { ...o, a } ->shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 105, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 105, 18)) ->b : Symbol(b, Decl(objectSpread.ts, 105, 29)) +>shortCutted : Symbol(shortCutted, Decl(objectSpread.ts, 117, 3)) +>a : Symbol(a, Decl(objectSpread.ts, 117, 18)) +>b : Symbol(b, Decl(objectSpread.ts, 117, 29)) >o : Symbol(o, Decl(objectSpread.ts, 0, 3)) ->a : Symbol(a, Decl(objectSpread.ts, 105, 51)) +>a : Symbol(a, Decl(objectSpread.ts, 117, 51)) // non primitive let spreadNonPrimitive = { ...{}}; ->spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 107, 3)) +>spreadNonPrimitive : Symbol(spreadNonPrimitive, Decl(objectSpread.ts, 119, 3)) diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index 10d8af02440..da24a558d51 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -230,27 +230,45 @@ let spreadFunc = { ...(function () { }) }; >(function () { }) : () => void >function () { } : () => void -// boolean && T results in Partial -function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { ->conditionalSpreadBoolean : (b: boolean) => { x?: number | undefined; y?: number | undefined; } ->b : boolean ->x : number | undefined ->y : number | undefined +type Header = { head: string, body: string, authToken: string } +>Header : Header +>head : string +>body : string +>authToken : string - return { ...b && { x: 1, y: 2 } }; ->{ ...b && { x: 1, y: 2 } } : { x?: number | undefined; y?: number | undefined; } ->b && { x: 1, y: 2 } : false | { x: number; y: number; } ->b : boolean ->{ x: 1, y: 2 } : { x: number; y: number; } ->x : number ->1 : 1 ->y : number ->2 : 2 +function from16326(this: { header: Header }, header: Header, authToken: string): Header { +>from16326 : (this: { header: Header; }, header: Header, authToken: string) => Header +>this : { header: Header; } +>header : Header +>Header : Header +>header : Header +>Header : Header +>authToken : string +>Header : Header + + return { +>{ ...this.header, ...header, ...authToken && { authToken } } : { authToken: string; head: string; body: string; } + + ...this.header, +>this.header : Header +>this : { header: Header; } +>header : Header + + ...header, +>header : Header + + ...authToken && { authToken } +>authToken && { authToken } : "" | { authToken: string; } +>authToken : string +>{ authToken } : { authToken: string; } +>authToken : string + } } -function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { ->conditionalSpreadNumber : (nt: number) => { x?: number | undefined; y: number; } ->nt : number ->x : number | undefined +// boolean && T results in Partial +function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { +>conditionalSpreadBoolean : (b: boolean) => { x: number; y: number; } +>b : boolean +>x : number >y : number let o = { x: 12, y: 13 } @@ -261,6 +279,47 @@ function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: numbe >y : number >13 : 13 + o = { +>o = { ...o, ...b && { x: 14 } } : { x: number; y: number; } +>o : { x: number; y: number; } +>{ ...o, ...b && { x: 14 } } : { x: number; y: number; } + + ...o, +>o : { x: number; y: number; } + + ...b && { x: 14 } +>b && { x: 14 } : false | { x: number; } +>b : boolean +>{ x: 14 } : { x: number; } +>x : number +>14 : 14 + } + let o2 = { ...b && { x: 21 }} +>o2 : { x?: number | undefined; } +>{ ...b && { x: 21 }} : { x?: number | undefined; } +>b && { x: 21 } : false | { x: number; } +>b : boolean +>{ x: 21 } : { x: number; } +>x : number +>21 : 21 + + return o; +>o : { x: number; y: number; } +} +function conditionalSpreadNumber(nt: number): { x: number, y: number } { +>conditionalSpreadNumber : (nt: number) => { x: number; y: number; } +>nt : number +>x : number +>y : number + + let o = { x: 15, y: 16 } +>o : { x: number; y: number; } +>{ x: 15, y: 16 } : { x: number; y: number; } +>x : number +>15 : 15 +>y : number +>16 : 16 + o = { >o = { ...o, ...nt && { x: nt } } : { x: number; y: number; } >o : { x: number; y: number; } @@ -288,19 +347,19 @@ function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: numbe return o; >o : { x: number; y: number; } } -function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { ->conditionalSpreadString : (st: string) => { x?: string | undefined; y: number; } +function conditionalSpreadString(st: string): { x: string, y: number } { +>conditionalSpreadString : (st: string) => { x: string; y: number; } >st : string ->x : string | undefined +>x : string >y : number - let o = { x: 'hi', y: 13 } + let o = { x: 'hi', y: 17 } >o : { x: string; y: number; } ->{ x: 'hi', y: 13 } : { x: string; y: number; } +>{ x: 'hi', y: 17 } : { x: string; y: number; } >x : string >'hi' : "hi" >y : number ->13 : 13 +>17 : 17 o = { >o = { ...o, ...st && { x: st } } : { x: string; y: number; } @@ -329,11 +388,6 @@ function conditionalSpreadString(st: string): { x?: string | undefined, y: numbe return o; >o : { x: string; y: number; } } -// other booleans result in { } -let spreadBool = { ... true } ->spreadBool : {} ->{ ... true } : {} ->true : true // any results in any let anything: any; diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 39639af545e..92225755c71 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -7,23 +7,26 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(25,1): error TS2322 Property 's' is missing in type '{ b: boolean; }'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,36): error TS2300: Duplicate identifier 'b'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(28,53): error TS2300: Duplicate identifier 'b'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,11): error TS2339: Property 'length' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,11): error TS2339: Property 'charAt' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(37,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(41,12): error TS2339: Property 'b' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(47,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,11): error TS2339: Property 'a' does not exist on type '{}'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(56,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(59,14): error TS2698: Spread types may only be created from object types. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(73,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(32,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(33,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(34,20): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(36,20): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(38,19): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(47,12): error TS2339: Property 'b' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(53,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(62,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(65,14): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(79,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(76,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(82,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(84,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. Object literal may only specify known properties, and 'extra' does not exist in type 'A'. -==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (17 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegative.ts (20 errors) ==== let o = { a: 1, b: 'no' } /// private propagates @@ -69,14 +72,26 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322 !!! error TS2300: Duplicate identifier 'b'. let duplicatedSpread = { ...o, ...o } - // primitives are skipped + // primitives are not allowed, except for falsy ones + let spreadNum = { ...12 }; + ~~~~~ +!!! error TS2698: Spread types may only be created from object types. + let spreadSum = { ...1 + 1 }; + ~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + let spreadZero = { ...0 }; + ~~~~ +!!! error TS2698: Spread types may only be created from object types. + spreadZero.toFixed(); // error, no methods even from a falsy number + let spreadBool = { ...true }; + ~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + spreadBool.valueOf(); let spreadStr = { ...'foo' }; + ~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. spreadStr.length; // error, no 'length' - ~~~~~~ -!!! error TS2339: Property 'length' does not exist on type '{}'. spreadStr.charAt(1); // error, no methods either - ~~~~~~ -!!! error TS2339: Property 'charAt' does not exist on type '{}'. // functions are skipped let spreadFunc = { ...function () { } } spreadFunc(); // error, no call signature diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index 41502dc028d..7e6720b9b16 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -29,7 +29,13 @@ spread = b; // error, missing 's' let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' } let duplicatedSpread = { ...o, ...o } -// primitives are skipped +// primitives are not allowed, except for falsy ones +let spreadNum = { ...12 }; +let spreadSum = { ...1 + 1 }; +let spreadZero = { ...0 }; +spreadZero.toFixed(); // error, no methods even from a falsy number +let spreadBool = { ...true }; +spreadBool.valueOf(); let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either @@ -116,7 +122,13 @@ spread = b; // error, missing 's' // literal repeats are not allowed, but spread repeats are fine var duplicated = __assign({ b: 'bad' }, o, { b: 'bad' }, o2, { b: 'bad' }); var duplicatedSpread = __assign({}, o, o); -// primitives are skipped +// primitives are not allowed, except for falsy ones +var spreadNum = __assign({}, 12); +var spreadSum = __assign({}, 1 + 1); +var spreadZero = __assign({}, 0); +spreadZero.toFixed(); // error, no methods even from a falsy number +var spreadBool = __assign({}, true); +spreadBool.valueOf(); var spreadStr = __assign({}, 'foo'); spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either diff --git a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt index 41651fb1d1c..b37200c4f02 100644 --- a/tests/baselines/reference/objectSpreadNegativeParse.errors.txt +++ b/tests/baselines/reference/objectSpreadNegativeParse.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,15): error TS2304: Cannot find name 'o'. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(1,18): error TS1109: Expression expected. +tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,12): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,15): error TS1109: Expression expected. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(2,16): error TS2304: Cannot find name 'o'. tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(3,15): error TS2304: Cannot find name 'matchMedia'. @@ -9,13 +10,15 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,16): error T tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error TS1005: ',' expected. -==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (9 errors) ==== +==== tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts (10 errors) ==== let o7 = { ...o? }; ~ !!! error TS2304: Cannot find name 'o'. ~ !!! error TS1109: Expression expected. let o8 = { ...*o }; + ~~~~~ +!!! error TS2698: Spread types may only be created from object types. ~ !!! error TS1109: Expression expected. ~ diff --git a/tests/baselines/reference/restInvalidArgumentType.errors.txt b/tests/baselines/reference/restInvalidArgumentType.errors.txt index 44577d5a24e..0cc4faea557 100644 --- a/tests/baselines/reference/restInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/restInvalidArgumentType.errors.txt @@ -1,13 +1,24 @@ -tests/cases/compiler/restInvalidArgumentType.ts(18,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(20,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(22,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(23,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(25,13): error TS2700: Rest types may only be created from object types. -tests/cases/compiler/restInvalidArgumentType.ts(28,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(27,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(29,13): error TS2700: Rest types may only be created from object types. tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(31,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(33,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(36,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(37,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(39,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(40,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(42,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(43,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(45,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(46,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(50,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(51,13): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restInvalidArgumentType.ts(53,13): error TS2700: Rest types may only be created from object types. -==== tests/cases/compiler/restInvalidArgumentType.ts (7 errors) ==== +==== tests/cases/compiler/restInvalidArgumentType.ts (16 errors) ==== + enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -18,7 +29,14 @@ tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } & string; + var num: number; + var str: string; + var literal_string: "string"; + var literal_number: 42; + var e: E; var u: undefined; var n: null; @@ -32,7 +50,6 @@ tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types var {...r3} = t; // Error, generic type paramter ~~ !!! error TS2700: Rest types may only be created from object types. - var {...r4} = i; // Error, index access ~~ !!! error TS2700: Rest types may only be created from object types. @@ -48,14 +65,42 @@ tests/cases/compiler/restInvalidArgumentType.ts(30,13): error TS2700: Rest types var {...r8} = union_generic; // Error, union with generic type parameter ~~ !!! error TS2700: Rest types may only be created from object types. + var {...r9} = union_primitive; // Error, union with generic type parameter + ~~ +!!! error TS2700: Rest types may only be created from object types. var {...r10} = intersection_generic; // Error, intersection with generic type parameter ~~~ !!! error TS2700: Rest types may only be created from object types. + var {...r11} = intersection_primitive; // Error, intersection with generic type parameter + ~~~ +!!! error TS2700: Rest types may only be created from object types. - var {...r14} = u; // OK - var {...r15} = n; // OK + var {...r12} = num; // Error + ~~~ +!!! error TS2700: Rest types may only be created from object types. + var {...r13} = str; // Error + ~~~ +!!! error TS2700: Rest types may only be created from object types. + + var {...r14} = u; // error, undefined-only not allowed + ~~~ +!!! error TS2700: Rest types may only be created from object types. + var {...r15} = n; // error, null-only not allowed + ~~~ +!!! error TS2700: Rest types may only be created from object types. var {...r16} = a; // OK + + var {...r17} = literal_string; // Error + ~~~ +!!! error TS2700: Rest types may only be created from object types. + var {...r18} = literal_number; // Error + ~~~ +!!! error TS2700: Rest types may only be created from object types. + + var {...r19} = e; // Error, enum + ~~~ +!!! error TS2700: Rest types may only be created from object types. } \ No newline at end of file diff --git a/tests/baselines/reference/restInvalidArgumentType.js b/tests/baselines/reference/restInvalidArgumentType.js index 81bcfb63a17..75b52a8c6e8 100644 --- a/tests/baselines/reference/restInvalidArgumentType.js +++ b/tests/baselines/reference/restInvalidArgumentType.js @@ -1,4 +1,6 @@ //// [restInvalidArgumentType.ts] +enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -9,7 +11,14 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } & string; + var num: number; + var str: string; + var literal_string: "string"; + var literal_number: 42; + var e: E; var u: undefined; var n: null; @@ -19,7 +28,6 @@ function f(p1: T, p2: T[]) { var {...r1} = p1; // Error, generic type paramterre var {...r2} = p2; // OK var {...r3} = t; // Error, generic type paramter - var {...r4} = i; // Error, index access var {...r5} = k; // Error, index @@ -27,13 +35,23 @@ function f(p1: T, p2: T[]) { var {...r7} = mapped; // OK, non-generic mapped type var {...r8} = union_generic; // Error, union with generic type parameter + var {...r9} = union_primitive; // Error, union with generic type parameter var {...r10} = intersection_generic; // Error, intersection with generic type parameter + var {...r11} = intersection_primitive; // Error, intersection with generic type parameter - var {...r14} = u; // OK - var {...r15} = n; // OK + var {...r12} = num; // Error + var {...r13} = str; // Error + + var {...r14} = u; // error, undefined-only not allowed + var {...r15} = n; // error, null-only not allowed var {...r16} = a; // OK + + var {...r17} = literal_string; // Error + var {...r18} = literal_number; // Error + + var {...r19} = e; // Error, enum } @@ -47,6 +65,12 @@ var __rest = (this && this.__rest) || function (s, e) { t[p[i]] = s[p[i]]; return t; }; +var E; +(function (E) { + E[E["v1"] = 0] = "v1"; + E[E["v2"] = 1] = "v2"; +})(E || (E = {})); +; function f(p1, p2) { var t; var i; @@ -54,7 +78,14 @@ function f(p1, p2) { var mapped_generic; var mapped; var union_generic; + var union_primitive; var intersection_generic; + var intersection_primitive; + var num; + var str; + var literal_string; + var literal_number; + var e; var u; var n; var a; @@ -66,8 +97,15 @@ function f(p1, p2) { var r6 = __rest(mapped_generic, []); // Error, generic mapped object type var r7 = __rest(mapped, []); // OK, non-generic mapped type var r8 = __rest(union_generic, []); // Error, union with generic type parameter + var r9 = __rest(union_primitive, []); // Error, union with generic type parameter var r10 = __rest(intersection_generic, []); // Error, intersection with generic type parameter - var r14 = __rest(u, []); // OK - var r15 = __rest(n, []); // OK + var r11 = __rest(intersection_primitive, []); // Error, intersection with generic type parameter + var r12 = __rest(num, []); // Error + var r13 = __rest(str, []); // Error + var r14 = __rest(u, []); // error, undefined-only not allowed + var r15 = __rest(n, []); // error, null-only not allowed var r16 = __rest(a, []); // OK + var r17 = __rest(literal_string, []); // Error + var r18 = __rest(literal_number, []); // Error + var r19 = __rest(e, []); // Error, enum } diff --git a/tests/baselines/reference/restUnion2.js b/tests/baselines/reference/restUnion2.js index 71f4b06cfef..437ea780193 100644 --- a/tests/baselines/reference/restUnion2.js +++ b/tests/baselines/reference/restUnion2.js @@ -7,15 +7,7 @@ var {...rest2 } = undefinedUnion; declare const nullUnion: { n: number } | null; var rest3: { n: number }; var {...rest3 } = nullUnion; - - -declare const nullAndUndefinedUnion: null | undefined; -var rest4: { }; -var {...rest4 } = nullAndUndefinedUnion; - -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; -var rest5: { n: number, s: string }; -var {...rest5 } = unionWithIntersection; + //// [restUnion2.js] var __rest = (this && this.__rest) || function (s, e) { @@ -31,7 +23,3 @@ var rest2; var rest2 = __rest(undefinedUnion, []); var rest3; var rest3 = __rest(nullUnion, []); -var rest4; -var rest4 = __rest(nullAndUndefinedUnion, []); -var rest5; -var rest5 = __rest(unionWithIntersection, []); diff --git a/tests/baselines/reference/restUnion2.symbols b/tests/baselines/reference/restUnion2.symbols index 54ac47f0694..c6c34511b17 100644 --- a/tests/baselines/reference/restUnion2.symbols +++ b/tests/baselines/reference/restUnion2.symbols @@ -24,28 +24,3 @@ var {...rest3 } = nullUnion; >rest3 : Symbol(rest3, Decl(restUnion2.ts, 6, 3), Decl(restUnion2.ts, 7, 5)) >nullUnion : Symbol(nullUnion, Decl(restUnion2.ts, 5, 13)) - -declare const nullAndUndefinedUnion: null | undefined; ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(restUnion2.ts, 10, 13)) - -var rest4: { }; ->rest4 : Symbol(rest4, Decl(restUnion2.ts, 11, 3), Decl(restUnion2.ts, 12, 5)) - -var {...rest4 } = nullAndUndefinedUnion; ->rest4 : Symbol(rest4, Decl(restUnion2.ts, 11, 3), Decl(restUnion2.ts, 12, 5)) ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(restUnion2.ts, 10, 13)) - -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; ->unionWithIntersection : Symbol(unionWithIntersection, Decl(restUnion2.ts, 14, 13)) ->n : Symbol(n, Decl(restUnion2.ts, 14, 39)) ->s : Symbol(s, Decl(restUnion2.ts, 14, 55)) - -var rest5: { n: number, s: string }; ->rest5 : Symbol(rest5, Decl(restUnion2.ts, 15, 3), Decl(restUnion2.ts, 16, 5)) ->n : Symbol(n, Decl(restUnion2.ts, 15, 12)) ->s : Symbol(s, Decl(restUnion2.ts, 15, 23)) - -var {...rest5 } = unionWithIntersection; ->rest5 : Symbol(rest5, Decl(restUnion2.ts, 15, 3), Decl(restUnion2.ts, 16, 5)) ->unionWithIntersection : Symbol(unionWithIntersection, Decl(restUnion2.ts, 14, 13)) - diff --git a/tests/baselines/reference/restUnion2.types b/tests/baselines/reference/restUnion2.types index 03c8d577e66..0e464930b07 100644 --- a/tests/baselines/reference/restUnion2.types +++ b/tests/baselines/reference/restUnion2.types @@ -25,30 +25,3 @@ var {...rest3 } = nullUnion; >rest3 : { n: number; } >nullUnion : { n: number; } | null - -declare const nullAndUndefinedUnion: null | undefined; ->nullAndUndefinedUnion : null | undefined ->null : null - -var rest4: { }; ->rest4 : {} - -var {...rest4 } = nullAndUndefinedUnion; ->rest4 : {} ->nullAndUndefinedUnion : null | undefined - -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; ->unionWithIntersection : ({ n: number; } & { s: string; } & undefined) | null ->n : number ->s : string ->null : null - -var rest5: { n: number, s: string }; ->rest5 : { n: number; s: string; } ->n : number ->s : string - -var {...rest5 } = unionWithIntersection; ->rest5 : { n: number; s: string; } ->unionWithIntersection : ({ n: number; } & { s: string; } & undefined) | null - diff --git a/tests/baselines/reference/restUnion3.errors.txt b/tests/baselines/reference/restUnion3.errors.txt new file mode 100644 index 00000000000..a960ad4a33b --- /dev/null +++ b/tests/baselines/reference/restUnion3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/restUnion3.ts(3,9): error TS2700: Rest types may only be created from object types. +tests/cases/compiler/restUnion3.ts(7,9): error TS2700: Rest types may only be created from object types. + + +==== tests/cases/compiler/restUnion3.ts (2 errors) ==== + declare const nullAndUndefinedUnion: null | undefined; + var rest4: { }; + var {...rest4 } = nullAndUndefinedUnion; + ~~~~~ +!!! error TS2700: Rest types may only be created from object types. + + declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; + var rest5: { n: number, s: string }; + var {...rest5 } = unionWithIntersection; + ~~~~~ +!!! error TS2700: Rest types may only be created from object types. + \ No newline at end of file diff --git a/tests/baselines/reference/restUnion3.js b/tests/baselines/reference/restUnion3.js new file mode 100644 index 00000000000..f10bd7ed0a7 --- /dev/null +++ b/tests/baselines/reference/restUnion3.js @@ -0,0 +1,25 @@ +//// [restUnion3.ts] +declare const nullAndUndefinedUnion: null | undefined; +var rest4: { }; +var {...rest4 } = nullAndUndefinedUnion; + +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +var rest5: { n: number, s: string }; +var {...rest5 } = unionWithIntersection; + + +//// [restUnion3.js] +"use strict"; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +}; +var rest4; +var rest4 = __rest(nullAndUndefinedUnion, []); +var rest5; +var rest5 = __rest(unionWithIntersection, []); diff --git a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt index 5b48e24ad0d..4c1aa286aad 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.errors.txt +++ b/tests/baselines/reference/spreadInvalidArgumentType.errors.txt @@ -1,13 +1,24 @@ -tests/cases/compiler/spreadInvalidArgumentType.ts(19,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(21,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(23,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(24,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(26,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(29,16): error TS2698: Spread types may only be created from object types. -tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(30,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(32,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(33,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(34,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(35,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(38,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(39,16): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(41,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(42,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(44,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(45,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(47,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(48,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(52,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(53,17): error TS2698: Spread types may only be created from object types. +tests/cases/compiler/spreadInvalidArgumentType.ts(55,17): error TS2698: Spread types may only be created from object types. -==== tests/cases/compiler/spreadInvalidArgumentType.ts (7 errors) ==== +==== tests/cases/compiler/spreadInvalidArgumentType.ts (16 errors) ==== + enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -18,14 +29,23 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread t var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } | string; + + var num: number; + var str: number; + var literal_string: "string"; + var literal_number: 42; var u: undefined; var n: null; - var a: any; + + var e: E; + var o1 = { ...p1 }; // Error, generic type paramterre ~~~~~ !!! error TS2698: Spread types may only be created from object types. @@ -33,14 +53,12 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread t var o3 = { ...t }; // Error, generic type paramter ~~~~ !!! error TS2698: Spread types may only be created from object types. - var o4 = { ...i }; // Error, index access ~~~~ !!! error TS2698: Spread types may only be created from object types. var o5 = { ...k }; // Error, index ~~~~ !!! error TS2698: Spread types may only be created from object types. - var o6 = { ...mapped_generic }; // Error, generic mapped object type ~~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. @@ -49,14 +67,42 @@ tests/cases/compiler/spreadInvalidArgumentType.ts(31,17): error TS2698: Spread t var o8 = { ...union_generic }; // Error, union with generic type parameter ~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. + var o9 = { ...union_primitive }; // Error, union with generic type parameter + ~~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2698: Spread types may only be created from object types. + var o11 = { ...intersection_primitive }; // Error, intersection with generic type parameter + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. - var o14 = { ...u }; // OK - var o15 = { ...n }; // OK + var o12 = { ...num }; // Error + ~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + var o13 = { ...str }; // Error + ~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + + var o14 = { ...u }; // error, undefined-only not allowed + ~~~~ +!!! error TS2698: Spread types may only be created from object types. + var o15 = { ...n }; // error, null-only not allowed + ~~~~ +!!! error TS2698: Spread types may only be created from object types. var o16 = { ...a }; // OK + + var o17 = { ...literal_string }; // Error + ~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + var o18 = { ...literal_number }; // Error + ~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + + var o19 = { ...e }; // Error, enum + ~~~~ +!!! error TS2698: Spread types may only be created from object types. } \ No newline at end of file diff --git a/tests/baselines/reference/spreadInvalidArgumentType.js b/tests/baselines/reference/spreadInvalidArgumentType.js index aa42419e59a..7aa04616fd1 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.js +++ b/tests/baselines/reference/spreadInvalidArgumentType.js @@ -1,4 +1,6 @@ //// [spreadInvalidArgumentType.ts] +enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -9,32 +11,49 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } | string; + + var num: number; + var str: number; + var literal_string: "string"; + var literal_number: 42; var u: undefined; var n: null; - var a: any; + + var e: E; + var o1 = { ...p1 }; // Error, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // Error, generic type paramter - var o4 = { ...i }; // Error, index access var o5 = { ...k }; // Error, index - var o6 = { ...mapped_generic }; // Error, generic mapped object type var o7 = { ...mapped }; // OK, non-generic mapped type var o8 = { ...union_generic }; // Error, union with generic type parameter + var o9 = { ...union_primitive }; // Error, union with generic type parameter var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter + var o11 = { ...intersection_primitive }; // Error, intersection with generic type parameter - var o14 = { ...u }; // OK - var o15 = { ...n }; // OK + var o12 = { ...num }; // Error + var o13 = { ...str }; // Error + + var o14 = { ...u }; // error, undefined-only not allowed + var o15 = { ...n }; // error, null-only not allowed var o16 = { ...a }; // OK + + var o17 = { ...literal_string }; // Error + var o18 = { ...literal_number }; // Error + + var o19 = { ...e }; // Error, enum } @@ -47,6 +66,12 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { } return t; }; +var E; +(function (E) { + E[E["v1"] = 0] = "v1"; + E[E["v2"] = 1] = "v2"; +})(E || (E = {})); +; function f(p1, p2) { var t; var i; @@ -54,10 +79,17 @@ function f(p1, p2) { var mapped_generic; var mapped; var union_generic; + var union_primitive; var intersection_generic; + var intersection_primitive; + var num; + var str; + var literal_string; + var literal_number; var u; var n; var a; + var e; var o1 = __assign({}, p1); // Error, generic type paramterre var o2 = __assign({}, p2); // OK var o3 = __assign({}, t); // Error, generic type paramter @@ -66,8 +98,15 @@ function f(p1, p2) { var o6 = __assign({}, mapped_generic); // Error, generic mapped object type var o7 = __assign({}, mapped); // OK, non-generic mapped type var o8 = __assign({}, union_generic); // Error, union with generic type parameter + var o9 = __assign({}, union_primitive); // Error, union with generic type parameter var o10 = __assign({}, intersection_generic); // Error, intersection with generic type parameter - var o14 = __assign({}, u); // OK - var o15 = __assign({}, n); // OK + var o11 = __assign({}, intersection_primitive); // Error, intersection with generic type parameter + var o12 = __assign({}, num); // Error + var o13 = __assign({}, str); // Error + var o14 = __assign({}, u); // error, undefined-only not allowed + var o15 = __assign({}, n); // error, null-only not allowed var o16 = __assign({}, a); // OK + var o17 = __assign({}, literal_string); // Error + var o18 = __assign({}, literal_number); // Error + var o19 = __assign({}, e); // Error, enum } diff --git a/tests/baselines/reference/spreadUnion2.js b/tests/baselines/reference/spreadUnion2.js index 48b12731817..662b7cd3e46 100644 --- a/tests/baselines/reference/spreadUnion2.js +++ b/tests/baselines/reference/spreadUnion2.js @@ -1,7 +1,6 @@ //// [spreadUnion2.ts] declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; -declare const nullAndUndefinedUnion: null | undefined; var o1: { a?: number | undefined }; var o1 = { ...undefinedUnion }; @@ -19,8 +18,6 @@ var o4 = { ...undefinedUnion, ...undefinedUnion }; var o5: { b?: number | undefined }; var o5 = { ...nullUnion, ...nullUnion }; -var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; -var o7 = { ...nullAndUndefinedUnion }; //// [spreadUnion2.js] @@ -43,5 +40,3 @@ var o4; var o4 = __assign({}, undefinedUnion, undefinedUnion); var o5; var o5 = __assign({}, nullUnion, nullUnion); -var o6 = __assign({}, nullAndUndefinedUnion, nullAndUndefinedUnion); -var o7 = __assign({}, nullAndUndefinedUnion); diff --git a/tests/baselines/reference/spreadUnion2.symbols b/tests/baselines/reference/spreadUnion2.symbols index 841bce12e42..2cc91f2980b 100644 --- a/tests/baselines/reference/spreadUnion2.symbols +++ b/tests/baselines/reference/spreadUnion2.symbols @@ -7,64 +7,53 @@ declare const nullUnion: { b: number } | null; >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >b : Symbol(b, Decl(spreadUnion2.ts, 1, 26)) -declare const nullAndUndefinedUnion: null | undefined; ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) - var o1: { a?: number | undefined }; ->o1 : Symbol(o1, Decl(spreadUnion2.ts, 4, 3), Decl(spreadUnion2.ts, 5, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 4, 9)) +>o1 : Symbol(o1, Decl(spreadUnion2.ts, 3, 3), Decl(spreadUnion2.ts, 4, 3)) +>a : Symbol(a, Decl(spreadUnion2.ts, 3, 9)) var o1 = { ...undefinedUnion }; ->o1 : Symbol(o1, Decl(spreadUnion2.ts, 4, 3), Decl(spreadUnion2.ts, 5, 3)) +>o1 : Symbol(o1, Decl(spreadUnion2.ts, 3, 3), Decl(spreadUnion2.ts, 4, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) var o2: { b?: number | undefined }; ->o2 : Symbol(o2, Decl(spreadUnion2.ts, 7, 3), Decl(spreadUnion2.ts, 8, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 7, 9)) +>o2 : Symbol(o2, Decl(spreadUnion2.ts, 6, 3), Decl(spreadUnion2.ts, 7, 3)) +>b : Symbol(b, Decl(spreadUnion2.ts, 6, 9)) var o2 = { ...nullUnion }; ->o2 : Symbol(o2, Decl(spreadUnion2.ts, 7, 3), Decl(spreadUnion2.ts, 8, 3)) +>o2 : Symbol(o2, Decl(spreadUnion2.ts, 6, 3), Decl(spreadUnion2.ts, 7, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) var o3: { a?: number | undefined, b?: number | undefined }; ->o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 10, 9)) ->b : Symbol(b, Decl(spreadUnion2.ts, 10, 33)) +>o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) +>a : Symbol(a, Decl(spreadUnion2.ts, 9, 9)) +>b : Symbol(b, Decl(spreadUnion2.ts, 9, 33)) var o3 = { ...undefinedUnion, ...nullUnion }; ->o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) +>o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) var o3 = { ...nullUnion, ...undefinedUnion }; ->o3 : Symbol(o3, Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3), Decl(spreadUnion2.ts, 12, 3)) +>o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) var o4: { a?: number | undefined }; ->o4 : Symbol(o4, Decl(spreadUnion2.ts, 14, 3), Decl(spreadUnion2.ts, 15, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 14, 9)) +>o4 : Symbol(o4, Decl(spreadUnion2.ts, 13, 3), Decl(spreadUnion2.ts, 14, 3)) +>a : Symbol(a, Decl(spreadUnion2.ts, 13, 9)) var o4 = { ...undefinedUnion, ...undefinedUnion }; ->o4 : Symbol(o4, Decl(spreadUnion2.ts, 14, 3), Decl(spreadUnion2.ts, 15, 3)) +>o4 : Symbol(o4, Decl(spreadUnion2.ts, 13, 3), Decl(spreadUnion2.ts, 14, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) var o5: { b?: number | undefined }; ->o5 : Symbol(o5, Decl(spreadUnion2.ts, 17, 3), Decl(spreadUnion2.ts, 18, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 17, 9)) +>o5 : Symbol(o5, Decl(spreadUnion2.ts, 16, 3), Decl(spreadUnion2.ts, 17, 3)) +>b : Symbol(b, Decl(spreadUnion2.ts, 16, 9)) var o5 = { ...nullUnion, ...nullUnion }; ->o5 : Symbol(o5, Decl(spreadUnion2.ts, 17, 3), Decl(spreadUnion2.ts, 18, 3)) +>o5 : Symbol(o5, Decl(spreadUnion2.ts, 16, 3), Decl(spreadUnion2.ts, 17, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) -var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; ->o6 : Symbol(o6, Decl(spreadUnion2.ts, 20, 3)) ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) - -var o7 = { ...nullAndUndefinedUnion }; ->o7 : Symbol(o7, Decl(spreadUnion2.ts, 21, 3)) ->nullAndUndefinedUnion : Symbol(nullAndUndefinedUnion, Decl(spreadUnion2.ts, 2, 13)) diff --git a/tests/baselines/reference/spreadUnion2.types b/tests/baselines/reference/spreadUnion2.types index 50f79cc7745..ccf587af591 100644 --- a/tests/baselines/reference/spreadUnion2.types +++ b/tests/baselines/reference/spreadUnion2.types @@ -8,10 +8,6 @@ declare const nullUnion: { b: number } | null; >b : number >null : null -declare const nullAndUndefinedUnion: null | undefined; ->nullAndUndefinedUnion : null | undefined ->null : null - var o1: { a?: number | undefined }; >o1 : { a?: number | undefined; } >a : number | undefined @@ -67,14 +63,4 @@ var o5 = { ...nullUnion, ...nullUnion }; >nullUnion : { b: number; } | null >nullUnion : { b: number; } | null -var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; ->o6 : {} ->{ ...nullAndUndefinedUnion, ...nullAndUndefinedUnion } : {} ->nullAndUndefinedUnion : null | undefined ->nullAndUndefinedUnion : null | undefined - -var o7 = { ...nullAndUndefinedUnion }; ->o7 : {} ->{ ...nullAndUndefinedUnion } : {} ->nullAndUndefinedUnion : null | undefined diff --git a/tests/baselines/reference/spreadUnion3.errors.txt b/tests/baselines/reference/spreadUnion3.errors.txt index f3fa2da7597..24d864d96fe 100644 --- a/tests/baselines/reference/spreadUnion3.errors.txt +++ b/tests/baselines/reference/spreadUnion3.errors.txt @@ -2,11 +2,13 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ Types of property 'y' are incompatible. Type 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. - Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/spreadUnion3.ts(9,9): error TS2322: Type 'number | undefined' is not assignable to type 'number'. + Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/types/spread/spreadUnion3.ts(17,11): error TS2698: Spread types may only be created from object types. +tests/cases/conformance/types/spread/spreadUnion3.ts(18,11): error TS2698: Spread types may only be created from object types. -==== tests/cases/conformance/types/spread/spreadUnion3.ts (2 errors) ==== +==== tests/cases/conformance/types/spread/spreadUnion3.ts (4 errors) ==== function f(x: { y: string } | undefined): { y: string } { return { y: 123, ...x } // y: string | number ~~~~~~~~~~~~~~~~~~~~~~~ @@ -21,11 +23,20 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Proper function g(t?: { a: number } | null): void { let b = { ...t }; let c: number = b.a; // might not have 'a' - ~ -!!! error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. -!!! error TS2339: Property 'a' does not exist on type '{}'. + ~ +!!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. } g() g(undefined) g(null) + + // spreading nothing but null and undefined is not allowed + declare const nullAndUndefinedUnion: null | undefined; + var x = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. + var y = { ...nullAndUndefinedUnion }; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2698: Spread types may only be created from object types. \ No newline at end of file diff --git a/tests/baselines/reference/spreadUnion3.js b/tests/baselines/reference/spreadUnion3.js index 2aaf9efeb78..253c2998b9d 100644 --- a/tests/baselines/reference/spreadUnion3.js +++ b/tests/baselines/reference/spreadUnion3.js @@ -12,6 +12,11 @@ function g(t?: { a: number } | null): void { g() g(undefined) g(null) + +// spreading nothing but null and undefined is not allowed +declare const nullAndUndefinedUnion: null | undefined; +var x = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; +var y = { ...nullAndUndefinedUnion }; //// [spreadUnion3.js] @@ -34,3 +39,5 @@ function g(t) { g(); g(undefined); g(null); +var x = __assign({}, nullAndUndefinedUnion, nullAndUndefinedUnion); +var y = __assign({}, nullAndUndefinedUnion); diff --git a/tests/cases/compiler/restInvalidArgumentType.ts b/tests/cases/compiler/restInvalidArgumentType.ts index 2d50903328f..db372fbd4af 100644 --- a/tests/cases/compiler/restInvalidArgumentType.ts +++ b/tests/cases/compiler/restInvalidArgumentType.ts @@ -1,3 +1,5 @@ +enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -8,7 +10,14 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } & string; + var num: number; + var str: string; + var literal_string: "string"; + var literal_number: 42; + var e: E; var u: undefined; var n: null; @@ -18,7 +27,6 @@ function f(p1: T, p2: T[]) { var {...r1} = p1; // Error, generic type paramterre var {...r2} = p2; // OK var {...r3} = t; // Error, generic type paramter - var {...r4} = i; // Error, index access var {...r5} = k; // Error, index @@ -26,11 +34,21 @@ function f(p1: T, p2: T[]) { var {...r7} = mapped; // OK, non-generic mapped type var {...r8} = union_generic; // Error, union with generic type parameter + var {...r9} = union_primitive; // Error, union with generic type parameter var {...r10} = intersection_generic; // Error, intersection with generic type parameter + var {...r11} = intersection_primitive; // Error, intersection with generic type parameter - var {...r14} = u; // OK - var {...r15} = n; // OK + var {...r12} = num; // Error + var {...r13} = str; // Error + + var {...r14} = u; // error, undefined-only not allowed + var {...r15} = n; // error, null-only not allowed var {...r16} = a; // OK + + var {...r17} = literal_string; // Error + var {...r18} = literal_number; // Error + + var {...r19} = e; // Error, enum } diff --git a/tests/cases/compiler/restUnion2.ts b/tests/cases/compiler/restUnion2.ts index 83d94e03a73..9ae6503fb13 100644 --- a/tests/cases/compiler/restUnion2.ts +++ b/tests/cases/compiler/restUnion2.ts @@ -8,12 +8,3 @@ var {...rest2 } = undefinedUnion; declare const nullUnion: { n: number } | null; var rest3: { n: number }; var {...rest3 } = nullUnion; - - -declare const nullAndUndefinedUnion: null | undefined; -var rest4: { }; -var {...rest4 } = nullAndUndefinedUnion; - -declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; -var rest5: { n: number, s: string }; -var {...rest5 } = unionWithIntersection; \ No newline at end of file diff --git a/tests/cases/compiler/restUnion3.ts b/tests/cases/compiler/restUnion3.ts new file mode 100644 index 00000000000..313d83d282d --- /dev/null +++ b/tests/cases/compiler/restUnion3.ts @@ -0,0 +1,8 @@ +// @strict: true +declare const nullAndUndefinedUnion: null | undefined; +var rest4: { }; +var {...rest4 } = nullAndUndefinedUnion; + +declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null; +var rest5: { n: number, s: string }; +var {...rest5 } = unionWithIntersection; diff --git a/tests/cases/compiler/spreadInvalidArgumentType.ts b/tests/cases/compiler/spreadInvalidArgumentType.ts index bf7365e8ab0..f18e73b31ef 100644 --- a/tests/cases/compiler/spreadInvalidArgumentType.ts +++ b/tests/cases/compiler/spreadInvalidArgumentType.ts @@ -1,3 +1,5 @@ +enum E { v1, v2 }; + function f(p1: T, p2: T[]) { var t: T; @@ -8,30 +10,47 @@ function f(p1: T, p2: T[]) { var mapped: {[P in "b"]: T[P]}; var union_generic: T | { a: number }; + var union_primitive: { a: number } | number; var intersection_generic: T & { a: number }; + var intersection_primitive: { a: number } | string; + + var num: number; + var str: number; + var literal_string: "string"; + var literal_number: 42; var u: undefined; var n: null; - var a: any; + + var e: E; + var o1 = { ...p1 }; // Error, generic type paramterre var o2 = { ...p2 }; // OK var o3 = { ...t }; // Error, generic type paramter - var o4 = { ...i }; // Error, index access var o5 = { ...k }; // Error, index - var o6 = { ...mapped_generic }; // Error, generic mapped object type var o7 = { ...mapped }; // OK, non-generic mapped type var o8 = { ...union_generic }; // Error, union with generic type parameter + var o9 = { ...union_primitive }; // Error, union with generic type parameter var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter + var o11 = { ...intersection_primitive }; // Error, intersection with generic type parameter - var o14 = { ...u }; // OK - var o15 = { ...n }; // OK + var o12 = { ...num }; // Error + var o13 = { ...str }; // Error + + var o14 = { ...u }; // error, undefined-only not allowed + var o15 = { ...n }; // error, null-only not allowed var o16 = { ...a }; // OK + + var o17 = { ...literal_string }; // Error + var o18 = { ...literal_number }; // Error + + var o19 = { ...e }; // Error, enum } diff --git a/tests/cases/conformance/types/spread/objectSpread.ts b/tests/cases/conformance/types/spread/objectSpread.ts index 566c9eb0384..c7cf5e49eed 100644 --- a/tests/cases/conformance/types/spread/objectSpread.ts +++ b/tests/cases/conformance/types/spread/objectSpread.ts @@ -39,12 +39,26 @@ getter.a = 12; // functions result in { } let spreadFunc = { ...(function () { }) }; -// boolean && T results in Partial -function conditionalSpreadBoolean(b: boolean) : { x?: number | undefined, y?: number | undefined } { - return { ...b && { x: 1, y: 2 } }; +type Header = { head: string, body: string, authToken: string } +function from16326(this: { header: Header }, header: Header, authToken: string): Header { + return { + ...this.header, + ...header, + ...authToken && { authToken } + } } -function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: number } { +// boolean && T results in Partial +function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { let o = { x: 12, y: 13 } + o = { + ...o, + ...b && { x: 14 } + } + let o2 = { ...b && { x: 21 }} + return o; +} +function conditionalSpreadNumber(nt: number): { x: number, y: number } { + let o = { x: 15, y: 16 } o = { ...o, ...nt && { x: nt } @@ -52,8 +66,8 @@ function conditionalSpreadNumber(nt: number): { x?: number | undefined, y: numbe let o2 = { ...nt && { x: nt }} return o; } -function conditionalSpreadString(st: string): { x?: string | undefined, y: number } { - let o = { x: 'hi', y: 13 } +function conditionalSpreadString(st: string): { x: string, y: number } { + let o = { x: 'hi', y: 17 } o = { ...o, ...st && { x: st } @@ -61,8 +75,6 @@ function conditionalSpreadString(st: string): { x?: string | undefined, y: numbe let o2 = { ...st && { x: st }} return o; } -// other booleans result in { } -let spreadBool = { ... true } // any results in any let anything: any; diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index 8fe9174f759..b6e7c5b88c9 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -29,7 +29,13 @@ spread = b; // error, missing 's' let duplicated = { b: 'bad', ...o, b: 'bad', ...o2, b: 'bad' } let duplicatedSpread = { ...o, ...o } -// primitives are skipped +// primitives are not allowed, except for falsy ones +let spreadNum = { ...12 }; +let spreadSum = { ...1 + 1 }; +let spreadZero = { ...0 }; +spreadZero.toFixed(); // error, no methods even from a falsy number +let spreadBool = { ...true }; +spreadBool.valueOf(); let spreadStr = { ...'foo' }; spreadStr.length; // error, no 'length' spreadStr.charAt(1); // error, no methods either diff --git a/tests/cases/conformance/types/spread/spreadUnion2.ts b/tests/cases/conformance/types/spread/spreadUnion2.ts index 17abdd4006a..549441be411 100644 --- a/tests/cases/conformance/types/spread/spreadUnion2.ts +++ b/tests/cases/conformance/types/spread/spreadUnion2.ts @@ -2,7 +2,6 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; -declare const nullAndUndefinedUnion: null | undefined; var o1: { a?: number | undefined }; var o1 = { ...undefinedUnion }; @@ -20,5 +19,3 @@ var o4 = { ...undefinedUnion, ...undefinedUnion }; var o5: { b?: number | undefined }; var o5 = { ...nullUnion, ...nullUnion }; -var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; -var o7 = { ...nullAndUndefinedUnion }; diff --git a/tests/cases/conformance/types/spread/spreadUnion3.ts b/tests/cases/conformance/types/spread/spreadUnion3.ts index c16acbdf7d3..42ad1a1c652 100644 --- a/tests/cases/conformance/types/spread/spreadUnion3.ts +++ b/tests/cases/conformance/types/spread/spreadUnion3.ts @@ -12,3 +12,8 @@ function g(t?: { a: number } | null): void { g() g(undefined) g(null) + +// spreading nothing but null and undefined is not allowed +declare const nullAndUndefinedUnion: null | undefined; +var x = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion }; +var y = { ...nullAndUndefinedUnion }; From 0197357e31007a1ff63290253a9ee269c5f96542 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 15 Sep 2017 10:28:13 -0700 Subject: [PATCH 180/216] Remove mistakenly added test file Intended for a different PR --- .../narrowContextualTypeOfObjectLiteral2.ts | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 tests/cases/compiler/narrowContextualTypeOfObjectLiteral2.ts diff --git a/tests/cases/compiler/narrowContextualTypeOfObjectLiteral2.ts b/tests/cases/compiler/narrowContextualTypeOfObjectLiteral2.ts deleted file mode 100644 index 2a199b74bd7..00000000000 --- a/tests/cases/compiler/narrowContextualTypeOfObjectLiteral2.ts +++ /dev/null @@ -1,21 +0,0 @@ -interface X { - type1: 'x'; - value: string; -} - -interface Y { - type2: 'y'; - value: 'none' | 'done'; -} - -function foo(bar: X | Y) { } - -foo({ - type2: 'y', - value: 'done', -}); -// you could do this (amybe) by noting that -// (1) the argument is a fresh object literal -// (2) of X | Y, the object literal is only assignable to Y -// - you can do *that* cheaply (ie, symbolically) just by throwing out types -// that are missing one of the fields in the object literal From 74139186ed6db214dcae39b019f5d29fc245a77a Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 15 Sep 2017 10:28:20 -0700 Subject: [PATCH 181/216] Re-enable extraction of single tokens Now that we explicitly prevent extraction of empty spans. --- src/services/refactors/extractMethod.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 9ea3d9d11bd..3b8ea19a9f0 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -92,7 +92,7 @@ namespace ts.refactor.extractMethod { export const CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators: DiagnosticMessage = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); export const TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); export const FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); - export const InsufficientSelection = createMessage("Select more than a single token."); + export const InsufficientSelection = createMessage("Select more than a single identifier."); export const CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); export const CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); export const CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); @@ -231,7 +231,7 @@ namespace ts.refactor.extractMethod { } function checkRootNode(node: Node): Diagnostic[] | undefined { - if (isToken(isExpressionStatement(node) ? node.expression : node)) { + if (isIdentifier(isExpressionStatement(node) ? node.expression : node)) { return [createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; From 7781245f1e9994c992161699d5f832d5131d2753 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 15 Sep 2017 10:38:05 -0700 Subject: [PATCH 182/216] Move RegionRange to private scope --- src/compiler/types.ts | 4 ---- src/services/outliningElementsCollector.ts | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4bf180c595a..608bc779042 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2037,10 +2037,6 @@ namespace ts { end: -1; } - export interface RegionRange extends TextRange { - name?: string; - } - // represents a top level: { type } expression in a JSDoc comment. export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index d4f70d52eda..20456b5241b 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -6,6 +6,10 @@ namespace ts.OutliningElementsCollector { const regionStart = new RegExp("^//\\s*#region(\\s+.*)?$"); const regionEnd = new RegExp("^//\\s*#endregion(\\s|$)"); + interface RegionRange extends TextRange { + name?: string; + } + export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; let depth = 0; From abd4f58824e2c3b09a486dfcfe2b5f42bc33e938 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 15 Sep 2017 10:45:15 -0700 Subject: [PATCH 183/216] Restore single-token tests --- ...d-not-for-token.ts => extract-method-not-for-empty.ts} | 0 tests/cases/fourslash/extract-method13.ts | 8 ++++---- tests/cases/fourslash/extract-method7.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename tests/cases/fourslash/{extract-method-not-for-token.ts => extract-method-not-for-empty.ts} (100%) diff --git a/tests/cases/fourslash/extract-method-not-for-token.ts b/tests/cases/fourslash/extract-method-not-for-empty.ts similarity index 100% rename from tests/cases/fourslash/extract-method-not-for-token.ts rename to tests/cases/fourslash/extract-method-not-for-empty.ts diff --git a/tests/cases/fourslash/extract-method13.ts b/tests/cases/fourslash/extract-method13.ts index 274753fd5cd..409b5f890ad 100644 --- a/tests/cases/fourslash/extract-method13.ts +++ b/tests/cases/fourslash/extract-method13.ts @@ -5,7 +5,7 @@ //// class C { //// static j = /*c*/1 + 1/*d*/; -//// constructor(q: string = /*a*/"a" + "b"/*b*/) { +//// constructor(q: string = /*a*/"hello"/*b*/) { //// } //// } @@ -21,7 +21,7 @@ edit.applyRefactor({ } private static newFunction(): string { - return "a" + "b"; + return "hello"; } }` }); @@ -32,7 +32,7 @@ verify.currentFileContentIs(`class C { } private static newFunction(): string { - return "a" + "b"; + return "hello"; } }`); @@ -52,7 +52,7 @@ edit.applyRefactor({ } private static newFunction(): string { - return "a" + "b"; + return "hello"; } }` }); diff --git a/tests/cases/fourslash/extract-method7.ts b/tests/cases/fourslash/extract-method7.ts index c28e12dce8c..0ce39c5a309 100644 --- a/tests/cases/fourslash/extract-method7.ts +++ b/tests/cases/fourslash/extract-method7.ts @@ -3,7 +3,7 @@ // You cannot extract a function initializer into the function's body. // The innermost scope (scope_0) is the sibling of the function, not the function itself. -//// function fn(x = /*a*/1 + 1/*b*/) { +//// function fn(x = /*a*/3/*b*/) { //// } goTo.select('a', 'b'); @@ -15,7 +15,7 @@ edit.applyRefactor({ `function fn(x = /*RENAME*/newFunction()) { } function newFunction() { - return 1 + 1; + return 3; } ` }); From 11333a7bc2599d6bb761936f7b5522a9b844a1e9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 15 Sep 2017 10:45:20 -0700 Subject: [PATCH 184/216] Conditional declaration (#18506) --- src/harness/parallel/host.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts index 58e794bbc7d..a3a1ec8082b 100644 --- a/src/harness/parallel/host.ts +++ b/src/harness/parallel/host.ts @@ -1,7 +1,7 @@ -// tslint:disable-next-line -var describe: Mocha.IContextDefinition; // If launched without mocha for parallel mode, we still need a global describe visible to satisfy the parsing of the unit tests -// tslint:disable-next-line -var it: Mocha.ITestDefinition; +if (typeof describe === "undefined") { + (global as any).describe = undefined; // If launched without mocha for parallel mode, we still need a global describe visible to satisfy the parsing of the unit tests + (global as any).it = undefined; +} namespace Harness.Parallel.Host { interface ChildProcessPartial { From 965a4d5aeb61610c97a8fec1e0cc2e7d9980e51e Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 15 Sep 2017 11:33:05 -0700 Subject: [PATCH 185/216] Restructure handling to TI messages to enforce exhaustiveness --- src/server/server.ts | 160 +++++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 74 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index fe83e879433..8849b5f3a8d 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -380,84 +380,96 @@ namespace ts.server { this.logger.info(`Received response: ${JSON.stringify(response)}`); } - if (response.kind === EventInitializationFailed) { - if (!this.eventSender) { - return; - } - const body: protocol.TypesInstallerInitializationFailedEventBody = { - message: response.message - }; - const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; - this.eventSender.event(body, eventName); - return; - } - - if (response.kind === EventBeginInstallTypes) { - if (!this.eventSender) { - return; - } - const body: protocol.BeginInstallTypesEventBody = { - eventId: response.eventId, - packages: response.packagesToInstall, - }; - const eventName: protocol.BeginInstallTypesEventName = "beginInstallTypes"; - this.eventSender.event(body, eventName); - - return; - } - - if (response.kind === EventEndInstallTypes) { - if (!this.eventSender) { - return; - } - if (this.telemetryEnabled) { - const body: protocol.TypingsInstalledTelemetryEventBody = { - telemetryEventName: "typingsInstalled", - payload: { - installedPackages: response.packagesToInstall.join(","), - installSuccess: response.installSuccess, - typingsInstallerVersion: response.typingsInstallerVersion - } - }; - const eventName: protocol.TelemetryEventName = "telemetry"; - this.eventSender.event(body, eventName); - } - - const body: protocol.EndInstallTypesEventBody = { - eventId: response.eventId, - packages: response.packagesToInstall, - success: response.installSuccess, - }; - const eventName: protocol.EndInstallTypesEventName = "endInstallTypes"; - this.eventSender.event(body, eventName); - return; - } - - if (response.kind === ActionSet) { - if (this.activeRequestCount > 0) { - this.activeRequestCount--; - } - else { - Debug.fail("Received too many responses"); - } - - while (this.requestQueue.length > 0) { - const queuedRequest = this.requestQueue.shift(); - if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { - this.requestMap.delete(queuedRequest.operationId); - this.scheduleRequest(queuedRequest); + switch (response.kind) { + case EventInitializationFailed: + { + if (!this.eventSender) { break; } - - if (this.logger.hasLevel(LogLevel.verbose)) { - this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); - } + const body: protocol.TypesInstallerInitializationFailedEventBody = { + message: response.message + }; + const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; + this.eventSender.event(body, eventName); + break; } - } + case EventBeginInstallTypes: + { + if (!this.eventSender) { + break; + } + const body: protocol.BeginInstallTypesEventBody = { + eventId: response.eventId, + packages: response.packagesToInstall, + }; + const eventName: protocol.BeginInstallTypesEventName = "beginInstallTypes"; + this.eventSender.event(body, eventName); + break; + } + case EventEndInstallTypes: + { + if (!this.eventSender) { + break; + } + if (this.telemetryEnabled) { + const body: protocol.TypingsInstalledTelemetryEventBody = { + telemetryEventName: "typingsInstalled", + payload: { + installedPackages: response.packagesToInstall.join(","), + installSuccess: response.installSuccess, + typingsInstallerVersion: response.typingsInstallerVersion + } + }; + const eventName: protocol.TelemetryEventName = "telemetry"; + this.eventSender.event(body, eventName); + } - this.projectService.updateTypingsForProject(response); - if (response.kind === ActionSet && this.socket) { - this.sendEvent(0, "setTypings", response); + const body: protocol.EndInstallTypesEventBody = { + eventId: response.eventId, + packages: response.packagesToInstall, + success: response.installSuccess, + }; + const eventName: protocol.EndInstallTypesEventName = "endInstallTypes"; + this.eventSender.event(body, eventName); + break; + } + case ActionInvalidate: + { + this.projectService.updateTypingsForProject(response); + break; + } + case ActionSet: + { + if (this.activeRequestCount > 0) { + this.activeRequestCount--; + } + else { + Debug.fail("Received too many responses"); + } + + while (this.requestQueue.length > 0) { + const queuedRequest = this.requestQueue.shift(); + if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { + this.requestMap.delete(queuedRequest.operationId); + this.scheduleRequest(queuedRequest); + break; + } + + if (this.logger.hasLevel(LogLevel.verbose)) { + this.logger.info(`Skipping defunct request for: ${queuedRequest.operationId}`); + } + } + + this.projectService.updateTypingsForProject(response); + + if (this.socket) { + this.sendEvent(0, "setTypings", response); + } + + break; + } + default: + assertTypeIsNever(response); } } From 7ba140445d7cde3effd76d52ec6538339a741a52 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 15 Sep 2017 13:58:49 -0700 Subject: [PATCH 186/216] Fix broken test --- src/harness/unittests/extractMethods.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index ca77af61c75..6d8eed3b8b0 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -410,7 +410,7 @@ function test(x: number) { "Statement or expression expected." ]); - testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single token."]); + testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single identifier."]); testExtractMethod("extractMethod1", `namespace A { From 3dfeb2d0f4274169e2974abe52e4213d666304d3 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 15 Sep 2017 15:33:34 -0700 Subject: [PATCH 187/216] Combine and simplify regex --- src/services/outliningElementsCollector.ts | 63 ++++++------------- .../fourslash/getOutliningSpansForRegions.ts | 5 ++ 2 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 20456b5241b..e215663372b 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -3,8 +3,7 @@ namespace ts.OutliningElementsCollector { const collapseText = "..."; const maxDepth = 20; const defaultLabel = "#region"; - const regionStart = new RegExp("^//\\s*#region(\\s+.*)?$"); - const regionEnd = new RegExp("^//\\s*#endregion(\\s|$)"); + const regionMatch = new RegExp("^\\s*//\\s*(#region|#endregion)(?:\\s+(.*))?$"); interface RegionRange extends TextRange { name?: string; @@ -111,55 +110,31 @@ namespace ts.OutliningElementsCollector { return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction; } - function getRegionName(start: number, end: number) { - if (!isInComment(sourceFile, start)) { - const comment = sourceFile.text.substring(start, end).trim(); - const result = comment.match(regionStart); - - if (result && result.length > 0) { - const label = result.pop(); - if (label) { - return label.trim(); - } - else { - return defaultLabel; - } - } - } - return ""; - } - - function isRegionEnd(start: number, end: number) { - if (!isInComment(sourceFile, start)) { - const comment = sourceFile.text.substring(start, end).trim(); - return !!comment.match(regionEnd); - } - return false; - } - function gatherRegions(): void { const lineStarts = sourceFile.getLineStarts(); for (let i = 0; i < lineStarts.length; i++) { const currentLineStart = lineStarts[i]; const lineEnd = lineStarts[i + 1] - 1 || sourceFile.getEnd(); + const comment = sourceFile.text.substring(currentLineStart, lineEnd); + const result = comment.match(regionMatch); - const name = getRegionName(currentLineStart, lineEnd); - if (name) { - const start = sourceFile.getFullText().indexOf("//", currentLineStart); - const region: RegionRange = { - pos: start, - end: lineEnd, - name, - }; - regions.push(region); - } - else if (isRegionEnd(currentLineStart, lineEnd)) { - const region = regions.pop(); - - if (region) { - region.end = lineEnd; - addOutliningSpanRegions(region); + if (result && !isInComment(sourceFile, currentLineStart)) { + if (result[1] === "#region") { + const start = sourceFile.getFullText().indexOf("//", currentLineStart); + const region: RegionRange = { + pos: start, + end: lineEnd, + name: result[2] || defaultLabel, + }; + regions.push(region); + } + else { + const region = regions.pop(); + if (region) { + region.end = lineEnd; + addOutliningSpanRegions(region); + } } } } diff --git a/tests/cases/fourslash/getOutliningSpansForRegions.ts b/tests/cases/fourslash/getOutliningSpansForRegions.ts index 151526c6b99..fcd71e29ef1 100644 --- a/tests/cases/fourslash/getOutliningSpansForRegions.ts +++ b/tests/cases/fourslash/getOutliningSpansForRegions.ts @@ -5,6 +5,11 @@ //// ////// #endregion|] //// +////// region without label with trailing spaces +////[|// #region +//// +////// #endregion|] +//// ////// region with label ////[|// #region label1 //// From cb8d9d6143c2d50b79e330599acff88ec20ac0b1 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 15 Sep 2017 16:11:41 -0700 Subject: [PATCH 188/216] Revert spread-falsy-union/fix spread of primitive Turns out partialising falsy unions wasn't needed -- I was just returning the wrong thing when spreading primitives. --- src/compiler/checker.ts | 36 ++++-------- tests/baselines/reference/objectSpread.types | 30 +++++----- .../reference/objectSpreadNegative.errors.txt | 4 +- tests/baselines/reference/spreadUnion2.js | 10 ++-- .../baselines/reference/spreadUnion2.symbols | 24 ++++---- tests/baselines/reference/spreadUnion2.types | 58 ++++++++++--------- .../reference/spreadUnion3.errors.txt | 22 +++---- .../conformance/types/spread/spreadUnion2.ts | 10 ++-- 8 files changed, 92 insertions(+), 102 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b55c592784..62d44d160a7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7846,7 +7846,6 @@ namespace ts { * and right = the new element to be spread. */ function getSpreadType(left: Type, right: Type): Type { - let truthyRight: Type; if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) { return anyType; } @@ -7860,16 +7859,13 @@ namespace ts { return mapType(left, t => getSpreadType(t, right)); } if (right.flags & TypeFlags.Union) { - truthyRight = getTruthyTypeFromFalsyUnion(right as UnionType); - if (!truthyRight || truthyRight.flags & TypeFlags.Union) { - return mapType(right, t => getSpreadType(left, t)); - } - else { - right = truthyRight; - } + return mapType(right, t => getSpreadType(left, t)); } - if (right.flags & (TypeFlags.NonPrimitive | TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.EnumLike)) { - return emptyObjectType; + if (right.flags & TypeFlags.NonPrimitive) { + return nonPrimitiveType; + } + if (right.flags & (TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.EnumLike)) { + return left; } const members = createSymbolTable(); @@ -7893,7 +7889,7 @@ namespace ts { skippedPrivateMembers.set(rightProp.escapedName, true); } else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { - members.set(rightProp.escapedName, getSymbolOfSpreadProperty(rightProp, !!truthyRight)); + members.set(rightProp.escapedName, getNonReadonlySymbol(rightProp)); } } @@ -7918,22 +7914,19 @@ namespace ts { } } else { - members.set(leftProp.escapedName, getSymbolOfSpreadProperty(leftProp, /*makeOptional*/ false)); + members.set(leftProp.escapedName, getNonReadonlySymbol(leftProp)); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } - function getSymbolOfSpreadProperty(prop: Symbol, makeOptional: boolean) { - if (!isReadonlySymbol(prop) && (!makeOptional || prop.flags & SymbolFlags.Optional)) { + function getNonReadonlySymbol(prop: Symbol) { + if (!isReadonlySymbol(prop)) { return prop; } - const flags = SymbolFlags.Property | (makeOptional ? SymbolFlags.Optional : prop.flags & SymbolFlags.Optional); + const flags = SymbolFlags.Property | (prop.flags & SymbolFlags.Optional); const result = createSymbol(flags, prop.escapedName); result.type = getTypeOfSymbol(prop); - if (makeOptional) { - result.type = getUnionType([result.type, undefinedType]); - } result.declarations = prop.declarations; result.syntheticOrigin = prop; return result; @@ -7943,13 +7936,6 @@ namespace ts { return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent)); } - function getTruthyTypeFromFalsyUnion(type: UnionType): Type | undefined { - const truthy = removeDefinitelyFalsyTypes(type); - if (truthy !== type) { - return truthy; - } - } - function createLiteralType(flags: TypeFlags, value: string | number, symbol: Symbol) { const type = createType(flags); type.symbol = symbol; diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index da24a558d51..0caef49f439 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -247,7 +247,7 @@ function from16326(this: { header: Header }, header: Header, authToken: string): >Header : Header return { ->{ ...this.header, ...header, ...authToken && { authToken } } : { authToken: string; head: string; body: string; } +>{ ...this.header, ...header, ...authToken && { authToken } } : { head: string; body: string; authToken: string; } | { authToken: string; head: string; body: string; } ...this.header, >this.header : Header @@ -280,9 +280,9 @@ function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { >13 : 13 o = { ->o = { ...o, ...b && { x: 14 } } : { x: number; y: number; } +>o = { ...o, ...b && { x: 14 } } : { x: number; y: number; } | { x: number; y: number; } >o : { x: number; y: number; } ->{ ...o, ...b && { x: 14 } } : { x: number; y: number; } +>{ ...o, ...b && { x: 14 } } : { x: number; y: number; } | { x: number; y: number; } ...o, >o : { x: number; y: number; } @@ -295,8 +295,8 @@ function conditionalSpreadBoolean(b: boolean) : { x: number, y: number } { >14 : 14 } let o2 = { ...b && { x: 21 }} ->o2 : { x?: number | undefined; } ->{ ...b && { x: 21 }} : { x?: number | undefined; } +>o2 : {} | { x: number; } +>{ ...b && { x: 21 }} : {} | { x: number; } >b && { x: 21 } : false | { x: number; } >b : boolean >{ x: 21 } : { x: number; } @@ -321,9 +321,9 @@ function conditionalSpreadNumber(nt: number): { x: number, y: number } { >16 : 16 o = { ->o = { ...o, ...nt && { x: nt } } : { x: number; y: number; } +>o = { ...o, ...nt && { x: nt } } : { x: number; y: number; } | { x: number; y: number; } >o : { x: number; y: number; } ->{ ...o, ...nt && { x: nt } } : { x: number; y: number; } +>{ ...o, ...nt && { x: nt } } : { x: number; y: number; } | { x: number; y: number; } ...o, >o : { x: number; y: number; } @@ -336,8 +336,8 @@ function conditionalSpreadNumber(nt: number): { x: number, y: number } { >nt : number } let o2 = { ...nt && { x: nt }} ->o2 : { x?: number | undefined; } ->{ ...nt && { x: nt }} : { x?: number | undefined; } +>o2 : {} | { x: number; } +>{ ...nt && { x: nt }} : {} | { x: number; } >nt && { x: nt } : 0 | { x: number; } >nt : number >{ x: nt } : { x: number; } @@ -362,9 +362,9 @@ function conditionalSpreadString(st: string): { x: string, y: number } { >17 : 17 o = { ->o = { ...o, ...st && { x: st } } : { x: string; y: number; } +>o = { ...o, ...st && { x: st } } : { x: string; y: number; } | { x: string; y: number; } >o : { x: string; y: number; } ->{ ...o, ...st && { x: st } } : { x: string; y: number; } +>{ ...o, ...st && { x: st } } : { x: string; y: number; } | { x: string; y: number; } ...o, >o : { x: string; y: number; } @@ -377,8 +377,8 @@ function conditionalSpreadString(st: string): { x: string, y: number } { >st : string } let o2 = { ...st && { x: st }} ->o2 : { x?: string | undefined; } ->{ ...st && { x: st }} : { x?: string | undefined; } +>o2 : {} | { x: string; } +>{ ...st && { x: st }} : {} | { x: string; } >st && { x: st } : "" | { x: string; } >st : string >{ x: st } : { x: string; } @@ -571,8 +571,8 @@ let shortCutted: { a: number, b: string } = { ...o, a } // non primitive let spreadNonPrimitive = { ...{}}; ->spreadNonPrimitive : {} ->{ ...{}} : {} +>spreadNonPrimitive : object +>{ ...{}} : object >{} : object >{} : {} diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 92225755c71..5b78f10f281 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -15,7 +15,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(38,19): error TS269 tests/cases/conformance/types/spread/objectSpreadNegative.ts(43,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/types/spread/objectSpreadNegative.ts(47,12): error TS2339: Property 'b' does not exist on type '{}'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(53,9): error TS2339: Property 'm' does not exist on type '{ p: number; }'. -tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,11): error TS2339: Property 'a' does not exist on type '{}'. +tests/cases/conformance/types/spread/objectSpreadNegative.ts(58,11): error TS2339: Property 'a' does not exist on type 'object'. tests/cases/conformance/types/spread/objectSpreadNegative.ts(62,14): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(65,14): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/objectSpreadNegative.ts(79,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'. @@ -117,7 +117,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(84,7): error TS2322 let spreadObj = { ...obj }; spreadObj.a; // error 'a' is not in {} ~ -!!! error TS2339: Property 'a' does not exist on type '{}'. +!!! error TS2339: Property 'a' does not exist on type 'object'. // generics function f(t: T, u: U) { diff --git a/tests/baselines/reference/spreadUnion2.js b/tests/baselines/reference/spreadUnion2.js index 662b7cd3e46..0ae63266da3 100644 --- a/tests/baselines/reference/spreadUnion2.js +++ b/tests/baselines/reference/spreadUnion2.js @@ -2,20 +2,20 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; -var o1: { a?: number | undefined }; +var o1: {} | { a: number }; var o1 = { ...undefinedUnion }; -var o2: { b?: number | undefined }; +var o2: {} | { b: number }; var o2 = { ...nullUnion }; -var o3: { a?: number | undefined, b?: number | undefined }; +var o3: {} | { a: number } | { b: number } | { a: number, b: number }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; -var o4: { a?: number | undefined }; +var o4: {} | { a: number }; var o4 = { ...undefinedUnion, ...undefinedUnion }; -var o5: { b?: number | undefined }; +var o5: {} | { b: number }; var o5 = { ...nullUnion, ...nullUnion }; diff --git a/tests/baselines/reference/spreadUnion2.symbols b/tests/baselines/reference/spreadUnion2.symbols index 2cc91f2980b..72e373d862d 100644 --- a/tests/baselines/reference/spreadUnion2.symbols +++ b/tests/baselines/reference/spreadUnion2.symbols @@ -7,26 +7,28 @@ declare const nullUnion: { b: number } | null; >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >b : Symbol(b, Decl(spreadUnion2.ts, 1, 26)) -var o1: { a?: number | undefined }; +var o1: {} | { a: number }; >o1 : Symbol(o1, Decl(spreadUnion2.ts, 3, 3), Decl(spreadUnion2.ts, 4, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 3, 9)) +>a : Symbol(a, Decl(spreadUnion2.ts, 3, 14)) var o1 = { ...undefinedUnion }; >o1 : Symbol(o1, Decl(spreadUnion2.ts, 3, 3), Decl(spreadUnion2.ts, 4, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o2: { b?: number | undefined }; +var o2: {} | { b: number }; >o2 : Symbol(o2, Decl(spreadUnion2.ts, 6, 3), Decl(spreadUnion2.ts, 7, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 6, 9)) +>b : Symbol(b, Decl(spreadUnion2.ts, 6, 14)) var o2 = { ...nullUnion }; >o2 : Symbol(o2, Decl(spreadUnion2.ts, 6, 3), Decl(spreadUnion2.ts, 7, 3)) >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) -var o3: { a?: number | undefined, b?: number | undefined }; +var o3: {} | { a: number } | { b: number } | { a: number, b: number }; >o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 9, 9)) ->b : Symbol(b, Decl(spreadUnion2.ts, 9, 33)) +>a : Symbol(a, Decl(spreadUnion2.ts, 9, 14)) +>b : Symbol(b, Decl(spreadUnion2.ts, 9, 30)) +>a : Symbol(a, Decl(spreadUnion2.ts, 9, 46)) +>b : Symbol(b, Decl(spreadUnion2.ts, 9, 57)) var o3 = { ...undefinedUnion, ...nullUnion }; >o3 : Symbol(o3, Decl(spreadUnion2.ts, 9, 3), Decl(spreadUnion2.ts, 10, 3), Decl(spreadUnion2.ts, 11, 3)) @@ -38,18 +40,18 @@ var o3 = { ...nullUnion, ...undefinedUnion }; >nullUnion : Symbol(nullUnion, Decl(spreadUnion2.ts, 1, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o4: { a?: number | undefined }; +var o4: {} | { a: number }; >o4 : Symbol(o4, Decl(spreadUnion2.ts, 13, 3), Decl(spreadUnion2.ts, 14, 3)) ->a : Symbol(a, Decl(spreadUnion2.ts, 13, 9)) +>a : Symbol(a, Decl(spreadUnion2.ts, 13, 14)) var o4 = { ...undefinedUnion, ...undefinedUnion }; >o4 : Symbol(o4, Decl(spreadUnion2.ts, 13, 3), Decl(spreadUnion2.ts, 14, 3)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) >undefinedUnion : Symbol(undefinedUnion, Decl(spreadUnion2.ts, 0, 13)) -var o5: { b?: number | undefined }; +var o5: {} | { b: number }; >o5 : Symbol(o5, Decl(spreadUnion2.ts, 16, 3), Decl(spreadUnion2.ts, 17, 3)) ->b : Symbol(b, Decl(spreadUnion2.ts, 16, 9)) +>b : Symbol(b, Decl(spreadUnion2.ts, 16, 14)) var o5 = { ...nullUnion, ...nullUnion }; >o5 : Symbol(o5, Decl(spreadUnion2.ts, 16, 3), Decl(spreadUnion2.ts, 17, 3)) diff --git a/tests/baselines/reference/spreadUnion2.types b/tests/baselines/reference/spreadUnion2.types index ccf587af591..5077949bc97 100644 --- a/tests/baselines/reference/spreadUnion2.types +++ b/tests/baselines/reference/spreadUnion2.types @@ -8,58 +8,60 @@ declare const nullUnion: { b: number } | null; >b : number >null : null -var o1: { a?: number | undefined }; ->o1 : { a?: number | undefined; } ->a : number | undefined +var o1: {} | { a: number }; +>o1 : {} | { a: number; } +>a : number var o1 = { ...undefinedUnion }; ->o1 : { a?: number | undefined; } ->{ ...undefinedUnion } : { a?: number | undefined; } +>o1 : {} | { a: number; } +>{ ...undefinedUnion } : {} | { a: number; } >undefinedUnion : { a: number; } | undefined -var o2: { b?: number | undefined }; ->o2 : { b?: number | undefined; } ->b : number | undefined +var o2: {} | { b: number }; +>o2 : {} | { b: number; } +>b : number var o2 = { ...nullUnion }; ->o2 : { b?: number | undefined; } ->{ ...nullUnion } : { b?: number | undefined; } +>o2 : {} | { b: number; } +>{ ...nullUnion } : {} | { b: number; } >nullUnion : { b: number; } | null -var o3: { a?: number | undefined, b?: number | undefined }; ->o3 : { a?: number | undefined; b?: number | undefined; } ->a : number | undefined ->b : number | undefined +var o3: {} | { a: number } | { b: number } | { a: number, b: number }; +>o3 : {} | { a: number; } | { b: number; } | { a: number; b: number; } +>a : number +>b : number +>a : number +>b : number var o3 = { ...undefinedUnion, ...nullUnion }; ->o3 : { a?: number | undefined; b?: number | undefined; } ->{ ...undefinedUnion, ...nullUnion } : { b?: number | undefined; a?: number | undefined; } +>o3 : {} | { a: number; } | { b: number; } | { a: number; b: number; } +>{ ...undefinedUnion, ...nullUnion } : {} | { b: number; } | { a: number; } | { b: number; a: number; } >undefinedUnion : { a: number; } | undefined >nullUnion : { b: number; } | null var o3 = { ...nullUnion, ...undefinedUnion }; ->o3 : { a?: number | undefined; b?: number | undefined; } ->{ ...nullUnion, ...undefinedUnion } : { a?: number | undefined; b?: number | undefined; } +>o3 : {} | { a: number; } | { b: number; } | { a: number; b: number; } +>{ ...nullUnion, ...undefinedUnion } : {} | { a: number; } | { b: number; } | { a: number; b: number; } >nullUnion : { b: number; } | null >undefinedUnion : { a: number; } | undefined -var o4: { a?: number | undefined }; ->o4 : { a?: number | undefined; } ->a : number | undefined +var o4: {} | { a: number }; +>o4 : {} | { a: number; } +>a : number var o4 = { ...undefinedUnion, ...undefinedUnion }; ->o4 : { a?: number | undefined; } ->{ ...undefinedUnion, ...undefinedUnion } : { a?: number | undefined; } +>o4 : {} | { a: number; } +>{ ...undefinedUnion, ...undefinedUnion } : {} | { a: number; } | { a: number; } | { a: number; } >undefinedUnion : { a: number; } | undefined >undefinedUnion : { a: number; } | undefined -var o5: { b?: number | undefined }; ->o5 : { b?: number | undefined; } ->b : number | undefined +var o5: {} | { b: number }; +>o5 : {} | { b: number; } +>b : number var o5 = { ...nullUnion, ...nullUnion }; ->o5 : { b?: number | undefined; } ->{ ...nullUnion, ...nullUnion } : { b?: number | undefined; } +>o5 : {} | { b: number; } +>{ ...nullUnion, ...nullUnion } : {} | { b: number; } | { b: number; } | { b: number; } >nullUnion : { b: number; } | null >nullUnion : { b: number; } | null diff --git a/tests/baselines/reference/spreadUnion3.errors.txt b/tests/baselines/reference/spreadUnion3.errors.txt index 24d864d96fe..b7c59697946 100644 --- a/tests/baselines/reference/spreadUnion3.errors.txt +++ b/tests/baselines/reference/spreadUnion3.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ y: string | number; }' is not assignable to type '{ y: string; }'. - Types of property 'y' are incompatible. - Type 'string | number' is not assignable to type 'string'. +tests/cases/conformance/types/spread/spreadUnion3.ts(2,5): error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'. + Type '{ y: number; }' is not assignable to type '{ y: string; }'. + Types of property 'y' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/spread/spreadUnion3.ts(9,9): error TS2322: Type 'number | undefined' is not assignable to type 'number'. - Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/types/spread/spreadUnion3.ts(9,23): error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. + Property 'a' does not exist on type '{}'. tests/cases/conformance/types/spread/spreadUnion3.ts(17,11): error TS2698: Spread types may only be created from object types. tests/cases/conformance/types/spread/spreadUnion3.ts(18,11): error TS2698: Spread types may only be created from object types. @@ -12,9 +12,9 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(18,11): error TS2698: Sprea function f(x: { y: string } | undefined): { y: string } { return { y: 123, ...x } // y: string | number ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ y: string | number; }' is not assignable to type '{ y: string; }'. -!!! error TS2322: Types of property 'y' are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type '{ y: number; } | { y: string; }' is not assignable to type '{ y: string; }'. +!!! error TS2322: Type '{ y: number; }' is not assignable to type '{ y: string; }'. +!!! error TS2322: Types of property 'y' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. } f(undefined) @@ -23,9 +23,9 @@ tests/cases/conformance/types/spread/spreadUnion3.ts(18,11): error TS2698: Sprea function g(t?: { a: number } | null): void { let b = { ...t }; let c: number = b.a; // might not have 'a' - ~ -!!! error TS2322: Type 'number | undefined' is not assignable to type 'number'. -!!! error TS2322: Type 'undefined' is not assignable to type 'number'. + ~ +!!! error TS2339: Property 'a' does not exist on type '{} | {} | { a: number; }'. +!!! error TS2339: Property 'a' does not exist on type '{}'. } g() g(undefined) diff --git a/tests/cases/conformance/types/spread/spreadUnion2.ts b/tests/cases/conformance/types/spread/spreadUnion2.ts index 549441be411..5fbca1d4bf2 100644 --- a/tests/cases/conformance/types/spread/spreadUnion2.ts +++ b/tests/cases/conformance/types/spread/spreadUnion2.ts @@ -3,19 +3,19 @@ declare const undefinedUnion: { a: number } | undefined; declare const nullUnion: { b: number } | null; -var o1: { a?: number | undefined }; +var o1: {} | { a: number }; var o1 = { ...undefinedUnion }; -var o2: { b?: number | undefined }; +var o2: {} | { b: number }; var o2 = { ...nullUnion }; -var o3: { a?: number | undefined, b?: number | undefined }; +var o3: {} | { a: number } | { b: number } | { a: number, b: number }; var o3 = { ...undefinedUnion, ...nullUnion }; var o3 = { ...nullUnion, ...undefinedUnion }; -var o4: { a?: number | undefined }; +var o4: {} | { a: number }; var o4 = { ...undefinedUnion, ...undefinedUnion }; -var o5: { b?: number | undefined }; +var o5: {} | { b: number }; var o5 = { ...nullUnion, ...nullUnion }; From 484bd2082ee8f92d4d604ae610afe654ff9ab8b1 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 15 Sep 2017 16:15:32 -0700 Subject: [PATCH 189/216] Refactored out RegionRange --- src/services/outliningElementsCollector.ts | 35 +++++++--------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index e215663372b..f5c9754cea8 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -5,14 +5,10 @@ namespace ts.OutliningElementsCollector { const defaultLabel = "#region"; const regionMatch = new RegExp("^\\s*//\\s*(#region|#endregion)(?:\\s+(.*))?$"); - interface RegionRange extends TextRange { - name?: string; - } - export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; let depth = 0; - const regions: RegionRange[] = []; + const regions: OutliningSpan[] = []; walk(sourceFile); gatherRegions(); @@ -43,19 +39,6 @@ namespace ts.OutliningElementsCollector { } } - function addOutliningSpanRegions(regionSpan: RegionRange) { - if (regionSpan) { - const textSpan = createTextSpanFromRange(regionSpan); - const span: OutliningSpan = { - textSpan, - hintSpan: textSpan, - bannerText: regionSpan.name, - autoCollapse: false, - }; - elements.push(span); - } - } - function addOutliningForLeadingCommentsForNode(n: Node) { const comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); @@ -122,18 +105,22 @@ namespace ts.OutliningElementsCollector { if (result && !isInComment(sourceFile, currentLineStart)) { if (result[1] === "#region") { const start = sourceFile.getFullText().indexOf("//", currentLineStart); - const region: RegionRange = { - pos: start, - end: lineEnd, - name: result[2] || defaultLabel, + const textSpan = createTextSpanFromBounds(start, lineEnd); + const region: OutliningSpan = { + textSpan, + hintSpan: textSpan, + bannerText: result[2] || defaultLabel, + autoCollapse: false }; regions.push(region); } else { const region = regions.pop(); if (region) { - region.end = lineEnd; - addOutliningSpanRegions(region); + const newTextSpan = createTextSpanFromBounds(region.textSpan.start, lineEnd); + region.textSpan = newTextSpan; + region.hintSpan = newTextSpan; + elements.push(region); } } } From e5c43cddb74406cf3df59f672ce99ca866ffd83d Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 15 Sep 2017 16:47:59 -0700 Subject: [PATCH 190/216] Remove extra OutliningSpan and simplify regex --- src/services/outliningElementsCollector.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index f5c9754cea8..03ae0529ca9 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -3,7 +3,7 @@ namespace ts.OutliningElementsCollector { const collapseText = "..."; const maxDepth = 20; const defaultLabel = "#region"; - const regionMatch = new RegExp("^\\s*//\\s*(#region|#endregion)(?:\\s+(.*))?$"); + const regionMatch = new RegExp("^\\s*//\\s*#(end)?region(?:\\s+(.*))?$"); export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; @@ -103,7 +103,7 @@ namespace ts.OutliningElementsCollector { const result = comment.match(regionMatch); if (result && !isInComment(sourceFile, currentLineStart)) { - if (result[1] === "#region") { + if (!result[1]) { const start = sourceFile.getFullText().indexOf("//", currentLineStart); const textSpan = createTextSpanFromBounds(start, lineEnd); const region: OutliningSpan = { @@ -117,9 +117,8 @@ namespace ts.OutliningElementsCollector { else { const region = regions.pop(); if (region) { - const newTextSpan = createTextSpanFromBounds(region.textSpan.start, lineEnd); - region.textSpan = newTextSpan; - region.hintSpan = newTextSpan; + region.textSpan.length = lineEnd - region.textSpan.start; + region.hintSpan.length = lineEnd - region.textSpan.start; elements.push(region); } } From 79e12eb48b33e0fbcf0c9e85dd27e41a0de2bf00 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 18 Sep 2017 10:05:44 -0700 Subject: [PATCH 191/216] Ensure that emitter calls callbacks for empty blocks (#18547) --- src/compiler/emitter.ts | 51 ++++++------------- .../convertToEs6Class_emptyCatchClause.ts | 20 ++++++++ .../extract-method-empty-namespace.ts | 22 ++++++++ 3 files changed, 57 insertions(+), 36 deletions(-) create mode 100644 tests/cases/fourslash/convertToEs6Class_emptyCatchClause.ts create mode 100644 tests/cases/fourslash/extract-method-empty-namespace.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 2c6eef3672f..502329bbd84 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1440,29 +1440,18 @@ namespace ts { // function emitBlock(node: Block) { - if (isSingleLineEmptyBlock(node)) { - writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); - write(" "); - writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); - } - else { - writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); - emitBlockStatements(node); - // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted - increaseIndent(); - emitLeadingCommentsOfPosition(node.statements.end); - decreaseIndent(); - writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); - } + writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); + emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); + writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); } - function emitBlockStatements(node: BlockLike) { - if (getEmitFlags(node) & EmitFlags.SingleLine) { - emitList(node, node.statements, ListFormat.SingleLineBlockStatements); - } - else { - emitList(node, node.statements, ListFormat.MultiLineBlockStatements); - } + function emitBlockStatements(node: BlockLike, forceSingleLine: boolean) { + const format = forceSingleLine || getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineBlockStatements : ListFormat.MultiLineBlockStatements; + emitList(node, node.statements, format); } function emitVariableStatement(node: VariableStatement) { @@ -1889,16 +1878,11 @@ namespace ts { } function emitModuleBlock(node: ModuleBlock) { - if (isEmptyBlock(node)) { - write("{ }"); - } - else { - pushNameGenerationScope(); - write("{"); - emitBlockStatements(node); - write("}"); - popNameGenerationScope(); - } + pushNameGenerationScope(); + write("{"); + emitBlockStatements(node, /*forceSingleLine*/ isEmptyBlock(node)); + write("}"); + popNameGenerationScope(); } function emitCaseBlock(node: CaseBlock) { @@ -2762,11 +2746,6 @@ namespace ts { && !rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } - function isSingleLineEmptyBlock(block: Block) { - return !block.multiLine - && isEmptyBlock(block); - } - function isEmptyBlock(block: BlockLike) { return block.statements.length === 0 && rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); diff --git a/tests/cases/fourslash/convertToEs6Class_emptyCatchClause.ts b/tests/cases/fourslash/convertToEs6Class_emptyCatchClause.ts new file mode 100644 index 00000000000..e9027178aa7 --- /dev/null +++ b/tests/cases/fourslash/convertToEs6Class_emptyCatchClause.ts @@ -0,0 +1,20 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: /a.js +////function /**/MyClass() {} +////MyClass.prototype.foo = function() { +//// try {} catch() {} +////} + +verify.applicableRefactorAvailableAtMarker(""); +verify.fileAfterApplyingRefactorAtMarker("", +`class MyClass { + constructor() { } + foo() { + try { } + catch () { } + } +} +`, +'Convert to ES2015 class', 'convert'); diff --git a/tests/cases/fourslash/extract-method-empty-namespace.ts b/tests/cases/fourslash/extract-method-empty-namespace.ts new file mode 100644 index 00000000000..9da3faaf927 --- /dev/null +++ b/tests/cases/fourslash/extract-method-empty-namespace.ts @@ -0,0 +1,22 @@ +/// + +// TODO: GH#18546 +// For now this tests that at least we don't crash. + +////function f() { +//// /*start*/namespace N {}/*end*/ +////} + +goTo.select('start', 'end') +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_1", + actionDescription: "Extract to function in global scope", + newContent: `function f() { + /*RENAME*/newFunction(N); +} +function newFunction(N: any) { + namespace N { } +} +` +}); From fe0ba0c743fb967ec456caf0c758ca991bff4c88 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 18 Sep 2017 11:21:33 -0700 Subject: [PATCH 192/216] fix: Add missing opening quote (#18534) And thank you for this tool! --- src/compiler/diagnosticMessages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8a76ddcda9a..e273950424c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2686,7 +2686,7 @@ "category": "Message", "code": 6015 }, - "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.": { + "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.": { "category": "Message", "code": 6016 }, From 8c2d79caa673bab04a0a2ab6ee387518270b5bfe Mon Sep 17 00:00:00 2001 From: Adrian Leonhard Date: Mon, 18 Sep 2017 21:12:08 +0200 Subject: [PATCH 193/216] TypedArrays: fixed find and findIndex callback param obj type. (#18493) Fixes #18425. --- src/lib/es5.d.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 820a90554ea..e08534d8ba9 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1577,7 +1577,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1588,7 +1588,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1844,7 +1844,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1855,7 +1855,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2111,7 +2111,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2122,7 +2122,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2377,7 +2377,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2388,7 +2388,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2644,7 +2644,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2655,7 +2655,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2911,7 +2911,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2922,7 +2922,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3178,7 +3178,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3189,7 +3189,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3444,7 +3444,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3455,7 +3455,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3712,7 +3712,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3723,7 +3723,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. From 49a73a96860ed7b425eb846e76e2c6bdf3bcbff8 Mon Sep 17 00:00:00 2001 From: Adrian Leonhard Date: Mon, 18 Sep 2017 22:34:03 +0200 Subject: [PATCH 194/216] Removed duplicated JSDoc for TypedArrays and ArrayBuffer. (#18555) I left the docs in es5.d.ts, as that seems to be the main file. Fixes #15883 --- src/lib/es2015.iterable.d.ts | 36 ------------------------ src/lib/es2015.symbol.wellknown.d.ts | 42 ---------------------------- 2 files changed, 78 deletions(-) diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 23e23510d3c..896d6526147 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -209,10 +209,6 @@ interface String { [Symbol.iterator](): IterableIterator; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { [Symbol.iterator](): IterableIterator; /** @@ -241,10 +237,6 @@ interface Int8ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { [Symbol.iterator](): IterableIterator; /** @@ -273,10 +265,6 @@ interface Uint8ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; /** @@ -308,10 +296,6 @@ interface Uint8ClampedArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { [Symbol.iterator](): IterableIterator; /** @@ -342,10 +326,6 @@ interface Int16ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { [Symbol.iterator](): IterableIterator; /** @@ -374,10 +354,6 @@ interface Uint16ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { [Symbol.iterator](): IterableIterator; /** @@ -406,10 +382,6 @@ interface Int32ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { [Symbol.iterator](): IterableIterator; /** @@ -438,10 +410,6 @@ interface Uint32ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { [Symbol.iterator](): IterableIterator; /** @@ -470,10 +438,6 @@ interface Float32ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { [Symbol.iterator](): IterableIterator; /** diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index b7c2610e652..268570ff232 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -240,12 +240,6 @@ interface String { split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; } -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; } @@ -254,74 +248,38 @@ interface DataView { readonly [Symbol.toStringTag]: "DataView"; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { readonly [Symbol.toStringTag]: "Int8Array"; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { readonly [Symbol.toStringTag]: "UInt8Array"; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { readonly [Symbol.toStringTag]: "Int16Array"; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { readonly [Symbol.toStringTag]: "Uint16Array"; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { readonly [Symbol.toStringTag]: "Int32Array"; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { readonly [Symbol.toStringTag]: "Uint32Array"; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { readonly [Symbol.toStringTag]: "Float32Array"; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } From 21bbee4044b792bd835423dbb3db6608ae492d24 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 18 Sep 2017 13:41:37 -0700 Subject: [PATCH 195/216] init progressbar dependencies within host start to avoid execution in a browser context (#18554) --- src/harness/parallel/host.ts | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts index a3a1ec8082b..92e21b5ada3 100644 --- a/src/harness/parallel/host.ts +++ b/src/harness/parallel/host.ts @@ -28,6 +28,7 @@ namespace Harness.Parallel.Host { } export function start() { + initializeProgressBarsDependencies(); console.log("Discovering tests..."); const discoverStart = +(new Date()); const { statSync }: { statSync(path: string): { size: number }; } = require("fs"); @@ -254,14 +255,26 @@ namespace Harness.Parallel.Host { return; } - const Mocha = require("mocha"); - const Base = Mocha.reporters.Base; - const color = Base.color; - const cursor = Base.cursor; - const readline = require("readline"); - const os = require("os"); - const tty: { isatty(x: number): boolean } = require("tty"); - const isatty = tty.isatty(1) && tty.isatty(2); + let Mocha: any; + let Base: any; + let color: any; + let cursor: any; + let readline: any; + let os: any; + let tty: { isatty(x: number): boolean }; + let isatty: boolean; + + function initializeProgressBarsDependencies() { + Mocha = require("mocha"); + Base = Mocha.reporters.Base; + color = Base.color; + cursor = Base.cursor; + readline = require("readline"); + os = require("os"); + tty = require("tty"); + isatty = tty.isatty(1) && tty.isatty(2); + } + class ProgressBars { public readonly _options: Readonly; private _enabled: boolean; From af49c60a2cb415e9481dec58285c497bd7f49fed Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 18 Sep 2017 19:12:06 -0700 Subject: [PATCH 196/216] Stop requiring that the full range of a declaration fall within the selection Fixes #18546 --- src/harness/unittests/extractMethods.ts | 5 +++++ src/services/refactors/extractMethod.ts | 2 +- .../extractMethod/extractMethod33.ts | 19 +++++++++++++++++++ .../extract-method-empty-namespace.ts | 7 ++----- 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/extractMethod/extractMethod33.ts diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts index 6d8eed3b8b0..190cd1d5be0 100644 --- a/src/harness/unittests/extractMethods.ts +++ b/src/harness/unittests/extractMethods.ts @@ -768,6 +768,11 @@ function parsePrimaryExpression(): any { } }|] } +}`); + // Selection excludes leading trivia of declaration + testExtractMethod("extractMethod33", + `function F() { + [#|function G() { }|] }`); }); diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 3b8ea19a9f0..8551ea2eddc 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -1209,7 +1209,7 @@ namespace ts.refactor.extractMethod { if (!declInFile) { return undefined; } - if (rangeContainsRange(enclosingTextRange, declInFile)) { + if (rangeContainsStartEnd(enclosingTextRange, declInFile.getStart(), declInFile.end)) { // declaration is located in range to be extracted - do nothing return undefined; } diff --git a/tests/baselines/reference/extractMethod/extractMethod33.ts b/tests/baselines/reference/extractMethod/extractMethod33.ts new file mode 100644 index 00000000000..79a6626a535 --- /dev/null +++ b/tests/baselines/reference/extractMethod/extractMethod33.ts @@ -0,0 +1,19 @@ +// ==ORIGINAL== +function F() { + function G() { } +} +// ==SCOPE::inner function in function 'F'== +function F() { + /*RENAME*/newFunction(); + + function newFunction() { + function G() { } + } +} +// ==SCOPE::function in global scope== +function F() { + /*RENAME*/newFunction(); +} +function newFunction() { + function G() { } +} diff --git a/tests/cases/fourslash/extract-method-empty-namespace.ts b/tests/cases/fourslash/extract-method-empty-namespace.ts index 9da3faaf927..3a29992350d 100644 --- a/tests/cases/fourslash/extract-method-empty-namespace.ts +++ b/tests/cases/fourslash/extract-method-empty-namespace.ts @@ -1,8 +1,5 @@ /// -// TODO: GH#18546 -// For now this tests that at least we don't crash. - ////function f() { //// /*start*/namespace N {}/*end*/ ////} @@ -13,9 +10,9 @@ edit.applyRefactor({ actionName: "scope_1", actionDescription: "Extract to function in global scope", newContent: `function f() { - /*RENAME*/newFunction(N); + /*RENAME*/newFunction(); } -function newFunction(N: any) { +function newFunction() { namespace N { } } ` From 951974dff61c9c70d817dba50f7bc777a97409ba Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 19 Sep 2017 08:27:31 -0700 Subject: [PATCH 197/216] Use `find` array helper (#18557) * Use `find` array helper * Provide explicit type argument to `find` --- src/services/refactors/extractMethod.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 3b8ea19a9f0..8e97b145aac 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -934,12 +934,8 @@ namespace ts.refactor.extractMethod { * Otherwise, return `undefined`. */ function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { - const children = getStatementsOrClassElements(scope); - for (const child of children) { - if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { - return child; - } - } + return find(getStatementsOrClassElements(scope), child => + child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)); } function getPropertyAssignmentsForWrites(writes: ReadonlyArray): ShorthandPropertyAssignment[] { From 0ae42ea3def8cab3405e55927320d9dbc2ebfcd9 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 19 Sep 2017 12:42:29 -0700 Subject: [PATCH 198/216] Allow relative imports of '.js' files when `--noImplicitAny` is disabled (#18489) * Allow relative imports of '.js' files when `--noImplicitAny` is disabled * Update baselines, and don't ignore a diagnostic about missing JSX --- src/compiler/checker.ts | 4 ++-- src/compiler/diagnosticMessages.json | 4 ---- src/compiler/program.ts | 12 +++++++++--- ...eResolutionWithExtensions_notSupported.errors.txt | 11 ++++------- .../moduleResolutionWithExtensions_notSupported.js | 6 +++--- ...ResolutionWithExtensions_notSupported3.errors.txt | 12 ------------ .../moduleResolutionWithExtensions_notSupported3.js | 2 +- ...uleResolutionWithExtensions_notSupported3.symbols | 4 ++++ ...oduleResolutionWithExtensions_notSupported3.types | 4 ++++ .../moduleResolution_relativeImportJsFile.js | 12 ++++++++++++ .../moduleResolution_relativeImportJsFile.symbols | 4 ++++ .../moduleResolution_relativeImportJsFile.types | 4 ++++ ...ion_relativeImportJsFile_noImplicitAny.errors.txt | 11 +++++++++++ ...eResolution_relativeImportJsFile_noImplicitAny.js | 12 ++++++++++++ .../moduleResolutionWithExtensions_notSupported.ts | 6 +++--- .../moduleResolutionWithExtensions_notSupported3.ts | 2 +- .../moduleResolution_relativeImportJsFile.ts | 7 +++++++ ...eResolution_relativeImportJsFile_noImplicitAny.ts | 8 ++++++++ .../untypedModuleImport_noLocalImports.ts | 9 --------- 19 files changed, 89 insertions(+), 45 deletions(-) delete mode 100644 tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.errors.txt create mode 100644 tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.symbols create mode 100644 tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.types create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile.js create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile.symbols create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile.types create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.errors.txt create mode 100644 tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.js create mode 100644 tests/cases/compiler/moduleResolution_relativeImportJsFile.ts create mode 100644 tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts delete mode 100644 tests/cases/conformance/moduleResolution/untypedModuleImport_noLocalImports.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 70bf20cdbf6..98b7a9d044f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1759,13 +1759,13 @@ namespace ts { } // May be an untyped module. If so, ignore resolutionDiagnostic. - if (resolvedModule && resolvedModule.isExternalLibraryImport && !extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && !extensionIsTypeScript(resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) { if (isForAugmentation) { const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } else if (noImplicitAny && moduleNotFoundError) { - let errorInfo = chainDiagnosticMessages(/*details*/ undefined, + let errorInfo = !resolvedModule.isExternalLibraryImport ? undefined : chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); errorInfo = chainDiagnosticMessages(errorInfo, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e273950424c..662e87d3159 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3146,10 +3146,6 @@ "category": "Error", "code": 6142 }, - "Module '{0}' was resolved to '{1}', but '--allowJs' is not set.": { - "category": "Error", - "code": 6143 - }, "Module '{0}' was resolved as locally declared ambient module in file '{1}'.": { "category": "Message", "code": 6144 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f18d396e9dd..fe0b4c4de36 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1846,7 +1846,8 @@ namespace ts { } const isFromNodeModulesSearch = resolution.isExternalLibraryImport; - const isJsFileFromNodeModules = isFromNodeModulesSearch && !extensionIsTypeScript(resolution.extension); + const isJsFile = !extensionIsTypeScript(resolution.extension); + const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile; const resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { @@ -1861,7 +1862,12 @@ namespace ts { const elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. - const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; + const shouldAddFile = resolvedFileName + && !getResolutionDiagnostic(options, resolution) + && !options.noResolve + && i < file.imports.length + && !elideImport + && !(isJsFile && !options.allowJs); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -2236,7 +2242,7 @@ namespace ts { return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } function needAllowJs() { - return options.allowJs ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + return options.allowJs || !options.noImplicitAny ? undefined : Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } } diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.errors.txt b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.errors.txt index 958837f7a0b..991b83bc306 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.errors.txt +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.errors.txt @@ -1,18 +1,15 @@ /a.ts(1,17): error TS6142: Module './tsx' was resolved to '/tsx.tsx', but '--jsx' is not set. /a.ts(2,17): error TS6142: Module './jsx' was resolved to '/jsx.jsx', but '--jsx' is not set. -/a.ts(3,16): error TS6143: Module './js' was resolved to '/js.js', but '--allowJs' is not set. -==== /a.ts (3 errors) ==== - import tsx from "./tsx"; +==== /a.ts (2 errors) ==== + import tsx from "./tsx"; // Not allowed. ~~~~~~~ !!! error TS6142: Module './tsx' was resolved to '/tsx.tsx', but '--jsx' is not set. - import jsx from "./jsx"; + import jsx from "./jsx"; // Not allowed. ~~~~~~~ !!! error TS6142: Module './jsx' was resolved to '/jsx.jsx', but '--jsx' is not set. - import js from "./js"; - ~~~~~~ -!!! error TS6143: Module './js' was resolved to '/js.js', but '--allowJs' is not set. + import js from "./js"; // OK because it's an untyped module. ==== /tsx.tsx (0 errors) ==== diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js index eb6057f9693..6771a977b35 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported.js @@ -7,9 +7,9 @@ //// [js.js] //// [a.ts] -import tsx from "./tsx"; -import jsx from "./jsx"; -import js from "./js"; +import tsx from "./tsx"; // Not allowed. +import jsx from "./jsx"; // Not allowed. +import js from "./js"; // OK because it's an untyped module. //// [a.js] diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.errors.txt b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.errors.txt deleted file mode 100644 index 45e058bae54..00000000000 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -/a.ts(1,17): error TS6143: Module './jsx' was resolved to '/jsx.jsx', but '--allowJs' is not set. - - -==== /a.ts (1 errors) ==== - import jsx from "./jsx"; - ~~~~~~~ -!!! error TS6143: Module './jsx' was resolved to '/jsx.jsx', but '--allowJs' is not set. - -==== /jsx.jsx (0 errors) ==== - // Test the error message if we have `--jsx` but not `--allowJw`. - - \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js index ca0fa6ca402..1c8a2537e0f 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.js @@ -1,7 +1,7 @@ //// [tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts] //// //// [jsx.jsx] -// Test the error message if we have `--jsx` but not `--allowJw`. +// If we have "--jsx" set and not "--allowJs", it's an implicit-any module. //// [a.ts] diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.symbols b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.symbols new file mode 100644 index 00000000000..071936029fa --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.symbols @@ -0,0 +1,4 @@ +=== /a.ts === +import jsx from "./jsx"; +>jsx : Symbol(jsx, Decl(a.ts, 0, 6)) + diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.types b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.types new file mode 100644 index 00000000000..70fe2e49dbf --- /dev/null +++ b/tests/baselines/reference/moduleResolutionWithExtensions_notSupported3.types @@ -0,0 +1,4 @@ +=== /a.ts === +import jsx from "./jsx"; +>jsx : any + diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile.js b/tests/baselines/reference/moduleResolution_relativeImportJsFile.js new file mode 100644 index 00000000000..94984a414e2 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/moduleResolution_relativeImportJsFile.ts] //// + +//// [b.js] +export const x = 0; + +//// [a.ts] +import * as b from "./b"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile.symbols b/tests/baselines/reference/moduleResolution_relativeImportJsFile.symbols new file mode 100644 index 00000000000..693e1501a11 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile.symbols @@ -0,0 +1,4 @@ +=== /src/a.ts === +import * as b from "./b"; +>b : Symbol(b, Decl(a.ts, 0, 6)) + diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile.types b/tests/baselines/reference/moduleResolution_relativeImportJsFile.types new file mode 100644 index 00000000000..051c4dad861 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile.types @@ -0,0 +1,4 @@ +=== /src/a.ts === +import * as b from "./b"; +>b : any + diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.errors.txt b/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.errors.txt new file mode 100644 index 00000000000..e3d36d4334c --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.errors.txt @@ -0,0 +1,11 @@ +/src/a.ts(1,20): error TS7016: Could not find a declaration file for module './b'. '/src/b.js' implicitly has an 'any' type. + + +==== /src/a.ts (1 errors) ==== + import * as b from "./b"; + ~~~~~ +!!! error TS7016: Could not find a declaration file for module './b'. '/src/b.js' implicitly has an 'any' type. + +==== /src/b.js (0 errors) ==== + export const x = 0; + \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.js b/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.js new file mode 100644 index 00000000000..28b512b91a4 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_relativeImportJsFile_noImplicitAny.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts] //// + +//// [b.js] +export const x = 0; + +//// [a.ts] +import * as b from "./b"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/cases/compiler/moduleResolutionWithExtensions_notSupported.ts b/tests/cases/compiler/moduleResolutionWithExtensions_notSupported.ts index 58b039ad8c2..931c1291e48 100644 --- a/tests/cases/compiler/moduleResolutionWithExtensions_notSupported.ts +++ b/tests/cases/compiler/moduleResolutionWithExtensions_notSupported.ts @@ -8,6 +8,6 @@ // @Filename: /js.js // @Filename: /a.ts -import tsx from "./tsx"; -import jsx from "./jsx"; -import js from "./js"; +import tsx from "./tsx"; // Not allowed. +import jsx from "./jsx"; // Not allowed. +import js from "./js"; // OK because it's an untyped module. diff --git a/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts b/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts index e06f603377c..b665f6932d7 100644 --- a/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts +++ b/tests/cases/compiler/moduleResolutionWithExtensions_notSupported3.ts @@ -1,7 +1,7 @@ // @noImplicitReferences: true // @jsx: preserve // @traceResolution: true -// Test the error message if we have `--jsx` but not `--allowJw`. +// If we have "--jsx" set and not "--allowJs", it's an implicit-any module. // @Filename: /jsx.jsx diff --git a/tests/cases/compiler/moduleResolution_relativeImportJsFile.ts b/tests/cases/compiler/moduleResolution_relativeImportJsFile.ts new file mode 100644 index 00000000000..41b6831d582 --- /dev/null +++ b/tests/cases/compiler/moduleResolution_relativeImportJsFile.ts @@ -0,0 +1,7 @@ +// @noImplicitReferences: true + +// @Filename: /src/b.js +export const x = 0; + +// @Filename: /src/a.ts +import * as b from "./b"; diff --git a/tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts b/tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts new file mode 100644 index 00000000000..cf89af925c3 --- /dev/null +++ b/tests/cases/compiler/moduleResolution_relativeImportJsFile_noImplicitAny.ts @@ -0,0 +1,8 @@ +// @noImplicitReferences: true +// @noImplicitAny: true + +// @Filename: /src/b.js +export const x = 0; + +// @Filename: /src/a.ts +import * as b from "./b"; diff --git a/tests/cases/conformance/moduleResolution/untypedModuleImport_noLocalImports.ts b/tests/cases/conformance/moduleResolution/untypedModuleImport_noLocalImports.ts deleted file mode 100644 index 8313628e6d7..00000000000 --- a/tests/cases/conformance/moduleResolution/untypedModuleImport_noLocalImports.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @noImplicitReferences: true -// @currentDirectory: / -// This tests that untyped module imports don't happen with local imports. - -// @filename: /foo.js -This file is not processed. - -// @filename: /a.ts -import * as foo from "./foo"; From 76ef97449c54b175c061a5b7eccba82d8916c93a Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Tue, 19 Sep 2017 22:18:15 +0100 Subject: [PATCH 199/216] Expand test to ensure property access on object literal has correct behaviour --- .../propertyAccessOnEmptyObjectLiteral.js | 12 -------- ...propertyAccessOnEmptyObjectLiteral.symbols | 9 ------ .../propertyAccessOnEmptyObjectLiteral.types | 13 --------- .../propertyAccessOnObjectLiteral.js | 20 +++++++++++++ .../propertyAccessOnObjectLiteral.symbols | 17 +++++++++++ .../propertyAccessOnObjectLiteral.types | 29 +++++++++++++++++++ .../propertyAccessOnEmptyObjectLiteral.ts | 3 -- .../compiler/propertyAccessOnObjectLiteral.ts | 7 +++++ 8 files changed, 73 insertions(+), 37 deletions(-) delete mode 100644 tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.js delete mode 100644 tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.symbols delete mode 100644 tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.types create mode 100644 tests/baselines/reference/propertyAccessOnObjectLiteral.js create mode 100644 tests/baselines/reference/propertyAccessOnObjectLiteral.symbols create mode 100644 tests/baselines/reference/propertyAccessOnObjectLiteral.types delete mode 100644 tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts create mode 100644 tests/cases/compiler/propertyAccessOnObjectLiteral.ts diff --git a/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.js b/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.js deleted file mode 100644 index f485e4fa618..00000000000 --- a/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.js +++ /dev/null @@ -1,12 +0,0 @@ -//// [propertyAccessOnEmptyObjectLiteral.ts] -class A { } - -({}).toString(); - -//// [propertyAccessOnEmptyObjectLiteral.js] -var A = /** @class */ (function () { - function A() { - } - return A; -}()); -({}).toString(); diff --git a/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.symbols b/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.symbols deleted file mode 100644 index 721cce14900..00000000000 --- a/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.symbols +++ /dev/null @@ -1,9 +0,0 @@ -=== tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts === -class A { } ->A : Symbol(A, Decl(propertyAccessOnEmptyObjectLiteral.ts, 0, 0)) - -({}).toString(); ->({}).toString : Symbol(Object.toString, Decl(lib.d.ts, --, --)) ->A : Symbol(A, Decl(propertyAccessOnEmptyObjectLiteral.ts, 0, 0)) ->toString : Symbol(Object.toString, Decl(lib.d.ts, --, --)) - diff --git a/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.types b/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.types deleted file mode 100644 index ac92f934066..00000000000 --- a/tests/baselines/reference/propertyAccessOnEmptyObjectLiteral.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts === -class A { } ->A : A - -({}).toString(); ->({}).toString() : string ->({}).toString : () => string ->({}) : A ->{} : A ->A : A ->{} : {} ->toString : () => string - diff --git a/tests/baselines/reference/propertyAccessOnObjectLiteral.js b/tests/baselines/reference/propertyAccessOnObjectLiteral.js new file mode 100644 index 00000000000..de584ece44c --- /dev/null +++ b/tests/baselines/reference/propertyAccessOnObjectLiteral.js @@ -0,0 +1,20 @@ +//// [propertyAccessOnObjectLiteral.ts] +class A { } + +({}).toString(); + +(() => { + ({}).toString(); +})(); + + +//// [propertyAccessOnObjectLiteral.js] +var A = /** @class */ (function () { + function A() { + } + return A; +}()); +({}).toString(); +(function () { + ({}).toString(); +})(); diff --git a/tests/baselines/reference/propertyAccessOnObjectLiteral.symbols b/tests/baselines/reference/propertyAccessOnObjectLiteral.symbols new file mode 100644 index 00000000000..5d4dff2dbce --- /dev/null +++ b/tests/baselines/reference/propertyAccessOnObjectLiteral.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/propertyAccessOnObjectLiteral.ts === +class A { } +>A : Symbol(A, Decl(propertyAccessOnObjectLiteral.ts, 0, 0)) + +({}).toString(); +>({}).toString : Symbol(Object.toString, Decl(lib.d.ts, --, --)) +>A : Symbol(A, Decl(propertyAccessOnObjectLiteral.ts, 0, 0)) +>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --)) + +(() => { + ({}).toString(); +>({}).toString : Symbol(Object.toString, Decl(lib.d.ts, --, --)) +>A : Symbol(A, Decl(propertyAccessOnObjectLiteral.ts, 0, 0)) +>toString : Symbol(Object.toString, Decl(lib.d.ts, --, --)) + +})(); + diff --git a/tests/baselines/reference/propertyAccessOnObjectLiteral.types b/tests/baselines/reference/propertyAccessOnObjectLiteral.types new file mode 100644 index 00000000000..6d12af799c8 --- /dev/null +++ b/tests/baselines/reference/propertyAccessOnObjectLiteral.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/propertyAccessOnObjectLiteral.ts === +class A { } +>A : A + +({}).toString(); +>({}).toString() : string +>({}).toString : () => string +>({}) : A +>{} : A +>A : A +>{} : {} +>toString : () => string + +(() => { +>(() => { ({}).toString();})() : void +>(() => { ({}).toString();}) : () => void +>() => { ({}).toString();} : () => void + + ({}).toString(); +>({}).toString() : string +>({}).toString : () => string +>({}) : A +>{} : A +>A : A +>{} : {} +>toString : () => string + +})(); + diff --git a/tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts b/tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts deleted file mode 100644 index 6112f269ee8..00000000000 --- a/tests/cases/compiler/propertyAccessOnEmptyObjectLiteral.ts +++ /dev/null @@ -1,3 +0,0 @@ -class A { } - -({}).toString(); \ No newline at end of file diff --git a/tests/cases/compiler/propertyAccessOnObjectLiteral.ts b/tests/cases/compiler/propertyAccessOnObjectLiteral.ts new file mode 100644 index 00000000000..89f4021e04b --- /dev/null +++ b/tests/cases/compiler/propertyAccessOnObjectLiteral.ts @@ -0,0 +1,7 @@ +class A { } + +({}).toString(); + +(() => { + ({}).toString(); +})(); From 12649516cf0372fbc84561f7986a74713f469dd8 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 19 Sep 2017 14:39:29 -0700 Subject: [PATCH 200/216] navigation tree / bar: Set span of anonymous function to span of VariableDeclaration containing it (#18575) * navigation tree / bar: Set span of anonymous function to span of VariableDeclaration containing it * Add back `isFunctionOrClassExpression` --- src/harness/fourslash.ts | 49 +++++++++--------- src/services/navigationBar.ts | 30 ++++++++--- tests/cases/fourslash/fourslash.ts | 5 +- ...BarAnonymousClassAndFunctionExpressions.ts | 15 ++---- .../navigationBarInitializerSpans.ts | 51 +++++++++++++++++++ .../navigationBarItemsNamedArrowFunctions.ts | 22 +++----- 6 files changed, 112 insertions(+), 60 deletions(-) create mode 100644 tests/cases/fourslash/navigationBarInitializerSpans.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 64e25e0eb9a..f0d335fda3b 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2571,20 +2571,29 @@ namespace FourSlash { } } - public verifyNavigationBar(json: any) { - const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - if (JSON.stringify(items, replacer) !== JSON.stringify(json)) { - this.raiseError(`verifyNavigationBar failed - expected: ${stringify(json)}, got: ${stringify(items, replacer)}`); + public verifyNavigationBar(json: any, options: { checkSpans?: boolean } | undefined) { + this.verifyNavigationTreeOrBar(json, this.languageService.getNavigationBarItems(this.activeFile.fileName), "Bar", options); + } + + public verifyNavigationTree(json: any, options: { checkSpans?: boolean } | undefined) { + this.verifyNavigationTreeOrBar(json, this.languageService.getNavigationTree(this.activeFile.fileName), "Tree", options); + } + + private verifyNavigationTreeOrBar(json: any, tree: any, name: "Tree" | "Bar", options: { checkSpans?: boolean } | undefined) { + if (JSON.stringify(tree, replacer) !== JSON.stringify(json)) { + this.raiseError(`verifyNavigation${name} failed - expected: ${stringify(json)}, got: ${stringify(tree, replacer)}`); } - // Make the data easier to read. function replacer(key: string, value: any) { switch (key) { case "spans": - // We won't ever check this. - return undefined; + return options && options.checkSpans ? value : undefined; + case "start": + case "length": + // Never omit the values in a span, even if they are 0. + return value; case "childItems": - return value.length === 0 ? undefined : value; + return !value || value.length === 0 ? undefined : value; default: // Omit falsy values, those are presumed to be the default. return value || undefined; @@ -2592,18 +2601,6 @@ namespace FourSlash { } } - public verifyNavigationTree(json: any) { - const tree = this.languageService.getNavigationTree(this.activeFile.fileName); - if (JSON.stringify(tree, replacer) !== JSON.stringify(json)) { - this.raiseError(`verifyNavigationTree failed - expected: ${stringify(json)}, got: ${stringify(tree, replacer)}`); - } - - function replacer(key: string, value: any) { - // Don't check "spans", and omit falsy values. - return key === "spans" ? undefined : (value || undefined); - } - } - public printNavigationItems(searchValue: string) { const items = this.languageService.getNavigateToItems(searchValue); Harness.IO.log(`NavigationItems list (${items.length} items)`); @@ -3533,6 +3530,10 @@ namespace FourSlashInterface { return this.state.getRanges(); } + public spans(): ts.TextSpan[] { + return this.ranges().map(r => ts.createTextSpan(r.start, r.end - r.start)); + } + public rangesByText(): ts.Map { return this.state.rangesByText(); } @@ -3966,12 +3967,12 @@ namespace FourSlashInterface { this.state.verifyImportFixAtPosition(expectedTextArray, errorCode); } - public navigationBar(json: any) { - this.state.verifyNavigationBar(json); + public navigationBar(json: any, options?: { checkSpans?: boolean }) { + this.state.verifyNavigationBar(json, options); } - public navigationTree(json: any) { - this.state.verifyNavigationTree(json); + public navigationTree(json: any, options?: { checkSpans?: boolean }) { + this.state.verifyNavigationTree(json, options); } public navigationItemsListCount(count: number, searchValue: string, matchKind?: string, fileName?: string) { diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index f7ed515a18f..bf34f28fed6 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -209,17 +209,24 @@ namespace ts.NavigationBar { case SyntaxKind.BindingElement: case SyntaxKind.VariableDeclaration: - const decl = node; - const name = decl.name; + const { name, initializer } = node; if (isBindingPattern(name)) { addChildrenRecursively(name); } - else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { - // For `const x = function() {}`, just use the function node, not the const. - addChildrenRecursively(decl.initializer); + else if (initializer && isFunctionOrClassExpression(initializer)) { + if (initializer.name) { + // Don't add a node for the VariableDeclaration, just for the initializer. + addChildrenRecursively(initializer); + } + else { + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + forEachChild(initializer, addChildrenRecursively); + endNode(); + } } else { - addNodeWithRecursiveChild(decl, decl.initializer); + addNodeWithRecursiveChild(node, initializer); } break; @@ -644,7 +651,14 @@ namespace ts.NavigationBar { } } - function isFunctionOrClassExpression(node: Node): boolean { - return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction || node.kind === SyntaxKind.ClassExpression; + function isFunctionOrClassExpression(node: Node): node is ArrowFunction | FunctionExpression | ClassExpression { + switch (node.kind) { + case SyntaxKind.ArrowFunction: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ClassExpression: + return true; + default: + return false; + } } } diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 7901d9550cb..b3d29456569 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -114,6 +114,7 @@ declare namespace FourSlashInterface { markerNames(): string[]; marker(name?: string): Marker; ranges(): Range[]; + spans(): Array<{ start: number, length: number }>; rangesByText(): ts.Map; markerByName(s: string): Marker; symbolsInScope(range: Range): any[]; @@ -250,8 +251,8 @@ declare namespace FourSlashInterface { fileAfterApplyingRefactorAtMarker(markerName: string, expectedContent: string, refactorNameToApply: string, formattingOptions?: FormatCodeOptions): void; importFixAtPosition(expectedTextArray: string[], errorCode?: number): void; - navigationBar(json: any): void; - navigationTree(json: any): void; + navigationBar(json: any, options?: { checkSpans?: boolean }): void; + navigationTree(json: any, options?: { checkSpans?: boolean }): void; navigationItemsListCount(count: number, searchValue: string, matchKind?: string, fileName?: string): void; navigationItemsListContains(name: string, kind: string, searchValue: string, matchKind: string, fileName?: string, parentName?: string): void; occurrencesAtPositionContains(range: Range, isWriteAccess?: boolean): void; diff --git a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts index 69fa697f7bc..9a2228c1eaf 100644 --- a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts +++ b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts @@ -46,7 +46,7 @@ verify.navigationTree({ }, { "text": "x", - "kind": "function", + "kind": "const", "childItems": [ { "text": "xx", @@ -90,7 +90,7 @@ verify.navigationTree({ }, { "text": "cls2", - "kind": "class" + "kind": "const" }, { "text": "cls3", @@ -138,7 +138,7 @@ verify.navigationBar([ }, { "text": "x", - "kind": "function" + "kind": "const" }, { "text": "y", @@ -160,7 +160,7 @@ verify.navigationBar([ }, { "text": "x", - "kind": "function", + "kind": "const", "childItems": [ { "text": "xx", @@ -205,7 +205,7 @@ verify.navigationBar([ }, { "text": "cls2", - "kind": "class" + "kind": "const" }, { "text": "cls3", @@ -219,11 +219,6 @@ verify.navigationBar([ "kind": "class", "indent": 2 }, - { - "text": "cls2", - "kind": "class", - "indent": 2 - }, { "text": "cls3", "kind": "class", diff --git a/tests/cases/fourslash/navigationBarInitializerSpans.ts b/tests/cases/fourslash/navigationBarInitializerSpans.ts new file mode 100644 index 00000000000..67752c85577 --- /dev/null +++ b/tests/cases/fourslash/navigationBarInitializerSpans.ts @@ -0,0 +1,51 @@ +/// + +////const [|x = () => 0|]; +////const f = [|function f() {}|]; + +const [s0, s1] = test.spans(); +const sGlobal = { start: 0, length: 45 }; + +verify.navigationTree({ + text: "", + kind: "script", + spans: [sGlobal], + childItems: [ + { + text: "f", + kind: "function", + spans: [s1], + }, + { + text: "x", + kind: "const", + spans: [s0], + }, + ] +}, { checkSpans: true }); + +verify.navigationBar([ + { + text: "", + kind: "script", + spans: [sGlobal], + childItems: [ + { + text: "f", + kind: "function", + spans: [s1], + }, + { + text: "x", + kind: "const", + spans: [s0], + }, + ], + }, + { + text: "f", + kind: "function", + spans: [s1], + indent: 1, + }, +], { checkSpans: true }); diff --git a/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts b/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts index 32abf4092c7..328f205b990 100644 --- a/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts +++ b/tests/cases/fourslash/navigationBarItemsNamedArrowFunctions.ts @@ -17,11 +17,13 @@ verify.navigationBar([ }, { "text": "func", - "kind": "function" + "kind": "const", + "kindModifiers": "export", }, { "text": "func2", - "kind": "function" + "kind": "const", + "kindModifiers": "export", }, { "text": "value", @@ -35,18 +37,6 @@ verify.navigationBar([ "kind": "function", "kindModifiers": "export", "indent": 1 - }, - { - "text": "func", - "kind": "function", - "kindModifiers": "export", - "indent": 1 - }, - { - "text": "func2", - "kind": "function", - "kindModifiers": "export", - "indent": 1 } ]); @@ -61,12 +51,12 @@ verify.navigationTree({ }, { "text": "func", - "kind": "function", + "kind": "const", "kindModifiers": "export" }, { "text": "func2", - "kind": "function", + "kind": "const", "kindModifiers": "export" }, { From 54edde889229c228dda0064327ffa91beae27a6e Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Tue, 19 Sep 2017 23:58:03 +0100 Subject: [PATCH 201/216] Fix property access bug instead by wrapping entire access in brackets Modify parenthesizeExpressionForExpressionStatement to add brackets around an expression statement in which the left-most expression is an object literal. --- src/compiler/factory.ts | 17 ++++++----------- .../reference/propertyAccessOnObjectLiteral.js | 4 ++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index ebb428640da..50004ba0127 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3875,18 +3875,14 @@ namespace ts { */ export function parenthesizeForAccess(expression: Expression): LeftHandSideExpression { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. There are two known exceptions: + // to parenthesize the expression before a dot. The known exception is: // // NewExpression: // new C.x -> not the same as (new C).x // - // ObjectLiteral: - // {a:1}.toString() -> is incorrect syntax, should be ({a:1}).toString() - // const emittedExpression = skipPartiallyEmittedExpressions(expression); if (isLeftHandSideExpression(emittedExpression) - && (!isNewExpression(emittedExpression) || (emittedExpression).arguments) - && !isObjectLiteralExpression(emittedExpression)) { + && (emittedExpression.kind !== SyntaxKind.NewExpression || (emittedExpression).arguments)) { return expression; } @@ -3945,11 +3941,10 @@ namespace ts { return recreateOuterExpressions(expression, mutableCall, OuterExpressionKinds.PartiallyEmittedExpressions); } } - else { - const leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === SyntaxKind.ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind.FunctionExpression) { - return setTextRange(createParen(expression), expression); - } + + const leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === SyntaxKind.ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind.FunctionExpression) { + return setTextRange(createParen(expression), expression); } return expression; diff --git a/tests/baselines/reference/propertyAccessOnObjectLiteral.js b/tests/baselines/reference/propertyAccessOnObjectLiteral.js index de584ece44c..4f1f8b042c9 100644 --- a/tests/baselines/reference/propertyAccessOnObjectLiteral.js +++ b/tests/baselines/reference/propertyAccessOnObjectLiteral.js @@ -14,7 +14,7 @@ var A = /** @class */ (function () { } return A; }()); -({}).toString(); +({}.toString()); (function () { - ({}).toString(); + ({}.toString()); })(); From 5f49357bf658e056674f16a356f63789478c68c1 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 19 Sep 2017 16:52:56 -0700 Subject: [PATCH 202/216] Fix unittest parallel reporting (#18583) * Some tests depended on late execution * Emulate mocha execution order * Polyfill a synchronous done to handle that one unittest * Accpept updates tsconfig baselines fixed by #18534 --- src/harness/parallel/worker.ts | 140 +++++++++++++----- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- 9 files changed, 114 insertions(+), 42 deletions(-) diff --git a/src/harness/parallel/worker.ts b/src/harness/parallel/worker.ts index 34f89d37f13..56f8fd43c58 100644 --- a/src/harness/parallel/worker.ts +++ b/src/harness/parallel/worker.ts @@ -1,52 +1,99 @@ namespace Harness.Parallel.Worker { let errors: ErrorInfo[] = []; let passing = 0; + let reportedUnitTests = false; + + type Executor = {name: string, callback: Function, kind: "suite" | "test"} | never; + function resetShimHarnessAndExecute(runner: RunnerBase) { - errors = []; - passing = 0; + if (reportedUnitTests) { + errors = []; + passing = 0; + testList.length = 0; + } + reportedUnitTests = true; runner.initializeTests(); + testList.forEach(({ name, callback, kind }) => executeCallback(name, callback, kind)); return { errors, passing }; } + + let beforeEachFunc: Function; + const namestack: string[] = []; + let testList: Executor[] = []; function shimMochaHarness() { (global as any).before = undefined; (global as any).after = undefined; (global as any).beforeEach = undefined; - let beforeEachFunc: Function; - describe = ((_name, callback) => { - const fakeContext: Mocha.ISuiteCallbackContext = { - retries() { return this; }, - slow() { return this; }, - timeout() { return this; }, - }; - (before as any) = (cb: Function) => cb(); - let afterFunc: Function; - (after as any) = (cb: Function) => afterFunc = cb; - const savedBeforeEach = beforeEachFunc; - (beforeEach as any) = (cb: Function) => beforeEachFunc = cb; - callback.call(fakeContext); - afterFunc && afterFunc(); - afterFunc = undefined; - beforeEachFunc = savedBeforeEach; + describe = ((name, callback) => { + testList.push({ name, callback, kind: "suite" }); }) as Mocha.IContextDefinition; it = ((name, callback) => { - const fakeContext: Mocha.ITestCallbackContext = { - skip() { return this; }, - timeout() { return this; }, - retries() { return this; }, - slow() { return this; }, - }; - // TODO: If we ever start using async test completions, polyfill the `done` parameter/promise return handling - if (beforeEachFunc) { - try { - beforeEachFunc(); - } - catch (error) { - errors.push({ error: error.message, stack: error.stack, name }); - return; - } + if (!testList) { + throw new Error("Tests must occur within a describe block"); } + testList.push({ name, callback, kind: "test" }); + }) as Mocha.ITestDefinition; + } + + function executeSuiteCallback(name: string, callback: Function) { + const fakeContext: Mocha.ISuiteCallbackContext = { + retries() { return this; }, + slow() { return this; }, + timeout() { return this; }, + }; + namestack.push(name); + let beforeFunc: Function; + (before as any) = (cb: Function) => beforeFunc = cb; + let afterFunc: Function; + (after as any) = (cb: Function) => afterFunc = cb; + const savedBeforeEach = beforeEachFunc; + (beforeEach as any) = (cb: Function) => beforeEachFunc = cb; + const savedTestList = testList; + + testList = []; + callback.call(fakeContext); + beforeFunc && beforeFunc(); + beforeFunc = undefined; + testList.forEach(({ name, callback, kind }) => executeCallback(name, callback, kind)); + testList.length = 0; + testList = savedTestList; + + afterFunc && afterFunc(); + afterFunc = undefined; + beforeEachFunc = savedBeforeEach; + namestack.pop(); + } + + function executeCallback(name: string, callback: Function, kind: "suite" | "test") { + if (kind === "suite") { + executeSuiteCallback(name, callback); + } + else { + executeTestCallback(name, callback); + } + } + + function executeTestCallback(name: string, callback: Function) { + const fakeContext: Mocha.ITestCallbackContext = { + skip() { return this; }, + timeout() { return this; }, + retries() { return this; }, + slow() { return this; }, + }; + name = [...namestack, name].join(" "); + if (beforeEachFunc) { try { + beforeEachFunc(); + } + catch (error) { + errors.push({ error: error.message, stack: error.stack, name }); + return; + } + } + if (callback.length === 0) { + try { + // TODO: If we ever start using async test completions, polyfill promise return handling callback.call(fakeContext); } catch (error) { @@ -54,7 +101,32 @@ namespace Harness.Parallel.Worker { return; } passing++; - }) as Mocha.ITestDefinition; + } + else { + // Uses `done` callback + let completed = false; + try { + callback.call(fakeContext, (err: any) => { + if (completed) { + throw new Error(`done() callback called multiple times; ensure it is only called once.`); + } + if (err) { + errors.push({ error: err.toString(), stack: "", name }); + } + else { + passing++; + } + completed = true; + }); + } + catch (error) { + errors.push({ error: error.message, stack: error.stack, name }); + return; + } + if (!completed) { + errors.push({ error: "Test completes asynchronously, which is unsupported by the parallel harness", stack: "", name }); + } + } } export function start() { diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 0f5b2378468..a1bc2185da5 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index a545124a723..12ce62fdefb 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index b53ac2d8552..ea94f857fa4 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 4e06e06d159..40181bc2553 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 94808d89ed0..228c332c1e3 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "lib": ["es5","es2015.promise"], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 0f5b2378468..a1bc2185da5 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index d165b0f2775..a3c6771965d 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "lib": ["es5","es2015.core"], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 2a169b3aaaf..96b15f67792 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { /* Basic Options */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ From ab6bb1618f32e7f21101dd517100bc17f76c52e7 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 19 Sep 2017 16:57:20 -0700 Subject: [PATCH 203/216] Actually capture oldTranspile baselines (#18584) --- src/harness/unittests/transpile.ts | 55 +++++++++---------- ...values for compile-options.oldTranspile.js | 2 + ...spile with CommonJS option.oldTranspile.js | 24 ++++++++ ...anspile with System option.oldTranspile.js | 35 ++++++++++++ ...erate semantic diagnostics.oldTranspile.js | 2 + ...tactic diagnostics.oldTranspile.errors.txt | 7 +++ ...cted syntactic diagnostics.oldTranspile.js | 3 + .../Generates module output.oldTranspile.js | 5 ++ ...or missing file references.oldTranspile.js | 3 + ...for missing module imports.oldTranspile.js | 3 + ...gnostics with valid inputs.oldTranspile.js | 2 + ...for file without extension.oldTranspile.js | 3 + ...nd is out-of-range.oldTranspile.errors.txt | 6 ++ ...odule-kind is out-of-range.oldTranspile.js | 1 + ...pt is out-of-range.oldTranspile.errors.txt | 6 ++ ...get-script is out-of-range.oldTranspile.js | 1 + .../Sets module name.oldTranspile.js | 11 ++++ ...rt options with lib values.oldTranspile.js | 2 + ... options with types values.oldTranspile.js | 2 + ...s backslashes in file name.oldTranspile.js | 2 + .../Supports setting allowJs.oldTranspile.js | 2 + ...lowSyntheticDefaultImports.oldTranspile.js | 2 + ...tting allowUnreachableCode.oldTranspile.js | 2 + ... setting allowUnusedLabels.oldTranspile.js | 2 + ...ports setting alwaysStrict.oldTranspile.js | 3 + .../Supports setting baseUrl.oldTranspile.js | 2 + .../Supports setting charset.oldTranspile.js | 2 + ...pports setting declaration.oldTranspile.js | 2 + ...rts setting declarationDir.oldTranspile.js | 2 + .../Supports setting emitBOM.oldTranspile.js | 2 + ...ting emitDecoratorMetadata.oldTranspile.js | 2 + ...ing experimentalDecorators.oldTranspile.js | 2 + ...onsistentCasingInFileNames.oldTranspile.js | 2 + ...ts setting isolatedModules.oldTranspile.js | 2 + .../Supports setting jsx.oldTranspile.js | 2 + ...upports setting jsxFactory.oldTranspile.js | 2 + .../Supports setting lib.oldTranspile.js | 2 + .../Supports setting locale.oldTranspile.js | 2 + .../Supports setting module.oldTranspile.js | 2 + ...s setting moduleResolution.oldTranspile.js | 2 + .../Supports setting newLine.oldTranspile.js | 2 + .../Supports setting noEmit.oldTranspile.js | 2 + ...orts setting noEmitHelpers.oldTranspile.js | 2 + ...orts setting noEmitOnError.oldTranspile.js | 2 + ... setting noErrorTruncation.oldTranspile.js | 2 + ...noFallthroughCasesInSwitch.oldTranspile.js | 2 + ...orts setting noImplicitAny.oldTranspile.js | 2 + ... setting noImplicitReturns.oldTranspile.js | 2 + ...rts setting noImplicitThis.oldTranspile.js | 2 + ...etting noImplicitUseStrict.oldTranspile.js | 2 + .../Supports setting noLib.oldTranspile.js | 2 + ...Supports setting noResolve.oldTranspile.js | 2 + .../Supports setting out.oldTranspile.js | 2 + .../Supports setting outDir.oldTranspile.js | 2 + .../Supports setting outFile.oldTranspile.js | 2 + .../Supports setting paths.oldTranspile.js | 2 + ...setting preserveConstEnums.oldTranspile.js | 2 + ...rts setting reactNamespace.oldTranspile.js | 2 + ...rts setting removeComments.oldTranspile.js | 2 + .../Supports setting rootDir.oldTranspile.js | 2 + .../Supports setting rootDirs.oldTranspile.js | 2 + ...etting skipDefaultLibCheck.oldTranspile.js | 2 + ...ports setting skipLibCheck.oldTranspile.js | 2 + ...s setting strictNullChecks.oldTranspile.js | 2 + ...orts setting stripInternal.oldTranspile.js | 2 + ...ppressExcessPropertyErrors.oldTranspile.js | 2 + ...ressImplicitAnyIndexErrors.oldTranspile.js | 2 + .../Supports setting target.oldTranspile.js | 2 + ...Supports setting typeRoots.oldTranspile.js | 2 + .../Supports setting types.oldTranspile.js | 2 + ...Supports urls in file name.oldTranspile.js | 2 + ...corators and emit metadata.oldTranspile.js | 20 +++++++ ... correct newLine character.oldTranspile.js | 2 + .../transpile .js files.oldTranspile.js | 2 + ...as tsx if jsx is specified.oldTranspile.js | 2 + 75 files changed, 275 insertions(+), 29 deletions(-) create mode 100644 tests/baselines/reference/transpile/Accepts string as enum values for compile-options.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Does not generate semantic diagnostics.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.errors.txt create mode 100644 tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Generates module output.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Generates no diagnostics for missing file references.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Generates no diagnostics for missing module imports.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/No extra errors for file without extension.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt create mode 100644 tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt create mode 100644 tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Sets module name.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Support options with lib values.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Support options with types values.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports backslashes in file name.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting allowJs.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting allowUnreachableCode.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting allowUnusedLabels.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting alwaysStrict.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting baseUrl.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting charset.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting declaration.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting declarationDir.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting emitBOM.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting experimentalDecorators.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting isolatedModules.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting jsx.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting jsxFactory.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting lib.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting locale.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting module.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting moduleResolution.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting newLine.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noEmit.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noEmitHelpers.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noEmitOnError.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noErrorTruncation.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noImplicitAny.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noImplicitReturns.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noImplicitThis.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noLib.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting noResolve.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting out.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting outDir.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting outFile.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting paths.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting preserveConstEnums.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting reactNamespace.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting removeComments.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting rootDir.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting rootDirs.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting skipLibCheck.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting strictNullChecks.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting stripInternal.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting target.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting typeRoots.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports setting types.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Supports urls in file name.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/Uses correct newLine character.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/transpile .js files.oldTranspile.js create mode 100644 tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.oldTranspile.js diff --git a/src/harness/unittests/transpile.ts b/src/harness/unittests/transpile.ts index e0c96797827..16bef6500f2 100644 --- a/src/harness/unittests/transpile.ts +++ b/src/harness/unittests/transpile.ts @@ -17,32 +17,33 @@ namespace ts { let oldTranspileResult: string; let oldTranspileDiagnostics: Diagnostic[]; + transpileOptions = testSettings.options || {}; + if (!transpileOptions.compilerOptions) { + transpileOptions.compilerOptions = {}; + } + + if (transpileOptions.compilerOptions.newLine === undefined) { + // use \r\n as default new line + transpileOptions.compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; + } + + transpileOptions.compilerOptions.sourceMap = true; + + if (!transpileOptions.fileName) { + transpileOptions.fileName = transpileOptions.compilerOptions.jsx ? "file.tsx" : "file.ts"; + } + + transpileOptions.reportDiagnostics = true; + + justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? Extension.Tsx : Extension.Ts); + toBeCompiled = [{ + unitName: transpileOptions.fileName, + content: input + }]; + + canUseOldTranspile = !transpileOptions.renamedDependencies; + before(() => { - transpileOptions = testSettings.options || {}; - if (!transpileOptions.compilerOptions) { - transpileOptions.compilerOptions = {}; - } - - if (transpileOptions.compilerOptions.newLine === undefined) { - // use \r\n as default new line - transpileOptions.compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; - } - - transpileOptions.compilerOptions.sourceMap = true; - - if (!transpileOptions.fileName) { - transpileOptions.fileName = transpileOptions.compilerOptions.jsx ? "file.tsx" : "file.ts"; - } - - transpileOptions.reportDiagnostics = true; - - justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? Extension.Tsx : Extension.Ts); - toBeCompiled = [{ - unitName: transpileOptions.fileName, - content: input - }]; - - canUseOldTranspile = !transpileOptions.renamedDependencies; transpileResult = transpileModule(input, transpileOptions); if (canUseOldTranspile) { @@ -52,10 +53,6 @@ namespace ts { }); after(() => { - justName = undefined; - transpileOptions = undefined; - canUseOldTranspile = undefined; - toBeCompiled = undefined; transpileResult = undefined; oldTranspileResult = undefined; oldTranspileDiagnostics = undefined; diff --git a/tests/baselines/reference/transpile/Accepts string as enum values for compile-options.oldTranspile.js b/tests/baselines/reference/transpile/Accepts string as enum values for compile-options.oldTranspile.js new file mode 100644 index 00000000000..981e2e706cb --- /dev/null +++ b/tests/baselines/reference/transpile/Accepts string as enum values for compile-options.oldTranspile.js @@ -0,0 +1,2 @@ +export const x = 0; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js new file mode 100644 index 00000000000..2b52d660f4e --- /dev/null +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js @@ -0,0 +1,24 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ng = require("angular2/core"); +var MyClass1 = /** @class */ (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + fooexport, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); + return MyClass1; + var _a; +}()); +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.oldTranspile.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.oldTranspile.js new file mode 100644 index 00000000000..00be51ec29e --- /dev/null +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with System option.oldTranspile.js @@ -0,0 +1,35 @@ +System.register(["angular2/core"], function (exports_1, context_1) { + "use strict"; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + var __moduleName = context_1 && context_1.id; + var ng, MyClass1; + return { + setters: [ + function (ng_1) { + ng = ng_1; + } + ], + execute: function () { + MyClass1 = /** @class */ (function () { + function MyClass1(_elementRef) { + this._elementRef = _elementRef; + } + MyClass1 = __decorate([ + fooexport, + __metadata("design:paramtypes", [typeof (_a = (typeof ng !== "undefined" && ng).ElementRef) === "function" && _a || Object]) + ], MyClass1); + return MyClass1; + var _a; + }()); + } + }; +}); +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.oldTranspile.js b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.oldTranspile.js new file mode 100644 index 00000000000..eb8be3556a1 --- /dev/null +++ b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.oldTranspile.js @@ -0,0 +1,2 @@ +var x = 0; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.errors.txt new file mode 100644 index 00000000000..6fbdba6f2c6 --- /dev/null +++ b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.errors.txt @@ -0,0 +1,7 @@ +file.ts(1,3): error TS1005: ';' expected. + + +==== file.ts (1 errors) ==== + a b + ~ +!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.js b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.js new file mode 100644 index 00000000000..c2c5134015c --- /dev/null +++ b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.oldTranspile.js @@ -0,0 +1,3 @@ +a; +b; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates module output.oldTranspile.js b/tests/baselines/reference/transpile/Generates module output.oldTranspile.js new file mode 100644 index 00000000000..9eadd1f2717 --- /dev/null +++ b/tests/baselines/reference/transpile/Generates module output.oldTranspile.js @@ -0,0 +1,5 @@ +define(["require", "exports"], function (require, exports) { + "use strict"; + var x = 0; +}); +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.oldTranspile.js b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.oldTranspile.js new file mode 100644 index 00000000000..9324d64de1e --- /dev/null +++ b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.oldTranspile.js @@ -0,0 +1,3 @@ +/// +var x = 0; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics for missing module imports.oldTranspile.js b/tests/baselines/reference/transpile/Generates no diagnostics for missing module imports.oldTranspile.js new file mode 100644 index 00000000000..e9493d9d591 --- /dev/null +++ b/tests/baselines/reference/transpile/Generates no diagnostics for missing module imports.oldTranspile.js @@ -0,0 +1,3 @@ +"use strict"; +exports.__esModule = true; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.oldTranspile.js b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.oldTranspile.js new file mode 100644 index 00000000000..eb8be3556a1 --- /dev/null +++ b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.oldTranspile.js @@ -0,0 +1,2 @@ +var x = 0; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/No extra errors for file without extension.oldTranspile.js b/tests/baselines/reference/transpile/No extra errors for file without extension.oldTranspile.js new file mode 100644 index 00000000000..61a703e13bb --- /dev/null +++ b/tests/baselines/reference/transpile/No extra errors for file without extension.oldTranspile.js @@ -0,0 +1,3 @@ +"use strict"; +var x = 0; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt new file mode 100644 index 00000000000..f746915da7d --- /dev/null +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt @@ -0,0 +1,6 @@ +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'. + + +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'. +==== file.ts (0 errors) ==== + \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.js b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.js new file mode 100644 index 00000000000..c7570e81192 --- /dev/null +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.js @@ -0,0 +1 @@ +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt new file mode 100644 index 00000000000..f746915da7d --- /dev/null +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt @@ -0,0 +1,6 @@ +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'. + + +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'. +==== file.ts (0 errors) ==== + \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.js b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.js new file mode 100644 index 00000000000..c7570e81192 --- /dev/null +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.js @@ -0,0 +1 @@ +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Sets module name.oldTranspile.js b/tests/baselines/reference/transpile/Sets module name.oldTranspile.js new file mode 100644 index 00000000000..72164ed6b16 --- /dev/null +++ b/tests/baselines/reference/transpile/Sets module name.oldTranspile.js @@ -0,0 +1,11 @@ +System.register("NamedModule", [], function (exports_1, context_1) { + var __moduleName = context_1 && context_1.id; + var x; + return { + setters: [], + execute: function () { + x = 1; + } + }; +}); +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with lib values.oldTranspile.js b/tests/baselines/reference/transpile/Support options with lib values.oldTranspile.js new file mode 100644 index 00000000000..1c5faaae678 --- /dev/null +++ b/tests/baselines/reference/transpile/Support options with lib values.oldTranspile.js @@ -0,0 +1,2 @@ +var a = 10; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with types values.oldTranspile.js b/tests/baselines/reference/transpile/Support options with types values.oldTranspile.js new file mode 100644 index 00000000000..1c5faaae678 --- /dev/null +++ b/tests/baselines/reference/transpile/Support options with types values.oldTranspile.js @@ -0,0 +1,2 @@ +var a = 10; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports backslashes in file name.oldTranspile.js b/tests/baselines/reference/transpile/Supports backslashes in file name.oldTranspile.js new file mode 100644 index 00000000000..7e5b546deba --- /dev/null +++ b/tests/baselines/reference/transpile/Supports backslashes in file name.oldTranspile.js @@ -0,0 +1,2 @@ +var x; +//# sourceMappingURL=b.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowJs.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting allowJs.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting allowJs.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting alwaysStrict.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting alwaysStrict.oldTranspile.js new file mode 100644 index 00000000000..8d91090453b --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting alwaysStrict.oldTranspile.js @@ -0,0 +1,3 @@ +"use strict"; +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting baseUrl.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting baseUrl.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting baseUrl.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting charset.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting charset.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting charset.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declaration.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting declaration.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting declaration.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declarationDir.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting declarationDir.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting declarationDir.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitBOM.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting emitBOM.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting emitBOM.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting isolatedModules.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting isolatedModules.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting isolatedModules.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsx.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting jsx.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting jsx.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsxFactory.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting jsxFactory.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting jsxFactory.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting lib.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting lib.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting lib.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting locale.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting locale.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting locale.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting module.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting module.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting module.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting moduleResolution.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting moduleResolution.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting moduleResolution.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting newLine.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting newLine.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting newLine.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmit.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noEmit.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noEmit.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitOnError.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noEmitOnError.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noEmitOnError.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitAny.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noImplicitAny.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noImplicitAny.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitThis.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noImplicitThis.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noImplicitThis.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noImplicitUseStrict.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noLib.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noLib.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noLib.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noResolve.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting noResolve.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting noResolve.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting out.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting out.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting out.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outDir.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting outDir.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting outDir.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outFile.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting outFile.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting outFile.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting paths.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting paths.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting paths.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting reactNamespace.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting reactNamespace.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting reactNamespace.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting removeComments.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting removeComments.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting removeComments.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDir.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting rootDir.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting rootDir.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDirs.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting rootDirs.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting rootDirs.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipLibCheck.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting skipLibCheck.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting skipLibCheck.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting strictNullChecks.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting strictNullChecks.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting strictNullChecks.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting stripInternal.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting stripInternal.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting stripInternal.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting target.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting target.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting target.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting typeRoots.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting typeRoots.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting typeRoots.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting types.oldTranspile.js b/tests/baselines/reference/transpile/Supports setting types.oldTranspile.js new file mode 100644 index 00000000000..8394371f908 --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting types.oldTranspile.js @@ -0,0 +1,2 @@ +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports urls in file name.oldTranspile.js b/tests/baselines/reference/transpile/Supports urls in file name.oldTranspile.js new file mode 100644 index 00000000000..50fa840c62e --- /dev/null +++ b/tests/baselines/reference/transpile/Supports urls in file name.oldTranspile.js @@ -0,0 +1,2 @@ +var x; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.oldTranspile.js b/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.oldTranspile.js new file mode 100644 index 00000000000..ed922d3f48a --- /dev/null +++ b/tests/baselines/reference/transpile/Transpile with emit decorators and emit metadata.oldTranspile.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var db_1 = require("./db"); +function someDecorator(target) { + return target; +} +var MyClass = /** @class */ (function () { + function MyClass(db) { + this.db = db; + this.db.doSomething(); + } + MyClass = __decorate([ + someDecorator, + __metadata("design:paramtypes", [typeof (_a = typeof db_1.db !== "undefined" && db_1.db) === "function" && _a || Object]) + ], MyClass); + return MyClass; + var _a; +}()); +exports.MyClass = MyClass; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Uses correct newLine character.oldTranspile.js b/tests/baselines/reference/transpile/Uses correct newLine character.oldTranspile.js new file mode 100644 index 00000000000..976498c2da8 --- /dev/null +++ b/tests/baselines/reference/transpile/Uses correct newLine character.oldTranspile.js @@ -0,0 +1,2 @@ +var x = 0; +//# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile .js files.oldTranspile.js b/tests/baselines/reference/transpile/transpile .js files.oldTranspile.js new file mode 100644 index 00000000000..36551461def --- /dev/null +++ b/tests/baselines/reference/transpile/transpile .js files.oldTranspile.js @@ -0,0 +1,2 @@ +var a = 10; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.oldTranspile.js b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.oldTranspile.js new file mode 100644 index 00000000000..8620309214f --- /dev/null +++ b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.oldTranspile.js @@ -0,0 +1,2 @@ +var x = React.createElement("div", null); +//# sourceMappingURL=file.js.map \ No newline at end of file From b549e2666567d39b0944173d7754850f7474f510 Mon Sep 17 00:00:00 2001 From: Magnus Kulke Date: Wed, 20 Sep 2017 01:57:26 +0200 Subject: [PATCH 204/216] Consider underscore for type parameters in unused-local checks (#18539) * Consider underscore for type parameters in unused-local errors. * Addressed review comments. --- src/compiler/checker.ts | 5 ++-- ...sedTypeParametersWithUnderscore.errors.txt | 23 +++++++++++++++++++ .../unusedTypeParametersWithUnderscore.js | 19 +++++++++++++++ .../unusedTypeParametersWithUnderscore.ts | 9 ++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/unusedTypeParametersWithUnderscore.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParametersWithUnderscore.js create mode 100644 tests/cases/compiler/unusedTypeParametersWithUnderscore.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 98b7a9d044f..e00465caa14 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19973,7 +19973,8 @@ namespace ts { const node = getNameOfDeclaration(declaration) || declaration; if (isIdentifierThatStartsWithUnderScore(node)) { const declaration = getRootDeclaration(node.parent); - if (declaration.kind === SyntaxKind.VariableDeclaration && isForInOrOfStatement(declaration.parent.parent)) { + if ((declaration.kind === SyntaxKind.VariableDeclaration && isForInOrOfStatement(declaration.parent.parent)) || + declaration.kind === SyntaxKind.TypeParameter) { return; } } @@ -20023,7 +20024,7 @@ namespace ts { return; } for (const typeParameter of node.typeParameters) { - if (!getMergedSymbol(typeParameter.symbol).isReferenced) { + if (!getMergedSymbol(typeParameter.symbol).isReferenced && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { error(typeParameter.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); } } diff --git a/tests/baselines/reference/unusedTypeParametersWithUnderscore.errors.txt b/tests/baselines/reference/unusedTypeParametersWithUnderscore.errors.txt new file mode 100644 index 00000000000..cd44a68b78c --- /dev/null +++ b/tests/baselines/reference/unusedTypeParametersWithUnderscore.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/unusedTypeParametersWithUnderscore.ts(1,16): error TS6133: 'U' is declared but its value is never read. +tests/cases/compiler/unusedTypeParametersWithUnderscore.ts(3,12): error TS6133: 'U' is declared but its value is never read. +tests/cases/compiler/unusedTypeParametersWithUnderscore.ts(5,17): error TS6133: 'U' is declared but its value is never read. +tests/cases/compiler/unusedTypeParametersWithUnderscore.ts(7,13): error TS6133: 'U' is declared but its value is never read. + + +==== tests/cases/compiler/unusedTypeParametersWithUnderscore.ts (4 errors) ==== + function f<_T, U>() { } + ~ +!!! error TS6133: 'U' is declared but its value is never read. + + type T<_T, U> = { }; + ~ +!!! error TS6133: 'U' is declared but its value is never read. + + interface I<_T, U> { }; + ~ +!!! error TS6133: 'U' is declared but its value is never read. + + class C<_T, U> { }; + ~ +!!! error TS6133: 'U' is declared but its value is never read. + \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParametersWithUnderscore.js b/tests/baselines/reference/unusedTypeParametersWithUnderscore.js new file mode 100644 index 00000000000..095cf2da85f --- /dev/null +++ b/tests/baselines/reference/unusedTypeParametersWithUnderscore.js @@ -0,0 +1,19 @@ +//// [unusedTypeParametersWithUnderscore.ts] +function f<_T, U>() { } + +type T<_T, U> = { }; + +interface I<_T, U> { }; + +class C<_T, U> { }; + + +//// [unusedTypeParametersWithUnderscore.js] +function f() { } +; +var C = /** @class */ (function () { + function C() { + } + return C; +}()); +; diff --git a/tests/cases/compiler/unusedTypeParametersWithUnderscore.ts b/tests/cases/compiler/unusedTypeParametersWithUnderscore.ts new file mode 100644 index 00000000000..dc66534118f --- /dev/null +++ b/tests/cases/compiler/unusedTypeParametersWithUnderscore.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true + +function f<_T, U>() { } + +type T<_T, U> = { }; + +interface I<_T, U> { }; + +class C<_T, U> { }; From 8245597bfef17b8983b6a642e9326bce64276633 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 20 Sep 2017 03:04:50 +0300 Subject: [PATCH 205/216] Adds VarDate and SafeArray as pseudonominal types to lib.d.ts (#18566) * SafeArray; stronger typing for VarDate, and for VBArray and Enumerator constructors * Add overload to Enumerator based on Item method * Add return type to Enumerator constructor --- src/lib/scripthost.d.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index bec8be31735..1fbd185949f 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -201,10 +201,18 @@ declare var WScript: { Sleep(intTime: number): void; }; +/** + * Represents an Automation SAFEARRAY + */ +declare class SafeArray { + private constructor(); + private SafeArray_typekey: SafeArray; +} + /** * Allows enumerating over a COM collection, which may not have indexed item access. */ -interface Enumerator { +interface Enumerator { /** * Returns true if the current item is the last one in the collection, or the collection is empty, * or the current item is undefined. @@ -230,8 +238,9 @@ interface Enumerator { } interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; + new (safearray: SafeArray): Enumerator; + new (collection: { Item(index: any): T }): Enumerator; + new (collection: any): Enumerator; } declare var Enumerator: EnumeratorConstructor; @@ -239,7 +248,7 @@ declare var Enumerator: EnumeratorConstructor; /** * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. */ -interface VBArray { +interface VBArray { /** * Returns the number of dimensions (1-based). */ @@ -271,8 +280,7 @@ interface VBArray { } interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; + new (safeArray: SafeArray): VBArray; } declare var VBArray: VBArrayConstructor; @@ -280,7 +288,10 @@ declare var VBArray: VBArrayConstructor; /** * Automation date (VT_DATE) */ -interface VarDate { } +declare class VarDate { + private constructor(); + private VarDate_typekey: VarDate; +} interface DateConstructor { new (vd: VarDate): Date; From d5e7227dbb1f96a20c012d4c745db2deb620ecf6 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Sep 2017 08:15:24 -0700 Subject: [PATCH 206/216] Look at correct 'package.json' location for a scoped package (#18580) * Look at correct 'package.json' location for a scoped package * Update baseline --- src/compiler/moduleNameResolver.ts | 13 ++++++++----- .../moduleResolution_packageJson_scopedPackage.js | 15 +++++++++++++++ ...leResolution_packageJson_scopedPackage.symbols | 8 ++++++++ ...esolution_packageJson_scopedPackage.trace.json | 14 ++++++++++++++ ...duleResolution_packageJson_scopedPackage.types | 8 ++++++++ .../baselines/reference/scopedPackages.trace.json | 2 +- .../moduleResolution_packageJson_scopedPackage.ts | 11 +++++++++++ 7 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/moduleResolution_packageJson_scopedPackage.js create mode 100644 tests/baselines/reference/moduleResolution_packageJson_scopedPackage.symbols create mode 100644 tests/baselines/reference/moduleResolution_packageJson_scopedPackage.trace.json create mode 100644 tests/baselines/reference/moduleResolution_packageJson_scopedPackage.types create mode 100644 tests/cases/compiler/moduleResolution_packageJson_scopedPackage.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index ddffe876d80..84256b3a1b1 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -976,8 +976,8 @@ namespace ts { } function loadModuleFromNodeModulesFolder(extensions: Extensions, moduleName: string, nodeModulesFolder: string, nodeModulesFolderExists: boolean, failedLookupLocations: Push, state: ModuleResolutionState): Resolved | undefined { - const { top, rest } = getNameOfTopDirectory(moduleName); - const packageRootPath = combinePaths(nodeModulesFolder, top); + const { packageName, rest } = getPackageName(moduleName); + const packageRootPath = combinePaths(nodeModulesFolder, packageName); const { packageJsonContent, packageId } = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state); const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); const pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || @@ -985,9 +985,12 @@ namespace ts { return withPackageId(packageId, pathAndExtension); } - function getNameOfTopDirectory(name: string): { top: string, rest: string } { - const idx = name.indexOf(directorySeparator); - return idx === -1 ? { top: name, rest: "" } : { top: name.slice(0, idx), rest: name.slice(idx + 1) }; + function getPackageName(moduleName: string): { packageName: string, rest: string } { + let idx = moduleName.indexOf(directorySeparator); + if (moduleName[0] === "@") { + idx = moduleName.indexOf(directorySeparator, idx + 1); + } + return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions: Extensions, moduleName: string, directory: string, failedLookupLocations: Push, state: ModuleResolutionState, cache: NonRelativeModuleNameResolutionCache): SearchResult { diff --git a/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.js b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.js new file mode 100644 index 00000000000..32495ee1ab3 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/moduleResolution_packageJson_scopedPackage.ts] //// + +//// [package.json] +{ "types": "types.d.ts" } + +//// [types.d.ts] +export const x: number; + +//// [a.ts] +import { x } from "@foo/bar"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.symbols b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.symbols new file mode 100644 index 00000000000..4522817e78f --- /dev/null +++ b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.symbols @@ -0,0 +1,8 @@ +=== /a.ts === +import { x } from "@foo/bar"; +>x : Symbol(x, Decl(a.ts, 0, 8)) + +=== /node_modules/@foo/bar/types.d.ts === +export const x: number; +>x : Symbol(x, Decl(types.d.ts, 0, 12)) + diff --git a/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.trace.json b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.trace.json new file mode 100644 index 00000000000..69dcfca4eb6 --- /dev/null +++ b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.trace.json @@ -0,0 +1,14 @@ +[ + "======== Resolving module '@foo/bar' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module '@foo/bar' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/@foo/bar/package.json'.", + "File '/node_modules/@foo/bar.ts' does not exist.", + "File '/node_modules/@foo/bar.tsx' does not exist.", + "File '/node_modules/@foo/bar.d.ts' does not exist.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'types.d.ts' that references '/node_modules/@foo/bar/types.d.ts'.", + "File '/node_modules/@foo/bar/types.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/@foo/bar/types.d.ts', result '/node_modules/@foo/bar/types.d.ts'.", + "======== Module name '@foo/bar' was successfully resolved to '/node_modules/@foo/bar/types.d.ts'. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.types b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.types new file mode 100644 index 00000000000..b2d16a70c2e --- /dev/null +++ b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.types @@ -0,0 +1,8 @@ +=== /a.ts === +import { x } from "@foo/bar"; +>x : number + +=== /node_modules/@foo/bar/types.d.ts === +export const x: number; +>x : number + diff --git a/tests/baselines/reference/scopedPackages.trace.json b/tests/baselines/reference/scopedPackages.trace.json index a2b8af48266..1844f8c6c8d 100644 --- a/tests/baselines/reference/scopedPackages.trace.json +++ b/tests/baselines/reference/scopedPackages.trace.json @@ -2,7 +2,7 @@ "======== Resolving module '@cow/boy' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@cow/boy' from 'node_modules' folder, target file type 'TypeScript'.", - "File '/node_modules/@cow/package.json' does not exist.", + "File '/node_modules/@cow/boy/package.json' does not exist.", "File '/node_modules/@cow/boy.ts' does not exist.", "File '/node_modules/@cow/boy.tsx' does not exist.", "File '/node_modules/@cow/boy.d.ts' does not exist.", diff --git a/tests/cases/compiler/moduleResolution_packageJson_scopedPackage.ts b/tests/cases/compiler/moduleResolution_packageJson_scopedPackage.ts new file mode 100644 index 00000000000..624d21b4d71 --- /dev/null +++ b/tests/cases/compiler/moduleResolution_packageJson_scopedPackage.ts @@ -0,0 +1,11 @@ +// @noImplicitReferences: true +// @traceResolution: true + +// @Filename: /node_modules/@foo/bar/package.json +{ "types": "types.d.ts" } + +// @Filename: /node_modules/@foo/bar/types.d.ts +export const x: number; + +// @Filename: /a.ts +import { x } from "@foo/bar"; From 136a3ea77d2b8cbe9853e51537e3ea31996216a3 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 20 Sep 2017 09:18:39 -0700 Subject: [PATCH 207/216] Handle unixy paths in RWC tests (#18585) --- src/harness/harness.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 7a6c061c6d4..88d32871c68 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -2077,10 +2077,9 @@ namespace Harness { for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { const [name, content, count] = value as [string, string, number | undefined]; if (count === 0) continue; // Allow error reporter to skip writing files without errors - const relativeFileName = ts.combinePaths(relativeFileBase, name) + extension; + const relativeFileName = relativeFileBase + (ts.startsWith(name, "/") ? "" : "/") + name + extension; const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); - const actual = content; - const comparison = compareToBaseline(actual, relativeFileName, opts); + const comparison = compareToBaseline(content, relativeFileName, opts); try { writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName); } From 7dec4ae9d1ccfeba317359ac49098e3058fecfe4 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 20 Sep 2017 13:22:12 -0700 Subject: [PATCH 208/216] Remove batching on unittest thread, use historical data to inform batching (#18578) * Remove batching on unittest thread * Batch more things, improve output, use past test perf as a better heuristic for future test runs * Fix merge sideeffect * Fix typo --- .gitignore | 1 + src/harness/parallel/host.ts | 157 +++++++++++++++++++++++++-------- src/harness/parallel/shared.ts | 2 +- src/harness/parallel/worker.ts | 13 ++- 4 files changed, 132 insertions(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index eb0df177040..8c83d319ed7 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ internal/ .idea yarn.lock package-lock.json +.parallelperf.json diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts index 92e21b5ada3..67d1a4db1a7 100644 --- a/src/harness/parallel/host.ts +++ b/src/harness/parallel/host.ts @@ -5,11 +5,10 @@ if (typeof describe === "undefined") { namespace Harness.Parallel.Host { interface ChildProcessPartial { - send(message: any, callback?: (error: Error) => void): boolean; + send(message: ParallelHostMessage, callback?: (error: Error) => void): boolean; on(event: "error", listener: (err: Error) => void): this; on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "message", listener: (message: any) => void): this; - disconnect(): void; + on(event: "message", listener: (message: ParallelClientMessage) => void): this; } interface ProgressBarsOptions { @@ -27,23 +26,54 @@ namespace Harness.Parallel.Host { text?: string; } + const perfdataFileName = ".parallelperf.json"; + function readSavedPerfData(): {[testHash: string]: number} { + const perfDataContents = Harness.IO.readFile(perfdataFileName); + if (perfDataContents) { + return JSON.parse(perfDataContents); + } + return undefined; + } + + function hashName(runner: TestRunnerKind, test: string) { + return `tsrunner-${runner}://${test}`; + } + export function start() { initializeProgressBarsDependencies(); console.log("Discovering tests..."); const discoverStart = +(new Date()); const { statSync }: { statSync(path: string): { size: number }; } = require("fs"); const tasks: { runner: TestRunnerKind, file: string, size: number }[] = []; - let totalSize = 0; + const perfData = readSavedPerfData(); + let totalCost = 0; + let unknownValue: string | undefined; for (const runner of runners) { const files = runner.enumerateTestFiles(); for (const file of files) { - const size = statSync(file).size; + let size: number; + if (!perfData) { + size = statSync(file).size; + + } + else { + const hashedName = hashName(runner.kind(), file); + size = perfData[hashedName]; + if (size === undefined) { + size = Number.MAX_SAFE_INTEGER; + unknownValue = hashedName; + } + } tasks.push({ runner: runner.kind(), file, size }); - totalSize += size; + totalCost += size; } } tasks.sort((a, b) => a.size - b.size); - const batchSize = (totalSize / workerCount) * 0.9; + // 1 fewer batches than threads to account for unittests running on the final thread + const batchCount = runners.length === 1 ? workerCount : workerCount - 1; + const packfraction = 0.9; + const chunkSize = 1000; // ~1KB or 1s for sending batches near the end of a test + const batchSize = (totalCost / workerCount) * packfraction; // Keep spare tests for unittest thread in reserve console.log(`Discovered ${tasks.length} test files in ${+(new Date()) - discoverStart}ms.`); console.log(`Starting to run tests using ${workerCount} threads...`); const { fork }: { fork(modulePath: string, args?: string[], options?: {}): ChildProcessPartial; } = require("child_process"); @@ -59,7 +89,10 @@ namespace Harness.Parallel.Host { const progressUpdateInterval = 1 / progressBars._options.width; let nextProgress = progressUpdateInterval; + const newPerfData: {[testHash: string]: number} = {}; + const workers: ChildProcessPartial[] = []; + let closedWorkers = 0; for (let i = 0; i < workerCount; i++) { // TODO: Just send the config over the IPC channel or in the command line arguments const config: TestConfig = { light: Harness.lightMode, listenForWork: true, runUnitTests: runners.length === 1 ? false : i === workerCount - 1 }; @@ -67,7 +100,6 @@ namespace Harness.Parallel.Host { Harness.IO.writeFile(configPath, JSON.stringify(config)); const child = fork(__filename, [`--config="${configPath}"`]); child.on("error", err => { - child.disconnect(); console.error("Unexpected error in child process:"); console.error(err); return process.exit(2); @@ -81,7 +113,6 @@ namespace Harness.Parallel.Host { child.on("message", (data: ParallelClientMessage) => { switch (data.type) { case "error": { - child.disconnect(); console.error(`Test worker encounted unexpected error and was forced to close: Message: ${data.payload.error} Stack: ${data.payload.stack}`); @@ -97,6 +128,7 @@ namespace Harness.Parallel.Host { else { passingFiles++; } + newPerfData[hashName(data.payload.runner, data.payload.file)] = data.payload.duration; const progress = (failingFiles + passingFiles) / totalFiles; if (progress >= nextProgress) { @@ -106,20 +138,27 @@ namespace Harness.Parallel.Host { updateProgress(progress, errorResults.length ? `${errorResults.length} failing` : `${totalPassing} passing`, errorResults.length ? "fail" : undefined); } - if (failingFiles + passingFiles === totalFiles) { - // Done. Finished every task and collected results. - child.send({ type: "close" }); - child.disconnect(); - return outputFinalResult(); - } - if (tasks.length === 0) { - // No more tasks to distribute - child.send({ type: "close" }); - child.disconnect(); - return; - } if (data.type === "result") { - child.send({ type: "test", payload: tasks.pop() }); + if (tasks.length === 0) { + // No more tasks to distribute + child.send({ type: "close" }); + closedWorkers++; + if (closedWorkers === workerCount) { + outputFinalResult(); + } + return; + } + // Send tasks in blocks if the tasks are small + const taskList = [tasks.pop()]; + while (tasks.length && taskList.reduce((p, c) => p + c.size, 0) > chunkSize) { + taskList.push(tasks.pop()); + } + if (taskList.length === 1) { + child.send({ type: "test", payload: taskList[0] }); + } + else { + child.send({ type: "batch", payload: taskList }); + } } } } @@ -130,12 +169,13 @@ namespace Harness.Parallel.Host { // It's only really worth doing an initial batching if there are a ton of files to go through if (totalFiles > 1000) { console.log("Batching initial test lists..."); - const batches: { runner: TestRunnerKind, file: string, size: number }[][] = new Array(workerCount); - const doneBatching = new Array(workerCount); + const batches: { runner: TestRunnerKind, file: string, size: number }[][] = new Array(batchCount); + const doneBatching = new Array(batchCount); + let scheduledTotal = 0; batcher: while (true) { - for (let i = 0; i < workerCount; i++) { + for (let i = 0; i < batchCount; i++) { if (tasks.length === 0) { - // TODO: This indicates a particularly suboptimal packing + console.log(`Suboptimal packing detected: no tests remain to be stolen. Reduce packing fraction from ${packfraction} to fix.`); break batcher; } if (doneBatching[i]) { @@ -145,26 +185,36 @@ namespace Harness.Parallel.Host { batches[i] = []; } const total = batches[i].reduce((p, c) => p + c.size, 0); - if (total >= batchSize && !doneBatching[i]) { + if (total >= batchSize) { doneBatching[i] = true; continue; } - batches[i].push(tasks.pop()); + const task = tasks.pop(); + batches[i].push(task); + scheduledTotal += task.size; } - for (let j = 0; j < workerCount; j++) { + for (let j = 0; j < batchCount; j++) { if (!doneBatching[j]) { - continue; + continue batcher; } } break; } - console.log(`Batched into ${workerCount} groups with approximate total file sizes of ${Math.floor(batchSize)} bytes in each group.`); + const prefix = `Batched into ${batchCount} groups`; + if (unknownValue) { + console.log(`${prefix}. Unprofiled tests including ${unknownValue} will be run first.`); + } + else { + console.log(`${prefix} with approximate total ${perfData ? "time" : "file sizes"} of ${perfData ? ms(batchSize) : `${Math.floor(batchSize)} bytes`} in each group. (${(scheduledTotal / totalCost * 100).toFixed(1)}% of total tests batched)`); + } for (const worker of workers) { - const action: ParallelBatchMessage = { type: "batch", payload: batches.pop() }; - if (!action.payload[0]) { - throw new Error(`Tried to send invalid message ${action}`); + const payload = batches.pop(); + if (payload) { + worker.send({ type: "batch", payload }); + } + else { // Unittest thread - send off just one test + worker.send({ type: "test", payload: tasks.pop() }); } - worker.send(action); } } else { @@ -177,7 +227,6 @@ namespace Harness.Parallel.Host { updateProgress(0); let duration: number; - const ms = require("mocha/lib/ms"); function completeBar() { const isPartitionFail = failingFiles !== 0; const summaryColor = isPartitionFail ? "fail" : "green"; @@ -235,6 +284,8 @@ namespace Harness.Parallel.Host { reporter.epilogue(); } + Harness.IO.writeFile(perfdataFileName, JSON.stringify(newPerfData, null, 4)); // tslint:disable-line:no-null-keyword + process.exit(errorResults.length); } @@ -264,6 +315,38 @@ namespace Harness.Parallel.Host { let tty: { isatty(x: number): boolean }; let isatty: boolean; + const s = 1000; + const m = s * 60; + const h = m * 60; + const d = h * 24; + function ms(ms: number) { + let result = ""; + if (ms >= d) { + const count = Math.floor(ms / d); + result += count + "d"; + ms -= count * d; + } + if (ms >= h) { + const count = Math.floor(ms / h); + result += count + "h"; + ms -= count * h; + } + if (ms >= m) { + const count = Math.floor(ms / m); + result += count + "m"; + ms -= count * m; + } + if (ms >= s) { + const count = Math.round(ms / s); + result += count + "s"; + return result; + } + if (ms > 0) { + result += Math.round(ms) + "ms"; + } + return result; + } + function initializeProgressBarsDependencies() { Mocha = require("mocha"); Base = Mocha.reporters.Base; @@ -286,7 +369,7 @@ namespace Harness.Parallel.Host { const close = options.close || "]"; const complete = options.complete || "▬"; const incomplete = options.incomplete || Base.symbols.dot; - const maxWidth = Base.window.width - open.length - close.length - 30; + const maxWidth = Base.window.width - open.length - close.length - 34; const width = minMax(options.width || maxWidth, 10, maxWidth); this._options = { open, diff --git a/src/harness/parallel/shared.ts b/src/harness/parallel/shared.ts index ebfe3278849..2caabaff1d7 100644 --- a/src/harness/parallel/shared.ts +++ b/src/harness/parallel/shared.ts @@ -8,7 +8,7 @@ namespace Harness.Parallel { export type ParallelErrorMessage = { type: "error", payload: { error: string, stack: string } } | never; export type ErrorInfo = ParallelErrorMessage["payload"] & { name: string }; - export type ParallelResultMessage = { type: "result", payload: { passing: number, errors: ErrorInfo[] } } | never; + export type ParallelResultMessage = { type: "result", payload: { passing: number, errors: ErrorInfo[], duration: number, runner: TestRunnerKind, file: string } } | never; export type ParallelBatchProgressMessage = { type: "progress", payload: ParallelResultMessage["payload"] } | never; export type ParallelClientMessage = ParallelErrorMessage | ParallelResultMessage | ParallelBatchProgressMessage; } \ No newline at end of file diff --git a/src/harness/parallel/worker.ts b/src/harness/parallel/worker.ts index 56f8fd43c58..1113039f4f7 100644 --- a/src/harness/parallel/worker.ts +++ b/src/harness/parallel/worker.ts @@ -12,9 +12,10 @@ namespace Harness.Parallel.Worker { testList.length = 0; } reportedUnitTests = true; + const start = +(new Date()); runner.initializeTests(); testList.forEach(({ name, callback, kind }) => executeCallback(name, callback, kind)); - return { errors, passing }; + return { errors, passing, duration: +(new Date()) - start }; } @@ -172,7 +173,13 @@ namespace Harness.Parallel.Worker { }); process.on("uncaughtException", error => { const message: ParallelErrorMessage = { type: "error", payload: { error: error.message, stack: error.stack } }; - process.send(message); + try { + process.send(message); + } + catch (e) { + console.error(error); + throw error; + } }); if (!runUnitTests) { // ensure unit tests do not get run @@ -189,7 +196,7 @@ namespace Harness.Parallel.Worker { } const instance = runners.get(runner); instance.tests = [file]; - return resetShimHarnessAndExecute(instance); + return { ...resetShimHarnessAndExecute(instance), runner, file }; } } } \ No newline at end of file From 4d2aa9bf2cef463df1cfea3b206eb3f04e1ca765 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Sep 2017 15:01:04 -0700 Subject: [PATCH 209/216] Fix formatting when keyword is parsed as part of a JSX identifier (e.g. `module-layout`) (#18598) --- src/services/formatting/formattingScanner.ts | 5 +++-- .../cases/fourslash/formatJsxWithKeywordInIdentifier.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/formatJsxWithKeywordInIdentifier.ts diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 9b4e1be323b..d69fb141ba1 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -125,7 +125,8 @@ namespace ts.formatting { case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxClosingElement: case SyntaxKind.JsxSelfClosingElement: - return node.kind === SyntaxKind.Identifier; + // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. + return isKeyword(node.kind) || node.kind === SyntaxKind.Identifier; } } @@ -209,7 +210,7 @@ namespace ts.formatting { currentToken = scanner.reScanTemplateToken(); lastScanAction = ScanAction.RescanTemplateToken; } - else if (expectedScanAction === ScanAction.RescanJsxIdentifier && currentToken === SyntaxKind.Identifier) { + else if (expectedScanAction === ScanAction.RescanJsxIdentifier) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = ScanAction.RescanJsxIdentifier; } diff --git a/tests/cases/fourslash/formatJsxWithKeywordInIdentifier.ts b/tests/cases/fourslash/formatJsxWithKeywordInIdentifier.ts new file mode 100644 index 00000000000..20a7d746414 --- /dev/null +++ b/tests/cases/fourslash/formatJsxWithKeywordInIdentifier.ts @@ -0,0 +1,9 @@ +/// + +// Test that we don't crash when encountering a keyword in a JSX identifier. + +// @Filename: /a.tsx +////
+ +format.document(); +verify.currentFileContentIs(`
`); From a1dee452faa9a6a5bdf1301d09b887e40d19852e Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 20 Sep 2017 14:48:11 -0700 Subject: [PATCH 210/216] JavaScript: handle lack of modifiers on extracted method The emitter expects undefined, rather than empty. This only affects JS, because TS applies `private` to all extracted methods. (cherry picked from commit 9630c46ea7174f78d9a2661cbcc204bdce1a7781) --- src/services/refactors/extractMethod.ts | 2 +- tests/cases/fourslash/extract-method26.ts | 30 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/extract-method26.ts diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index c2ffdc1d2fe..30d95e81534 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -664,7 +664,7 @@ namespace ts.refactor.extractMethod { } newFunction = createMethod( /*decorators*/ undefined, - modifiers, + modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? createToken(SyntaxKind.AsteriskToken) : undefined, functionName, /*questionToken*/ undefined, diff --git a/tests/cases/fourslash/extract-method26.ts b/tests/cases/fourslash/extract-method26.ts new file mode 100644 index 00000000000..68982eda86c --- /dev/null +++ b/tests/cases/fourslash/extract-method26.ts @@ -0,0 +1,30 @@ +/// + +// Handle having zero modifiers on a method. + +// @allowNonTsExtensions: true +// @Filename: file1.js +//// class C { +//// M() { +//// const q = /*a*/1 + 2/*b*/; +//// q.toString(); +//// } +//// } + +goTo.select('a', 'b') +edit.applyRefactor({ + refactorName: "Extract Method", + actionName: "scope_0", + actionDescription: "Extract to method in class 'C'", + newContent: +`class C { + M() { + const q = this./*RENAME*/newFunction(); + q.toString(); + } + + newFunction() { + return 1 + 2; + } +}` +}); From ae87db7b3e7031431b4fd62cc74877db2b5b5009 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 20 Sep 2017 16:26:46 -0700 Subject: [PATCH 211/216] getAdjustedStartPosition shouldn't skip to next line when on 1st line --- src/services/textChanges.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index f3ad7df1607..fdfac9e54cc 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -152,7 +152,7 @@ namespace ts.textChanges { return position === Position.Start ? start : fullStart; } // get start position of the line following the line that contains fullstart position - let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + (fullStart > 0 ? 1 : 0), sourceFile); // skip whitespaces/newlines adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return getStartPositionOfLine(getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); From 410f84656dea7487e99983c13a593658fb55292a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 20 Sep 2017 16:31:28 -0700 Subject: [PATCH 212/216] Update baselines temporarily The loss of comments is not good, but should be fixed when (1) trivia-handling issues are fixed or (2) the reafactorings themselves add a workaround. --- tests/cases/fourslash/extract-method-uniqueName.ts | 3 +-- .../cases/fourslash/server/convertFunctionToEs6Class-server.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/cases/fourslash/extract-method-uniqueName.ts b/tests/cases/fourslash/extract-method-uniqueName.ts index 44f026ae8a8..5c359b23164 100644 --- a/tests/cases/fourslash/extract-method-uniqueName.ts +++ b/tests/cases/fourslash/extract-method-uniqueName.ts @@ -9,8 +9,7 @@ edit.applyRefactor({ actionName: "scope_0", actionDescription: "Extract to function in global scope", newContent: -`// newFunction -/*RENAME*/newFunction_1(); +`/*RENAME*/newFunction_1(); function newFunction_1() { // newFunction diff --git a/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts b/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts index 5782b4a1f41..83a05b0661a 100644 --- a/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts +++ b/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts @@ -13,8 +13,7 @@ verify.applicableRefactorAvailableAtMarker('1'); verify.fileAfterApplyingRefactorAtMarker('1', -`// Comment -class fn { +`class fn { constructor() { this.baz = 10; } From 6a34dc953a8c81439220f28832812782cc3715ae Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 Sep 2017 02:07:33 -0700 Subject: [PATCH 213/216] Added test and accepted baselines. --- tests/baselines/reference/parserNotRegex2.js | 15 +++++++++ .../reference/parserNotRegex2.symbols | 24 ++++++++++++++ .../baselines/reference/parserNotRegex2.types | 33 +++++++++++++++++++ .../parser/ecmascript5/parserNotRegex2.ts | 9 +++++ 4 files changed, 81 insertions(+) create mode 100644 tests/baselines/reference/parserNotRegex2.js create mode 100644 tests/baselines/reference/parserNotRegex2.symbols create mode 100644 tests/baselines/reference/parserNotRegex2.types create mode 100644 tests/cases/conformance/parser/ecmascript5/parserNotRegex2.ts diff --git a/tests/baselines/reference/parserNotRegex2.js b/tests/baselines/reference/parserNotRegex2.js new file mode 100644 index 00000000000..189e7a1015b --- /dev/null +++ b/tests/baselines/reference/parserNotRegex2.js @@ -0,0 +1,15 @@ +//// [parserNotRegex2.ts] +declare const A: any; +declare const B: any; +declare const C: any; +const x = (A / 2); +B( + C(), + () => { }, + () => { } +); + + +//// [parserNotRegex2.js] +var x = (A / 2); +B(C(), function () { }, function () { }); diff --git a/tests/baselines/reference/parserNotRegex2.symbols b/tests/baselines/reference/parserNotRegex2.symbols new file mode 100644 index 00000000000..85a6dbeb340 --- /dev/null +++ b/tests/baselines/reference/parserNotRegex2.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/parser/ecmascript5/parserNotRegex2.ts === +declare const A: any; +>A : Symbol(A, Decl(parserNotRegex2.ts, 0, 13)) + +declare const B: any; +>B : Symbol(B, Decl(parserNotRegex2.ts, 1, 13)) + +declare const C: any; +>C : Symbol(C, Decl(parserNotRegex2.ts, 2, 13)) + +const x = (A / 2); +>x : Symbol(x, Decl(parserNotRegex2.ts, 3, 5)) +>A : Symbol(A, Decl(parserNotRegex2.ts, 0, 13)) + +B( +>B : Symbol(B, Decl(parserNotRegex2.ts, 1, 13)) + + C(), +>C : Symbol(C, Decl(parserNotRegex2.ts, 2, 13)) + + () => { }, + () => { } +); + diff --git a/tests/baselines/reference/parserNotRegex2.types b/tests/baselines/reference/parserNotRegex2.types new file mode 100644 index 00000000000..b5f04db3e31 --- /dev/null +++ b/tests/baselines/reference/parserNotRegex2.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/parser/ecmascript5/parserNotRegex2.ts === +declare const A: any; +>A : any + +declare const B: any; +>B : any + +declare const C: any; +>C : any + +const x = (A / 2); +>x : number +>(A / 2) : number +>A / 2 : number +>A : any +>2 : 2 + +B( +>B( C(), () => { }, () => { }) : any +>B : any + + C(), +>C() : any +>C : any + + () => { }, +>() => { } : () => void + + () => { } +>() => { } : () => void + +); + diff --git a/tests/cases/conformance/parser/ecmascript5/parserNotRegex2.ts b/tests/cases/conformance/parser/ecmascript5/parserNotRegex2.ts new file mode 100644 index 00000000000..3cd019f1a2c --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/parserNotRegex2.ts @@ -0,0 +1,9 @@ +declare const A: any; +declare const B: any; +declare const C: any; +const x = (A / 2); +B( + C(), + () => { }, + () => { } +); From 18217351366774f8cc31967f1116f28001367b3f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 21 Sep 2017 08:36:50 -0700 Subject: [PATCH 214/216] Add custom formatter which has clickable links, reduce error duplication in gulp output (#18613) --- Gulpfile.ts | 12 +-- Jakefile.js | 26 +++-- package.json | 4 +- .../autolinkableStylishFormatter.ts | 97 +++++++++++++++++++ .../tslint/{ => rules}/booleanTriviaRule.ts | 0 scripts/tslint/{ => rules}/debugAssertRule.ts | 0 scripts/tslint/{ => rules}/nextLineRule.ts | 0 scripts/tslint/{ => rules}/noBomRule.ts | 0 .../tslint/{ => rules}/noInOperatorRule.ts | 0 .../{ => rules}/noIncrementDecrementRule.ts | 0 .../noTypeAssertionWhitespaceRule.ts | 0 .../objectLiteralSurroundingSpaceRule.ts | 0 .../{ => rules}/typeOperatorSpacingRule.ts | 0 tslint.json | 2 +- 14 files changed, 127 insertions(+), 14 deletions(-) create mode 100644 scripts/tslint/formatters/autolinkableStylishFormatter.ts rename scripts/tslint/{ => rules}/booleanTriviaRule.ts (100%) rename scripts/tslint/{ => rules}/debugAssertRule.ts (100%) rename scripts/tslint/{ => rules}/nextLineRule.ts (100%) rename scripts/tslint/{ => rules}/noBomRule.ts (100%) rename scripts/tslint/{ => rules}/noInOperatorRule.ts (100%) rename scripts/tslint/{ => rules}/noIncrementDecrementRule.ts (100%) rename scripts/tslint/{ => rules}/noTypeAssertionWhitespaceRule.ts (100%) rename scripts/tslint/{ => rules}/objectLiteralSurroundingSpaceRule.ts (100%) rename scripts/tslint/{ => rules}/typeOperatorSpacingRule.ts (100%) diff --git a/Gulpfile.ts b/Gulpfile.ts index 676d07ec570..4ca099b56e4 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -674,11 +674,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: }); function failWithStatus(err?: any, status?: number) { - if (err) { - console.log(err); + if (err || status) { + process.exit(typeof status === "number" ? status : 2); } - done(err || status); - process.exit(status); + done(); } function lintThenFinish() { @@ -1051,10 +1050,11 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: const fileMatcher = cmdLineOptions["files"]; const files = fileMatcher ? `src/**/${fileMatcher}` - : "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; - const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; + : "Gulpfile.ts 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; + const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`; console.log("Linting: " + cmd); child_process.execSync(cmd, { stdio: [0, 1, 2] }); + if (fold.isTravis()) console.log(fold.end("lint")); }); gulp.task("default", "Runs 'local'", ["local"]); diff --git a/Jakefile.js b/Jakefile.js index 6fd2f549015..7de0635542b 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1121,7 +1121,7 @@ task("update-sublime", ["local", serverFile], function () { jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/"); }); -var tslintRuleDir = "scripts/tslint"; +var tslintRuleDir = "scripts/tslint/rules"; var tslintRules = [ "booleanTriviaRule", "debugAssertRule", @@ -1137,13 +1137,27 @@ var tslintRulesFiles = tslintRules.map(function (p) { return path.join(tslintRuleDir, p + ".ts"); }); var tslintRulesOutFiles = tslintRules.map(function (p) { - return path.join(builtLocalDirectory, "tslint", p + ".js"); + return path.join(builtLocalDirectory, "tslint/rules", p + ".js"); +}); +var tslintFormattersDir = "scripts/tslint/formatters"; +var tslintFormatters = [ + "autolinkableStylishFormatter", +]; +var tslintFormatterFiles = tslintFormatters.map(function (p) { + return path.join(tslintFormattersDir, p + ".ts"); +}); +var tslintFormattersOutFiles = tslintFormatters.map(function (p) { + return path.join(builtLocalDirectory, "tslint/formatters", p + ".js"); }); desc("Compiles tslint rules to js"); -task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"])); +task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(tslintFormattersOutFiles).concat(["build-rules-end"])); tslintRulesFiles.forEach(function (ruleFile, i) { compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, - { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" }); + { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint/rules"), lib: "es6" }); +}); +tslintFormatterFiles.forEach(function (ruleFile, i) { + compileFile(tslintFormattersOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, + { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint/formatters"), lib: "es6" }); }); desc("Emit the start of the build-rules fold"); @@ -1211,8 +1225,8 @@ task("lint", ["build-rules"], () => { const fileMatcher = process.env.f || process.env.file || process.env.files; const files = fileMatcher ? `src/**/${fileMatcher}` - : "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; - const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; + : "Gulpfile.ts 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; + const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`; console.log("Linting: " + cmd); jake.exec([cmd], { interactive: true }, () => { if (fold.isTravis()) console.log(fold.end("lint")); diff --git a/package.json b/package.json index 9e4b3234770..ca7d48c7774 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "devDependencies": { "@types/browserify": "latest", "@types/chai": "latest", + "@types/colors": "latest", "@types/convert-source-map": "latest", "@types/del": "latest", "@types/glob": "latest", @@ -48,8 +49,8 @@ "@types/q": "latest", "@types/run-sequence": "latest", "@types/through2": "latest", - "browserify": "latest", "browser-resolve": "^1.11.2", + "browserify": "latest", "chai": "latest", "convert-source-map": "latest", "del": "latest", @@ -75,6 +76,7 @@ "travis-fold": "latest", "ts-node": "latest", "tslint": "latest", + "colors": "latest", "typescript": "next" }, "scripts": { diff --git a/scripts/tslint/formatters/autolinkableStylishFormatter.ts b/scripts/tslint/formatters/autolinkableStylishFormatter.ts new file mode 100644 index 00000000000..6a02ec24f05 --- /dev/null +++ b/scripts/tslint/formatters/autolinkableStylishFormatter.ts @@ -0,0 +1,97 @@ +import * as Lint from "tslint"; +import * as colors from "colors"; +import { sep } from "path"; +function groupBy(array: ReadonlyArray | undefined, getGroupId: (elem: T, index: number) => number | string): T[][] { + if (!array) { + return []; + } + + const groupIdToGroup: { [index: string]: T[] } = {}; + let result: T[][] | undefined; // Compacted array for return value + for (let index = 0; index < array.length; index++) { + const value = array[index]; + const key = getGroupId(value, index); + if (groupIdToGroup[key]) { + groupIdToGroup[key].push(value); + } + else { + const newGroup = [value]; + groupIdToGroup[key] = newGroup; + if (!result) { + result = [newGroup]; + } + else { + result.push(newGroup); + } + } + } + + return result || []; +} + +function max(array: ReadonlyArray | undefined, selector: (elem: T) => number): number { + if (!array) { + return 0; + } + + let max = 0; + for (const item of array) { + const scalar = selector(item); + if (scalar > max) { + max = scalar; + } + } + return max; +} + +function getLink(failure: Lint.RuleFailure, color: boolean): string { + const lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); + const sev = failure.getRuleSeverity().toUpperCase(); + let path = failure.getFileName(); + // Most autolinks only become clickable if they contain a slash in some way; so we make a top level file into a relative path here + if (path.indexOf("/") === -1 && path.indexOf("\\") === -1) { + path = `.${sep}${path}`; + } + return `${color ? (sev === "WARNING" ? colors.blue(sev) : colors.red(sev)) : sev}: ${path}:${lineAndCharacter.line + 1}:${lineAndCharacter.character + 1}`; +} + +function getLinkMaxSize(failures: Lint.RuleFailure[]): number { + return max(failures, f => getLink(f, /*color*/ false).length); +} + +function getNameMaxSize(failures: Lint.RuleFailure[]): number { + return max(failures, f => f.getRuleName().length); +} + +function pad(str: string, visiblelen: number, len: number) { + if (visiblelen >= len) return str; + const count = len - visiblelen; + for (let i = 0; i < count; i++) { + str += " "; + } + return str; +} + +export class Formatter extends Lint.Formatters.AbstractFormatter { + public static metadata: Lint.IFormatterMetadata = { + formatterName: "autolinkableStylish", + description: "Human-readable formatter which creates stylish messages with autolinkable filepaths.", + descriptionDetails: Lint.Utils.dedent` + Colorized output grouped by file, with autolinkable filepaths containing line and column information + `, + sample: Lint.Utils.dedent` + src/myFile.ts + ERROR: src/myFile.ts:1:14 semicolon Missing semicolon`, + consumer: "human" + }; + public format(failures: Lint.RuleFailure[]): string { + return groupBy(failures, f => f.getFileName()).map(group => { + const currentFile = group[0].getFileName(); + const linkMaxSize = getLinkMaxSize(group); + const nameMaxSize = getNameMaxSize(group); + return ` +${currentFile} +${group.map(f => `${pad(getLink(f, /*color*/ true), getLink(f, /*color*/ false).length, linkMaxSize)} ${colors.grey(pad(f.getRuleName(), f.getRuleName().length, nameMaxSize))} ${colors.yellow(f.getFailure())}`).join("\n")}`; + }).join("\n"); + } +} \ No newline at end of file diff --git a/scripts/tslint/booleanTriviaRule.ts b/scripts/tslint/rules/booleanTriviaRule.ts similarity index 100% rename from scripts/tslint/booleanTriviaRule.ts rename to scripts/tslint/rules/booleanTriviaRule.ts diff --git a/scripts/tslint/debugAssertRule.ts b/scripts/tslint/rules/debugAssertRule.ts similarity index 100% rename from scripts/tslint/debugAssertRule.ts rename to scripts/tslint/rules/debugAssertRule.ts diff --git a/scripts/tslint/nextLineRule.ts b/scripts/tslint/rules/nextLineRule.ts similarity index 100% rename from scripts/tslint/nextLineRule.ts rename to scripts/tslint/rules/nextLineRule.ts diff --git a/scripts/tslint/noBomRule.ts b/scripts/tslint/rules/noBomRule.ts similarity index 100% rename from scripts/tslint/noBomRule.ts rename to scripts/tslint/rules/noBomRule.ts diff --git a/scripts/tslint/noInOperatorRule.ts b/scripts/tslint/rules/noInOperatorRule.ts similarity index 100% rename from scripts/tslint/noInOperatorRule.ts rename to scripts/tslint/rules/noInOperatorRule.ts diff --git a/scripts/tslint/noIncrementDecrementRule.ts b/scripts/tslint/rules/noIncrementDecrementRule.ts similarity index 100% rename from scripts/tslint/noIncrementDecrementRule.ts rename to scripts/tslint/rules/noIncrementDecrementRule.ts diff --git a/scripts/tslint/noTypeAssertionWhitespaceRule.ts b/scripts/tslint/rules/noTypeAssertionWhitespaceRule.ts similarity index 100% rename from scripts/tslint/noTypeAssertionWhitespaceRule.ts rename to scripts/tslint/rules/noTypeAssertionWhitespaceRule.ts diff --git a/scripts/tslint/objectLiteralSurroundingSpaceRule.ts b/scripts/tslint/rules/objectLiteralSurroundingSpaceRule.ts similarity index 100% rename from scripts/tslint/objectLiteralSurroundingSpaceRule.ts rename to scripts/tslint/rules/objectLiteralSurroundingSpaceRule.ts diff --git a/scripts/tslint/typeOperatorSpacingRule.ts b/scripts/tslint/rules/typeOperatorSpacingRule.ts similarity index 100% rename from scripts/tslint/typeOperatorSpacingRule.ts rename to scripts/tslint/rules/typeOperatorSpacingRule.ts diff --git a/tslint.json b/tslint.json index 30e71eb5e0d..be289ae1328 100644 --- a/tslint.json +++ b/tslint.json @@ -1,5 +1,5 @@ { - "rulesDirectory": "built/local/tslint", + "rulesDirectory": "built/local/tslint/rules", "rules": { "boolean-trivia": true, "class-name": true, From 3cc0aeb6be1652c08b3803a29fd0a6dedc6faf69 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 21 Sep 2017 09:44:51 -0700 Subject: [PATCH 215/216] PR comments I plan to fix the missing comment issue when I add the convert-jsdoc-types-to-typescript-types refactoring. Or at least work around it. --- src/services/textChanges.ts | 4 +++- tests/cases/fourslash/extract-method-uniqueName.ts | 2 ++ .../fourslash/server/convertFunctionToEs6Class-server.ts | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index fdfac9e54cc..5a01752f38e 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -152,7 +152,9 @@ namespace ts.textChanges { return position === Position.Start ? start : fullStart; } // get start position of the line following the line that contains fullstart position - let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + (fullStart > 0 ? 1 : 0), sourceFile); + // (but only if the fullstart isn't the very beginning of the file) + const nextLineStart = fullStart > 0 ? 1 : 0; + let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + nextLineStart, sourceFile); // skip whitespaces/newlines adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return getStartPositionOfLine(getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); diff --git a/tests/cases/fourslash/extract-method-uniqueName.ts b/tests/cases/fourslash/extract-method-uniqueName.ts index 5c359b23164..8f024ad6a47 100644 --- a/tests/cases/fourslash/extract-method-uniqueName.ts +++ b/tests/cases/fourslash/extract-method-uniqueName.ts @@ -3,6 +3,8 @@ ////// newFunction /////*start*/1 + 1/*end*/; +// NOTE: '// newFunction' should be included, but due to incorrect handling of trivia, +// it's omitted right now. goTo.select('start', 'end') edit.applyRefactor({ refactorName: "Extract Method", diff --git a/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts b/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts index 83a05b0661a..437bf6dadf4 100644 --- a/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts +++ b/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts @@ -12,6 +12,8 @@ //// } verify.applicableRefactorAvailableAtMarker('1'); +// NOTE: '// Comment' should be included, but due to incorrect handling of trivia, +// it's omitted right now. verify.fileAfterApplyingRefactorAtMarker('1', `class fn { constructor() { From b670b9763f3bf007309edf13cb250ca8bfd4bf2f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 21 Sep 2017 10:42:06 -0700 Subject: [PATCH 216/216] Typo fix --- src/harness/parallel/host.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts index 67d1a4db1a7..9f5ebdd790c 100644 --- a/src/harness/parallel/host.ts +++ b/src/harness/parallel/host.ts @@ -150,7 +150,7 @@ namespace Harness.Parallel.Host { } // Send tasks in blocks if the tasks are small const taskList = [tasks.pop()]; - while (tasks.length && taskList.reduce((p, c) => p + c.size, 0) > chunkSize) { + while (tasks.length && taskList.reduce((p, c) => p + c.size, 0) < chunkSize) { taskList.push(tasks.pop()); } if (taskList.length === 1) { @@ -469,4 +469,4 @@ namespace Harness.Parallel.Host { if (value > max) return max; return value; } -} \ No newline at end of file +}