@operated/typescript 6.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -74
- package/lib/_tsc.js +94 -14
- package/lib/typescript.js +94 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,83 +1,33 @@
|
|
|
1
1
|
# Operator Overloading TypeScript Fork
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Installation
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
| Operator | Method Name |
|
|
8
|
-
|----|----|
|
|
9
|
-
| + | plus |
|
|
10
|
-
| - | minus |
|
|
11
|
-
| * | times |
|
|
12
|
-
| / | div, invDiv* |
|
|
13
|
-
| % | rem |
|
|
14
|
-
| == | equals |
|
|
15
|
-
| === | exactEquals |
|
|
16
|
-
| a() | run |
|
|
17
|
-
|
|
18
|
-
_* — `invDiv` is inverted division and is needed when divided type is not an object. For example, `2 / vec2(1, 0)` will result in `vec2(1, 0).invDiv(2)`_
|
|
19
|
-
|
|
20
|
-
-----------
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# TypeScript
|
|
24
|
-
|
|
25
|
-
<!-- CODING AGENTS: READ AGENTS.md BEFORE WRITING CODE -->
|
|
26
|
-
|
|
27
|
-
[](https://github.com/microsoft/TypeScript/actions/workflows/ci.yml)
|
|
28
|
-
[](https://www.npmjs.com/package/typescript)
|
|
29
|
-
[](https://www.npmjs.com/package/typescript)
|
|
30
|
-
[](https://securityscorecards.dev/viewer/?uri=github.com/microsoft/TypeScript)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
[TypeScript](https://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](https://www.typescriptlang.org/play/), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescript).
|
|
34
|
-
|
|
35
|
-
Find others who are using TypeScript at [our community page](https://www.typescriptlang.org/community/).
|
|
36
|
-
|
|
37
|
-
## Installing
|
|
38
|
-
|
|
39
|
-
For the latest stable version:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
npm install -D typescript
|
|
5
|
+
```sh
|
|
6
|
+
npm install -D typescript@npm:@operated/typescript
|
|
43
7
|
```
|
|
8
|
+
And for VS Code:
|
|
9
|
+
- Ctrl/⌘+Shift+P
|
|
10
|
+
- Open Settings
|
|
11
|
+
- Type in Search "typescript tsdk"
|
|
12
|
+
- Put path `{your_project}/node_modules/typescript/lib/`
|
|
13
|
+
- Restart VS Code
|
|
44
14
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm install -D typescript@next
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Contribute
|
|
52
|
-
|
|
53
|
-
**NOTE: Code changes in this repo are now limited to a small category of fixes**:
|
|
54
|
-
|
|
55
|
-
* Crashes that were introduced in 5.9 or 6.0 that *also* repro in 7.0 *and* have a portable fix *and* don't incur other behavioral changes
|
|
56
|
-
* Security issues
|
|
57
|
-
* Language service crashes that substantially impact mainline usage
|
|
58
|
-
* Serious regressions from 5.9 (these must *seriously* impact a *large* proportion of users)
|
|
15
|
+
## Usage
|
|
59
16
|
|
|
60
|
-
|
|
61
|
-
Feature additions and behavorial changes are currently on pause until TypeScript 7.0 is completed.
|
|
17
|
+
When operators are run on objects, TypeScript checks whether there is a method to call, instead of an operator. In final JS, it would look like an object method was called. (`a + b` => `a.plus(b)`)
|
|
62
18
|
|
|
63
|
-
|
|
64
|
-
* [Submit bugs](https://github.com/microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
|
|
65
|
-
* Review the [source code changes](https://github.com/microsoft/TypeScript/pulls).
|
|
66
|
-
* Engage with other TypeScript users and developers on [StackOverflow](https://stackoverflow.com/questions/tagged/typescript).
|
|
67
|
-
* Help each other in the [TypeScript Community Discord](https://discord.gg/typescript).
|
|
68
|
-
* Join the [#typescript](https://twitter.com/search?q=%23TypeScript) discussion on Twitter.
|
|
69
|
-
* [Contribute bug fixes](https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md).
|
|
19
|
+
Along with a compiler, "Go To Definition" feature was supported for IDE: click on an operator between the objects to jump to method, that will be invoked.
|
|
70
20
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
21
|
+
| Operator | Method Name |
|
|
22
|
+
|----|----|
|
|
23
|
+
| +, += | plus |
|
|
24
|
+
| -, -= | minus |
|
|
25
|
+
| *, *= | times |
|
|
26
|
+
| /, /= | div, invDiv* |
|
|
27
|
+
| %, %= | rem |
|
|
28
|
+
| ^. ^= | pow |
|
|
29
|
+
| ==, != | equals |
|
|
30
|
+
| ===, !== | exactEquals |
|
|
31
|
+
| a() | run |
|
|
82
32
|
|
|
83
|
-
|
|
33
|
+
_* — `invDiv` is inverted division, needed when divided type is not an object. For example, `2 / vec2(1, 0)` will result in `vec2(1, 0).invDiv(2)`_
|
package/lib/_tsc.js
CHANGED
|
@@ -47901,13 +47901,15 @@ function createTypeChecker(host) {
|
|
|
47901
47901
|
const nodeId = getNodeId(node);
|
|
47902
47902
|
return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
|
|
47903
47903
|
}
|
|
47904
|
-
function setResolvedOperator(node, sym, name, isInverted, isUnary, isAccess) {
|
|
47904
|
+
function setResolvedOperator(node, sym, name, isInverted, isUnary, isAccess, isNegated, isCompoundAssignment2) {
|
|
47905
47905
|
const links = getNodeLinks(node);
|
|
47906
47906
|
links.resolvedOperatorSymbol = sym;
|
|
47907
47907
|
links.resolvedOperatorMethodName = name;
|
|
47908
47908
|
links.resolvedOperatorIsInverted = isInverted;
|
|
47909
47909
|
links.resolvedOperatorIsUnary = isUnary;
|
|
47910
47910
|
links.resolvedOperatorIsAccess = isAccess;
|
|
47911
|
+
links.resolvedOperatorIsNegated = isNegated;
|
|
47912
|
+
links.resolvedOperatorIsCompoundAssignment = isCompoundAssignment2;
|
|
47911
47913
|
}
|
|
47912
47914
|
function getSymbol(symbols, name, meaning) {
|
|
47913
47915
|
if (meaning) {
|
|
@@ -75748,7 +75750,9 @@ function createTypeChecker(host) {
|
|
|
75748
75750
|
methodName,
|
|
75749
75751
|
false,
|
|
75750
75752
|
false,
|
|
75751
|
-
true
|
|
75753
|
+
true,
|
|
75754
|
+
false,
|
|
75755
|
+
false
|
|
75752
75756
|
);
|
|
75753
75757
|
return returnT;
|
|
75754
75758
|
}
|
|
@@ -79499,6 +79503,8 @@ function createTypeChecker(host) {
|
|
|
79499
79503
|
methodName,
|
|
79500
79504
|
false,
|
|
79501
79505
|
true,
|
|
79506
|
+
false,
|
|
79507
|
+
false,
|
|
79502
79508
|
false
|
|
79503
79509
|
);
|
|
79504
79510
|
return getReturnTypeOfSignature(match);
|
|
@@ -80096,7 +80102,7 @@ function createTypeChecker(host) {
|
|
|
80096
80102
|
const rightType = checkExpression(right, checkMode);
|
|
80097
80103
|
return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode);
|
|
80098
80104
|
}
|
|
80099
|
-
function tryResolveBinaryOperatorOverload(operatorToken, methodName, left, right, leftType, rightType, inverted) {
|
|
80105
|
+
function tryResolveBinaryOperatorOverload(operatorToken, methodName, left, right, leftType, rightType, inverted, isNegated, isCompoundAssignment2) {
|
|
80100
80106
|
if (!methodName) return void 0;
|
|
80101
80107
|
const lhsApparent = getApparentType(leftType);
|
|
80102
80108
|
const methodSym = getPropertyOfType(lhsApparent, methodName);
|
|
@@ -80121,7 +80127,9 @@ function createTypeChecker(host) {
|
|
|
80121
80127
|
methodName,
|
|
80122
80128
|
inverted,
|
|
80123
80129
|
false,
|
|
80124
|
-
false
|
|
80130
|
+
false,
|
|
80131
|
+
isNegated,
|
|
80132
|
+
isCompoundAssignment2
|
|
80125
80133
|
);
|
|
80126
80134
|
return returnT;
|
|
80127
80135
|
}
|
|
@@ -80131,6 +80139,8 @@ function createTypeChecker(host) {
|
|
|
80131
80139
|
}
|
|
80132
80140
|
function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode) {
|
|
80133
80141
|
const operator = operatorToken.kind;
|
|
80142
|
+
const operatorIsNegated = operator === 36 /* ExclamationEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */;
|
|
80143
|
+
const operatorIsCompoundAssignment = isCompoundAssignment(operator);
|
|
80134
80144
|
switch (operator) {
|
|
80135
80145
|
case 42 /* AsteriskToken */:
|
|
80136
80146
|
case 43 /* AsteriskAsteriskToken */:
|
|
@@ -80166,7 +80176,9 @@ function createTypeChecker(host) {
|
|
|
80166
80176
|
right,
|
|
80167
80177
|
leftType,
|
|
80168
80178
|
rightType,
|
|
80169
|
-
false
|
|
80179
|
+
false,
|
|
80180
|
+
operatorIsNegated,
|
|
80181
|
+
operatorIsCompoundAssignment
|
|
80170
80182
|
);
|
|
80171
80183
|
if (!resultTypeOverloaded) {
|
|
80172
80184
|
resultTypeOverloaded = tryResolveBinaryOperatorOverload(
|
|
@@ -80176,7 +80188,9 @@ function createTypeChecker(host) {
|
|
|
80176
80188
|
left,
|
|
80177
80189
|
rightType,
|
|
80178
80190
|
leftType,
|
|
80179
|
-
true
|
|
80191
|
+
true,
|
|
80192
|
+
operatorIsNegated,
|
|
80193
|
+
operatorIsCompoundAssignment
|
|
80180
80194
|
);
|
|
80181
80195
|
}
|
|
80182
80196
|
if (resultTypeOverloaded) {
|
|
@@ -80306,7 +80320,9 @@ function createTypeChecker(host) {
|
|
|
80306
80320
|
right,
|
|
80307
80321
|
leftType,
|
|
80308
80322
|
rightType,
|
|
80309
|
-
false
|
|
80323
|
+
false,
|
|
80324
|
+
operatorIsNegated,
|
|
80325
|
+
operatorIsCompoundAssignment
|
|
80310
80326
|
);
|
|
80311
80327
|
if (!resultType) {
|
|
80312
80328
|
resultType = tryResolveBinaryOperatorOverload(
|
|
@@ -80316,7 +80332,9 @@ function createTypeChecker(host) {
|
|
|
80316
80332
|
left,
|
|
80317
80333
|
rightType,
|
|
80318
80334
|
leftType,
|
|
80319
|
-
true
|
|
80335
|
+
true,
|
|
80336
|
+
operatorIsNegated,
|
|
80337
|
+
operatorIsCompoundAssignment
|
|
80320
80338
|
);
|
|
80321
80339
|
}
|
|
80322
80340
|
}
|
|
@@ -80354,7 +80372,34 @@ function createTypeChecker(host) {
|
|
|
80354
80372
|
case 35 /* EqualsEqualsToken */:
|
|
80355
80373
|
case 36 /* ExclamationEqualsToken */:
|
|
80356
80374
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
80357
|
-
case 38 /* ExclamationEqualsEqualsToken */:
|
|
80375
|
+
case 38 /* ExclamationEqualsEqualsToken */: {
|
|
80376
|
+
let eqOverload = tryResolveBinaryOperatorOverload(
|
|
80377
|
+
operatorToken,
|
|
80378
|
+
getBinaryOperatorMethodName(operator, false),
|
|
80379
|
+
left,
|
|
80380
|
+
right,
|
|
80381
|
+
leftType,
|
|
80382
|
+
rightType,
|
|
80383
|
+
false,
|
|
80384
|
+
operatorIsNegated,
|
|
80385
|
+
operatorIsCompoundAssignment
|
|
80386
|
+
);
|
|
80387
|
+
if (!eqOverload) {
|
|
80388
|
+
eqOverload = tryResolveBinaryOperatorOverload(
|
|
80389
|
+
operatorToken,
|
|
80390
|
+
getBinaryOperatorMethodName(operator, true),
|
|
80391
|
+
right,
|
|
80392
|
+
left,
|
|
80393
|
+
rightType,
|
|
80394
|
+
leftType,
|
|
80395
|
+
true,
|
|
80396
|
+
operatorIsNegated,
|
|
80397
|
+
operatorIsCompoundAssignment
|
|
80398
|
+
);
|
|
80399
|
+
}
|
|
80400
|
+
if (eqOverload) {
|
|
80401
|
+
return eqOverload;
|
|
80402
|
+
}
|
|
80358
80403
|
if (!(checkMode && checkMode & 64 /* TypeOnly */)) {
|
|
80359
80404
|
if ((isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) && // only report for === and !== in JS, not == or !=
|
|
80360
80405
|
(!isInJSFile(left) || (operator === 37 /* EqualsEqualsEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */))) {
|
|
@@ -80365,6 +80410,7 @@ function createTypeChecker(host) {
|
|
|
80365
80410
|
reportOperatorErrorUnless((left2, right2) => isTypeEqualityComparableTo(left2, right2) || isTypeEqualityComparableTo(right2, left2));
|
|
80366
80411
|
}
|
|
80367
80412
|
return booleanType;
|
|
80413
|
+
}
|
|
80368
80414
|
case 104 /* InstanceOfKeyword */:
|
|
80369
80415
|
return checkInstanceOfExpression(left, right, leftType, rightType, checkMode);
|
|
80370
80416
|
case 103 /* InKeyword */:
|
|
@@ -88851,7 +88897,9 @@ function createTypeChecker(host) {
|
|
|
88851
88897
|
const isUnary = !!links.resolvedOperatorIsUnary;
|
|
88852
88898
|
const isInverted = !!links.resolvedOperatorIsInverted;
|
|
88853
88899
|
const isAccess = !!links.resolvedOperatorIsAccess;
|
|
88854
|
-
|
|
88900
|
+
const isNegated = !!links.resolvedOperatorIsNegated;
|
|
88901
|
+
const isCompoundAssignment2 = !!links.resolvedOperatorIsCompoundAssignment;
|
|
88902
|
+
return name ? { name, isUnary, isInverted, isAccess, isNegated, isCompoundAssignment: isCompoundAssignment2 } : void 0;
|
|
88855
88903
|
},
|
|
88856
88904
|
getImplicitLift(node) {
|
|
88857
88905
|
var _a;
|
|
@@ -91125,9 +91173,14 @@ function getBinaryOperatorMethodName(op, inverted) {
|
|
|
91125
91173
|
case 70 /* PercentEqualsToken */:
|
|
91126
91174
|
return "rem";
|
|
91127
91175
|
case 35 /* EqualsEqualsToken */:
|
|
91176
|
+
case 36 /* ExclamationEqualsToken */:
|
|
91128
91177
|
return "equals";
|
|
91129
91178
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
91179
|
+
case 38 /* ExclamationEqualsEqualsToken */:
|
|
91130
91180
|
return "exactEquals";
|
|
91181
|
+
case 53 /* CaretToken */:
|
|
91182
|
+
case 79 /* CaretEqualsToken */:
|
|
91183
|
+
return "pow";
|
|
91131
91184
|
default:
|
|
91132
91185
|
return void 0;
|
|
91133
91186
|
}
|
|
@@ -116093,12 +116146,39 @@ function transformOperatorOverloads(context) {
|
|
|
116093
116146
|
case 41 /* MinusToken */:
|
|
116094
116147
|
case 42 /* AsteriskToken */:
|
|
116095
116148
|
case 44 /* SlashToken */:
|
|
116096
|
-
case
|
|
116097
|
-
|
|
116098
|
-
|
|
116149
|
+
case 35 /* EqualsEqualsToken */:
|
|
116150
|
+
case 36 /* ExclamationEqualsToken */:
|
|
116151
|
+
case 37 /* EqualsEqualsEqualsToken */:
|
|
116152
|
+
case 38 /* ExclamationEqualsEqualsToken */:
|
|
116153
|
+
case 53 /* CaretToken */:
|
|
116154
|
+
case 45 /* PercentToken */: {
|
|
116155
|
+
const receiver = info.isInverted ? right : left;
|
|
116156
|
+
const arg = info.isInverted ? left : right;
|
|
116157
|
+
const call = f.createCallExpression(
|
|
116158
|
+
f.createPropertyAccessExpression(receiver, info.name),
|
|
116099
116159
|
void 0,
|
|
116100
|
-
[
|
|
116160
|
+
[arg]
|
|
116101
116161
|
);
|
|
116162
|
+
if (info.isNegated) {
|
|
116163
|
+
return f.createPrefixUnaryExpression(54 /* ExclamationToken */, call);
|
|
116164
|
+
}
|
|
116165
|
+
return call;
|
|
116166
|
+
}
|
|
116167
|
+
case 65 /* PlusEqualsToken */:
|
|
116168
|
+
case 66 /* MinusEqualsToken */:
|
|
116169
|
+
case 67 /* AsteriskEqualsToken */:
|
|
116170
|
+
case 69 /* SlashEqualsToken */:
|
|
116171
|
+
case 70 /* PercentEqualsToken */:
|
|
116172
|
+
case 79 /* CaretEqualsToken */: {
|
|
116173
|
+
const receiver = info.isInverted ? right : left;
|
|
116174
|
+
const arg = info.isInverted ? left : right;
|
|
116175
|
+
const call = f.createCallExpression(
|
|
116176
|
+
f.createPropertyAccessExpression(receiver, info.name),
|
|
116177
|
+
void 0,
|
|
116178
|
+
[arg]
|
|
116179
|
+
);
|
|
116180
|
+
return f.createAssignment(left, call);
|
|
116181
|
+
}
|
|
116102
116182
|
}
|
|
116103
116183
|
}
|
|
116104
116184
|
}
|
package/lib/typescript.js
CHANGED
|
@@ -52538,13 +52538,15 @@ function createTypeChecker(host) {
|
|
|
52538
52538
|
const nodeId = getNodeId(node);
|
|
52539
52539
|
return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
|
|
52540
52540
|
}
|
|
52541
|
-
function setResolvedOperator(node, sym, name, isInverted, isUnary, isAccess) {
|
|
52541
|
+
function setResolvedOperator(node, sym, name, isInverted, isUnary, isAccess, isNegated, isCompoundAssignment2) {
|
|
52542
52542
|
const links = getNodeLinks(node);
|
|
52543
52543
|
links.resolvedOperatorSymbol = sym;
|
|
52544
52544
|
links.resolvedOperatorMethodName = name;
|
|
52545
52545
|
links.resolvedOperatorIsInverted = isInverted;
|
|
52546
52546
|
links.resolvedOperatorIsUnary = isUnary;
|
|
52547
52547
|
links.resolvedOperatorIsAccess = isAccess;
|
|
52548
|
+
links.resolvedOperatorIsNegated = isNegated;
|
|
52549
|
+
links.resolvedOperatorIsCompoundAssignment = isCompoundAssignment2;
|
|
52548
52550
|
}
|
|
52549
52551
|
function getSymbol2(symbols, name, meaning) {
|
|
52550
52552
|
if (meaning) {
|
|
@@ -80385,7 +80387,9 @@ function createTypeChecker(host) {
|
|
|
80385
80387
|
methodName,
|
|
80386
80388
|
false,
|
|
80387
80389
|
false,
|
|
80388
|
-
true
|
|
80390
|
+
true,
|
|
80391
|
+
false,
|
|
80392
|
+
false
|
|
80389
80393
|
);
|
|
80390
80394
|
return returnT;
|
|
80391
80395
|
}
|
|
@@ -84136,6 +84140,8 @@ function createTypeChecker(host) {
|
|
|
84136
84140
|
methodName,
|
|
84137
84141
|
false,
|
|
84138
84142
|
true,
|
|
84143
|
+
false,
|
|
84144
|
+
false,
|
|
84139
84145
|
false
|
|
84140
84146
|
);
|
|
84141
84147
|
return getReturnTypeOfSignature(match);
|
|
@@ -84733,7 +84739,7 @@ function createTypeChecker(host) {
|
|
|
84733
84739
|
const rightType = checkExpression(right, checkMode);
|
|
84734
84740
|
return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode);
|
|
84735
84741
|
}
|
|
84736
|
-
function tryResolveBinaryOperatorOverload(operatorToken, methodName, left, right, leftType, rightType, inverted) {
|
|
84742
|
+
function tryResolveBinaryOperatorOverload(operatorToken, methodName, left, right, leftType, rightType, inverted, isNegated, isCompoundAssignment2) {
|
|
84737
84743
|
if (!methodName) return void 0;
|
|
84738
84744
|
const lhsApparent = getApparentType(leftType);
|
|
84739
84745
|
const methodSym = getPropertyOfType(lhsApparent, methodName);
|
|
@@ -84758,7 +84764,9 @@ function createTypeChecker(host) {
|
|
|
84758
84764
|
methodName,
|
|
84759
84765
|
inverted,
|
|
84760
84766
|
false,
|
|
84761
|
-
false
|
|
84767
|
+
false,
|
|
84768
|
+
isNegated,
|
|
84769
|
+
isCompoundAssignment2
|
|
84762
84770
|
);
|
|
84763
84771
|
return returnT;
|
|
84764
84772
|
}
|
|
@@ -84768,6 +84776,8 @@ function createTypeChecker(host) {
|
|
|
84768
84776
|
}
|
|
84769
84777
|
function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, checkMode, errorNode) {
|
|
84770
84778
|
const operator = operatorToken.kind;
|
|
84779
|
+
const operatorIsNegated = operator === 36 /* ExclamationEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */;
|
|
84780
|
+
const operatorIsCompoundAssignment = isCompoundAssignment(operator);
|
|
84771
84781
|
switch (operator) {
|
|
84772
84782
|
case 42 /* AsteriskToken */:
|
|
84773
84783
|
case 43 /* AsteriskAsteriskToken */:
|
|
@@ -84803,7 +84813,9 @@ function createTypeChecker(host) {
|
|
|
84803
84813
|
right,
|
|
84804
84814
|
leftType,
|
|
84805
84815
|
rightType,
|
|
84806
|
-
false
|
|
84816
|
+
false,
|
|
84817
|
+
operatorIsNegated,
|
|
84818
|
+
operatorIsCompoundAssignment
|
|
84807
84819
|
);
|
|
84808
84820
|
if (!resultTypeOverloaded) {
|
|
84809
84821
|
resultTypeOverloaded = tryResolveBinaryOperatorOverload(
|
|
@@ -84813,7 +84825,9 @@ function createTypeChecker(host) {
|
|
|
84813
84825
|
left,
|
|
84814
84826
|
rightType,
|
|
84815
84827
|
leftType,
|
|
84816
|
-
true
|
|
84828
|
+
true,
|
|
84829
|
+
operatorIsNegated,
|
|
84830
|
+
operatorIsCompoundAssignment
|
|
84817
84831
|
);
|
|
84818
84832
|
}
|
|
84819
84833
|
if (resultTypeOverloaded) {
|
|
@@ -84943,7 +84957,9 @@ function createTypeChecker(host) {
|
|
|
84943
84957
|
right,
|
|
84944
84958
|
leftType,
|
|
84945
84959
|
rightType,
|
|
84946
|
-
false
|
|
84960
|
+
false,
|
|
84961
|
+
operatorIsNegated,
|
|
84962
|
+
operatorIsCompoundAssignment
|
|
84947
84963
|
);
|
|
84948
84964
|
if (!resultType) {
|
|
84949
84965
|
resultType = tryResolveBinaryOperatorOverload(
|
|
@@ -84953,7 +84969,9 @@ function createTypeChecker(host) {
|
|
|
84953
84969
|
left,
|
|
84954
84970
|
rightType,
|
|
84955
84971
|
leftType,
|
|
84956
|
-
true
|
|
84972
|
+
true,
|
|
84973
|
+
operatorIsNegated,
|
|
84974
|
+
operatorIsCompoundAssignment
|
|
84957
84975
|
);
|
|
84958
84976
|
}
|
|
84959
84977
|
}
|
|
@@ -84991,7 +85009,34 @@ function createTypeChecker(host) {
|
|
|
84991
85009
|
case 35 /* EqualsEqualsToken */:
|
|
84992
85010
|
case 36 /* ExclamationEqualsToken */:
|
|
84993
85011
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
84994
|
-
case 38 /* ExclamationEqualsEqualsToken */:
|
|
85012
|
+
case 38 /* ExclamationEqualsEqualsToken */: {
|
|
85013
|
+
let eqOverload = tryResolveBinaryOperatorOverload(
|
|
85014
|
+
operatorToken,
|
|
85015
|
+
getBinaryOperatorMethodName(operator, false),
|
|
85016
|
+
left,
|
|
85017
|
+
right,
|
|
85018
|
+
leftType,
|
|
85019
|
+
rightType,
|
|
85020
|
+
false,
|
|
85021
|
+
operatorIsNegated,
|
|
85022
|
+
operatorIsCompoundAssignment
|
|
85023
|
+
);
|
|
85024
|
+
if (!eqOverload) {
|
|
85025
|
+
eqOverload = tryResolveBinaryOperatorOverload(
|
|
85026
|
+
operatorToken,
|
|
85027
|
+
getBinaryOperatorMethodName(operator, true),
|
|
85028
|
+
right,
|
|
85029
|
+
left,
|
|
85030
|
+
rightType,
|
|
85031
|
+
leftType,
|
|
85032
|
+
true,
|
|
85033
|
+
operatorIsNegated,
|
|
85034
|
+
operatorIsCompoundAssignment
|
|
85035
|
+
);
|
|
85036
|
+
}
|
|
85037
|
+
if (eqOverload) {
|
|
85038
|
+
return eqOverload;
|
|
85039
|
+
}
|
|
84995
85040
|
if (!(checkMode && checkMode & 64 /* TypeOnly */)) {
|
|
84996
85041
|
if ((isLiteralExpressionOfObject(left) || isLiteralExpressionOfObject(right)) && // only report for === and !== in JS, not == or !=
|
|
84997
85042
|
(!isInJSFile(left) || (operator === 37 /* EqualsEqualsEqualsToken */ || operator === 38 /* ExclamationEqualsEqualsToken */))) {
|
|
@@ -85002,6 +85047,7 @@ function createTypeChecker(host) {
|
|
|
85002
85047
|
reportOperatorErrorUnless((left2, right2) => isTypeEqualityComparableTo(left2, right2) || isTypeEqualityComparableTo(right2, left2));
|
|
85003
85048
|
}
|
|
85004
85049
|
return booleanType;
|
|
85050
|
+
}
|
|
85005
85051
|
case 104 /* InstanceOfKeyword */:
|
|
85006
85052
|
return checkInstanceOfExpression(left, right, leftType, rightType, checkMode);
|
|
85007
85053
|
case 103 /* InKeyword */:
|
|
@@ -93488,7 +93534,9 @@ function createTypeChecker(host) {
|
|
|
93488
93534
|
const isUnary = !!links.resolvedOperatorIsUnary;
|
|
93489
93535
|
const isInverted = !!links.resolvedOperatorIsInverted;
|
|
93490
93536
|
const isAccess = !!links.resolvedOperatorIsAccess;
|
|
93491
|
-
|
|
93537
|
+
const isNegated = !!links.resolvedOperatorIsNegated;
|
|
93538
|
+
const isCompoundAssignment2 = !!links.resolvedOperatorIsCompoundAssignment;
|
|
93539
|
+
return name ? { name, isUnary, isInverted, isAccess, isNegated, isCompoundAssignment: isCompoundAssignment2 } : void 0;
|
|
93492
93540
|
},
|
|
93493
93541
|
getImplicitLift(node) {
|
|
93494
93542
|
var _a;
|
|
@@ -95762,9 +95810,14 @@ function getBinaryOperatorMethodName(op, inverted) {
|
|
|
95762
95810
|
case 70 /* PercentEqualsToken */:
|
|
95763
95811
|
return "rem";
|
|
95764
95812
|
case 35 /* EqualsEqualsToken */:
|
|
95813
|
+
case 36 /* ExclamationEqualsToken */:
|
|
95765
95814
|
return "equals";
|
|
95766
95815
|
case 37 /* EqualsEqualsEqualsToken */:
|
|
95816
|
+
case 38 /* ExclamationEqualsEqualsToken */:
|
|
95767
95817
|
return "exactEquals";
|
|
95818
|
+
case 53 /* CaretToken */:
|
|
95819
|
+
case 79 /* CaretEqualsToken */:
|
|
95820
|
+
return "pow";
|
|
95768
95821
|
default:
|
|
95769
95822
|
return void 0;
|
|
95770
95823
|
}
|
|
@@ -120912,12 +120965,39 @@ function transformOperatorOverloads(context) {
|
|
|
120912
120965
|
case 41 /* MinusToken */:
|
|
120913
120966
|
case 42 /* AsteriskToken */:
|
|
120914
120967
|
case 44 /* SlashToken */:
|
|
120915
|
-
case
|
|
120916
|
-
|
|
120917
|
-
|
|
120968
|
+
case 35 /* EqualsEqualsToken */:
|
|
120969
|
+
case 36 /* ExclamationEqualsToken */:
|
|
120970
|
+
case 37 /* EqualsEqualsEqualsToken */:
|
|
120971
|
+
case 38 /* ExclamationEqualsEqualsToken */:
|
|
120972
|
+
case 53 /* CaretToken */:
|
|
120973
|
+
case 45 /* PercentToken */: {
|
|
120974
|
+
const receiver = info.isInverted ? right : left;
|
|
120975
|
+
const arg = info.isInverted ? left : right;
|
|
120976
|
+
const call = f.createCallExpression(
|
|
120977
|
+
f.createPropertyAccessExpression(receiver, info.name),
|
|
120918
120978
|
void 0,
|
|
120919
|
-
[
|
|
120979
|
+
[arg]
|
|
120920
120980
|
);
|
|
120981
|
+
if (info.isNegated) {
|
|
120982
|
+
return f.createPrefixUnaryExpression(54 /* ExclamationToken */, call);
|
|
120983
|
+
}
|
|
120984
|
+
return call;
|
|
120985
|
+
}
|
|
120986
|
+
case 65 /* PlusEqualsToken */:
|
|
120987
|
+
case 66 /* MinusEqualsToken */:
|
|
120988
|
+
case 67 /* AsteriskEqualsToken */:
|
|
120989
|
+
case 69 /* SlashEqualsToken */:
|
|
120990
|
+
case 70 /* PercentEqualsToken */:
|
|
120991
|
+
case 79 /* CaretEqualsToken */: {
|
|
120992
|
+
const receiver = info.isInverted ? right : left;
|
|
120993
|
+
const arg = info.isInverted ? left : right;
|
|
120994
|
+
const call = f.createCallExpression(
|
|
120995
|
+
f.createPropertyAccessExpression(receiver, info.name),
|
|
120996
|
+
void 0,
|
|
120997
|
+
[arg]
|
|
120998
|
+
);
|
|
120999
|
+
return f.createAssignment(left, call);
|
|
121000
|
+
}
|
|
120921
121001
|
}
|
|
120922
121002
|
}
|
|
120923
121003
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@operated/typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "6.0.
|
|
5
|
+
"version": "6.0.1",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|