Skip to content

Commit f6aa47a

Browse files
Merge branch 'main' into release-5.3
2 parents cbcf511 + efc343a commit f6aa47a

File tree

143 files changed

+6542
-7387
lines changed

Some content is hidden

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

143 files changed

+6542
-7387
lines changed

Diff for: .dprint.jsonc

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
],
5252
// Note: if adding new languages, make sure settings.template.json is updated too.
5353
"plugins": [
54-
"https://plugins.dprint.dev/typescript-0.87.1.wasm",
54+
"https://plugins.dprint.dev/typescript-0.88.1.wasm",
5555
"https://plugins.dprint.dev/prettier-0.27.0.json@3557a62b4507c55a47d8cde0683195b14d13c41dda66d0f0b0e111aed107e2fe",
5656
"https://plugins.dprint.dev/json-0.17.4.wasm"
5757
]

Diff for: .github/workflows/new-release-branch.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
contents: write
2222

2323
steps:
24+
- uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 5
2427
- uses: actions/setup-node@v3
2528
- run: |
2629
npm --version
2730
# corepack enable npm
2831
npm install -g $(jq -r '.packageManager' < package.json)
2932
npm --version
30-
- uses: actions/checkout@v3
31-
with:
32-
fetch-depth: 5
3333
- run: |
3434
git checkout -b ${{ github.event.client_payload.branch_name }}
3535
sed -i -e 's/"version": ".*"/"version": "${{ github.event.client_payload.package_version }}"/g' package.json

Diff for: .github/workflows/set-version.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
contents: write
2222

2323
steps:
24-
- uses: actions/setup-node@v3
2524
- uses: actions/checkout@v3
2625
with:
2726
ref: ${{ github.event.client_payload.branch_name }}
27+
- uses: actions/setup-node@v3
2828
- run: |
2929
npm --version
3030
# corepack enable npm

Diff for: package-lock.json

+247-241
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/compiler/checker.ts

+151-31
Large diffs are not rendered by default.

Diff for: src/compiler/diagnosticMessages.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@
19201920
"category": "Error",
19211921
"code": 2358
19221922
},
1923-
"The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.": {
1923+
"The right-hand side of an 'instanceof' expression must be either of type 'any', a class, function, or other type assignable to the 'Function' interface type, or an object type with a 'Symbol.hasInstance' method.": {
19241924
"category": "Error",
19251925
"code": 2359
19261926
},
@@ -3691,6 +3691,14 @@
36913691
"category": "Error",
36923692
"code": 2859
36933693
},
3694+
"The left-hand side of an 'instanceof' expression must be assignable to the first argument of the right-hand side's '[Symbol.hasInstance]' method.": {
3695+
"category": "Error",
3696+
"code": 2860
3697+
},
3698+
"An object's '[Symbol.hasInstance]' method must return a boolean value for it to be used on the right-hand side of an 'instanceof' expression.": {
3699+
"category": "Error",
3700+
"code": 2861
3701+
},
36943702

36953703
"Import declaration '{0}' is using private name '{1}'.": {
36963704
"category": "Error",

Diff for: src/compiler/types.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -3053,12 +3053,17 @@ export interface TaggedTemplateExpression extends MemberExpression {
30533053
/** @internal */ questionDotToken?: QuestionDotToken; // NOTE: Invalid syntax, only used to report a grammar error.
30543054
}
30553055

3056+
export interface InstanceofExpression extends BinaryExpression {
3057+
readonly operatorToken: Token<SyntaxKind.InstanceOfKeyword>;
3058+
}
3059+
30563060
export type CallLikeExpression =
30573061
| CallExpression
30583062
| NewExpression
30593063
| TaggedTemplateExpression
30603064
| Decorator
3061-
| JsxOpeningLikeElement;
3065+
| JsxOpeningLikeElement
3066+
| InstanceofExpression;
30623067

30633068
export interface AsExpression extends Expression {
30643069
readonly kind: SyntaxKind.AsExpression;

Diff for: src/compiler/utilities.ts

+12
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ import {
231231
IndexSignatureDeclaration,
232232
InitializedVariableDeclaration,
233233
insertSorted,
234+
InstanceofExpression,
234235
InterfaceDeclaration,
235236
InternalEmitFlags,
236237
isAccessor,
@@ -3120,6 +3121,8 @@ export function getInvokedExpression(node: CallLikeExpression): Expression | Jsx
31203121
case SyntaxKind.JsxOpeningElement:
31213122
case SyntaxKind.JsxSelfClosingElement:
31223123
return node.tagName;
3124+
case SyntaxKind.BinaryExpression:
3125+
return node.right;
31233126
default:
31243127
return node.expression;
31253128
}
@@ -7235,6 +7238,15 @@ export function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node
72357238
|| isPropertyAccessExpression(node.parent) && node.parent.name === node
72367239
|| isJSDocMemberName(node.parent) && node.parent.right === node;
72377240
}
7241+
/** @internal */
7242+
export function isInstanceOfExpression(node: Node): node is InstanceofExpression {
7243+
return isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.InstanceOfKeyword;
7244+
}
7245+
7246+
/** @internal */
7247+
export function isRightSideOfInstanceofExpression(node: Node) {
7248+
return isInstanceOfExpression(node.parent) && node === node.parent.right;
7249+
}
72387250

72397251
/** @internal */
72407252
export function isEmptyObjectLiteral(expression: Node): boolean {

Diff for: src/compiler/utilitiesPublic.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ import {
102102
isArrowFunction,
103103
isAssignmentExpression,
104104
isBinaryExpression,
105+
isBindableStaticAccessExpression,
105106
isBindableStaticElementAccessExpression,
107+
isBindableStaticNameExpression,
106108
isBindingElement,
107109
isBlock,
108110
isCallExpression,
@@ -111,6 +113,7 @@ import {
111113
isClassStaticBlockDeclaration,
112114
isDecorator,
113115
isElementAccessExpression,
116+
isExpandoPropertyDeclaration,
114117
isExportAssignment,
115118
isExportDeclaration,
116119
isExportSpecifier,
@@ -153,6 +156,7 @@ import {
153156
isPropertyAccessExpression,
154157
isPropertyAssignment,
155158
isPropertyDeclaration,
159+
isPrototypeAccess,
156160
isRootedDiskPath,
157161
isSourceFile,
158162
isStringLiteral,
@@ -1705,7 +1709,10 @@ export function isAutoAccessorPropertyDeclaration(node: Node): node is AutoAcces
17051709
}
17061710

17071711
/** @internal */
1708-
export function isClassFieldAndNotAutoAccessor(node: Node): boolean {
1712+
export function isClassInstanceProperty(node: Declaration): boolean {
1713+
if (isInJSFile(node) && isExpandoPropertyDeclaration(node)) {
1714+
return (!isBindableStaticAccessExpression(node) || !isPrototypeAccess(node.expression)) && !isBindableStaticNameExpression(node, /*excludeThisKeyword*/ true);
1715+
}
17091716
return node.parent && isClassLike(node.parent) && isPropertyDeclaration(node) && !hasAccessorModifier(node);
17101717
}
17111718

Diff for: src/harness/fourslashImpl.ts

+28-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import ArrayOrSingle = FourSlashInterface.ArrayOrSingle;
1010

1111
export const enum FourSlashTestType {
1212
Native,
13-
Shims,
14-
ShimsWithPreprocess,
1513
Server,
1614
}
1715

@@ -202,6 +200,32 @@ const enum CallHierarchyItemDirection {
202200
Outgoing,
203201
}
204202

203+
interface RealizedDiagnostic {
204+
message: string;
205+
start: number;
206+
length: number;
207+
category: string;
208+
code: number;
209+
reportsUnnecessary?: {};
210+
reportsDeprecated?: {};
211+
}
212+
213+
function realizeDiagnostics(diagnostics: readonly ts.Diagnostic[], newLine: string): RealizedDiagnostic[] {
214+
return diagnostics.map(d => realizeDiagnostic(d, newLine));
215+
}
216+
217+
function realizeDiagnostic(diagnostic: ts.Diagnostic, newLine: string): RealizedDiagnostic {
218+
return {
219+
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine),
220+
start: diagnostic.start!, // TODO: GH#18217
221+
length: diagnostic.length!, // TODO: GH#18217
222+
category: ts.diagnosticCategoryName(diagnostic),
223+
code: diagnostic.code,
224+
reportsUnnecessary: diagnostic.reportsUnnecessary,
225+
reportsDeprecated: diagnostic.reportsDeprecated,
226+
};
227+
}
228+
205229
export class TestState {
206230
// Language service instance
207231
private languageServiceAdapterHost: Harness.LanguageService.LanguageServiceAdapterHost;
@@ -267,10 +291,6 @@ export class TestState {
267291
switch (testType) {
268292
case FourSlashTestType.Native:
269293
return new Harness.LanguageService.NativeLanguageServiceAdapter(cancellationToken, compilationOptions);
270-
case FourSlashTestType.Shims:
271-
return new Harness.LanguageService.ShimLanguageServiceAdapter(/*preprocessToResolve*/ false, cancellationToken, compilationOptions);
272-
case FourSlashTestType.ShimsWithPreprocess:
273-
return new Harness.LanguageService.ShimLanguageServiceAdapter(/*preprocessToResolve*/ true, cancellationToken, compilationOptions);
274294
case FourSlashTestType.Server:
275295
return new Harness.LanguageService.ServerLanguageServiceAdapter(cancellationToken, compilationOptions);
276296
default:
@@ -1764,8 +1784,8 @@ export class TestState {
17641784

17651785
private testDiagnostics(expected: readonly FourSlashInterface.Diagnostic[], diagnostics: readonly ts.Diagnostic[], category: string) {
17661786
assert.deepEqual(
1767-
ts.realizeDiagnostics(diagnostics, "\n"),
1768-
expected.map((e): ts.RealizedDiagnostic => {
1787+
realizeDiagnostics(diagnostics, "\n"),
1788+
expected.map((e): RealizedDiagnostic => {
17691789
const range = e.range || this.getRangesInFile()[0];
17701790
if (!range) {
17711791
this.raiseError("Must provide a range for each expected diagnostic, or have one range in the fourslash source.");

0 commit comments

Comments
 (0)