From ac0447d500e480e573a767d3362b79716b3d1492 Mon Sep 17 00:00:00 2001 From: Deniz Kusefoglu Date: Thu, 13 Feb 2020 16:30:27 -0800 Subject: [PATCH] feat(lsp): Add monaco to window type --- ui/global.d.ts | 8 ++++++++ .../components/TimeMachineFluxEditor.tsx | 16 +++++++++++++--- ui/tsconfig.json | 3 ++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ui/global.d.ts b/ui/global.d.ts index 555580a7c7e..f4389d8aa25 100644 --- a/ui/global.d.ts +++ b/ui/global.d.ts @@ -6,3 +6,11 @@ import {MonacoType} from 'src/types' declare module '*.png' declare let monaco: MonacoType + +declare global { + interface Window { + monaco: MonacoType + } +} + +window.monaco = window.monaco || {} diff --git a/ui/src/timeMachine/components/TimeMachineFluxEditor.tsx b/ui/src/timeMachine/components/TimeMachineFluxEditor.tsx index cb834bd124b..31e79d5b89a 100644 --- a/ui/src/timeMachine/components/TimeMachineFluxEditor.tsx +++ b/ui/src/timeMachine/components/TimeMachineFluxEditor.tsx @@ -59,7 +59,12 @@ const TimeMachineFluxEditor: FC = ({ const p = editorInstance.getPosition() editorInstance.executeEdits('', [ { - range: new monaco.Range(p.lineNumber, p.column, p.lineNumber, p.column), + range: new window.monaco.Range( + p.lineNumber, + p.column, + p.lineNumber, + p.column + ), text: `v.${variableName}`, }, ]) @@ -70,7 +75,12 @@ const TimeMachineFluxEditor: FC = ({ const p = editorInstance.getPosition() const edits = [ { - range: new monaco.Range(p.lineNumber, p.column, p.lineNumber, p.column), + range: new window.monaco.Range( + p.lineNumber, + p.column, + p.lineNumber, + p.column + ), text: formatFunctionForInsert(func.name, func.example), }, ] @@ -80,7 +90,7 @@ const TimeMachineFluxEditor: FC = ({ ) if (importStatement) { edits.unshift({ - range: new monaco.Range(1, 1, 1, 1), + range: new window.monaco.Range(1, 1, 1, 1), text: `${importStatement}\n`, }) } diff --git a/ui/tsconfig.json b/ui/tsconfig.json index 6635aeca431..3d4392f09b0 100644 --- a/ui/tsconfig.json +++ b/ui/tsconfig.json @@ -40,5 +40,6 @@ "src/**/*.test.tsx", "src/**/mocks.ts", "coverage" - ] + ], + "include": ["global.d.ts"] }