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

Unnecessary TypeReference wrapper for ImportType in TypeReference's typeParameters #507

Closed
ikatyang opened this issue Aug 4, 2018 · 0 comments
Labels

Comments

@ikatyang
Copy link
Contributor

ikatyang commented Aug 4, 2018

What version of TypeScript are you using?
3.0.1

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

What code were you trying to parse?

type X = A<import("").B<any>>;

What did you expect to happen?

{
  "type": "Program",
  "body": [
    {
      "type": "VariableDeclaration",
      "kind": "type",
      "declarations": [
        {
          "type": "VariableDeclarator",
          "id": { "type": "Identifier", "name": "X" },
          "init": {
            "type": "TSTypeReference",
            "typeName": { "type": "Identifier", "name": "A" },
            "typeParameters": {
              "type": "TSTypeParameterInstantiation",
              "params": [
                {
                  "type": "TSImportType",
                  "argument": {
                    "type": "TSLiteralType",
                    "literal": {
                      "type": "Literal",
                      "raw": "\"\"",
                      "value": ""
                    }
                  },
                  "qualifier": { "type": "Identifier", "name": "B" },
                  "typeParameters": {
                    "type": "TSTypeParameterInstantiation",
                    "params": [{ "type": "TSAnyKeyword" }]
                  }
                }
              ]
            }
          }
        }
      ]
    }
  ],
  "sourceType": "script"
}

What happened?

 {
   "type": "Program",
   "body": [
     {
       "type": "VariableDeclaration",
       "kind": "type",
       "declarations": [
         {
           "type": "VariableDeclarator",
           "id": { "type": "Identifier", "name": "X" },
           "init": {
             "type": "TSTypeReference",
             "typeName": { "type": "Identifier", "name": "A" },
             "typeParameters": {
               "type": "TSTypeParameterInstantiation",
               "params": [
                 {
+                  "type": "TSTypeReference",
+                  "typeName": {
-                    "type": "TSImportType",
+                    "type": "TSLastTypeNode",
                     "argument": {
                       "type": "TSLiteralType",
                       "literal": {
                         "type": "Literal",
                         "raw": "\"\"",
                         "value": ""
                       }
                     },
                     "qualifier": { "type": "Identifier", "name": "B" },
                     "typeParameters": {
                       "type": "TSTypeParameterInstantiation",
                       "params": [{ "type": "TSAnyKeyword" }]
                     }
+                  },
+                  "typeParameters": {
+                    "type": "TSTypeParameterInstantiation",
+                    "params": [{ "type": "TSAnyKeyword" }]
+                  }
                 }
               ]
             }
           }
         }
       ]
     }
   ],
   "sourceType": "script"
 }

Original post: prettier/prettier#4938

@ikatyang ikatyang changed the title Duplicate typeParameters in TypeReference's generic caused by ImportType Unnecessary TypeReference wrapper for ImportType in TypeReference's typeParameters Aug 5, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant