diff --git a/src/controller.js b/src/controller.js index ff02a10..98f400d 100644 --- a/src/controller.js +++ b/src/controller.js @@ -37,6 +37,10 @@ let withCompilerOptions = (callback) => { }) } +let typeCheckOnSave = () => { + withCompilerOptions(commands.typecheckFile) +} + let runCommand = (command) => { return (_) => { withCompilerOptions(command) @@ -47,5 +51,6 @@ module.exports = { getCommands, destroy: commands.destroy, diagnosticCollection: commands.diagnosticCollection, - withCompilerOptions: withCompilerOptions + withCompilerOptions: withCompilerOptions, + typeCheckOnSave: typeCheckOnSave } diff --git a/src/extension.js b/src/extension.js index aaebbe0..ec3df0e 100644 --- a/src/extension.js +++ b/src/extension.js @@ -19,6 +19,10 @@ function activate(context) { } }) + vscode.workspace.onDidSaveTextDocument((event) => { + controller.typeCheckOnSave() + }) + context.subscriptions.push(controller.diagnosticCollection) controller.getCommands().forEach(([key, value]) => { let disposable = vscode.commands.registerCommand(key, value)