@typescript-eslint/typescript-estree 8.52.1-alpha.3 → 8.52.1-alpha.5
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/check-syntax-errors.js +36 -0
- package/dist/convert.js +2 -19
- package/package.json +5 -5
|
@@ -301,6 +301,12 @@ function checkSyntaxError(tsNode, parent, allowPattern) {
|
|
|
301
301
|
if (seenImplementsClause) {
|
|
302
302
|
throw (0, node_utils_1.createError)(heritageClause, "'implements' clause already seen.");
|
|
303
303
|
}
|
|
304
|
+
for (const heritageType of heritageClause.types) {
|
|
305
|
+
if (!(0, node_utils_1.isEntityNameExpression)(heritageType.expression) ||
|
|
306
|
+
ts.isOptionalChain(heritageType.expression)) {
|
|
307
|
+
throw (0, node_utils_1.createError)(heritageType, 'A class can only implement an identifier/qualified-name with optional type arguments.');
|
|
308
|
+
}
|
|
309
|
+
}
|
|
304
310
|
seenImplementsClause = true;
|
|
305
311
|
}
|
|
306
312
|
}
|
|
@@ -360,6 +366,36 @@ function checkSyntaxError(tsNode, parent, allowPattern) {
|
|
|
360
366
|
}
|
|
361
367
|
break;
|
|
362
368
|
}
|
|
369
|
+
case SyntaxKind.ImportEqualsDeclaration:
|
|
370
|
+
if (node.isTypeOnly &&
|
|
371
|
+
node.moduleReference.kind !== SyntaxKind.ExternalModuleReference) {
|
|
372
|
+
throw (0, node_utils_1.createError)(node, "An import alias cannot use 'import type'");
|
|
373
|
+
}
|
|
374
|
+
break;
|
|
375
|
+
case SyntaxKind.ModuleDeclaration: {
|
|
376
|
+
if (node.flags & ts.NodeFlags.GlobalAugmentation) {
|
|
377
|
+
const { body } = node;
|
|
378
|
+
if (body == null || body.kind === SyntaxKind.ModuleDeclaration) {
|
|
379
|
+
throw (0, node_utils_1.createError)(node.body ?? node, 'Expected a valid module body');
|
|
380
|
+
}
|
|
381
|
+
const { name } = node;
|
|
382
|
+
if (name.kind !== ts.SyntaxKind.Identifier) {
|
|
383
|
+
throw (0, node_utils_1.createError)(name, 'global module augmentation must have an Identifier id');
|
|
384
|
+
}
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (ts.isStringLiteral(node.name)) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if (node.body == null) {
|
|
391
|
+
throw (0, node_utils_1.createError)(node, 'Expected a module body');
|
|
392
|
+
}
|
|
393
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Fixme: confirm if it's possible
|
|
394
|
+
if (node.name.kind !== ts.SyntaxKind.Identifier) {
|
|
395
|
+
throw (0, node_utils_1.createError)(node.name, '`namespace`s must have an Identifier id');
|
|
396
|
+
}
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
363
399
|
case SyntaxKind.ForInStatement:
|
|
364
400
|
case SyntaxKind.ForOfStatement: {
|
|
365
401
|
checkForStatementDeclaration(node);
|
package/dist/convert.js
CHANGED
|
@@ -1996,23 +1996,12 @@ class Converter {
|
|
|
1996
1996
|
const result = this.createNode(node, {
|
|
1997
1997
|
type: ts_estree_1.AST_NODE_TYPES.TSModuleDeclaration,
|
|
1998
1998
|
...(() => {
|
|
1999
|
-
// the constraints checked by this function are syntactically enforced by TS
|
|
2000
|
-
// the checks mostly exist for type's sake
|
|
2001
1999
|
if (node.flags & ts.NodeFlags.GlobalAugmentation) {
|
|
2002
|
-
const id = this.convertChild(node.name);
|
|
2003
|
-
const body = this.convertChild(node.body);
|
|
2004
|
-
if (body == null ||
|
|
2005
|
-
body.type === ts_estree_1.AST_NODE_TYPES.TSModuleDeclaration) {
|
|
2006
|
-
this.#throwError(node.body ?? node, 'Expected a valid module body');
|
|
2007
|
-
}
|
|
2008
|
-
if (id.type !== ts_estree_1.AST_NODE_TYPES.Identifier) {
|
|
2009
|
-
this.#throwError(node.name, 'global module augmentation must have an Identifier id');
|
|
2010
|
-
}
|
|
2011
2000
|
return {
|
|
2012
|
-
body: body,
|
|
2001
|
+
body: this.convertChild(node.body),
|
|
2013
2002
|
declare: false,
|
|
2014
2003
|
global: false,
|
|
2015
|
-
id,
|
|
2004
|
+
id: this.convertChild(node.name),
|
|
2016
2005
|
kind: 'global',
|
|
2017
2006
|
};
|
|
2018
2007
|
}
|
|
@@ -2029,12 +2018,6 @@ class Converter {
|
|
|
2029
2018
|
// Nested module declarations are stored in TypeScript as nested tree nodes.
|
|
2030
2019
|
// We "unravel" them here by making our own nested TSQualifiedName,
|
|
2031
2020
|
// with the innermost node's body as the actual node body.
|
|
2032
|
-
if (node.body == null) {
|
|
2033
|
-
this.#throwError(node, 'Expected a module body');
|
|
2034
|
-
}
|
|
2035
|
-
if (node.name.kind !== ts.SyntaxKind.Identifier) {
|
|
2036
|
-
this.#throwError(node.name, '`namespace`s must have an Identifier id');
|
|
2037
|
-
}
|
|
2038
2021
|
let name = this.createNode(node.name, {
|
|
2039
2022
|
type: ts_estree_1.AST_NODE_TYPES.Identifier,
|
|
2040
2023
|
range: [node.name.getStart(this.ast), node.name.getEnd()],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/typescript-estree",
|
|
3
|
-
"version": "8.52.1-alpha.
|
|
3
|
+
"version": "8.52.1-alpha.5",
|
|
4
4
|
"description": "A parser that converts TypeScript source code into an ESTree compatible form",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"typecheck": "yarn run -BT nx typecheck"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@typescript-eslint/project-service": "8.52.1-alpha.
|
|
56
|
-
"@typescript-eslint/tsconfig-utils": "8.52.1-alpha.
|
|
57
|
-
"@typescript-eslint/types": "8.52.1-alpha.
|
|
58
|
-
"@typescript-eslint/visitor-keys": "8.52.1-alpha.
|
|
55
|
+
"@typescript-eslint/project-service": "8.52.1-alpha.5",
|
|
56
|
+
"@typescript-eslint/tsconfig-utils": "8.52.1-alpha.5",
|
|
57
|
+
"@typescript-eslint/types": "8.52.1-alpha.5",
|
|
58
|
+
"@typescript-eslint/visitor-keys": "8.52.1-alpha.5",
|
|
59
59
|
"debug": "^4.4.3",
|
|
60
60
|
"minimatch": "^9.0.5",
|
|
61
61
|
"semver": "^7.7.3",
|