{"id":16222450,"url":"https://github.com/shiyangzhaoa/tsserver","last_synced_at":"2025-04-08T01:39:59.754Z","repository":{"id":65177739,"uuid":"539270165","full_name":"shiyangzhaoa/tsserver","owner":"shiyangzhaoa","description":"A lite wrapper around tsserver","archived":false,"fork":false,"pushed_at":"2023-12-14T06:22:47.000Z","size":77,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T03:19:34.528Z","etag":null,"topics":["tsserver","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shiyangzhaoa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-21T02:21:06.000Z","updated_at":"2023-01-06T06:56:04.000Z","dependencies_parsed_at":"2024-11-03T23:41:30.097Z","dependency_job_id":null,"html_url":"https://github.com/shiyangzhaoa/tsserver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiyangzhaoa%2Ftsserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiyangzhaoa%2Ftsserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiyangzhaoa%2Ftsserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiyangzhaoa%2Ftsserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shiyangzhaoa","download_url":"https://codeload.github.com/shiyangzhaoa/tsserver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247761051,"owners_count":20991533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["tsserver","typescript"],"created_at":"2024-10-10T12:14:12.811Z","updated_at":"2025-04-08T01:39:59.734Z","avatar_url":"https://github.com/shiyangzhaoa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TSServer wrapper\n\nA lite wrapper around tsserver\n\n\u003cp\u003e\n  \u003cimg src=\"https://github.com/shiyangzhaoa/tsserver/blob/main/typescript.svg\" alt=\"tsserver\"\u003e\n\u003c/p\u003e\n\u003cp\u003e\n    \u003ca href=\"https://www.npmjs.com/package/tsserver-lite\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/tsserver-lite?style=flat-square\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/tsserver-lite\"\u003e\u003cimg src=\"https://img.shields.io/bundlephobia/minzip/tsserver-lite?style=flat-square\" alt=\"Latest Release\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/shiyangzhaoa/tsserver/blob/main/LICENSE\"\u003e\u003cimg src=\"https://shields.io/github/license/shiyangzhaoa/tsserver?style=flat-square\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Install\n\n```shell\nyarn add tsserver-lite\n```\n\n## Example\n\nFor example, your project structure:\n\n```shell\n├── src\n│  └── test.ts\n└──── xxx\n```\n\n```ts\n// src/test.ts\nexport const number = 123;\nexport const string = 'abc';\n```\n\nHow to use:\n```mjs\n// index.mjs\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport { fileURLToPath } from 'node:url';\n\nimport { client } from 'tsserver-lite';\n\nconst updateTSFile = async (info) =\u003e {\n  const fileInfo = Object.assign(\n    {\n      changedFiles: [],\n      closedFiles: [],\n      openFiles: [],\n    },\n    info,\n  );\n\n  await client.execute('updateOpen', fileInfo);\n};\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst filePath = path.resolve(__dirname, './test.ts');\n\nconst main = async () =\u003e {\n  client.startService();\n\n  const openFile = {\n    file: filePath,\n    fileContent: fs.readFileSync(filePath, 'utf-8'),\n    projectRootPath: path.resolve(__dirname, '../'),\n    scriptKindName: 'ts',\n  };\n\n  try {\n    await updateTSFile({\n      openFiles: [openFile]\n    });\n\n    const result = await client.execute(\n      'quickinfo',\n      {\n        file: filePath,\n        line: 1,\n        offset: 15,\n      },\n    );\n    if (result.type === 'response') {\n      console.log('result---', result);\n    }\n  } catch (err) {\n    console.log(`tsserver error: ${err.message}`);\n  }\n\n  client.closeService();\n};\n\nmain().catch(err =\u003e {\n  console.error(err);\n  process.exit(1);\n});\n```\n\nTry run script:\n\n```shell\nnode index.mjs\n```\n\nYou will see these logs:\n\n```ts\nresult: {\n  seq: 0,\n  type: 'response',\n  command: 'quickinfo',\n  request_seq: 3,\n  success: true,\n  body: {\n    kind: 'const',\n    kindModifiers: 'export',\n    start: { line: 1, offset: 14 },\n    end: { line: 1, offset: 20 },\n    displayString: 'const number: 123',\n    documentation: '',\n    tags: []\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiyangzhaoa%2Ftsserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshiyangzhaoa%2Ftsserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiyangzhaoa%2Ftsserver/lists"}