svelte-language-server
Version:
A language server for Svelte
85 lines (84 loc) • 2.55 kB
TypeScript
import ts from 'typescript';
import { Diagnostic } from 'vscode-languageserver';
export declare function mapSvelteCheckDiagnostics(sourcePath: string, sourceText: string, tsDiagnostics: ts.Diagnostic[], options?: {
rewriteExternalImports?: {
workspacePath: string;
generatedPath: string;
};
}): Diagnostic[];
export type SvelteCheckDiagnosticSource = 'js' | 'css' | 'svelte';
export interface SvelteCheckOptions {
compilerWarnings?: Record<string, 'ignore' | 'error'>;
diagnosticSources?: SvelteCheckDiagnosticSource[];
/**
* Path has to be absolute
*/
tsconfig?: string;
/**
* Path to a svelte.config or vite.config file. Path has to be absolute.
*/
configPath?: string;
onProjectReload?: () => void;
watch?: boolean;
/**
* Optional callback invoked when a new snapshot is created.
* Provides the absolute file path of the snapshot.
*/
onFileSnapshotCreated?: (filePath: string) => void;
experimental?: {
tsgo: {
apiModule: unknown;
astModule: unknown;
};
};
}
/**
* Small wrapper around PluginHost's Diagnostic Capabilities
* for svelte-check, without the overhead of the lsp.
*/
export declare class SvelteCheck {
private options;
private docManager;
private configManager;
private pluginHost;
private lsAndTSDocResolver?;
private tsGoDiagnosticsProvider?;
constructor(workspacePath: string, options?: SvelteCheckOptions);
private initialize;
/**
* Creates/updates given document
*
* @param doc Text and Uri of the document
* @param isNew Whether or not this is the creation of the document
*/
upsertDocument(doc: {
text: string;
uri: string;
}, isNew: boolean): Promise<void>;
/**
* Removes/closes document
*
* @param uri Uri of the document
*/
removeDocument(uri: string): Promise<void>;
/**
* Gets the diagnostics for all currently open files.
*/
getDiagnostics(): Promise<Array<{
filePath: string;
text: string;
diagnostics: Diagnostic[];
}>>;
private getDiagnosticsForTsconfig;
private getDiagnosticsForTsconfigTsGo;
private getDiagnosticsForFile;
private getLSContainer;
/**
* Gets the watch directories based on the tsconfig include patterns.
* Returns null if no tsconfig is specified.
*/
getWatchDirectories(): Promise<{
path: string;
recursive: boolean;
}[] | null>;
}