Skip to content

Commit c71fe64

Browse files
committed
Merge branch 'main' into diagnostics-module-3
2 parents 9f0c273 + 9cf44dc commit c71fe64

File tree

110 files changed

+5360
-7305
lines changed

Some content is hidden

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

110 files changed

+5360
-7305
lines changed

.github/workflows/new-release-branch.yaml

Lines changed: 3 additions & 3 deletions
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

.github/workflows/set-version.yaml

Lines changed: 1 addition & 1 deletion
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

package-lock.json

Lines changed: 235 additions & 229 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/checker.ts

Lines changed: 137 additions & 18 deletions
Large diffs are not rendered by default.

src/compiler/diagnosticMessages.json

Lines changed: 9 additions & 1 deletion
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",

src/compiler/types.ts

Lines changed: 6 additions & 1 deletion
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;

src/compiler/utilities.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ import {
230230
IndexSignatureDeclaration,
231231
InitializedVariableDeclaration,
232232
insertSorted,
233+
InstanceofExpression,
233234
InterfaceDeclaration,
234235
InternalEmitFlags,
235236
isAccessor,
@@ -3121,6 +3122,8 @@ export function getInvokedExpression(node: CallLikeExpression): Expression | Jsx
31213122
case SyntaxKind.JsxOpeningElement:
31223123
case SyntaxKind.JsxSelfClosingElement:
31233124
return node.tagName;
3125+
case SyntaxKind.BinaryExpression:
3126+
return node.right;
31243127
default:
31253128
return node.expression;
31263129
}
@@ -7236,6 +7239,15 @@ export function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node
72367239
|| isPropertyAccessExpression(node.parent) && node.parent.name === node
72377240
|| isJSDocMemberName(node.parent) && node.parent.right === node;
72387241
}
7242+
/** @internal */
7243+
export function isInstanceOfExpression(node: Node): node is InstanceofExpression {
7244+
return isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.InstanceOfKeyword;
7245+
}
7246+
7247+
/** @internal */
7248+
export function isRightSideOfInstanceofExpression(node: Node) {
7249+
return isInstanceOfExpression(node.parent) && node === node.parent.right;
7250+
}
72397251

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

src/harness/fourslashImpl.ts

Lines changed: 28 additions & 8 deletions
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)