eslint / typescript-eslint-parser

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.
Other
915 stars 92 forks source link

`decorators` is missing in TSInterfaceDeclaration #478

Closed ikatyang closed 6 years ago

ikatyang commented 6 years ago

Context: prettier/prettier#4552

What version of TypeScript are you using? 2.9.0-rc

What version of typescript-eslint-parser are you using? 2960b002746c01fb9cb15bb5f4c1e7e925c6519a (typescript-eslint-parser#ts-2.9)

What code were you trying to parse?

@decorator()
interface X {}

What did you expect to happen?

{
  "type": "TSInterfaceDeclaration",
  "abstract": false,
  "body": {
    "type": "TSInterfaceBody",
    "body": []
  },
  "decorators": [
    {
      "type": "Decorator",
      "expression": {
      "type": "CallExpression",
      "callee": {
        "type": "Identifier",
        "name": "decorator"
      },
      "arguments": []
      }
    }
  ],
  "id": {
    "type": "Identifier",
    "name": "X"
  },
  "heritage": []
}

What happened?

 {
   "type": "TSInterfaceDeclaration",
   "abstract": false,
   "body": {
     "type": "TSInterfaceBody",
     "body": []
   },
-  "decorators": [
-    {
-      "type": "Decorator",
-      "expression": {
-      "type": "CallExpression",
-      "callee": {
-        "type": "Identifier",
-        "name": "decorator"
-      },
-      "arguments": []
-      }
-    }
-  ],
   "id": {
     "type": "Identifier",
     "name": "X"
   },
   "heritage": []
 }
j-f1 commented 6 years ago

For reference, here’s an ASTExplorer page with that code snippet as parsed by TypeScript.