New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

typescript-language-server

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-language-server - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

28

lib/server.js

@@ -22,3 +22,5 @@ "use strict";

this.connection.onDidChangeTextDocument(this.onDidChangeTextDocument.bind(this));
this.connection.onDefinition(this.onDefinition.bind(this));
this.connection.onCompletion(this.onCompletion.bind(this));
this.connection.onReferences(this.onReferences.bind(this));
}

@@ -45,3 +47,5 @@ listen() {

resolveProvider: false
}
},
definitionProvider: true,
referencesProvider: true
}

@@ -74,2 +78,11 @@ };

}
onDefinition(params) {
const path = utils.uriToPath(params.textDocument.uri);
this.logger.info('Server.onDefinition()', params, path);
return this.tsServerClient.sendDefinition(path, params.position.line + 1, params.position.character + 1)
.then(result => {
return result.body
.map(fileSpan => utils.tsServerFileSpanToLspLocation(fileSpan));
});
}
onCompletion(params) {

@@ -79,6 +92,6 @@ const path = utils.uriToPath(params.textDocument.uri);

return this.tsServerClient.sendCompletions(path, params.position.line + 1, params.position.character + 1, '')
.then(completions => {
.then(result => {
return {
isIncomplete: false,
items: completions.body
items: result.body
.map(item => {

@@ -93,3 +106,12 @@ return {

}
onReferences(params) {
const path = utils.uriToPath(params.textDocument.uri);
this.logger.info('Server.onReferences()', params, path);
return this.tsServerClient.sendReferences(path, params.position.line + 1, params.position.character + 1)
.then(result => {
return result.body.refs
.map(fileSpan => utils.tsServerFileSpanToLspLocation(fileSpan));
});
}
}
exports.Server = Server;

@@ -129,2 +129,7 @@ "use strict";

}
sendDefinition(file, line, offset) {
const args = { file, line, offset };
this.logger.info('TsServerClient.sendDefinition()', args);
return this.sendRequest('definition', false, args);
}
sendCompletions(file, line, offset, prefix) {

@@ -135,3 +140,8 @@ const args = { file, line, offset, prefix };

}
sendReferences(file, line, offset) {
const args = { file, line, offset };
this.logger.info('TsServerClient.sendReferences()', args);
return this.sendRequest('references', false, args);
}
}
exports.TsServerClient = TsServerClient;

@@ -11,5 +11,25 @@ "use strict";

const p = path.resolve(uri.replace(/file:\/\/\//, ''));
return isWindows() ? p.replace(/\//g, "\\") : p;
return isWindows() ? p.replace(/\//g, '\\') : p;
}
exports.uriToPath = uriToPath;
function pathToUri(p) {
return 'file://' + (isWindows() ? '/' + p.replace(/\//g, '/') : p);
}
exports.pathToUri = pathToUri;
function tsServerFileSpanToLspLocation(fileSpan) {
return {
uri: pathToUri(fileSpan.file),
range: {
start: {
line: fileSpan.start.line - 1,
character: fileSpan.start.offset - 1
},
end: {
line: fileSpan.end.line - 1,
character: fileSpan.end.offset - 1
}
}
};
}
exports.tsServerFileSpanToLspLocation = tsServerFileSpanToLspLocation;
exports.completionKindsMapping = {

@@ -16,0 +36,0 @@ class: vscode_languageserver_1.CompletionItemKind.Class,

2

package.json
{
"name": "typescript-language-server",
"version": "0.0.7",
"version": "0.0.8",
"description": "Language Server Protocol (LSP) implementation for TypeScript using tsserver",

@@ -5,0 +5,0 @@ "scripts": {

# typescript-language-server
Language Server Protocol implementation for Typescript via tsserver.cmd
Language Server Protocol implementation for Typescript via tsserver.cmd :warning: WIP :warning:
WIP
[![https://nodei.co/npm/typescript-language-server.png?downloads=true&downloadRank=true&stars=true](https://nodei.co/npm/typescript-language-server.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/typescript-language-server)

@@ -10,3 +10,36 @@ # Installing

npm install -g typescript-language-server
```
# Running the language server
```
typescript-language-server --stdio
```
```
**Note:** `typescript-language-server` requires `tsserver` to be in path. You can install it using `npm install -g typescript`.
# Supported Protocol features
* textDocument/completion
* textDocument/definition
* textDocument/didChange
* textDocument/didClose
* textDocument/didOpen
* textDocument/didSave
* textDocument/references
# Development
### Build
```sh
npm install
npm run build
```
### Watch
```sh
npm install
npm run watch
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc