UNPKG

vite-esbuild-typescript-checker

Version:

* Speeds up [TypeScript](https://github.com/Microsoft/TypeScript) type checking * Supports [Vue Single File Component](https://vuejs.org/v2/guide/single-file-components.html) * Displays nice error messages with the [code frame](https://babeljs.io/docs/en/

60 lines (59 loc) 2.41 kB
import ts from 'typescript'; import { createWatchCompilerHost } from './watch-compiler-host.js'; import { getSystem } from '../system.js'; import { getVueExtension } from '../vue/type-script-vue-extension.js'; export function createWatchSolutionBuilderHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, reportSolutionBuilderStatus, afterProgramCreate, afterProgramEmitAndDiagnostics) { const system = getSystem(); const typescriptVueExtension = getVueExtension(); const controlledWatchCompilerHost = createWatchCompilerHost(parsedConfig, createProgram, reportDiagnostic, reportWatchStatus, afterProgramCreate); let controlledWatchSolutionBuilderHost = { ...controlledWatchCompilerHost, reportDiagnostic (diagnostic) { if (reportDiagnostic) { reportDiagnostic(diagnostic); } }, reportSolutionBuilderStatus (diagnostic) { if (reportSolutionBuilderStatus) { reportSolutionBuilderStatus(diagnostic); } }, afterProgramEmitAndDiagnostics (program) { if (afterProgramEmitAndDiagnostics) { afterProgramEmitAndDiagnostics(program); } }, createDirectory (path) { system.createDirectory(path); }, writeFile (path, data) { system.writeFile(path, data); }, getModifiedTime (fileName) { return system.getModifiedTime(fileName); }, setModifiedTime (fileName, date) { system.setModifiedTime(fileName, date); }, deleteFile (fileName) { system.deleteFile(fileName); }, getParsedCommandLine (fileName) { return ts.getParsedCommandLineOfConfigFile(fileName, { skipLibCheck: true }, { ...system, onUnRecoverableConfigFileDiagnostic: (diagnostic)=>{ if (reportDiagnostic) { reportDiagnostic(diagnostic); } } }); } }; // controlledWatchSolutionBuilderHost = typescriptVueExtension.extendWatchSolutionBuilderHost< // TProgram, // ts.SolutionBuilderWithWatchHost<TProgram> // >(controlledWatchSolutionBuilderHost, parsedConfig); return controlledWatchSolutionBuilderHost; }