@typescript-eslint/typescript-estree 8.52.1-alpha.3 → 8.52.1-alpha.4

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.
@@ -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,30 @@ function checkSyntaxError(tsNode, parent, allowPattern) {
360
366
  }
361
367
  break;
362
368
  }
369
+ case SyntaxKind.ModuleDeclaration: {
370
+ if (node.flags & ts.NodeFlags.GlobalAugmentation) {
371
+ const { body } = node;
372
+ if (body == null || body.kind === SyntaxKind.ModuleDeclaration) {
373
+ throw (0, node_utils_1.createError)(node.body ?? node, 'Expected a valid module body');
374
+ }
375
+ const { name } = node;
376
+ if (name.kind !== ts.SyntaxKind.Identifier) {
377
+ throw (0, node_utils_1.createError)(name, 'global module augmentation must have an Identifier id');
378
+ }
379
+ return;
380
+ }
381
+ if (ts.isStringLiteral(node.name)) {
382
+ return;
383
+ }
384
+ if (node.body == null) {
385
+ throw (0, node_utils_1.createError)(node, 'Expected a module body');
386
+ }
387
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Fixme: confirm if it's possible
388
+ if (node.name.kind !== ts.SyntaxKind.Identifier) {
389
+ throw (0, node_utils_1.createError)(node.name, '`namespace`s must have an Identifier id');
390
+ }
391
+ break;
392
+ }
363
393
  case SyntaxKind.ForInStatement:
364
394
  case SyntaxKind.ForOfStatement: {
365
395
  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",
3
+ "version": "8.52.1-alpha.4",
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.3",
56
- "@typescript-eslint/tsconfig-utils": "8.52.1-alpha.3",
57
- "@typescript-eslint/types": "8.52.1-alpha.3",
58
- "@typescript-eslint/visitor-keys": "8.52.1-alpha.3",
55
+ "@typescript-eslint/project-service": "8.52.1-alpha.4",
56
+ "@typescript-eslint/tsconfig-utils": "8.52.1-alpha.4",
57
+ "@typescript-eslint/types": "8.52.1-alpha.4",
58
+ "@typescript-eslint/visitor-keys": "8.52.1-alpha.4",
59
59
  "debug": "^4.4.3",
60
60
  "minimatch": "^9.0.5",
61
61
  "semver": "^7.7.3",