@singapore-editor/typescript-lsp
v0.2.18
Published
TypeScript and JavaScript language services in a browser worker for the Singapore editor.
Maintainers
Readme
@singapore-editor/typescript-lsp
TypeScript and JavaScript language services in a browser worker for the Singapore editor.
Part of Singapore. A code editor for the browser that keeps every version.
Install
npm install @singapore-editor/core @singapore-editor/typescript-lspUsage
import { Editor } from '@singapore-editor/core/editor'
import { createTypeScriptLspPlugin } from '@singapore-editor/typescript-lsp'
const host = document.createElement('div')
host.style.height = '400px'
document.body.append(host)
const typescript = createTypeScriptLspPlugin()
const editor = new Editor(host, {
plugins: [typescript],
})
typescript.setWorkspaceFiles([
{ path: '/src/math.ts', text: 'export const add = (a: number, b: number) => a + b\n' },
])
editor.openDocument({
documentId: '/src/main.ts',
text: "import { add } from './math'\n\nadd(1, '2')\n",
languageId: 'typescript',
})API highlights
createTypeScriptLspPlugin()connects the worker language service.setWorkspaceFiles()supplies imported files.upsertWorkspaceFiles()updates those files.
In the Singapore family
@singapore-editor/core owns the editor view. Add this plugin for TypeScript and JavaScript language features.
Use a bundler that serves the package worker and data assets. See the hosting guide.
Singapore README · Documentation
License
MIT. License
