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

Missing static from TSParameterProperty #286

Closed
vjeux opened this issue May 23, 2017 · 3 comments
Closed

Missing static from TSParameterProperty #286

vjeux opened this issue May 23, 2017 · 3 comments
Assignees
Labels

Comments

@vjeux
Copy link

vjeux commented May 23, 2017

What version of typescript-eslint-parser are you using?
b7220fd

What code were you trying to parse?

// ../TypeScript/tests/cases/compiler/constructorArgsErrors1.ts
class foo {
  constructor(static a: number) {}
}

What did you expect to happen?
Have static: true inside of TSParameterProperty

What happened?

Doesn't have it

{
  "type": "TSParameterProperty",
  "range": [
    30,
    46
  ],
  "loc": {
    "start": {
      "line": 2,
      "column": 17
    },
    "end": {
      "line": 2,
      "column": 33
    }
  },
  "accessibility": null,
  "isReadonly": false,
  "parameter": {
    "type": "Identifier",
    "range": [
      37,
      38
    ],
    "loc": {
      "start": {
        "line": 2,
        "column": 24
      },
      "end": {
        "line": 2,
        "column": 25
      }
    },
    "name": "a",
    "typeAnnotation": {
      "type": "TypeAnnotation",
      "loc": {
        "start": {
          "line": 2,
          "column": 27
        },
        "end": {
          "line": 2,
          "column": 33
        }
      },
      "range": [
        40,
        46
      ],
      "typeAnnotation": {
        "type": "TSNumberKeyword",
        "range": [
          40,
          46
        ],
        "loc": {
          "start": {
            "line": 2,
            "column": 27
          },
          "end": {
            "line": 2,
            "column": 33
          }
        }
      }
    }
  },
  "decorators": []
}
@vjeux
Copy link
Author

vjeux commented May 23, 2017

Actually, i'm not really sure what's going on here. The ast difference is:

../TypeScript/tests/cases/compiler/constructorArgsErrors1.ts
: ast(input) !== ast(prettier(input))
Index:
===================================================================
---
+++
@@ -18,15 +18,10 @@
               "params": [
                 {
-                  "type": "TSParameterProperty",
-                  "accessibility": null,
-                  "isReadonly": false,
-                  "parameter": {
-                    "type": "Identifier",
-                    "name": "a",
+                  "type": "Identifier",
+                  "name": "a",
+                  "typeAnnotation": {
+                    "type": "TypeAnnotation",
                     "typeAnnotation": {
-                      "type": "TypeAnnotation",
-                      "typeAnnotation": {
-                        "type": "TSNumberKeyword"
-                      }
+                      "type": "TSNumberKeyword"
                     }
                   },

I don't think that it's actually valid to have static there.

@soda0289
Copy link
Member

Good catch thanks. Should be a simple fix, just need to check for static modifier.

Typescript does complain: 'static' modifier cannot appear on a parameter. But I think we should still generate a matching AST. We do something similar for abstract interface even thou it is invalid as well.

@vjeux
Copy link
Author

vjeux commented May 23, 2017

constructor (export a: number) {

has the same issue fyi.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants