@typescript-eslint/typescript-estree 6.0.0-alpha.81 → 6.0.0-alpha.91
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/_ts4.2/dist/convert.d.ts +2 -2
- package/_ts4.2/dist/node-utils.d.ts +2 -7
- package/_ts4.2/dist/parseSettings/index.d.ts +4 -0
- package/_ts4.2/dist/parser-options.d.ts +4 -0
- package/dist/ast-converter.d.ts.map +1 -1
- package/dist/ast-converter.js +3 -2
- package/dist/ast-converter.js.map +1 -1
- package/dist/convert.d.ts +2 -2
- package/dist/convert.d.ts.map +1 -1
- package/dist/convert.js +157 -90
- package/dist/convert.js.map +1 -1
- package/dist/getModifiers.d.ts.map +1 -1
- package/dist/getModifiers.js +2 -2
- package/dist/getModifiers.js.map +1 -1
- package/dist/node-utils.d.ts +2 -7
- package/dist/node-utils.d.ts.map +1 -1
- package/dist/node-utils.js +38 -16
- package/dist/node-utils.js.map +1 -1
- package/dist/parseSettings/ExpiringCache.js.map +1 -1
- package/dist/parseSettings/createParseSettings.d.ts.map +1 -1
- package/dist/parseSettings/createParseSettings.js +2 -0
- package/dist/parseSettings/createParseSettings.js.map +1 -1
- package/dist/parseSettings/index.d.ts +4 -0
- package/dist/parseSettings/index.d.ts.map +1 -1
- package/dist/parseSettings/warnAboutTSVersion.js +2 -2
- package/dist/parseSettings/warnAboutTSVersion.js.map +1 -1
- package/dist/parser-options.d.ts +4 -0
- package/dist/parser-options.d.ts.map +1 -1
- package/dist/parser.js +1 -1
- package/dist/parser.js.map +1 -1
- package/dist/ts-estree/ts-nodes.d.ts.map +1 -1
- package/package.json +4 -4
package/_ts4.2/dist/convert.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import type { TSError } from './node-utils';
|
|
|
3
3
|
import type { ParserWeakMap, ParserWeakMapESTreeToTSNode } from './parser-options';
|
|
4
4
|
import type { SemanticOrSyntacticError } from './semantic-or-syntactic-errors';
|
|
5
5
|
import type { TSESTree, TSNode } from './ts-estree';
|
|
6
|
-
interface ConverterOptions {
|
|
6
|
+
export interface ConverterOptions {
|
|
7
7
|
allowInvalidAST?: boolean;
|
|
8
8
|
errorOnUnknownASTType?: boolean;
|
|
9
9
|
shouldPreserveNodeMaps?: boolean;
|
|
10
|
+
suppressDeprecatedPropertyWarnings?: boolean;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Extends and formats a given error object
|
|
@@ -138,5 +139,4 @@ export declare class Converter {
|
|
|
138
139
|
*/
|
|
139
140
|
private convertNode;
|
|
140
141
|
}
|
|
141
|
-
export {};
|
|
142
142
|
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -42,13 +42,6 @@ export declare function isESTreeClassMember(node: ts.Node): boolean;
|
|
|
42
42
|
* @returns has the modifier specified
|
|
43
43
|
*/
|
|
44
44
|
export declare function hasModifier(modifierKind: ts.KeywordSyntaxKind, node: ts.Node): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Get a modifier from a ts.Node
|
|
47
|
-
* @param modifierKind TypeScript SyntaxKind modifier
|
|
48
|
-
* @param node TypeScript AST node
|
|
49
|
-
* @returns matched modifier if present or null
|
|
50
|
-
*/
|
|
51
|
-
export declare function getModifier(modifierKind: ts.KeywordSyntaxKind, node: ts.Node): ts.Modifier | null;
|
|
52
45
|
/**
|
|
53
46
|
* Get last last modifier in ast
|
|
54
47
|
* @param node TypeScript AST node
|
|
@@ -261,5 +254,7 @@ export declare function firstDefined<T, U>(array: readonly T[] | undefined, call
|
|
|
261
254
|
export declare function identifierIsThisKeyword(id: ts.Identifier): boolean;
|
|
262
255
|
export declare function isThisIdentifier(node: ts.Node | undefined): node is ts.Identifier;
|
|
263
256
|
export declare function isThisInTypeQuery(node: ts.Node): boolean;
|
|
257
|
+
export declare function nodeIsPresent(node: ts.Node | undefined): node is ts.Node;
|
|
258
|
+
export declare function getContainingFunction(node: ts.Node): ts.SignatureDeclaration | undefined;
|
|
264
259
|
export {};
|
|
265
260
|
//# sourceMappingURL=node-utils.d.ts.map
|
|
@@ -95,6 +95,10 @@ export interface MutableParseSettings {
|
|
|
95
95
|
* Whether this is part of a single run, rather than a long-running process.
|
|
96
96
|
*/
|
|
97
97
|
singleRun: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether deprecated AST properties should skip calling console.warn on accesses.
|
|
100
|
+
*/
|
|
101
|
+
suppressDeprecatedPropertyWarnings: boolean;
|
|
98
102
|
/**
|
|
99
103
|
* If the `tokens` parse option is enabled, retrieved tokens.
|
|
100
104
|
*/
|
|
@@ -58,6 +58,10 @@ interface ParseOptions {
|
|
|
58
58
|
* Set to true to create a top-level array containing all tokens from the file.
|
|
59
59
|
*/
|
|
60
60
|
tokens?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Whether deprecated AST properties should skip calling console.warn on accesses.
|
|
63
|
+
*/
|
|
64
|
+
suppressDeprecatedPropertyWarnings?: boolean;
|
|
61
65
|
}
|
|
62
66
|
interface ParseAndGenerateServicesOptions extends ParseOptions {
|
|
63
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-converter.d.ts","sourceRoot":"","sources":["../src/ast-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,YAAY,CAC1B,GAAG,EAAE,UAAU,EACf,aAAa,EAAE,aAAa,EAC5B,sBAAsB,EAAE,OAAO,GAC9B;IAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"ast-converter.d.ts","sourceRoot":"","sources":["../src/ast-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAgB,YAAY,CAC1B,GAAG,EAAE,UAAU,EACf,aAAa,EAAE,aAAa,EAC5B,sBAAsB,EAAE,OAAO,GAC9B;IAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA4DhD"}
|
package/dist/ast-converter.js
CHANGED
|
@@ -18,9 +18,10 @@ function astConverter(ast, parseSettings, shouldPreserveNodeMaps) {
|
|
|
18
18
|
* Recursively convert the TypeScript AST into an ESTree-compatible AST
|
|
19
19
|
*/
|
|
20
20
|
const instance = new convert_1.Converter(ast, {
|
|
21
|
-
allowInvalidAST: parseSettings.allowInvalidAST
|
|
22
|
-
errorOnUnknownASTType: parseSettings.errorOnUnknownASTType
|
|
21
|
+
allowInvalidAST: parseSettings.allowInvalidAST,
|
|
22
|
+
errorOnUnknownASTType: parseSettings.errorOnUnknownASTType,
|
|
23
23
|
shouldPreserveNodeMaps,
|
|
24
|
+
suppressDeprecatedPropertyWarnings: parseSettings.suppressDeprecatedPropertyWarnings,
|
|
24
25
|
});
|
|
25
26
|
const estree = instance.convertProgram();
|
|
26
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-converter.js","sourceRoot":"","sources":["../src/ast-converter.ts"],"names":[],"mappings":";;;AAGA,uCAAoD;AACpD,yDAAqD;AACrD,6CAA6C;AAE7C,uDAAmD;AAGnD,SAAgB,YAAY,CAC1B,GAAe,EACf,aAA4B,EAC5B,sBAA+B;IAE/B;;;OAGG;IACH,MAAM,EAAE,gBAAgB,EAAE,GAAG,GAAG,CAAC;IACjC,IAAI,gBAAgB,CAAC,MAAM,EAAE;QAC3B,MAAM,IAAA,sBAAY,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;KACzC;IAED;;OAEG;IACH,MAAM,QAAQ,GAAG,IAAI,mBAAS,CAAC,GAAG,EAAE;QAClC,eAAe,EAAE,aAAa,CAAC,eAAe
|
|
1
|
+
{"version":3,"file":"ast-converter.js","sourceRoot":"","sources":["../src/ast-converter.ts"],"names":[],"mappings":";;;AAGA,uCAAoD;AACpD,yDAAqD;AACrD,6CAA6C;AAE7C,uDAAmD;AAGnD,SAAgB,YAAY,CAC1B,GAAe,EACf,aAA4B,EAC5B,sBAA+B;IAE/B;;;OAGG;IACH,MAAM,EAAE,gBAAgB,EAAE,GAAG,GAAG,CAAC;IACjC,IAAI,gBAAgB,CAAC,MAAM,EAAE;QAC3B,MAAM,IAAA,sBAAY,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;KACzC;IAED;;OAEG;IACH,MAAM,QAAQ,GAAG,IAAI,mBAAS,CAAC,GAAG,EAAE;QAClC,eAAe,EAAE,aAAa,CAAC,eAAe;QAC9C,qBAAqB,EAAE,aAAa,CAAC,qBAAqB;QAC1D,sBAAsB;QACtB,kCAAkC,EAChC,aAAa,CAAC,kCAAkC;KACnD,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,EAAE,CAAC;IAEzC;;OAEG;IACH,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;QAC9C,IAAA,gCAAc,EAAC,MAAM,EAAE;YACrB,KAAK,EAAE,IAAI,CAAC,EAAE;gBACZ,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;oBACxB,4HAA4H;oBAC5H,mBAAmB;oBACnB,OAAO,IAAI,CAAC,KAAK,CAAC;iBACnB;gBACD,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;oBACtB,4HAA4H;oBAC5H,mBAAmB;oBACnB,OAAO,IAAI,CAAC,GAAG,CAAC;iBACjB;YACH,CAAC;SACF,CAAC,CAAC;KACJ;IAED;;OAEG;IACH,IAAI,aAAa,CAAC,MAAM,EAAE;QACxB,MAAM,CAAC,MAAM,GAAG,IAAA,0BAAa,EAAC,GAAG,CAAC,CAAC;KACpC;IAED;;OAEG;IACH,IAAI,aAAa,CAAC,OAAO,EAAE;QACzB,MAAM,CAAC,QAAQ,GAAG,IAAA,kCAAe,EAAC,GAAG,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACpE;IAED,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC;IAEtC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC;AAhED,oCAgEC"}
|
package/dist/convert.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import type { TSError } from './node-utils';
|
|
|
3
3
|
import type { ParserWeakMap, ParserWeakMapESTreeToTSNode } from './parser-options';
|
|
4
4
|
import type { SemanticOrSyntacticError } from './semantic-or-syntactic-errors';
|
|
5
5
|
import type { TSESTree, TSNode } from './ts-estree';
|
|
6
|
-
interface ConverterOptions {
|
|
6
|
+
export interface ConverterOptions {
|
|
7
7
|
allowInvalidAST?: boolean;
|
|
8
8
|
errorOnUnknownASTType?: boolean;
|
|
9
9
|
shouldPreserveNodeMaps?: boolean;
|
|
10
|
+
suppressDeprecatedPropertyWarnings?: boolean;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Extends and formats a given error object
|
|
@@ -138,5 +139,4 @@ export declare class Converter {
|
|
|
138
139
|
*/
|
|
139
140
|
private convertNode;
|
|
140
141
|
}
|
|
141
|
-
export {};
|
|
142
142
|
//# sourceMappingURL=convert.d.ts.map
|
package/dist/convert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AA0B5C,OAAO,KAAK,EACV,aAAa,EACb,2BAA2B,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAoB,MAAM,EAAE,MAAM,aAAa,CAAC;AAKtE,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,EAAE,CAAC,sBAAsB,GAAG,wBAAwB,GAC1D,OAAO,CAMT;AAED,MAAM,WAAW,OAAO;IACtB,qBAAqB,EAAE,2BAA2B,CAAC;IACnD,qBAAqB,EAAE,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED,qBAAa,SAAS;;IACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAiB;IACvD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAiB;IAEvD,OAAO,CAAC,YAAY,CAAS;IAE7B;;;;;OAKG;gBACS,GAAG,EAAE,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,gBAAgB;IAK1D,UAAU,IAAI,OAAO;IAOrB,cAAc,IAAI,QAAQ,CAAC,OAAO;IAIlC;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IA8BjB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAmElB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAW/B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAItB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,oCAAoC;IAe5C;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAqB7B;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAkC9B;;;;;OAKG;IACH,OAAO,CAAC,gDAAgD;IAexD;;;;OAIG;IACH,OAAO,CAAC,kDAAkD;IAe1D;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,sBAAsB;IA4C9B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IA+FlB,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,+BAA+B;IA6BvC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IA8BzB,OAAO,CAAC,sBAAsB;IAoC9B,OAAO,CAAC,mBAAmB;IAQ3B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,qBAAqB;IAsB7B;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;CAykFpB"}
|
package/dist/convert.js
CHANGED
|
@@ -27,7 +27,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
27
27
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
28
28
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
29
|
};
|
|
30
|
-
var _Converter_instances,
|
|
30
|
+
var _Converter_instances, _Converter_checkModifiers, _Converter_throwUnlessAllowInvalidAST, _Converter_withDeprecatedAliasGetter, _Converter_throwError;
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.Converter = exports.convertError = void 0;
|
|
33
33
|
// There's lots of funny stuff due to the typing of ts.Node
|
|
@@ -53,7 +53,7 @@ class Converter {
|
|
|
53
53
|
* @param options additional options for the conversion
|
|
54
54
|
* @returns the converted ESTreeNode
|
|
55
55
|
*/
|
|
56
|
-
constructor(ast, options
|
|
56
|
+
constructor(ast, options) {
|
|
57
57
|
_Converter_instances.add(this);
|
|
58
58
|
this.esTreeNodeToTSNodeMap = new WeakMap();
|
|
59
59
|
this.tsNodeToESTreeNodeMap = new WeakMap();
|
|
@@ -84,6 +84,7 @@ class Converter {
|
|
|
84
84
|
if (!node) {
|
|
85
85
|
return null;
|
|
86
86
|
}
|
|
87
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_checkModifiers).call(this, node);
|
|
87
88
|
const pattern = this.allowPattern;
|
|
88
89
|
if (allowPattern !== undefined) {
|
|
89
90
|
this.allowPattern = allowPattern;
|
|
@@ -340,10 +341,11 @@ class Converter {
|
|
|
340
341
|
: null;
|
|
341
342
|
}
|
|
342
343
|
if ('typeArguments' in node) {
|
|
343
|
-
result.typeArguments =
|
|
344
|
+
result.typeArguments =
|
|
344
345
|
node.typeArguments && 'pos' in node.typeArguments
|
|
345
346
|
? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
|
|
346
347
|
: null;
|
|
348
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, result, 'typeParameters', 'typeArguments');
|
|
347
349
|
}
|
|
348
350
|
if ('typeParameters' in node) {
|
|
349
351
|
result.typeParameters =
|
|
@@ -458,10 +460,6 @@ class Converter {
|
|
|
458
460
|
return result;
|
|
459
461
|
}
|
|
460
462
|
convertMethodSignature(node) {
|
|
461
|
-
const exportKeyword = (0, node_utils_1.getModifier)(SyntaxKind.ExportKeyword, node);
|
|
462
|
-
if (exportKeyword) {
|
|
463
|
-
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwUnlessAllowInvalidAST).call(this, exportKeyword, 'A method signature cannot have an export modifier.');
|
|
464
|
-
}
|
|
465
463
|
return this.createNode(node, {
|
|
466
464
|
type: ts_estree_1.AST_NODE_TYPES.TSMethodSignature,
|
|
467
465
|
accessibility: (0, node_utils_1.getTSNodeAccessibility)(node),
|
|
@@ -683,7 +681,6 @@ class Converter {
|
|
|
683
681
|
});
|
|
684
682
|
// Declarations
|
|
685
683
|
case SyntaxKind.FunctionDeclaration: {
|
|
686
|
-
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_checkIllegalDecorators).call(this, node);
|
|
687
684
|
const isDeclare = (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, node);
|
|
688
685
|
const result = this.createNode(node, {
|
|
689
686
|
type: isDeclare || !node.body
|
|
@@ -711,7 +708,6 @@ class Converter {
|
|
|
711
708
|
});
|
|
712
709
|
}
|
|
713
710
|
case SyntaxKind.VariableStatement: {
|
|
714
|
-
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_checkIllegalDecorators).call(this, node);
|
|
715
711
|
const result = this.createNode(node, {
|
|
716
712
|
type: ts_estree_1.AST_NODE_TYPES.VariableDeclaration,
|
|
717
713
|
declarations: node.declarationList.declarations.map(el => this.convertChild(el)),
|
|
@@ -1182,18 +1178,14 @@ class Converter {
|
|
|
1182
1178
|
});
|
|
1183
1179
|
return result;
|
|
1184
1180
|
}
|
|
1185
|
-
case SyntaxKind.TaggedTemplateExpression:
|
|
1186
|
-
|
|
1187
|
-
? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
|
|
1188
|
-
: undefined;
|
|
1189
|
-
return this.createNode(node, {
|
|
1181
|
+
case SyntaxKind.TaggedTemplateExpression:
|
|
1182
|
+
return this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
1190
1183
|
type: ts_estree_1.AST_NODE_TYPES.TaggedTemplateExpression,
|
|
1191
|
-
typeArguments
|
|
1192
|
-
|
|
1184
|
+
typeArguments: node.typeArguments &&
|
|
1185
|
+
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node),
|
|
1193
1186
|
tag: this.convertChild(node.tag),
|
|
1194
1187
|
quasi: this.convertChild(node.template),
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1188
|
+
}, 'typeParameters', 'typeArguments'));
|
|
1197
1189
|
case SyntaxKind.TemplateHead:
|
|
1198
1190
|
case SyntaxKind.TemplateMiddle:
|
|
1199
1191
|
case SyntaxKind.TemplateTail: {
|
|
@@ -1273,10 +1265,6 @@ class Converter {
|
|
|
1273
1265
|
}
|
|
1274
1266
|
const modifiers = (0, getModifiers_1.getModifiers)(node);
|
|
1275
1267
|
if (modifiers) {
|
|
1276
|
-
const exportKeyword = (0, node_utils_1.getModifier)(SyntaxKind.ExportKeyword, node);
|
|
1277
|
-
if (exportKeyword) {
|
|
1278
|
-
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwUnlessAllowInvalidAST).call(this, exportKeyword, 'A parameter cannot have an export modifier.');
|
|
1279
|
-
}
|
|
1280
1268
|
return this.createNode(node, {
|
|
1281
1269
|
type: ts_estree_1.AST_NODE_TYPES.TSParameterProperty,
|
|
1282
1270
|
accessibility: (0, node_utils_1.getTSNodeAccessibility)(node),
|
|
@@ -1328,7 +1316,7 @@ class Converter {
|
|
|
1328
1316
|
implementsClause ??= heritageClause;
|
|
1329
1317
|
}
|
|
1330
1318
|
}
|
|
1331
|
-
const result = this.createNode(node, {
|
|
1319
|
+
const result = this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
1332
1320
|
type: classNodeType,
|
|
1333
1321
|
abstract: (0, node_utils_1.hasModifier)(SyntaxKind.AbstractKeyword, node),
|
|
1334
1322
|
body: this.createNode(node, {
|
|
@@ -1346,13 +1334,11 @@ class Converter {
|
|
|
1346
1334
|
? this.convertChild(extendsClause.types[0].expression)
|
|
1347
1335
|
: null,
|
|
1348
1336
|
superTypeArguments: undefined,
|
|
1349
|
-
superTypeParameters: undefined,
|
|
1350
1337
|
typeParameters: node.typeParameters &&
|
|
1351
1338
|
this.convertTSTypeParametersToTypeParametersDeclaration(node.typeParameters),
|
|
1352
|
-
});
|
|
1339
|
+
}, 'superTypeParameters', 'superTypeArguments'));
|
|
1353
1340
|
if (extendsClause?.types[0]?.typeArguments) {
|
|
1354
|
-
|
|
1355
|
-
result.superTypeArguments = result.superTypeParameters =
|
|
1341
|
+
result.superTypeArguments =
|
|
1356
1342
|
this.convertTypeArgumentsToTypeParameterInstantiation(extendsClause.types[0].typeArguments, extendsClause.types[0]);
|
|
1357
1343
|
}
|
|
1358
1344
|
return this.fixExports(node, result);
|
|
@@ -1598,29 +1584,27 @@ class Converter {
|
|
|
1598
1584
|
const args = node.arguments.map(el => this.convertChild(el));
|
|
1599
1585
|
const typeArguments = node.typeArguments &&
|
|
1600
1586
|
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node);
|
|
1601
|
-
const result = this.createNode(node, {
|
|
1587
|
+
const result = this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
1602
1588
|
type: ts_estree_1.AST_NODE_TYPES.CallExpression,
|
|
1603
1589
|
callee,
|
|
1604
1590
|
arguments: args,
|
|
1605
1591
|
optional: node.questionDotToken !== undefined,
|
|
1606
1592
|
typeArguments,
|
|
1607
|
-
|
|
1608
|
-
});
|
|
1593
|
+
}, 'typeParameters', 'typeArguments'));
|
|
1609
1594
|
return this.convertChainExpression(result, node);
|
|
1610
1595
|
}
|
|
1611
1596
|
case SyntaxKind.NewExpression: {
|
|
1612
1597
|
const typeArguments = node.typeArguments &&
|
|
1613
1598
|
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node);
|
|
1614
1599
|
// NOTE - NewExpression cannot have an optional chain in it
|
|
1615
|
-
return this.createNode(node, {
|
|
1600
|
+
return this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
1616
1601
|
type: ts_estree_1.AST_NODE_TYPES.NewExpression,
|
|
1617
1602
|
arguments: node.arguments
|
|
1618
1603
|
? node.arguments.map(el => this.convertChild(el))
|
|
1619
1604
|
: [],
|
|
1620
1605
|
callee: this.convertChild(node.expression),
|
|
1621
1606
|
typeArguments,
|
|
1622
|
-
|
|
1623
|
-
});
|
|
1607
|
+
}, 'typeParameters', 'typeArguments'));
|
|
1624
1608
|
}
|
|
1625
1609
|
case SyntaxKind.ConditionalExpression:
|
|
1626
1610
|
return this.createNode(node, {
|
|
@@ -1748,39 +1732,35 @@ class Converter {
|
|
|
1748
1732
|
children: node.children.map(el => this.convertChild(el)),
|
|
1749
1733
|
});
|
|
1750
1734
|
case SyntaxKind.JsxSelfClosingElement: {
|
|
1751
|
-
const typeArguments = node.typeArguments
|
|
1752
|
-
? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
|
|
1753
|
-
: undefined;
|
|
1754
1735
|
return this.createNode(node, {
|
|
1755
1736
|
type: ts_estree_1.AST_NODE_TYPES.JSXElement,
|
|
1756
1737
|
/**
|
|
1757
1738
|
* Convert SyntaxKind.JsxSelfClosingElement to SyntaxKind.JsxOpeningElement,
|
|
1758
1739
|
* TypeScript does not seem to have the idea of openingElement when tag is self-closing
|
|
1759
1740
|
*/
|
|
1760
|
-
openingElement: this.createNode(node, {
|
|
1741
|
+
openingElement: this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
1761
1742
|
type: ts_estree_1.AST_NODE_TYPES.JSXOpeningElement,
|
|
1762
|
-
typeArguments
|
|
1763
|
-
|
|
1743
|
+
typeArguments: node.typeArguments
|
|
1744
|
+
? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
|
|
1745
|
+
: undefined,
|
|
1764
1746
|
selfClosing: true,
|
|
1765
1747
|
name: this.convertJSXTagName(node.tagName, node),
|
|
1766
1748
|
attributes: node.attributes.properties.map(el => this.convertChild(el)),
|
|
1767
1749
|
range: (0, node_utils_1.getRange)(node, this.ast),
|
|
1768
|
-
}),
|
|
1750
|
+
}, 'typeParameters', 'typeArguments')),
|
|
1769
1751
|
closingElement: null,
|
|
1770
1752
|
children: [],
|
|
1771
1753
|
});
|
|
1772
1754
|
}
|
|
1773
1755
|
case SyntaxKind.JsxOpeningElement: {
|
|
1774
|
-
|
|
1775
|
-
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node);
|
|
1776
|
-
return this.createNode(node, {
|
|
1756
|
+
return this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
1777
1757
|
type: ts_estree_1.AST_NODE_TYPES.JSXOpeningElement,
|
|
1778
|
-
typeArguments
|
|
1779
|
-
|
|
1758
|
+
typeArguments: node.typeArguments &&
|
|
1759
|
+
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node),
|
|
1780
1760
|
selfClosing: false,
|
|
1781
1761
|
name: this.convertJSXTagName(node.tagName, node),
|
|
1782
1762
|
attributes: node.attributes.properties.map(el => this.convertChild(el)),
|
|
1783
|
-
});
|
|
1763
|
+
}, 'typeParameters', 'typeArguments'));
|
|
1784
1764
|
}
|
|
1785
1765
|
case SyntaxKind.JsxClosingElement:
|
|
1786
1766
|
return this.createNode(node, {
|
|
@@ -1846,17 +1826,13 @@ class Converter {
|
|
|
1846
1826
|
});
|
|
1847
1827
|
}
|
|
1848
1828
|
// TypeScript specific
|
|
1849
|
-
case SyntaxKind.TypeReference:
|
|
1850
|
-
|
|
1851
|
-
? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
|
|
1852
|
-
: undefined;
|
|
1853
|
-
return this.createNode(node, {
|
|
1829
|
+
case SyntaxKind.TypeReference:
|
|
1830
|
+
return this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
1854
1831
|
type: ts_estree_1.AST_NODE_TYPES.TSTypeReference,
|
|
1855
1832
|
typeName: this.convertChild(node.typeName),
|
|
1856
|
-
typeArguments
|
|
1857
|
-
|
|
1858
|
-
});
|
|
1859
|
-
}
|
|
1833
|
+
typeArguments: node.typeArguments &&
|
|
1834
|
+
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node),
|
|
1835
|
+
}, 'typeParameters', 'typeArguments'));
|
|
1860
1836
|
case SyntaxKind.TypeParameter: {
|
|
1861
1837
|
return this.createNode(node, {
|
|
1862
1838
|
type: ts_estree_1.AST_NODE_TYPES.TSTypeParameter,
|
|
@@ -1865,6 +1841,7 @@ class Converter {
|
|
|
1865
1841
|
default: node.default ? this.convertChild(node.default) : undefined,
|
|
1866
1842
|
in: (0, node_utils_1.hasModifier)(SyntaxKind.InKeyword, node),
|
|
1867
1843
|
out: (0, node_utils_1.hasModifier)(SyntaxKind.OutKeyword, node),
|
|
1844
|
+
const: (0, node_utils_1.hasModifier)(SyntaxKind.ConstKeyword, node),
|
|
1868
1845
|
});
|
|
1869
1846
|
}
|
|
1870
1847
|
case SyntaxKind.ThisType:
|
|
@@ -1922,16 +1899,13 @@ class Converter {
|
|
|
1922
1899
|
falseType: this.convertChild(node.falseType),
|
|
1923
1900
|
});
|
|
1924
1901
|
}
|
|
1925
|
-
case SyntaxKind.TypeQuery:
|
|
1926
|
-
|
|
1927
|
-
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node);
|
|
1928
|
-
return this.createNode(node, {
|
|
1902
|
+
case SyntaxKind.TypeQuery:
|
|
1903
|
+
return this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
1929
1904
|
type: ts_estree_1.AST_NODE_TYPES.TSTypeQuery,
|
|
1930
1905
|
exprName: this.convertChild(node.exprName),
|
|
1931
|
-
typeArguments
|
|
1932
|
-
|
|
1933
|
-
});
|
|
1934
|
-
}
|
|
1906
|
+
typeArguments: node.typeArguments &&
|
|
1907
|
+
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node),
|
|
1908
|
+
}, 'typeParameters', 'typeArguments'));
|
|
1935
1909
|
case SyntaxKind.MappedType: {
|
|
1936
1910
|
return this.createNode(node, {
|
|
1937
1911
|
type: ts_estree_1.AST_NODE_TYPES.TSMappedType,
|
|
@@ -1949,7 +1923,6 @@ class Converter {
|
|
|
1949
1923
|
case SyntaxKind.ParenthesizedExpression:
|
|
1950
1924
|
return this.convertChild(node.expression, parent);
|
|
1951
1925
|
case SyntaxKind.TypeAliasDeclaration: {
|
|
1952
|
-
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_checkIllegalDecorators).call(this, node);
|
|
1953
1926
|
const result = this.createNode(node, {
|
|
1954
1927
|
type: ts_estree_1.AST_NODE_TYPES.TSTypeAliasDeclaration,
|
|
1955
1928
|
declare: (0, node_utils_1.hasModifier)(SyntaxKind.DeclareKeyword, node),
|
|
@@ -1969,10 +1942,6 @@ class Converter {
|
|
|
1969
1942
|
if (initializer) {
|
|
1970
1943
|
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, initializer, 'A property signature cannot have an initializer.');
|
|
1971
1944
|
}
|
|
1972
|
-
const exportKeyword = (0, node_utils_1.getModifier)(SyntaxKind.ExportKeyword, node);
|
|
1973
|
-
if (exportKeyword) {
|
|
1974
|
-
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwUnlessAllowInvalidAST).call(this, exportKeyword, 'A property signature cannot have an export modifier.');
|
|
1975
|
-
}
|
|
1976
1945
|
return this.createNode(node, {
|
|
1977
1946
|
type: ts_estree_1.AST_NODE_TYPES.TSPropertySignature,
|
|
1978
1947
|
accessibility: (0, node_utils_1.getTSNodeAccessibility)(node),
|
|
@@ -1985,10 +1954,6 @@ class Converter {
|
|
|
1985
1954
|
});
|
|
1986
1955
|
}
|
|
1987
1956
|
case SyntaxKind.IndexSignature: {
|
|
1988
|
-
const exportKeyword = (0, node_utils_1.getModifier)(SyntaxKind.ExportKeyword, node);
|
|
1989
|
-
if (exportKeyword) {
|
|
1990
|
-
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwUnlessAllowInvalidAST).call(this, exportKeyword, 'An index signature cannot have an export modifier.');
|
|
1991
|
-
}
|
|
1992
1957
|
return this.createNode(node, {
|
|
1993
1958
|
type: ts_estree_1.AST_NODE_TYPES.TSIndexSignature,
|
|
1994
1959
|
accessibility: (0, node_utils_1.getTSNodeAccessibility)(node),
|
|
@@ -2038,18 +2003,14 @@ class Converter {
|
|
|
2038
2003
|
: parentKind === SyntaxKind.HeritageClause
|
|
2039
2004
|
? ts_estree_1.AST_NODE_TYPES.TSClassImplements
|
|
2040
2005
|
: ts_estree_1.AST_NODE_TYPES.TSInstantiationExpression;
|
|
2041
|
-
|
|
2042
|
-
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node);
|
|
2043
|
-
const result = this.createNode(node, {
|
|
2006
|
+
return this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
2044
2007
|
type,
|
|
2045
2008
|
expression: this.convertChild(node.expression),
|
|
2046
|
-
typeArguments
|
|
2047
|
-
|
|
2048
|
-
});
|
|
2049
|
-
return result;
|
|
2009
|
+
typeArguments: node.typeArguments &&
|
|
2010
|
+
this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node),
|
|
2011
|
+
}, 'typeParameters', 'typeArguments'));
|
|
2050
2012
|
}
|
|
2051
2013
|
case SyntaxKind.InterfaceDeclaration: {
|
|
2052
|
-
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_checkIllegalDecorators).call(this, node);
|
|
2053
2014
|
const interfaceHeritageClauses = node.heritageClauses ?? [];
|
|
2054
2015
|
const interfaceExtends = [];
|
|
2055
2016
|
for (const heritageClause of interfaceHeritageClauses) {
|
|
@@ -2101,17 +2062,15 @@ class Converter {
|
|
|
2101
2062
|
const token = (0, node_utils_1.findNextToken)(node.getFirstToken(), node, this.ast);
|
|
2102
2063
|
range[0] = token.getStart(this.ast);
|
|
2103
2064
|
}
|
|
2104
|
-
const
|
|
2105
|
-
? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
|
|
2106
|
-
: null;
|
|
2107
|
-
const result = this.createNode(node, {
|
|
2065
|
+
const result = this.createNode(node, __classPrivateFieldGet(this, _Converter_instances, "m", _Converter_withDeprecatedAliasGetter).call(this, {
|
|
2108
2066
|
type: ts_estree_1.AST_NODE_TYPES.TSImportType,
|
|
2109
2067
|
argument: this.convertChild(node.argument),
|
|
2110
2068
|
qualifier: this.convertChild(node.qualifier),
|
|
2111
|
-
typeArguments
|
|
2112
|
-
|
|
2069
|
+
typeArguments: node.typeArguments
|
|
2070
|
+
? this.convertTypeArgumentsToTypeParameterInstantiation(node.typeArguments, node)
|
|
2071
|
+
: null,
|
|
2113
2072
|
range: range,
|
|
2114
|
-
});
|
|
2073
|
+
}, 'typeParameters', 'typeArguments'));
|
|
2115
2074
|
if (node.isTypeOf) {
|
|
2116
2075
|
return this.createNode(node, {
|
|
2117
2076
|
type: ts_estree_1.AST_NODE_TYPES.TSTypeQuery,
|
|
@@ -2123,7 +2082,6 @@ class Converter {
|
|
|
2123
2082
|
return result;
|
|
2124
2083
|
}
|
|
2125
2084
|
case SyntaxKind.EnumDeclaration: {
|
|
2126
|
-
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_checkIllegalDecorators).call(this, node);
|
|
2127
2085
|
const result = this.createNode(node, {
|
|
2128
2086
|
type: ts_estree_1.AST_NODE_TYPES.TSEnumDeclaration,
|
|
2129
2087
|
const: (0, node_utils_1.hasModifier)(SyntaxKind.ConstKeyword, node),
|
|
@@ -2387,14 +2345,123 @@ class Converter {
|
|
|
2387
2345
|
}
|
|
2388
2346
|
}
|
|
2389
2347
|
exports.Converter = Converter;
|
|
2390
|
-
_Converter_instances = new WeakSet(),
|
|
2348
|
+
_Converter_instances = new WeakSet(), _Converter_checkModifiers = function _Converter_checkModifiers(node) {
|
|
2349
|
+
if (this.options.allowInvalidAST) {
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2391
2352
|
if ((0, node_utils_1.nodeHasIllegalDecorators)(node)) {
|
|
2392
|
-
__classPrivateFieldGet(this, _Converter_instances, "m",
|
|
2353
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, node.illegalDecorators[0], 'Decorators are not valid here.');
|
|
2354
|
+
}
|
|
2355
|
+
for (const modifier of (0, getModifiers_1.getModifiers)(node) ?? []) {
|
|
2356
|
+
if (modifier.kind !== SyntaxKind.ReadonlyKeyword) {
|
|
2357
|
+
if (node.kind === SyntaxKind.PropertySignature ||
|
|
2358
|
+
node.kind === SyntaxKind.MethodSignature) {
|
|
2359
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, `'${ts.tokenToString(modifier.kind)}' modifier cannot appear on a type member`);
|
|
2360
|
+
}
|
|
2361
|
+
if (node.kind === SyntaxKind.IndexSignature &&
|
|
2362
|
+
(modifier.kind !== SyntaxKind.StaticKeyword ||
|
|
2363
|
+
!ts.isClassLike(node.parent))) {
|
|
2364
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, `'${ts.tokenToString(modifier.kind)}' modifier cannot appear on an index signature`);
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
if (modifier.kind !== SyntaxKind.InKeyword &&
|
|
2368
|
+
modifier.kind !== SyntaxKind.OutKeyword &&
|
|
2369
|
+
modifier.kind !== SyntaxKind.ConstKeyword &&
|
|
2370
|
+
node.kind === SyntaxKind.TypeParameter) {
|
|
2371
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, `'${ts.tokenToString(modifier.kind)}' modifier cannot appear on a type parameter`);
|
|
2372
|
+
}
|
|
2373
|
+
if ((modifier.kind === SyntaxKind.InKeyword ||
|
|
2374
|
+
modifier.kind === SyntaxKind.OutKeyword) &&
|
|
2375
|
+
(node.kind !== SyntaxKind.TypeParameter ||
|
|
2376
|
+
!(ts.isInterfaceDeclaration(node.parent) ||
|
|
2377
|
+
ts.isClassLike(node.parent) ||
|
|
2378
|
+
ts.isTypeAliasDeclaration(node.parent)))) {
|
|
2379
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, `'${ts.tokenToString(modifier.kind)}' modifier can only appear on a type parameter of a class, interface or type alias`);
|
|
2380
|
+
}
|
|
2381
|
+
if (modifier.kind === SyntaxKind.ReadonlyKeyword &&
|
|
2382
|
+
node.kind !== SyntaxKind.PropertyDeclaration &&
|
|
2383
|
+
node.kind !== SyntaxKind.PropertySignature &&
|
|
2384
|
+
node.kind !== SyntaxKind.IndexSignature &&
|
|
2385
|
+
node.kind !== SyntaxKind.Parameter) {
|
|
2386
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, "'readonly' modifier can only appear on a property declaration or index signature.");
|
|
2387
|
+
}
|
|
2388
|
+
if (modifier.kind === SyntaxKind.DeclareKeyword &&
|
|
2389
|
+
ts.isClassLike(node.parent) &&
|
|
2390
|
+
!ts.isPropertyDeclaration(node)) {
|
|
2391
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, `'${ts.tokenToString(modifier.kind)}' modifier cannot appear on class elements of this kind.`);
|
|
2392
|
+
}
|
|
2393
|
+
if (modifier.kind === SyntaxKind.AbstractKeyword &&
|
|
2394
|
+
node.kind !== SyntaxKind.ClassDeclaration &&
|
|
2395
|
+
node.kind !== SyntaxKind.ConstructorType &&
|
|
2396
|
+
node.kind !== SyntaxKind.MethodDeclaration &&
|
|
2397
|
+
node.kind !== SyntaxKind.PropertyDeclaration &&
|
|
2398
|
+
node.kind !== SyntaxKind.GetAccessor &&
|
|
2399
|
+
node.kind !== SyntaxKind.SetAccessor) {
|
|
2400
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, `'${ts.tokenToString(modifier.kind)}' modifier can only appear on a class, method, or property declaration.`);
|
|
2401
|
+
}
|
|
2402
|
+
if ((modifier.kind === SyntaxKind.StaticKeyword ||
|
|
2403
|
+
modifier.kind === SyntaxKind.PublicKeyword ||
|
|
2404
|
+
modifier.kind === SyntaxKind.ProtectedKeyword ||
|
|
2405
|
+
modifier.kind === SyntaxKind.PrivateKeyword) &&
|
|
2406
|
+
(node.parent.kind === SyntaxKind.ModuleBlock ||
|
|
2407
|
+
node.parent.kind === SyntaxKind.SourceFile)) {
|
|
2408
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, `'${ts.tokenToString(modifier.kind)}' modifier cannot appear on a module or namespace element.`);
|
|
2409
|
+
}
|
|
2410
|
+
if (modifier.kind === SyntaxKind.AccessorKeyword &&
|
|
2411
|
+
node.kind !== SyntaxKind.PropertyDeclaration) {
|
|
2412
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, "'accessor' modifier can only appear on a property declaration.");
|
|
2413
|
+
}
|
|
2414
|
+
// `checkGrammarAsyncModifier` function in `typescript`
|
|
2415
|
+
if (modifier.kind === SyntaxKind.AsyncKeyword &&
|
|
2416
|
+
node.kind !== SyntaxKind.MethodDeclaration &&
|
|
2417
|
+
node.kind !== SyntaxKind.FunctionDeclaration &&
|
|
2418
|
+
node.kind !== SyntaxKind.FunctionExpression &&
|
|
2419
|
+
node.kind !== SyntaxKind.ArrowFunction) {
|
|
2420
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, "'async' modifier cannot be used here.");
|
|
2421
|
+
}
|
|
2422
|
+
// `checkGrammarModifiers` function in `typescript`
|
|
2423
|
+
if (node.kind === SyntaxKind.Parameter &&
|
|
2424
|
+
(modifier.kind === SyntaxKind.StaticKeyword ||
|
|
2425
|
+
modifier.kind === SyntaxKind.ExportKeyword ||
|
|
2426
|
+
modifier.kind === SyntaxKind.DeclareKeyword ||
|
|
2427
|
+
modifier.kind === SyntaxKind.AsyncKeyword)) {
|
|
2428
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, `'${ts.tokenToString(modifier.kind)}' modifier cannot appear on a parameter.`);
|
|
2429
|
+
}
|
|
2430
|
+
// `checkParameter` function in `typescript`
|
|
2431
|
+
if (node.kind === SyntaxKind.Parameter &&
|
|
2432
|
+
// In `typescript` package, it's `ts.hasSyntacticModifier(node, ts.ModifierFlags.ParameterPropertyModifier)`
|
|
2433
|
+
// https://github.com/typescript-eslint/typescript-eslint/pull/6615#discussion_r1136489935
|
|
2434
|
+
(modifier.kind === SyntaxKind.PublicKeyword ||
|
|
2435
|
+
modifier.kind === SyntaxKind.PrivateKeyword ||
|
|
2436
|
+
modifier.kind === SyntaxKind.ProtectedKeyword ||
|
|
2437
|
+
modifier.kind === SyntaxKind.ReadonlyKeyword)) {
|
|
2438
|
+
const func = (0, node_utils_1.getContainingFunction)(node);
|
|
2439
|
+
if (!(func.kind === SyntaxKind.Constructor && (0, node_utils_1.nodeIsPresent)(func.body))) {
|
|
2440
|
+
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, modifier, 'A parameter property is only allowed in a constructor implementation.');
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2393
2443
|
}
|
|
2394
2444
|
}, _Converter_throwUnlessAllowInvalidAST = function _Converter_throwUnlessAllowInvalidAST(node, message) {
|
|
2395
2445
|
if (!this.options.allowInvalidAST) {
|
|
2396
2446
|
__classPrivateFieldGet(this, _Converter_instances, "m", _Converter_throwError).call(this, node, message);
|
|
2397
2447
|
}
|
|
2448
|
+
}, _Converter_withDeprecatedAliasGetter = function _Converter_withDeprecatedAliasGetter(node, aliasKey, valueKey) {
|
|
2449
|
+
let errored = false;
|
|
2450
|
+
Object.defineProperty(node, aliasKey, {
|
|
2451
|
+
get: this.options.suppressDeprecatedPropertyWarnings
|
|
2452
|
+
? () => node[valueKey]
|
|
2453
|
+
: () => {
|
|
2454
|
+
if (!this.options.suppressDeprecatedPropertyWarnings) {
|
|
2455
|
+
if (!errored) {
|
|
2456
|
+
// eslint-disable-next-line no-console
|
|
2457
|
+
console.warn(`The '${aliasKey}' property is deprecated on ${node.type} nodes. Use '${valueKey}' instead. See https://typescript-eslint.io/linting/troubleshooting#the-key-property-is-deprecated-on-type-nodes-use-key-instead-warnings.`);
|
|
2458
|
+
errored = true;
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
return node[valueKey];
|
|
2462
|
+
},
|
|
2463
|
+
});
|
|
2464
|
+
return node;
|
|
2398
2465
|
}, _Converter_throwError = function _Converter_throwError(node, message) {
|
|
2399
2466
|
let start;
|
|
2400
2467
|
let end;
|