Skip to content

Commit 7275ded

Browse files
Bump version to 5.1.3 and update LKG.
1 parent 1143a21 commit 7275ded

9 files changed

+221
-138
lines changed

Diff for: lib/tsc.js

+28-29
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and limitations under the License.
1818

1919
// src/compiler/corePublic.ts
2020
var versionMajorMinor = "5.1";
21-
var version = "5.1.1-rc";
21+
var version = "5.1.3";
2222

2323
// src/compiler/core.ts
2424
var emptyArray = [];
@@ -7704,6 +7704,7 @@ var Diagnostics = {
77047704
Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
77057705
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
77067706
Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
7707+
Cannot_move_to_file_selected_file_is_invalid: diag(95179, 3 /* Message */, "Cannot_move_to_file_selected_file_is_invalid_95179", "Cannot move to file, selected file is invalid"),
77077708
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
77087709
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
77097710
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -53984,7 +53985,7 @@ function createTypeChecker(host) {
5398453985
} else if (type !== firstType) {
5398553986
checkFlags |= 64 /* HasNonUniformType */;
5398653987
}
53987-
if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
53988+
if (isLiteralType(type) || isPatternLiteralType(type)) {
5398853989
checkFlags |= 128 /* HasLiteralType */;
5398953990
}
5399053991
if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
@@ -56183,31 +56184,28 @@ function createTypeChecker(host) {
5618356184
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
5618456185
}
5618556186
function getUnionOrIntersectionTypePredicate(signatures, kind) {
56186-
let first2;
56187+
let last2;
5618756188
const types = [];
5618856189
for (const sig of signatures) {
5618956190
const pred = getTypePredicateOfSignature(sig);
56190-
if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) {
56191-
if (kind !== 2097152 /* Intersection */) {
56192-
continue;
56193-
} else {
56194-
return;
56195-
}
56196-
}
56197-
if (first2) {
56198-
if (!typePredicateKindsMatch(first2, pred)) {
56191+
if (pred) {
56192+
if (pred.kind !== 0 /* This */ && pred.kind !== 1 /* Identifier */ || last2 && !typePredicateKindsMatch(last2, pred)) {
5619956193
return void 0;
5620056194
}
56195+
last2 = pred;
56196+
types.push(pred.type);
5620156197
} else {
56202-
first2 = pred;
56198+
const returnType = kind !== 2097152 /* Intersection */ ? getReturnTypeOfSignature(sig) : void 0;
56199+
if (returnType !== falseType && returnType !== regularFalseType) {
56200+
return void 0;
56201+
}
5620356202
}
56204-
types.push(pred.type);
5620556203
}
56206-
if (!first2) {
56204+
if (!last2) {
5620756205
return void 0;
5620856206
}
5620956207
const compositeType = getUnionOrIntersectionType(types, kind);
56210-
return createTypePredicate(first2.kind, first2.parameterName, first2.parameterIndex, compositeType);
56208+
return createTypePredicate(last2.kind, last2.parameterName, last2.parameterIndex, compositeType);
5621156209
}
5621256210
function typePredicateKindsMatch(a, b) {
5621356211
return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
@@ -58088,18 +58086,19 @@ function createTypeChecker(host) {
5808858086
case 185 /* TypeQuery */:
5808958087
const entityName = node2.exprName;
5809058088
const firstIdentifier = getFirstIdentifier(entityName);
58091-
const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
58092-
const tpDeclaration = tp.symbol.declarations[0];
58093-
let tpScope;
58094-
if (tpDeclaration.kind === 167 /* TypeParameter */) {
58095-
tpScope = tpDeclaration.parent;
58096-
} else if (tp.isThisType) {
58097-
tpScope = tpDeclaration;
58098-
} else {
58099-
return true;
58100-
}
58101-
if (firstIdentifierSymbol.declarations) {
58102-
return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
58089+
if (!isThisIdentifier(firstIdentifier)) {
58090+
const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
58091+
const tpDeclaration = tp.symbol.declarations[0];
58092+
const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
58093+
// Type parameter is a regular type parameter, e.g. foo<T>
58094+
tp.isThisType ? tpDeclaration : (
58095+
// Type parameter is the this type, and its declaration is the class declaration.
58096+
void 0
58097+
)
58098+
);
58099+
if (firstIdentifierSymbol.declarations && tpScope) {
58100+
return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
58101+
}
5810358102
}
5810458103
return true;
5810558104
case 173 /* MethodDeclaration */:
@@ -81638,7 +81637,7 @@ function createTypeChecker(host) {
8163881637
if (requestedExternalEmitHelperNames.has(name))
8163981638
continue;
8164081639
requestedExternalEmitHelperNames.add(name);
81641-
const symbol = getSymbol(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
81640+
const symbol = resolveSymbol(getSymbol(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
8164281641
if (!symbol) {
8164381642
error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
8164481643
} else if (helper & 524288 /* ClassPrivateFieldGet */) {

Diff for: lib/tsserver.js

+62-35
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,7 @@ module.exports = __toCommonJS(server_exports);
23042304

23052305
// src/compiler/corePublic.ts
23062306
var versionMajorMinor = "5.1";
2307-
var version = "5.1.1-rc";
2307+
var version = "5.1.3";
23082308
var Comparison = /* @__PURE__ */ ((Comparison3) => {
23092309
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
23102310
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -11212,6 +11212,7 @@ var Diagnostics = {
1121211212
Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
1121311213
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
1121411214
Move_to_file: diag(95178, 3 /* Message */, "Move_to_file_95178", "Move to file"),
11215+
Cannot_move_to_file_selected_file_is_invalid: diag(95179, 3 /* Message */, "Cannot_move_to_file_selected_file_is_invalid_95179", "Cannot move to file, selected file is invalid"),
1121511216
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
1121611217
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
1121711218
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -58635,7 +58636,7 @@ function createTypeChecker(host) {
5863558636
} else if (type !== firstType) {
5863658637
checkFlags |= 64 /* HasNonUniformType */;
5863758638
}
58638-
if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) {
58639+
if (isLiteralType(type) || isPatternLiteralType(type)) {
5863958640
checkFlags |= 128 /* HasLiteralType */;
5864058641
}
5864158642
if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) {
@@ -60834,31 +60835,28 @@ function createTypeChecker(host) {
6083460835
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
6083560836
}
6083660837
function getUnionOrIntersectionTypePredicate(signatures, kind) {
60837-
let first2;
60838+
let last2;
6083860839
const types = [];
6083960840
for (const sig of signatures) {
6084060841
const pred = getTypePredicateOfSignature(sig);
60841-
if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) {
60842-
if (kind !== 2097152 /* Intersection */) {
60843-
continue;
60844-
} else {
60845-
return;
60846-
}
60847-
}
60848-
if (first2) {
60849-
if (!typePredicateKindsMatch(first2, pred)) {
60842+
if (pred) {
60843+
if (pred.kind !== 0 /* This */ && pred.kind !== 1 /* Identifier */ || last2 && !typePredicateKindsMatch(last2, pred)) {
6085060844
return void 0;
6085160845
}
60846+
last2 = pred;
60847+
types.push(pred.type);
6085260848
} else {
60853-
first2 = pred;
60849+
const returnType = kind !== 2097152 /* Intersection */ ? getReturnTypeOfSignature(sig) : void 0;
60850+
if (returnType !== falseType && returnType !== regularFalseType) {
60851+
return void 0;
60852+
}
6085460853
}
60855-
types.push(pred.type);
6085660854
}
60857-
if (!first2) {
60855+
if (!last2) {
6085860856
return void 0;
6085960857
}
6086060858
const compositeType = getUnionOrIntersectionType(types, kind);
60861-
return createTypePredicate(first2.kind, first2.parameterName, first2.parameterIndex, compositeType);
60859+
return createTypePredicate(last2.kind, last2.parameterName, last2.parameterIndex, compositeType);
6086260860
}
6086360861
function typePredicateKindsMatch(a, b) {
6086460862
return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
@@ -62739,18 +62737,19 @@ function createTypeChecker(host) {
6273962737
case 185 /* TypeQuery */:
6274062738
const entityName = node2.exprName;
6274162739
const firstIdentifier = getFirstIdentifier(entityName);
62742-
const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
62743-
const tpDeclaration = tp.symbol.declarations[0];
62744-
let tpScope;
62745-
if (tpDeclaration.kind === 167 /* TypeParameter */) {
62746-
tpScope = tpDeclaration.parent;
62747-
} else if (tp.isThisType) {
62748-
tpScope = tpDeclaration;
62749-
} else {
62750-
return true;
62751-
}
62752-
if (firstIdentifierSymbol.declarations) {
62753-
return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
62740+
if (!isThisIdentifier(firstIdentifier)) {
62741+
const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
62742+
const tpDeclaration = tp.symbol.declarations[0];
62743+
const tpScope = tpDeclaration.kind === 167 /* TypeParameter */ ? tpDeclaration.parent : (
62744+
// Type parameter is a regular type parameter, e.g. foo<T>
62745+
tp.isThisType ? tpDeclaration : (
62746+
// Type parameter is the this type, and its declaration is the class declaration.
62747+
void 0
62748+
)
62749+
);
62750+
if (firstIdentifierSymbol.declarations && tpScope) {
62751+
return some(firstIdentifierSymbol.declarations, (idDecl) => isNodeDescendantOf(idDecl, tpScope)) || some(node2.typeArguments, containsReference);
62752+
}
6275462753
}
6275562754
return true;
6275662755
case 173 /* MethodDeclaration */:
@@ -86289,7 +86288,7 @@ function createTypeChecker(host) {
8628986288
if (requestedExternalEmitHelperNames.has(name))
8629086289
continue;
8629186290
requestedExternalEmitHelperNames.add(name);
86292-
const symbol = getSymbol2(helpersModule.exports, escapeLeadingUnderscores(name), 111551 /* Value */);
86291+
const symbol = resolveSymbol(getSymbol2(getExportsOfModule(helpersModule), escapeLeadingUnderscores(name), 111551 /* Value */));
8629386292
if (!symbol) {
8629486293
error(location, Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, externalHelpersModuleNameText, name);
8629586294
} else if (helper & 524288 /* ClassPrivateFieldGet */) {
@@ -136456,15 +136455,18 @@ registerRefactor(refactorNameForMoveToFile, {
136456136455
Debug.assert(actionName2 === refactorNameForMoveToFile, "Wrong refactor invoked");
136457136456
const statements = Debug.checkDefined(getStatementsToMove(context));
136458136457
Debug.assert(interactiveRefactorArguments, "No interactive refactor arguments available");
136459-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
136460-
return { edits, renameFilename: void 0, renameLocation: void 0 };
136458+
const targetFile = interactiveRefactorArguments.targetFile;
136459+
if (hasJSFileExtension(targetFile) || hasTSFileExtension(targetFile)) {
136460+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(context, context.file, interactiveRefactorArguments.targetFile, context.program, statements, t, context.host, context.preferences));
136461+
return { edits, renameFilename: void 0, renameLocation: void 0 };
136462+
}
136463+
return { edits: [], renameFilename: void 0, renameLocation: void 0, notApplicableReason: getLocaleSpecificMessage(Diagnostics.Cannot_move_to_file_selected_file_is_invalid) };
136461136464
}
136462136465
});
136463136466
function doChange4(context, oldFile, targetFile, program, toMove, changes, host, preferences) {
136464-
var _a;
136465136467
const checker = program.getTypeChecker();
136466136468
const usage = getUsageInfo(oldFile, toMove.all, checker);
136467-
if (!host.fileExists(targetFile) || host.fileExists(targetFile) && ((_a = program.getSourceFile(targetFile)) == null ? void 0 : _a.statements.length) === 0) {
136469+
if (!host.fileExists(targetFile)) {
136468136470
changes.createNewFile(oldFile, targetFile, getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, changes, toMove, program, host, preferences));
136469136471
addNewFileToTsconfig(program, changes, oldFile.fileName, targetFile, hostGetCanonicalFileName(host));
136470136472
} else {
@@ -136502,6 +136504,13 @@ function getNewStatementsAndRemoveFromOldFile2(oldFile, targetFile, usage, chang
136502136504
if (typeof targetFile !== "string") {
136503136505
if (targetFile.statements.length > 0) {
136504136506
changes.insertNodesAfter(targetFile, targetFile.statements[targetFile.statements.length - 1], body);
136507+
} else {
136508+
changes.insertNodesAtEndOfFile(
136509+
targetFile,
136510+
body,
136511+
/*blankLineBetween*/
136512+
false
136513+
);
136505136514
}
136506136515
if (imports.length > 0) {
136507136516
insertImports(
@@ -141839,7 +141848,11 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
141839141848
onUnRecoverableConfigFileDiagnostic: noop
141840141849
};
141841141850
const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
141851+
let releasedScriptKinds = /* @__PURE__ */ new Set();
141842141852
if (isProgramUptoDate(program, rootFileNames, newSettings, (_path, fileName) => host.getScriptVersion(fileName), (fileName) => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasInvalidatedLibResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
141853+
compilerHost = void 0;
141854+
parsedCommandLines = void 0;
141855+
releasedScriptKinds = void 0;
141843141856
return;
141844141857
}
141845141858
const options = {
@@ -141852,6 +141865,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
141852141865
program = createProgram(options);
141853141866
compilerHost = void 0;
141854141867
parsedCommandLines = void 0;
141868+
releasedScriptKinds = void 0;
141855141869
sourceMapper.clearCache();
141856141870
program.getTypeChecker();
141857141871
return;
@@ -141906,10 +141920,11 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
141906141920
if (!shouldCreateNewSourceFile) {
141907141921
const oldSourceFile = program && program.getSourceFileByPath(path);
141908141922
if (oldSourceFile) {
141909-
if (scriptKind === oldSourceFile.scriptKind) {
141923+
if (scriptKind === oldSourceFile.scriptKind || releasedScriptKinds.has(oldSourceFile.resolvedPath)) {
141910141924
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
141911141925
} else {
141912141926
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
141927+
releasedScriptKinds.add(oldSourceFile.resolvedPath);
141913141928
}
141914141929
}
141915141930
}
@@ -165853,6 +165868,17 @@ var ChangeTracker = class {
165853165868
this.insertNodeAt(sourceFile, pos, insert, options);
165854165869
}
165855165870
}
165871+
insertNodesAtEndOfFile(sourceFile, newNodes, blankLineBetween) {
165872+
this.insertAtEndOfFile(sourceFile, newNodes, blankLineBetween);
165873+
}
165874+
insertAtEndOfFile(sourceFile, insert, blankLineBetween) {
165875+
const pos = sourceFile.end + 1;
165876+
const options = {
165877+
prefix: this.newLineCharacter,
165878+
suffix: this.newLineCharacter + (blankLineBetween ? this.newLineCharacter : "")
165879+
};
165880+
this.insertNodesAt(sourceFile, pos, insert, options);
165881+
}
165856165882
insertStatementsInNewFile(fileName, statements, oldFile) {
165857165883
if (!this.newFileChanges) {
165858165884
this.newFileChanges = createMultiMap();
@@ -181964,7 +181990,8 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
181964181990
return {
181965181991
renameLocation: mappedRenameLocation,
181966181992
renameFilename,
181967-
edits: this.mapTextChangesToCodeEdits(edits)
181993+
edits: this.mapTextChangesToCodeEdits(edits),
181994+
notApplicableReason: result.notApplicableReason
181968181995
};
181969181996
}
181970181997
return result;

Diff for: lib/tsserverlibrary.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ declare namespace ts {
619619
*/
620620
renameLocation?: Location;
621621
renameFilename?: string;
622+
notApplicableReason?: string;
622623
}
623624
/**
624625
* Organize imports by:
@@ -10190,7 +10191,7 @@ declare namespace ts {
1019010191
* arguments for any interactive action before offering it.
1019110192
*/
1019210193
getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string, includeInteractiveActions?: boolean): ApplicableRefactorInfo[];
10193-
getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined, includeInteractiveActions?: InteractiveRefactorArguments): RefactorEditInfo | undefined;
10194+
getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined, interactiveRefactorArguments?: InteractiveRefactorArguments): RefactorEditInfo | undefined;
1019410195
getMoveToRefactoringFileSuggestions(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): {
1019510196
newFileName: string;
1019610197
files: string[];
@@ -10480,6 +10481,7 @@ declare namespace ts {
1048010481
renameFilename?: string;
1048110482
renameLocation?: number;
1048210483
commands?: CodeActionCommand[];
10484+
notApplicableReason?: string;
1048310485
}
1048410486
type RefactorTriggerReason = "implicit" | "invoked";
1048510487
interface TextInsertion {

0 commit comments

Comments
 (0)