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

Breaking: typescript-estree to 9.0.0 and typescript to 3.2.1 #590

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Upgrade: typescript-estree to 7.0.0
  • Loading branch information
armano2 committed Dec 24, 2018
commit 6aad31d5edf06d25677651446d9a88fdd29ef990
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ _test.js
.vscode
yarn.lock
.eslint-release-info.json
.idea
26 changes: 7 additions & 19 deletions analyze-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,6 @@ class Referencer extends OriginalReferencer {
super.MethodDefinition(node);
}

/**
* Override.
* Don't make variable if `kind === "type"`.
* It doesn't declare variables but declare types.
* @param {VariableDeclaration} node The VariableDeclaration node to visit.
* @returns {void}
*/
VariableDeclaration(node) {
if (node.kind !== "type") {
super.VariableDeclaration(node);
return;
}

// To detect typeof.
this.typeMode = true;
this.visitChildren(node);
this.typeMode = false;
}

/**
* Don't create the reference object for the key if not computed.
* @param {TSEmptyBodyFunctionDeclaration} node The TSEmptyBodyFunctionDeclaration node to visit.
Expand Down Expand Up @@ -337,6 +318,7 @@ class Referencer extends OriginalReferencer {
this.visit(returnType);
this.typeMode = upperTypeMode;
}

TSEmptyBodyDeclareFunction(node) {
this.TSEmptyBodyFunctionDeclaration(node);
}
Expand Down Expand Up @@ -556,6 +538,12 @@ class Referencer extends OriginalReferencer {
this.visit(body);
}

TSTypeAliasDeclaration(node) {
this.typeMode = true;
this.visitChildren(node);
this.typeMode = false;
}

/**
* Process the module block.
* @param {TSModuleBlock} node The TSModuleBlock node to visit.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"dependencies": {
"eslint-scope": "^4.0.0",
"eslint-visitor-keys": "^1.0.0",
"typescript-estree": "^6.0.0"
"typescript-estree": "^7.0.0"
},
"devDependencies": {
"eslint": "^4.19.1",
Expand Down
4 changes: 2 additions & 2 deletions parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ exports.parseForESLint = function parseForESLint(code, options) {
enter: node => {
switch (node.type) {
// Just for backward compatibility.
case "DeclareFunction":
case "TSDeclareFunction":
if (!node.body) {
node.type = `TSEmptyBody${node.type}`;
node.type = "TSEmptyBodyDeclareFunction";
}
break;

Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/scope-analysis/type-alias.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type foo = string
2 changes: 0 additions & 2 deletions tests/lib/__snapshots__/ecma-features.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -102029,7 +102029,6 @@ Object {
"body": Array [
Object {
"async": false,
"body": null,
"expression": false,
"generator": false,
"id": Object {
Expand Down Expand Up @@ -102347,7 +102346,6 @@ Object {
"body": Array [
Object {
"async": false,
"body": null,
"expression": false,
"generator": false,
"id": Object {
Expand Down
25 changes: 25 additions & 0 deletions tests/lib/__snapshots__/scope-analysis.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5298,6 +5298,31 @@ Object {
}
`;

exports[`TypeScript scope analysis tests/fixtures/scope-analysis/type-alias.ts 1`] = `
Object {
"$id": 0,
"block": Object {
"range": Array [
0,
19,
],
"type": "Program",
},
"childScopes": Array [],
"functionExpressionScope": false,
"isStrict": false,
"references": Array [],
"throughReferences": Array [],
"type": "global",
"upperScope": null,
"variableMap": Object {},
"variableScope": Object {
"$ref": 0,
},
"variables": Array [],
}
`;

exports[`TypeScript scope analysis tests/fixtures/scope-analysis/type-annotations.ts 1`] = `
Object {
"$id": 7,
Expand Down
214 changes: 97 additions & 117 deletions tests/lib/__snapshots__/tsx.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -500,148 +500,128 @@ Object {
"type": "ImportDeclaration",
},
Object {
"declarations": Array [
Object {
"id": Object {
"loc": Object {
"end": Object {
"column": 10,
"line": 2,
},
"start": Object {
"column": 5,
"line": 2,
"id": Object {
"loc": Object {
"end": Object {
"column": 10,
"line": 2,
},
"start": Object {
"column": 5,
"line": 2,
},
},
"name": "Props",
"range": Array [
36,
41,
],
"type": "Identifier",
},
"loc": Object {
"end": Object {
"column": 1,
"line": 4,
},
"start": Object {
"column": 0,
"line": 2,
},
},
"range": Array [
31,
63,
],
"type": "TSTypeAliasDeclaration",
"typeAnnotation": Object {
"loc": Object {
"end": Object {
"column": 1,
"line": 4,
},
"start": Object {
"column": 13,
"line": 2,
},
},
"members": Array [
Object {
"computed": false,
"key": Object {
"loc": Object {
"end": Object {
"column": 7,
"line": 3,
},
"start": Object {
"column": 2,
"line": 3,
},
},
"name": "title",
"range": Array [
48,
53,
],
"type": "Identifier",
},
"name": "Props",
"range": Array [
36,
41,
],
"type": "Identifier",
},
"init": Object {
"loc": Object {
"end": Object {
"column": 1,
"line": 4,
"column": 15,
"line": 3,
},
"start": Object {
"column": 13,
"line": 2,
"column": 2,
"line": 3,
},
},
"members": Array [
Object {
"computed": false,
"key": Object {
"loc": Object {
"end": Object {
"column": 7,
"line": 3,
},
"start": Object {
"column": 2,
"line": 3,
},
},
"name": "title",
"range": Array [
48,
53,
],
"type": "Identifier",
"range": Array [
48,
61,
],
"type": "TSPropertySignature",
"typeAnnotation": Object {
"loc": Object {
"end": Object {
"column": 15,
"line": 3,
},
"start": Object {
"column": 7,
"line": 3,
},
},
"range": Array [
53,
61,
],
"type": "TSTypeAnnotation",
"typeAnnotation": Object {
"loc": Object {
"end": Object {
"column": 15,
"line": 3,
},
"start": Object {
"column": 2,
"column": 9,
"line": 3,
},
},
"range": Array [
48,
55,
61,
],
"type": "TSPropertySignature",
"typeAnnotation": Object {
"loc": Object {
"end": Object {
"column": 15,
"line": 3,
},
"start": Object {
"column": 7,
"line": 3,
},
},
"range": Array [
53,
61,
],
"type": "TSTypeAnnotation",
"typeAnnotation": Object {
"loc": Object {
"end": Object {
"column": 15,
"line": 3,
},
"start": Object {
"column": 9,
"line": 3,
},
},
"range": Array [
55,
61,
],
"type": "TSStringKeyword",
},
},
"type": "TSStringKeyword",
},
],
"range": Array [
44,
63,
],
"type": "TSTypeLiteral",
},
"loc": Object {
"end": Object {
"column": 1,
"line": 4,
},
"start": Object {
"column": 5,
"line": 2,
},
},
"range": Array [
36,
63,
],
"type": "VariableDeclarator",
},
],
"kind": "type",
"loc": Object {
"end": Object {
"column": 1,
"line": 4,
},
"start": Object {
"column": 0,
"line": 2,
},
],
"range": Array [
44,
63,
],
"type": "TSTypeLiteral",
},
"range": Array [
31,
63,
],
"type": "VariableDeclaration",
},
Object {
"declaration": Object {
Expand Down
Loading