Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 34adb5d

Browse files
committed
Upgrade: typescript-estree to 8.1.0 and add new tests
1 parent 18598d9 commit 34adb5d

30 files changed

+1897
-22
lines changed

analyze-scope.js

+104-1
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,97 @@ class Referencer extends OriginalReferencer {
400400
}
401401
}
402402

403+
/**
404+
* @param {TSTypeReference} node The TSTypeReference node to visit.
405+
* @returns {void}
406+
*/
407+
TSTypeReference(node) {
408+
this.visitTypeNodes(node);
409+
}
410+
411+
/**
412+
* @param {TSTypeLiteral} node The TSTypeLiteral node to visit.
413+
* @returns {void}
414+
*/
415+
TSTypeLiteral(node) {
416+
this.visitTypeNodes(node);
417+
}
418+
419+
/**
420+
* @param {TSLiteralType} node The TSLiteralType node to visit.
421+
* @returns {void}
422+
*/
423+
TSLiteralType(node) {
424+
this.visitTypeNodes(node);
425+
}
426+
427+
/**
428+
* @param {TSIntersectionType} node The TSIntersectionType node to visit.
429+
* @returns {void}
430+
*/
431+
TSIntersectionType(node) {
432+
this.visitTypeNodes(node);
433+
}
434+
435+
/**
436+
* @param {TSConditionalType} node The TSConditionalType node to visit.
437+
* @returns {void}
438+
*/
439+
TSConditionalType(node) {
440+
this.visitTypeNodes(node);
441+
}
442+
443+
/**
444+
* @param {TSIndexedAccessType} node The TSIndexedAccessType node to visit.
445+
* @returns {void}
446+
*/
447+
TSIndexedAccessType(node) {
448+
this.visitTypeNodes(node);
449+
}
450+
451+
/**
452+
* @param {TSMappedType} node The TSMappedType node to visit.
453+
* @returns {void}
454+
*/
455+
TSMappedType(node) {
456+
this.visitTypeNodes(node);
457+
}
458+
459+
/**
460+
* @param {TSOptionalType} node The TSOptionalType node to visit.
461+
* @returns {void}
462+
*/
463+
TSOptionalType(node) {
464+
this.visitTypeNodes(node);
465+
}
466+
467+
/**
468+
* @param {TSParenthesizedType} node The TSParenthesizedType node to visit.
469+
* @returns {void}
470+
*/
471+
TSParenthesizedType(node) {
472+
this.visitTypeNodes(node);
473+
}
474+
475+
/**
476+
* @param {TSRestType} node The TSRestType node to visit.
477+
* @returns {void}
478+
*/
479+
TSRestType(node) {
480+
this.visitTypeNodes(node);
481+
}
482+
483+
/**
484+
* @param {TSTupleType} node The TSTupleType node to visit.
485+
* @returns {void}
486+
*/
487+
TSTupleType(node) {
488+
this.visitTypeNodes(node);
489+
}
490+
403491
/**
404492
* Create reference objects for the object part. (This is `obj.prop`)
405-
* @param {TSTypeQuery} node The TSTypeQuery node to visit.
493+
* @param {TSQualifiedName} node The TSQualifiedName node to visit.
406494
* @returns {void}
407495
*/
408496
TSQualifiedName(node) {
@@ -616,6 +704,21 @@ class Referencer extends OriginalReferencer {
616704
decorators.forEach(this.visit, this);
617705
}
618706
}
707+
708+
/**
709+
* Process all child of type nodes
710+
* @param {any} node node to be processed
711+
* @returns {void}
712+
*/
713+
visitTypeNodes(node) {
714+
if (this.typeMode) {
715+
this.visitChildren(node);
716+
} else {
717+
this.typeMode = true;
718+
this.visitChildren(node);
719+
this.typeMode = false;
720+
}
721+
}
619722
}
620723

621724
module.exports = function(ast, parserOptions, extraOptions) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"dependencies": {
4747
"eslint-scope": "^4.0.0",
4848
"eslint-visitor-keys": "^1.0.0",
49-
"typescript-estree": "^7.0.0"
49+
"typescript-estree": "8.1.0"
5050
},
5151
"devDependencies": {
5252
"eslint": "^4.19.1",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Foo = string[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: number extends string ? boolean : null;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: number extends string ? boolean : string;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: T[K];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type LinkedList<T> = T & { next: LinkedList<T> };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let map: { -readonly [P in string]-?: number };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let map: { +readonly [P in string]+?: number; };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let map: { readonly [P in string]?: number; };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let map: { [P in string]: number; };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Foo = [number, string?, boolean?] | [{}, [number?] | null & boolean[]] & {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Foo = (string | number)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: Array<Array<number>>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: Array<number>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: T;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: [];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: [string, number?, (string | number)?]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: [string, ...number[]]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Foo = [string, string?]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: [number, number, number];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let obj: { x: number };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let x: keyof T;
2+
let y: unique symbol;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let x: typeof y.z;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let union: number | null | undefined;
2+
let intersection: number & string;
3+
let precedence1: number | string & boolean;
4+
let precedence2: number & string | boolean;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Foo = string & number

tests/lib/__snapshots__/ecma-features.js.snap

+17
Original file line numberDiff line numberDiff line change
@@ -2375,6 +2375,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-default-param-eval.sr
23752375
Object {
23762376
"body": Array [
23772377
Object {
2378+
"directive": "use strict",
23782379
"expression": Object {
23792380
"loc": Object {
23802381
"end": Object {
@@ -2730,6 +2731,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-dup-params.src 1`] =
27302731
Object {
27312732
"body": Array [
27322733
Object {
2734+
"directive": "use strict",
27332735
"expression": Object {
27342736
"loc": Object {
27352737
"end": Object {
@@ -3072,6 +3074,7 @@ Object {
30723074
"body": Object {
30733075
"body": Array [
30743076
Object {
3077+
"directive": "use strict",
30753078
"expression": Object {
30763079
"loc": Object {
30773080
"end": Object {
@@ -3404,6 +3407,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-eval-return.src 1`] =
34043407
Object {
34053408
"body": Array [
34063409
Object {
3410+
"directive": "use strict",
34073411
"expression": Object {
34083412
"loc": Object {
34093413
"end": Object {
@@ -3669,6 +3673,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-octal.src 1`] = `
36693673
Object {
36703674
"body": Array [
36713675
Object {
3676+
"directive": "use strict",
36723677
"expression": Object {
36733678
"loc": Object {
36743679
"end": Object {
@@ -3952,6 +3957,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-arguments.src 1
39523957
Object {
39533958
"body": Array [
39543959
Object {
3960+
"directive": "use strict",
39553961
"expression": Object {
39563962
"loc": Object {
39573963
"end": Object {
@@ -4289,6 +4295,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-eval.src 1`] =
42894295
Object {
42904296
"body": Array [
42914297
Object {
4298+
"directive": "use strict",
42924299
"expression": Object {
42934300
"loc": Object {
42944301
"end": Object {
@@ -4626,6 +4633,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-names.src 1`] =
46264633
Object {
46274634
"body": Array [
46284635
Object {
4636+
"directive": "use strict",
46294637
"expression": Object {
46304638
"loc": Object {
46314639
"end": Object {
@@ -4963,6 +4971,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-no-paren-argume
49634971
Object {
49644972
"body": Array [
49654973
Object {
4974+
"directive": "use strict",
49664975
"expression": Object {
49674976
"loc": Object {
49684977
"end": Object {
@@ -5210,6 +5219,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-no-paren-eval.s
52105219
Object {
52115220
"body": Array [
52125221
Object {
5222+
"directive": "use strict",
52135223
"expression": Object {
52145224
"loc": Object {
52155225
"end": Object {
@@ -93424,6 +93434,7 @@ exports[`ecmaFeatures fixtures/objectLiteralDuplicateProperties/error-proto-prop
9342493434
Object {
9342593435
"body": Array [
9342693436
Object {
93437+
"directive": "use strict",
9342793438
"expression": Object {
9342893439
"loc": Object {
9342993440
"end": Object {
@@ -94125,6 +94136,7 @@ exports[`ecmaFeatures fixtures/objectLiteralDuplicateProperties/error-proto-stri
9412594136
Object {
9412694137
"body": Array [
9412794138
Object {
94139+
"directive": "use strict",
9412894140
"expression": Object {
9412994141
"loc": Object {
9413094142
"end": Object {
@@ -94828,6 +94840,7 @@ exports[`ecmaFeatures fixtures/objectLiteralDuplicateProperties/strict-duplicate
9482894840
Object {
9482994841
"body": Array [
9483094842
Object {
94843+
"directive": "use strict",
9483194844
"expression": Object {
9483294845
"loc": Object {
9483394846
"end": Object {
@@ -95350,6 +95363,7 @@ exports[`ecmaFeatures fixtures/objectLiteralDuplicateProperties/strict-duplicate
9535095363
Object {
9535195364
"body": Array [
9535295365
Object {
95366+
"directive": "use strict",
9535395367
"expression": Object {
9535495368
"loc": Object {
9535595369
"end": Object {
@@ -99632,6 +99646,7 @@ exports[`ecmaFeatures fixtures/octalLiterals/strict-uppercase.src 1`] = `
9963299646
Object {
9963399647
"body": Array [
9963499648
Object {
99649+
"directive": "use strict",
9963599650
"expression": Object {
9963699651
"loc": Object {
9963799652
"end": Object {
@@ -107763,6 +107778,7 @@ exports[`ecmaFeatures fixtures/unicodeCodePointEscapes/basic-string-literal.src
107763107778
Object {
107764107779
"body": Array [
107765107780
Object {
107781+
"directive": "\\\\u{714E}\\\\u{8336}",
107766107782
"expression": Object {
107767107783
"loc": Object {
107768107784
"end": Object {
@@ -107861,6 +107877,7 @@ exports[`ecmaFeatures fixtures/unicodeCodePointEscapes/complex-string-literal.sr
107861107877
Object {
107862107878
"body": Array [
107863107879
Object {
107880+
"directive": "\\\\u{20BB7}\\\\u{10FFFF}\\\\u{1}",
107864107881
"expression": Object {
107865107882
"loc": Object {
107866107883
"end": Object {

0 commit comments

Comments
 (0)