Skip to content
This repository has been archived by the owner on Jun 26, 2022. It is now read-only.

A client implementation for tsserver for TypeScript

License

Notifications You must be signed in to change notification settings

appetizermonster/tslang-client

Repository files navigation

tslang-client · Travis (.org) branch

A client implementation for tsserver for TypeScript. Currently, it's just working but not completely tested.

You can see the details about tsserver in the TypeScript wiki

Rationale

TypeScript provides a powerful Type System. So I was trying to leverage the Type System to make good tooling environment for TypeScript based projects. and I found some facts:

  • TypeScript provides full-featured Compiler API but slow and complicated.
  • ts-simple-ast provides well-designed wrapper API around the Compiler API but slow for my needs.
  • tsserver is fast but there is no library for communication with tsserver.

So I made this.

Requirements

  • TypeScript 2.8 or above

Installation

npm install --save-dev tslang-client

Usage

import { TsLangClient } from 'tslang-client';

// Create a client instance
const client = new TsLangClient();

// Connect to installed tsserver
await client.connect();

// Call open(file) api
await client.api.open({ file: 'filename.ts' });

// Close the connection
client.close();

Import with CommonJS

tslang-client supports CommonJS-style module along with the ES2015-style.

const { TsLangClient } = require('tslang-client');

EOF

About

A client implementation for tsserver for TypeScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published