Skip to content

TypeScriptServer

Base classes

Name Children Inherits
LSPServerInfo
anyenv.lsp_servers._base
Static configuration for an LSP server.

⋔ Inheritance diagram

graph TD
  2799890["js_ts_lsps.TypeScriptServer"]
  514706066["_base.LSPServerInfo"]
  2751680898["builtins.object"]
  514706066 --> 2799890
  2751680898 --> 514706066

🛈 DocStrings

Bases: LSPServerInfo

TypeScript language server with tsserver path detection.

Source code in src/anyenv/lsp_servers/_servers/js_ts_lsps.py
@dataclass
class TypeScriptServer(LSPServerInfo):
    """TypeScript language server with tsserver path detection."""

    async def resolve_initialization(self, root: str, fs: AsyncFileSystem) -> dict[str, Any]:
        """Detect tsserver.js path."""
        init = await super().resolve_initialization(root, fs)
        tsserver = posixpath.join(root, "node_modules", "typescript", "lib", "tsserver.js")
        try:
            if await fs._exists(tsserver):  # noqa: SLF001
                init["tsserver"] = {"path": tsserver}
        except Exception:  # noqa: BLE001
            pass

        return init

resolve_initialization async

resolve_initialization(root: str, fs: AsyncFileSystem) -> dict[str, Any]

Detect tsserver.js path.

Source code in src/anyenv/lsp_servers/_servers/js_ts_lsps.py
async def resolve_initialization(self, root: str, fs: AsyncFileSystem) -> dict[str, Any]:
    """Detect tsserver.js path."""
    init = await super().resolve_initialization(root, fs)
    tsserver = posixpath.join(root, "node_modules", "typescript", "lib", "tsserver.js")
    try:
        if await fs._exists(tsserver):  # noqa: SLF001
            init["tsserver"] = {"path": tsserver}
    except Exception:  # noqa: BLE001
        pass

    return init

:fa-brands-github: Show source on GitHub