diff --git a/lib/tsc.js b/lib/tsc.js index db7a3e764cc..bad684cc668 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -61,7 +61,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook var ts; (function (ts) { ts.versionMajorMinor = "3.2"; - ts.version = ts.versionMajorMinor + ".1"; + ts.version = ts.versionMajorMinor + ".2"; })(ts || (ts = {})); (function (ts) { ts.emptyArray = []; diff --git a/lib/tsserver.js b/lib/tsserver.js index c33ea2f41fe..e8a957a6339 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -88,7 +88,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.2"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".1"; + ts.version = ts.versionMajorMinor + ".2"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -96713,14 +96713,11 @@ var ts; // If already using commonjs, don't introduce ES6. if (sourceFile.commonJsModuleIndicator) return false; - // For JS, stay on the safe side. - if (isUncheckedFile) - return false; - // If some file is using ES6 modules, assume that it's OK to add more. - if (ts.programContainsEs6Modules(program)) - return true; // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK. - return ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()); + if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) + return true; + // If some file is using ES6 modules, assume that it's OK to add more. + return ts.programContainsEs6Modules(program); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { @@ -97519,7 +97516,7 @@ var ts; } } function isFunctionLikeBodyKeyword(kind) { - return kind === 121 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); + return kind === 121 /* AsyncKeyword */ || kind === 122 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; @@ -106816,10 +106813,7 @@ var ts; * Trimming will be done for lines after the previous range */ function trimTrailingWhitespacesForRemainingRange() { - if (!previousRange) { - return; - } - var startPosition = previousRange.end; + var startPosition = previousRange ? previousRange.end : originalRange.pos; var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); @@ -109120,20 +109114,8 @@ var ts; annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); } } - function isApplicableFunctionForInference(declaration) { - switch (declaration.kind) { - case 239 /* FunctionDeclaration */: - case 156 /* MethodDeclaration */: - case 157 /* Constructor */: - return true; - case 196 /* FunctionExpression */: - var parent = declaration.parent; - return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) || !!declaration.name; - } - return false; - } function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { - if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { + if (!ts.isIdentifier(parameterDeclaration.name)) { return; } var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || @@ -109146,12 +109128,17 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + if (needParens) + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.createToken(20 /* OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { annotate(changes, sourceFile, declaration, type, program, host); } } + if (needParens) + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.createToken(21 /* CloseParenToken */)); } } function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { @@ -109272,6 +109259,7 @@ var ts; case 157 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 124 /* ConstructorKeyword */, sourceFile); break; + case 197 /* ArrowFunction */: case 196 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 18c25a199a9..997b33e1177 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -84,7 +84,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.2"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".1"; + ts.version = ts.versionMajorMinor + ".2"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -97023,14 +97023,11 @@ var ts; // If already using commonjs, don't introduce ES6. if (sourceFile.commonJsModuleIndicator) return false; - // For JS, stay on the safe side. - if (isUncheckedFile) - return false; - // If some file is using ES6 modules, assume that it's OK to add more. - if (ts.programContainsEs6Modules(program)) - return true; // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK. - return ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()); + if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) + return true; + // If some file is using ES6 modules, assume that it's OK to add more. + return ts.programContainsEs6Modules(program); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { @@ -97829,7 +97826,7 @@ var ts; } } function isFunctionLikeBodyKeyword(kind) { - return kind === 121 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); + return kind === 121 /* AsyncKeyword */ || kind === 122 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; @@ -107126,10 +107123,7 @@ var ts; * Trimming will be done for lines after the previous range */ function trimTrailingWhitespacesForRemainingRange() { - if (!previousRange) { - return; - } - var startPosition = previousRange.end; + var startPosition = previousRange ? previousRange.end : originalRange.pos; var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); @@ -109396,20 +109390,8 @@ var ts; annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); } } - function isApplicableFunctionForInference(declaration) { - switch (declaration.kind) { - case 239 /* FunctionDeclaration */: - case 156 /* MethodDeclaration */: - case 157 /* Constructor */: - return true; - case 196 /* FunctionExpression */: - var parent = declaration.parent; - return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) || !!declaration.name; - } - return false; - } function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { - if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { + if (!ts.isIdentifier(parameterDeclaration.name)) { return; } var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || @@ -109422,12 +109404,17 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + if (needParens) + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.createToken(20 /* OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { annotate(changes, sourceFile, declaration, type, program, host); } } + if (needParens) + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.createToken(21 /* CloseParenToken */)); } } function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { @@ -109548,6 +109535,7 @@ var ts; case 157 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 124 /* ConstructorKeyword */, sourceFile); break; + case 197 /* ArrowFunction */: case 196 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? diff --git a/lib/typescript.js b/lib/typescript.js index bf405c5c095..2a87d69eca7 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -75,7 +75,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.2"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".1"; + ts.version = ts.versionMajorMinor + ".2"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -97014,14 +97014,11 @@ var ts; // If already using commonjs, don't introduce ES6. if (sourceFile.commonJsModuleIndicator) return false; - // For JS, stay on the safe side. - if (isUncheckedFile) - return false; - // If some file is using ES6 modules, assume that it's OK to add more. - if (ts.programContainsEs6Modules(program)) - return true; // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK. - return ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()); + if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) + return true; + // If some file is using ES6 modules, assume that it's OK to add more. + return ts.programContainsEs6Modules(program); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { @@ -97820,7 +97817,7 @@ var ts; } } function isFunctionLikeBodyKeyword(kind) { - return kind === 121 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); + return kind === 121 /* AsyncKeyword */ || kind === 122 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; @@ -107117,10 +107114,7 @@ var ts; * Trimming will be done for lines after the previous range */ function trimTrailingWhitespacesForRemainingRange() { - if (!previousRange) { - return; - } - var startPosition = previousRange.end; + var startPosition = previousRange ? previousRange.end : originalRange.pos; var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); @@ -109387,20 +109381,8 @@ var ts; annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); } } - function isApplicableFunctionForInference(declaration) { - switch (declaration.kind) { - case 239 /* FunctionDeclaration */: - case 156 /* MethodDeclaration */: - case 157 /* Constructor */: - return true; - case 196 /* FunctionExpression */: - var parent = declaration.parent; - return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) || !!declaration.name; - } - return false; - } function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { - if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { + if (!ts.isIdentifier(parameterDeclaration.name)) { return; } var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || @@ -109413,12 +109395,17 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + if (needParens) + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.createToken(20 /* OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { annotate(changes, sourceFile, declaration, type, program, host); } } + if (needParens) + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.createToken(21 /* CloseParenToken */)); } } function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { @@ -109539,6 +109526,7 @@ var ts; case 157 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 124 /* ConstructorKeyword */, sourceFile); break; + case 197 /* ArrowFunction */: case 196 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index bf405c5c095..2a87d69eca7 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -75,7 +75,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.2"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".1"; + ts.version = ts.versionMajorMinor + ".2"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -97014,14 +97014,11 @@ var ts; // If already using commonjs, don't introduce ES6. if (sourceFile.commonJsModuleIndicator) return false; - // For JS, stay on the safe side. - if (isUncheckedFile) - return false; - // If some file is using ES6 modules, assume that it's OK to add more. - if (ts.programContainsEs6Modules(program)) - return true; // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK. - return ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()); + if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) + return true; + // If some file is using ES6 modules, assume that it's OK to add more. + return ts.programContainsEs6Modules(program); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { @@ -97820,7 +97817,7 @@ var ts; } } function isFunctionLikeBodyKeyword(kind) { - return kind === 121 /* AsyncKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); + return kind === 121 /* AsyncKeyword */ || kind === 122 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; @@ -107117,10 +107114,7 @@ var ts; * Trimming will be done for lines after the previous range */ function trimTrailingWhitespacesForRemainingRange() { - if (!previousRange) { - return; - } - var startPosition = previousRange.end; + var startPosition = previousRange ? previousRange.end : originalRange.pos; var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); @@ -109387,20 +109381,8 @@ var ts; annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); } } - function isApplicableFunctionForInference(declaration) { - switch (declaration.kind) { - case 239 /* FunctionDeclaration */: - case 156 /* MethodDeclaration */: - case 157 /* Constructor */: - return true; - case 196 /* FunctionExpression */: - var parent = declaration.parent; - return ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) || !!declaration.name; - } - return false; - } function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { - if (!ts.isIdentifier(parameterDeclaration.name) || !isApplicableFunctionForInference(containingFunction)) { + if (!ts.isIdentifier(parameterDeclaration.name)) { return; } var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || @@ -109413,12 +109395,17 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + if (needParens) + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.createToken(20 /* OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { annotate(changes, sourceFile, declaration, type, program, host); } } + if (needParens) + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.createToken(21 /* CloseParenToken */)); } } function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { @@ -109539,6 +109526,7 @@ var ts; case 157 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 124 /* ConstructorKeyword */, sourceFile); break; + case 197 /* ArrowFunction */: case 196 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index f6d1631491b..7de5d4544d0 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -88,7 +88,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.2"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".1"; + ts.version = ts.versionMajorMinor + ".2"; })(ts || (ts = {})); (function (ts) { /* @internal */