Skip to content

Commit e5fd876

Browse files
committed
Merge branch 'master' into report-multiple-overload-errors
2 parents caff266 + 7ed3896 commit e5fd876

File tree

393 files changed

+5171
-3777
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+5171
-3777
lines changed

.yarnrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--install.no-lockfile true

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4998,7 +4998,10 @@
49984998
"category": "Message",
49994999
"code": 95079
50005000
},
5001-
5001+
"Infer 'this' type of '{0}' from usage": {
5002+
"category": "Message",
5003+
"code": 95080
5004+
},
50025005
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
50035006
"category": "Error",
50045007
"code": 18004

src/compiler/factory.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,6 +2204,13 @@ namespace ts {
22042204
return tag;
22052205
}
22062206

2207+
/** @internal */
2208+
export function createJSDocThisTag(typeExpression?: JSDocTypeExpression): JSDocThisTag {
2209+
const tag = createJSDocTag<JSDocThisTag>(SyntaxKind.JSDocThisTag, "this");
2210+
tag.typeExpression = typeExpression;
2211+
return tag;
2212+
}
2213+
22072214
/* @internal */
22082215
export function createJSDocParamTag(name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, comment?: string): JSDocParameterTag {
22092216
const tag = createJSDocTag<JSDocParameterTag>(SyntaxKind.JSDocParameterTag, "param");

src/compiler/utilities.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5187,6 +5187,9 @@ namespace ts {
51875187
return node.parent.left.name;
51885188
}
51895189
}
5190+
else if (isVariableDeclaration(node.parent) && isIdentifier(node.parent.name)) {
5191+
return node.parent.name;
5192+
}
51905193
}
51915194

51925195
/**

src/harness/client.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,15 @@ namespace ts.server {
395395
const locations: RenameLocation[] = [];
396396
for (const entry of body.locs) {
397397
const fileName = entry.file;
398-
for (const { start, end, ...prefixSuffixText } of entry.locs) {
399-
locations.push({ textSpan: this.decodeSpan({ start, end }, fileName), fileName, ...prefixSuffixText });
398+
for (const { start, end, contextStart, contextEnd, ...prefixSuffixText } of entry.locs) {
399+
locations.push({
400+
textSpan: this.decodeSpan({ start, end }, fileName),
401+
fileName,
402+
...(contextStart !== undefined ?
403+
{ contextSpan: this.decodeSpan({ start: contextStart, end: contextEnd! }, fileName) } :
404+
undefined),
405+
...prefixSuffixText
406+
});
400407
}
401408
}
402409

src/harness/fourslash.ts

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace FourSlash {
4242
* is a range with `text in range` "selected".
4343
*/
4444
ranges: Range[];
45+
rangesByText?: ts.MultiMap<Range>;
4546
}
4647

4748
export interface Marker {
@@ -955,12 +956,15 @@ namespace FourSlash {
955956
const fullExpected = ts.map<FourSlashInterface.ReferenceGroup, ReferenceGroupJson>(parts, ({ definition, ranges }) => ({
956957
definition: typeof definition === "string" ? definition : { ...definition, range: ts.createTextSpanFromRange(definition.range) },
957958
references: ranges.map<ts.ReferenceEntry>(r => {
958-
const { isWriteAccess = false, isDefinition = false, isInString } = (r.marker && r.marker.data || {}) as { isWriteAccess?: boolean, isDefinition?: boolean, isInString?: true };
959+
const { isWriteAccess = false, isDefinition = false, isInString, contextRangeIndex } = (r.marker && r.marker.data || {}) as { isWriteAccess?: boolean, isDefinition?: boolean, isInString?: true, contextRangeIndex?: number };
959960
return {
960961
fileName: r.fileName,
961962
textSpan: ts.createTextSpanFromRange(r),
962963
isWriteAccess,
963964
isDefinition,
965+
...(contextRangeIndex !== undefined ?
966+
{ contextSpan: ts.createTextSpanFromRange(this.getRanges()[contextRangeIndex]) } :
967+
undefined),
964968
...(isInString ? { isInString: true } : undefined),
965969
};
966970
}),
@@ -997,8 +1001,8 @@ namespace FourSlash {
9971001
assert.deepEqual<ReadonlyArray<ts.ReferenceEntry> | undefined>(refs, expected);
9981002
}
9991003

1000-
public verifySingleReferenceGroup(definition: FourSlashInterface.ReferenceGroupDefinition, ranges?: Range[]) {
1001-
ranges = ranges || this.getRanges();
1004+
public verifySingleReferenceGroup(definition: FourSlashInterface.ReferenceGroupDefinition, ranges?: Range[] | string) {
1005+
ranges = ts.isString(ranges) ? this.rangesByText().get(ranges)! : ranges || this.getRanges();
10021006
this.verifyReferenceGroups(ranges, [{ definition, ranges }]);
10031007
}
10041008

@@ -1011,7 +1015,7 @@ Actual: ${stringify(fullActual)}`);
10111015
};
10121016

10131017
if ((actual === undefined) !== (expected === undefined)) {
1014-
fail(`Expected ${expected}, got ${actual}`);
1018+
fail(`Expected ${stringify(expected)}, got ${stringify(actual)}`);
10151019
}
10161020

10171021
for (const key in actual) {
@@ -1021,7 +1025,7 @@ Actual: ${stringify(fullActual)}`);
10211025
recur(ak, ek, path ? path + "." + key : key);
10221026
}
10231027
else if (ak !== ek) {
1024-
fail(`Expected '${key}' to be '${ek}', got '${ak}'`);
1028+
fail(`Expected '${key}' to be '${stringify(ek)}', got '${stringify(ak)}'`);
10251029
}
10261030
}
10271031
}
@@ -1189,7 +1193,15 @@ Actual: ${stringify(fullActual)}`);
11891193
locations && ts.sort(locations, (r1, r2) => ts.compareStringsCaseSensitive(r1.fileName, r2.fileName) || r1.textSpan.start - r2.textSpan.start);
11901194
assert.deepEqual(sort(references), sort(ranges.map((rangeOrOptions): ts.RenameLocation => {
11911195
const { range, ...prefixSuffixText } = "range" in rangeOrOptions ? rangeOrOptions : { range: rangeOrOptions };
1192-
return { fileName: range.fileName, textSpan: ts.createTextSpanFromRange(range), ...prefixSuffixText };
1196+
const { contextRangeIndex } = (range.marker && range.marker.data || {}) as { contextRangeIndex?: number; };
1197+
return {
1198+
fileName: range.fileName,
1199+
textSpan: ts.createTextSpanFromRange(range),
1200+
...(contextRangeIndex !== undefined ?
1201+
{ contextSpan: ts.createTextSpanFromRange(this.getRanges()[contextRangeIndex]) } :
1202+
undefined),
1203+
...prefixSuffixText
1204+
};
11931205
})));
11941206
}
11951207
}
@@ -1844,6 +1856,7 @@ Actual: ${stringify(fullActual)}`);
18441856
range.end = updatePosition(range.end, editStart, editEnd, newText);
18451857
}
18461858
}
1859+
this.testData.rangesByText = undefined;
18471860
}
18481861

18491862
private removeWhitespace(text: string): string {
@@ -2026,7 +2039,9 @@ Actual: ${stringify(fullActual)}`);
20262039
}
20272040

20282041
public rangesByText(): ts.Map<Range[]> {
2042+
if (this.testData.rangesByText) return this.testData.rangesByText;
20292043
const result = ts.createMultiMap<Range>();
2044+
this.testData.rangesByText = result;
20302045
for (const range of this.getRanges()) {
20312046
const text = this.rangeText(range);
20322047
result.add(text, range);
@@ -2714,8 +2729,8 @@ Actual: ${stringify(fullActual)}`);
27142729
return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch);
27152730
}
27162731

2717-
public verifyRangesAreOccurrences(isWriteAccess?: boolean) {
2718-
const ranges = this.getRanges();
2732+
public verifyRangesAreOccurrences(isWriteAccess?: boolean, ranges?: Range[]) {
2733+
ranges = ranges || this.getRanges();
27192734
for (const r of ranges) {
27202735
this.goToRangeStart(r);
27212736
this.verifyOccurrencesAtPositionListCount(ranges.length);
@@ -2725,8 +2740,13 @@ Actual: ${stringify(fullActual)}`);
27252740
}
27262741
}
27272742

2728-
public verifyRangesWithSameTextAreRenameLocations() {
2729-
this.rangesByText().forEach(ranges => this.verifyRangesAreRenameLocations(ranges));
2743+
public verifyRangesWithSameTextAreRenameLocations(...texts: string[]) {
2744+
if (texts.length) {
2745+
texts.forEach(text => this.verifyRangesAreRenameLocations(this.rangesByText().get(text)!));
2746+
}
2747+
else {
2748+
this.rangesByText().forEach(ranges => this.verifyRangesAreRenameLocations(ranges));
2749+
}
27302750
}
27312751

27322752
public verifyRangesWithSameTextAreDocumentHighlights() {
@@ -3971,7 +3991,7 @@ namespace FourSlashInterface {
39713991
this.state.verifyGetReferencesForServerTest(expected);
39723992
}
39733993

3974-
public singleReferenceGroup(definition: ReferenceGroupDefinition, ranges?: FourSlash.Range[]) {
3994+
public singleReferenceGroup(definition: ReferenceGroupDefinition, ranges?: FourSlash.Range[] | string) {
39753995
this.state.verifySingleReferenceGroup(definition, ranges);
39763996
}
39773997

@@ -4093,12 +4113,12 @@ namespace FourSlashInterface {
40934113
this.state.verifyOccurrencesAtPositionListCount(expectedCount);
40944114
}
40954115

4096-
public rangesAreOccurrences(isWriteAccess?: boolean) {
4097-
this.state.verifyRangesAreOccurrences(isWriteAccess);
4116+
public rangesAreOccurrences(isWriteAccess?: boolean, ranges?: FourSlash.Range[]) {
4117+
this.state.verifyRangesAreOccurrences(isWriteAccess, ranges);
40984118
}
40994119

4100-
public rangesWithSameTextAreRenameLocations() {
4101-
this.state.verifyRangesWithSameTextAreRenameLocations();
4120+
public rangesWithSameTextAreRenameLocations(...texts: string[]) {
4121+
this.state.verifyRangesWithSameTextAreRenameLocations(...texts);
41024122
}
41034123

41044124
public rangesAreRenameLocations(options?: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: FourSlash.Range[] }) {

0 commit comments

Comments
 (0)