Import Sort Parser for TypeScript

6.0.0 · maintenance · verified Sun Apr 19

import-sort-parser-typescript is a specialized parser module designed for the import-sort ecosystem, specifically to handle TypeScript and TSX files. It leverages the native TypeScript compiler for syntax parsing, enabling import sorting based on the TypeScript language rules. As a component, it is typically used in conjunction with `import-sort`, `import-sort-config`, and a chosen sorting style. The package is currently at version 6.0.0, but was last published approximately 7 years ago, suggesting a maintenance or possibly abandoned status rather than active development. Its primary differentiation lies in using the TypeScript parser directly, which historically provided accurate parsing for TypeScript-specific constructs, but its age raises concerns about compatibility with recent TypeScript versions and features. Release cadence is effectively halted given its last update.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to integrate `import-sort-parser-typescript` into a project's `package.json` for automatic import sorting with the `import-sort` CLI tool. It sets up the necessary dependencies and configures `import-sort` to use the 'typescript' parser for .ts and .tsx files.

{
  "name": "my-project",
  "version": "1.0.0",
  "description": "Example project using import-sort with TypeScript",
  "main": "index.js",
  "scripts": {
    "sort-imports": "import-sort -l"
  },
  "devDependencies": {
    "import-sort": "^5.0.0",
    "import-sort-cli": "^6.0.0",
    "import-sort-config": "^6.0.0",
    "import-sort-parser-typescript": "^6.0.0",
    "import-sort-style-renke": "^6.0.0",
    "typescript": "^4.0.0" 
  },
  "importSort": {
    "\.ts$": {
      "parser": "typescript",
      "style": "renke"
    },
    "\.tsx?$": {
      "parser": "typescript",
      "style": "renke"
    }
  }
}

// To use this, save the above as package.json, then run:
// npm install
// npm run sort-imports

view raw JSON →