boperators 0.1.0 → 0.1.2
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/dist/cjs/core/OverloadStore.js +18 -12
- package/dist/cjs/core/helpers/resolveExpressionType.js +12 -1
- package/dist/cjs/core/operatorMap.js +3 -0
- package/dist/cjs/lib/operatorSymbols.js +2 -0
- package/dist/esm/core/OverloadStore.js +18 -12
- package/dist/esm/core/helpers/resolveExpressionType.d.ts +8 -0
- package/dist/esm/core/helpers/resolveExpressionType.js +11 -1
- package/dist/esm/core/operatorMap.d.ts +3 -1
- package/dist/esm/core/operatorMap.js +3 -0
- package/dist/esm/lib/operatorSymbols.d.ts +2 -0
- package/dist/esm/lib/operatorSymbols.js +2 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ const ts_morph_1 = require("ts-morph");
|
|
|
5
5
|
const operatorSymbols_1 = require("../lib/operatorSymbols");
|
|
6
6
|
const ErrorManager_1 = require("./ErrorManager");
|
|
7
7
|
const getOperatorStringFromProperty_1 = require("./helpers/getOperatorStringFromProperty");
|
|
8
|
+
const resolveExpressionType_1 = require("./helpers/resolveExpressionType");
|
|
8
9
|
const unwrapInitializer_1 = require("./helpers/unwrapInitializer");
|
|
9
10
|
const operatorMap_1 = require("./operatorMap");
|
|
10
11
|
class OverloadStore extends Map {
|
|
@@ -158,7 +159,7 @@ class OverloadStore extends Map {
|
|
|
158
159
|
this._parsedFiles.add(filePath);
|
|
159
160
|
const classes = sourceFile.getClasses();
|
|
160
161
|
classes.forEach((classDecl) => {
|
|
161
|
-
const classType = classDecl.getType().getText();
|
|
162
|
+
const classType = (0, resolveExpressionType_1.normalizeTypeName)(classDecl.getType().getText());
|
|
162
163
|
classDecl.getProperties().forEach((property) => {
|
|
163
164
|
var _a, _b;
|
|
164
165
|
if (!ts_morph_1.Node.isPropertyDeclaration(property))
|
|
@@ -255,12 +256,14 @@ class OverloadStore extends Map {
|
|
|
255
256
|
});
|
|
256
257
|
}
|
|
257
258
|
_addBinaryOverload(syntaxKind, classDecl, classType, filePath, property, element, parameters, operatorString, index, isStatic) {
|
|
258
|
-
var _a, _b, _c, _d, _e;
|
|
259
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
259
260
|
let hasWarning = false;
|
|
260
|
-
const lhsType = isStatic
|
|
261
|
+
const lhsType = isStatic
|
|
262
|
+
? (0, resolveExpressionType_1.normalizeTypeName)((_b = (_a = parameters[0]) === null || _a === void 0 ? void 0 : _a.getType().getText()) !== null && _b !== void 0 ? _b : "")
|
|
263
|
+
: classType;
|
|
261
264
|
const rhsType = isStatic
|
|
262
|
-
? (
|
|
263
|
-
: (
|
|
265
|
+
? (0, resolveExpressionType_1.normalizeTypeName)((_d = (_c = parameters[1]) === null || _c === void 0 ? void 0 : _c.getType().getText()) !== null && _d !== void 0 ? _d : "")
|
|
266
|
+
: (0, resolveExpressionType_1.normalizeTypeName)((_f = (_e = parameters[0]) === null || _e === void 0 ? void 0 : _e.getType().getText()) !== null && _f !== void 0 ? _f : "");
|
|
264
267
|
if (isStatic && lhsType !== classType && rhsType !== classType) {
|
|
265
268
|
this._errorManager.addWarning(new ErrorManager_1.ErrorDescription(`Overload for operator ${operatorString} ` +
|
|
266
269
|
"must have either LHS or RHS parameter matching its class type.", property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
@@ -277,8 +280,8 @@ class OverloadStore extends Map {
|
|
|
277
280
|
`must have a return type of 'void', got '${returnType}'.`, property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
278
281
|
hasWarning = true;
|
|
279
282
|
}
|
|
280
|
-
const operatorOverloads = (
|
|
281
|
-
const lhsMap = (
|
|
283
|
+
const operatorOverloads = (_g = this.get(syntaxKind)) !== null && _g !== void 0 ? _g : new Map();
|
|
284
|
+
const lhsMap = (_h = operatorOverloads.get(lhsType)) !== null && _h !== void 0 ? _h : new Map();
|
|
282
285
|
if (lhsMap.has(rhsType)) {
|
|
283
286
|
this._errorManager.addWarning(new ErrorManager_1.ErrorDescription(`Duplicate overload for operator ${operatorString} with LHS type ${lhsType} and RHS type ${rhsType}`, property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
284
287
|
hasWarning = true;
|
|
@@ -311,15 +314,15 @@ class OverloadStore extends Map {
|
|
|
311
314
|
fileEntries.push({ syntaxKind, lhsType, rhsType });
|
|
312
315
|
}
|
|
313
316
|
_addPrefixUnaryOverload(syntaxKind, classDecl, classType, filePath, property, element, parameters, operatorString, index) {
|
|
314
|
-
var _a, _b;
|
|
317
|
+
var _a, _b, _c;
|
|
315
318
|
let hasWarning = false;
|
|
316
|
-
const operandType = (_a = parameters[0]) === null || _a === void 0 ? void 0 : _a.getType().getText();
|
|
319
|
+
const operandType = (0, resolveExpressionType_1.normalizeTypeName)((_b = (_a = parameters[0]) === null || _a === void 0 ? void 0 : _a.getType().getText()) !== null && _b !== void 0 ? _b : "");
|
|
317
320
|
if (operandType !== classType) {
|
|
318
321
|
this._errorManager.addWarning(new ErrorManager_1.ErrorDescription(`Prefix unary overload for operator ${operatorString} ` +
|
|
319
322
|
"must have its parameter matching its class type.", property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
320
323
|
hasWarning = true;
|
|
321
324
|
}
|
|
322
|
-
const operatorOverloads = (
|
|
325
|
+
const operatorOverloads = (_c = this._prefixUnaryOverloads.get(syntaxKind)) !== null && _c !== void 0 ? _c : new Map();
|
|
323
326
|
if (operatorOverloads.has(operandType)) {
|
|
324
327
|
this._errorManager.addWarning(new ErrorManager_1.ErrorDescription(`Duplicate prefix unary overload for operator ${operatorString} with operand type ${operandType}`, property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
325
328
|
hasWarning = true;
|
|
@@ -419,7 +422,10 @@ class OverloadStore extends Map {
|
|
|
419
422
|
const decl = sym.getValueDeclaration();
|
|
420
423
|
if (!decl)
|
|
421
424
|
continue;
|
|
422
|
-
params.push({
|
|
425
|
+
params.push({
|
|
426
|
+
name,
|
|
427
|
+
type: (0, resolveExpressionType_1.normalizeTypeName)(decl.getType().getText()),
|
|
428
|
+
});
|
|
423
429
|
}
|
|
424
430
|
const paramCount = params.length;
|
|
425
431
|
const returnType = sig.getReturnType().getText();
|
|
@@ -574,7 +580,7 @@ class OverloadStore extends Map {
|
|
|
574
580
|
if (classDecl) {
|
|
575
581
|
let current = classDecl.getBaseClass();
|
|
576
582
|
while (current) {
|
|
577
|
-
chain.push(current.getType().getText());
|
|
583
|
+
chain.push((0, resolveExpressionType_1.normalizeTypeName)(current.getType().getText()));
|
|
578
584
|
current = current.getBaseClass();
|
|
579
585
|
}
|
|
580
586
|
break;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeTypeName = normalizeTypeName;
|
|
3
4
|
exports.resolveExpressionType = resolveExpressionType;
|
|
4
5
|
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
/**
|
|
7
|
+
* Strips `import("...").` qualification from a type name as returned by
|
|
8
|
+
* ts-morph's `getType().getText()`. Language-server and cross-package contexts
|
|
9
|
+
* produce fully-qualified names like `import("/path/to/file").ClassName`, but
|
|
10
|
+
* overloads are keyed by short class names.
|
|
11
|
+
*/
|
|
12
|
+
function normalizeTypeName(typeName) {
|
|
13
|
+
return typeName.replace(/import\("[^"]*"\)\./g, "");
|
|
14
|
+
}
|
|
5
15
|
/**
|
|
6
16
|
* Resolves the effective type name for a node in a binary expression.
|
|
7
17
|
*
|
|
@@ -10,6 +20,7 @@ const ts_morph_1 = require("ts-morph");
|
|
|
10
20
|
* - Boolean literals (not in string context) → `"boolean"`
|
|
11
21
|
* - `"any"` type → falls back to the declared type of the symbol
|
|
12
22
|
* (needed for compound assignments where TS can't infer the result type)
|
|
23
|
+
* - Qualified type names → stripped to short class name via `normalizeTypeName`
|
|
13
24
|
*/
|
|
14
25
|
function resolveExpressionType(node) {
|
|
15
26
|
var _a;
|
|
@@ -26,5 +37,5 @@ function resolveExpressionType(node) {
|
|
|
26
37
|
if (decl)
|
|
27
38
|
typeName = decl.getType().getText();
|
|
28
39
|
}
|
|
29
|
-
return typeName;
|
|
40
|
+
return normalizeTypeName(typeName);
|
|
30
41
|
}
|
|
@@ -13,6 +13,8 @@ exports.operatorMap = {
|
|
|
13
13
|
[operatorSymbols_1.Operator.MINUS_EQUALS]: ts_morph_1.SyntaxKind.MinusEqualsToken,
|
|
14
14
|
[operatorSymbols_1.Operator.MULTIPLY]: ts_morph_1.SyntaxKind.AsteriskToken,
|
|
15
15
|
[operatorSymbols_1.Operator.MULTIPLY_EQUALS]: ts_morph_1.SyntaxKind.AsteriskEqualsToken,
|
|
16
|
+
[operatorSymbols_1.Operator.EXPONENT]: ts_morph_1.SyntaxKind.AsteriskAsteriskToken,
|
|
17
|
+
[operatorSymbols_1.Operator.EXPONENT_EQUALS]: ts_morph_1.SyntaxKind.AsteriskAsteriskEqualsToken,
|
|
16
18
|
[operatorSymbols_1.Operator.DIVIDE]: ts_morph_1.SyntaxKind.SlashToken,
|
|
17
19
|
[operatorSymbols_1.Operator.DIVIDE_EQUALS]: ts_morph_1.SyntaxKind.SlashEqualsToken,
|
|
18
20
|
[operatorSymbols_1.Operator.GREATER_THAN]: ts_morph_1.SyntaxKind.GreaterThanToken,
|
|
@@ -43,6 +45,7 @@ exports.instanceOperators = new Set([
|
|
|
43
45
|
exports.operatorMap[operatorSymbols_1.Operator.PLUS_EQUALS],
|
|
44
46
|
exports.operatorMap[operatorSymbols_1.Operator.MINUS_EQUALS],
|
|
45
47
|
exports.operatorMap[operatorSymbols_1.Operator.MULTIPLY_EQUALS],
|
|
48
|
+
exports.operatorMap[operatorSymbols_1.Operator.EXPONENT_EQUALS],
|
|
46
49
|
exports.operatorMap[operatorSymbols_1.Operator.DIVIDE_EQUALS],
|
|
47
50
|
exports.operatorMap[operatorSymbols_1.Operator.MODULO_EQUALS],
|
|
48
51
|
exports.operatorMap[operatorSymbols_1.Operator.AND_EQUALS],
|
|
@@ -12,6 +12,8 @@ var Operator;
|
|
|
12
12
|
Operator["MINUS_EQUALS"] = "-=";
|
|
13
13
|
Operator["MULTIPLY"] = "*";
|
|
14
14
|
Operator["MULTIPLY_EQUALS"] = "*=";
|
|
15
|
+
Operator["EXPONENT"] = "**";
|
|
16
|
+
Operator["EXPONENT_EQUALS"] = "**=";
|
|
15
17
|
Operator["DIVIDE"] = "/";
|
|
16
18
|
Operator["DIVIDE_EQUALS"] = "/=";
|
|
17
19
|
Operator["GREATER_THAN"] = ">";
|
|
@@ -2,6 +2,7 @@ import { Node, SourceFile, SyntaxKind, } from "ts-morph";
|
|
|
2
2
|
import { operatorSymbols } from "../lib/operatorSymbols";
|
|
3
3
|
import { ErrorDescription } from "./ErrorManager";
|
|
4
4
|
import { getOperatorStringFromProperty } from "./helpers/getOperatorStringFromProperty";
|
|
5
|
+
import { normalizeTypeName } from "./helpers/resolveExpressionType";
|
|
5
6
|
import { unwrapInitializer } from "./helpers/unwrapInitializer";
|
|
6
7
|
import { comparisonOperators, instanceOperators, operatorMap, postfixUnaryOperatorMap, prefixUnaryOperatorMap, } from "./operatorMap";
|
|
7
8
|
export class OverloadStore extends Map {
|
|
@@ -155,7 +156,7 @@ export class OverloadStore extends Map {
|
|
|
155
156
|
this._parsedFiles.add(filePath);
|
|
156
157
|
const classes = sourceFile.getClasses();
|
|
157
158
|
classes.forEach((classDecl) => {
|
|
158
|
-
const classType = classDecl.getType().getText();
|
|
159
|
+
const classType = normalizeTypeName(classDecl.getType().getText());
|
|
159
160
|
classDecl.getProperties().forEach((property) => {
|
|
160
161
|
var _a, _b;
|
|
161
162
|
if (!Node.isPropertyDeclaration(property))
|
|
@@ -252,12 +253,14 @@ export class OverloadStore extends Map {
|
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
255
|
_addBinaryOverload(syntaxKind, classDecl, classType, filePath, property, element, parameters, operatorString, index, isStatic) {
|
|
255
|
-
var _a, _b, _c, _d, _e;
|
|
256
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
256
257
|
let hasWarning = false;
|
|
257
|
-
const lhsType = isStatic
|
|
258
|
+
const lhsType = isStatic
|
|
259
|
+
? normalizeTypeName((_b = (_a = parameters[0]) === null || _a === void 0 ? void 0 : _a.getType().getText()) !== null && _b !== void 0 ? _b : "")
|
|
260
|
+
: classType;
|
|
258
261
|
const rhsType = isStatic
|
|
259
|
-
? (
|
|
260
|
-
: (
|
|
262
|
+
? normalizeTypeName((_d = (_c = parameters[1]) === null || _c === void 0 ? void 0 : _c.getType().getText()) !== null && _d !== void 0 ? _d : "")
|
|
263
|
+
: normalizeTypeName((_f = (_e = parameters[0]) === null || _e === void 0 ? void 0 : _e.getType().getText()) !== null && _f !== void 0 ? _f : "");
|
|
261
264
|
if (isStatic && lhsType !== classType && rhsType !== classType) {
|
|
262
265
|
this._errorManager.addWarning(new ErrorDescription(`Overload for operator ${operatorString} ` +
|
|
263
266
|
"must have either LHS or RHS parameter matching its class type.", property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
@@ -274,8 +277,8 @@ export class OverloadStore extends Map {
|
|
|
274
277
|
`must have a return type of 'void', got '${returnType}'.`, property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
275
278
|
hasWarning = true;
|
|
276
279
|
}
|
|
277
|
-
const operatorOverloads = (
|
|
278
|
-
const lhsMap = (
|
|
280
|
+
const operatorOverloads = (_g = this.get(syntaxKind)) !== null && _g !== void 0 ? _g : new Map();
|
|
281
|
+
const lhsMap = (_h = operatorOverloads.get(lhsType)) !== null && _h !== void 0 ? _h : new Map();
|
|
279
282
|
if (lhsMap.has(rhsType)) {
|
|
280
283
|
this._errorManager.addWarning(new ErrorDescription(`Duplicate overload for operator ${operatorString} with LHS type ${lhsType} and RHS type ${rhsType}`, property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
281
284
|
hasWarning = true;
|
|
@@ -308,15 +311,15 @@ export class OverloadStore extends Map {
|
|
|
308
311
|
fileEntries.push({ syntaxKind, lhsType, rhsType });
|
|
309
312
|
}
|
|
310
313
|
_addPrefixUnaryOverload(syntaxKind, classDecl, classType, filePath, property, element, parameters, operatorString, index) {
|
|
311
|
-
var _a, _b;
|
|
314
|
+
var _a, _b, _c;
|
|
312
315
|
let hasWarning = false;
|
|
313
|
-
const operandType = (_a = parameters[0]) === null || _a === void 0 ? void 0 : _a.getType().getText();
|
|
316
|
+
const operandType = normalizeTypeName((_b = (_a = parameters[0]) === null || _a === void 0 ? void 0 : _a.getType().getText()) !== null && _b !== void 0 ? _b : "");
|
|
314
317
|
if (operandType !== classType) {
|
|
315
318
|
this._errorManager.addWarning(new ErrorDescription(`Prefix unary overload for operator ${operatorString} ` +
|
|
316
319
|
"must have its parameter matching its class type.", property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
317
320
|
hasWarning = true;
|
|
318
321
|
}
|
|
319
|
-
const operatorOverloads = (
|
|
322
|
+
const operatorOverloads = (_c = this._prefixUnaryOverloads.get(syntaxKind)) !== null && _c !== void 0 ? _c : new Map();
|
|
320
323
|
if (operatorOverloads.has(operandType)) {
|
|
321
324
|
this._errorManager.addWarning(new ErrorDescription(`Duplicate prefix unary overload for operator ${operatorString} with operand type ${operandType}`, property.getSourceFile().getFilePath(), property.getStartLineNumber(), this._minifyString(element.getText())));
|
|
322
325
|
hasWarning = true;
|
|
@@ -416,7 +419,10 @@ export class OverloadStore extends Map {
|
|
|
416
419
|
const decl = sym.getValueDeclaration();
|
|
417
420
|
if (!decl)
|
|
418
421
|
continue;
|
|
419
|
-
params.push({
|
|
422
|
+
params.push({
|
|
423
|
+
name,
|
|
424
|
+
type: normalizeTypeName(decl.getType().getText()),
|
|
425
|
+
});
|
|
420
426
|
}
|
|
421
427
|
const paramCount = params.length;
|
|
422
428
|
const returnType = sig.getReturnType().getText();
|
|
@@ -571,7 +577,7 @@ export class OverloadStore extends Map {
|
|
|
571
577
|
if (classDecl) {
|
|
572
578
|
let current = classDecl.getBaseClass();
|
|
573
579
|
while (current) {
|
|
574
|
-
chain.push(current.getType().getText());
|
|
580
|
+
chain.push(normalizeTypeName(current.getType().getText()));
|
|
575
581
|
current = current.getBaseClass();
|
|
576
582
|
}
|
|
577
583
|
break;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { type Node } from "ts-morph";
|
|
2
|
+
/**
|
|
3
|
+
* Strips `import("...").` qualification from a type name as returned by
|
|
4
|
+
* ts-morph's `getType().getText()`. Language-server and cross-package contexts
|
|
5
|
+
* produce fully-qualified names like `import("/path/to/file").ClassName`, but
|
|
6
|
+
* overloads are keyed by short class names.
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeTypeName(typeName: string): string;
|
|
2
9
|
/**
|
|
3
10
|
* Resolves the effective type name for a node in a binary expression.
|
|
4
11
|
*
|
|
@@ -7,5 +14,6 @@ import { type Node } from "ts-morph";
|
|
|
7
14
|
* - Boolean literals (not in string context) → `"boolean"`
|
|
8
15
|
* - `"any"` type → falls back to the declared type of the symbol
|
|
9
16
|
* (needed for compound assignments where TS can't infer the result type)
|
|
17
|
+
* - Qualified type names → stripped to short class name via `normalizeTypeName`
|
|
10
18
|
*/
|
|
11
19
|
export declare function resolveExpressionType(node: Node): string;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { SyntaxKind } from "ts-morph";
|
|
2
|
+
/**
|
|
3
|
+
* Strips `import("...").` qualification from a type name as returned by
|
|
4
|
+
* ts-morph's `getType().getText()`. Language-server and cross-package contexts
|
|
5
|
+
* produce fully-qualified names like `import("/path/to/file").ClassName`, but
|
|
6
|
+
* overloads are keyed by short class names.
|
|
7
|
+
*/
|
|
8
|
+
export function normalizeTypeName(typeName) {
|
|
9
|
+
return typeName.replace(/import\("[^"]*"\)\./g, "");
|
|
10
|
+
}
|
|
2
11
|
/**
|
|
3
12
|
* Resolves the effective type name for a node in a binary expression.
|
|
4
13
|
*
|
|
@@ -7,6 +16,7 @@ import { SyntaxKind } from "ts-morph";
|
|
|
7
16
|
* - Boolean literals (not in string context) → `"boolean"`
|
|
8
17
|
* - `"any"` type → falls back to the declared type of the symbol
|
|
9
18
|
* (needed for compound assignments where TS can't infer the result type)
|
|
19
|
+
* - Qualified type names → stripped to short class name via `normalizeTypeName`
|
|
10
20
|
*/
|
|
11
21
|
export function resolveExpressionType(node) {
|
|
12
22
|
var _a;
|
|
@@ -23,5 +33,5 @@ export function resolveExpressionType(node) {
|
|
|
23
33
|
if (decl)
|
|
24
34
|
typeName = decl.getType().getText();
|
|
25
35
|
}
|
|
26
|
-
return typeName;
|
|
36
|
+
return normalizeTypeName(typeName);
|
|
27
37
|
}
|
|
@@ -9,6 +9,8 @@ export declare const operatorMap: {
|
|
|
9
9
|
readonly "-=": SyntaxKind.MinusEqualsToken;
|
|
10
10
|
readonly "*": SyntaxKind.AsteriskToken;
|
|
11
11
|
readonly "*=": SyntaxKind.AsteriskEqualsToken;
|
|
12
|
+
readonly "**": SyntaxKind.AsteriskAsteriskToken;
|
|
13
|
+
readonly "**=": SyntaxKind.AsteriskAsteriskEqualsToken;
|
|
12
14
|
readonly "/": SyntaxKind.SlashToken;
|
|
13
15
|
readonly "/=": SyntaxKind.SlashEqualsToken;
|
|
14
16
|
readonly ">": SyntaxKind.GreaterThanToken;
|
|
@@ -28,7 +30,7 @@ export declare const operatorMap: {
|
|
|
28
30
|
readonly "??": SyntaxKind.QuestionQuestionToken;
|
|
29
31
|
};
|
|
30
32
|
export type OperatorString = keyof typeof operatorMap;
|
|
31
|
-
export declare const operatorSyntaxKinds: (SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.AmpersandAmpersandEqualsToken)[];
|
|
33
|
+
export declare const operatorSyntaxKinds: (SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.AmpersandAmpersandEqualsToken)[];
|
|
32
34
|
export type OperatorSyntaxKind = (typeof operatorMap)[OperatorString];
|
|
33
35
|
export declare const isOperatorSyntaxKind: (syntaxKind: SyntaxKind) => syntaxKind is OperatorSyntaxKind;
|
|
34
36
|
/**
|
|
@@ -10,6 +10,8 @@ export const operatorMap = {
|
|
|
10
10
|
[Operator.MINUS_EQUALS]: SyntaxKind.MinusEqualsToken,
|
|
11
11
|
[Operator.MULTIPLY]: SyntaxKind.AsteriskToken,
|
|
12
12
|
[Operator.MULTIPLY_EQUALS]: SyntaxKind.AsteriskEqualsToken,
|
|
13
|
+
[Operator.EXPONENT]: SyntaxKind.AsteriskAsteriskToken,
|
|
14
|
+
[Operator.EXPONENT_EQUALS]: SyntaxKind.AsteriskAsteriskEqualsToken,
|
|
13
15
|
[Operator.DIVIDE]: SyntaxKind.SlashToken,
|
|
14
16
|
[Operator.DIVIDE_EQUALS]: SyntaxKind.SlashEqualsToken,
|
|
15
17
|
[Operator.GREATER_THAN]: SyntaxKind.GreaterThanToken,
|
|
@@ -39,6 +41,7 @@ export const instanceOperators = new Set([
|
|
|
39
41
|
operatorMap[Operator.PLUS_EQUALS],
|
|
40
42
|
operatorMap[Operator.MINUS_EQUALS],
|
|
41
43
|
operatorMap[Operator.MULTIPLY_EQUALS],
|
|
44
|
+
operatorMap[Operator.EXPONENT_EQUALS],
|
|
42
45
|
operatorMap[Operator.DIVIDE_EQUALS],
|
|
43
46
|
operatorMap[Operator.MODULO_EQUALS],
|
|
44
47
|
operatorMap[Operator.AND_EQUALS],
|
|
@@ -9,6 +9,8 @@ export var Operator;
|
|
|
9
9
|
Operator["MINUS_EQUALS"] = "-=";
|
|
10
10
|
Operator["MULTIPLY"] = "*";
|
|
11
11
|
Operator["MULTIPLY_EQUALS"] = "*=";
|
|
12
|
+
Operator["EXPONENT"] = "**";
|
|
13
|
+
Operator["EXPONENT_EQUALS"] = "**=";
|
|
12
14
|
Operator["DIVIDE"] = "/";
|
|
13
15
|
Operator["DIVIDE_EQUALS"] = "/=";
|
|
14
16
|
Operator["GREATER_THAN"] = ">";
|