kungfooman / RuntimeTypeInspector.js

Checking JSDoc types at runtime for high-quality types - Trust is good, control is better.
MIT License
8 stars 0 forks source link

Fix output of mixed `ImportDefaultSpecifier` / `ImportSpecifier` #191

Open kungfooman opened 1 month ago

kungfooman commented 1 month ago

Example input:

import React, { useState, useEffect, useRef } from 'react';

Current wrong output:

import React, useState, useEffect, useRef from 'react';

AST:

{
  "type": "File",
  "errors": [],
  "program": {
    "type": "Program",
    "sourceType": "module",
    "interpreter": null,
    "body": [
      {
        "type": "ImportDeclaration",
        "specifiers": [
          {
            "type": "ImportDefaultSpecifier",
            "local": {
              "type": "Identifier",
              "name": "React"
            }
          },
          {
            "type": "ImportSpecifier",
            "imported": {
              "type": "Identifier",
              "name": "useState"
            },
            "local": {
              "type": "Identifier",
              "name": "useState"
            }
          },
          {
            "type": "ImportSpecifier",
            "imported": {
              "type": "Identifier",
              "name": "useEffect"
            },
            "local": {
              "type": "Identifier",
              "name": "useEffect"
            }
          },
          {
            "type": "ImportSpecifier",
            "imported": {
              "type": "Identifier",
              "name": "useRef"
            },
            "local": {
              "type": "Identifier",
              "name": "useRef"
            }
          }
        ],
        "source": {
          "type": "StringLiteral",
          "extra": {
            "rawValue": "react",
            "raw": "'react'"
          },
          "value": "react"
        }
      }
    ],
    "directives": []
  },
  "comments": []
}