From 92bf23df995f99b7f52f8f9a33f0b73c49648962 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sun, 27 Feb 2022 13:35:47 +0100 Subject: [PATCH] Use async functions in .svelte files (#1693) * Use async functions in CodeMirror.svelte * Fix using async functions by modifying svelte-preprocess output * Revert "Fix using async functions by modifying svelte-preprocess output" This reverts commit 94c9cadaaa3ca2084780833e9efc7807f2f1d1a9. Trying a different fix. * Change TypeScript target to ES2019 --- ts/editor/CodeMirror.svelte | 22 +++++++++++----------- ts/tsconfig.json | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ts/editor/CodeMirror.svelte b/ts/editor/CodeMirror.svelte index 755365544..204d22161 100644 --- a/ts/editor/CodeMirror.svelte +++ b/ts/editor/CodeMirror.svelte @@ -40,11 +40,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /** * Convenience function for editor.setOption. */ - function setOption( + async function setOption( key: T, value: CodeMirrorLib.EditorConfiguration[T], - ): void { - editorPromise.then((editor) => editor.setOption(key, value)); + ): Promise { + const editor = await editorPromise; + editor.setOption(key, value); } const direction = getContext>(directionKey); @@ -62,14 +63,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const dispatch = createEventDispatcher(); - onMount(() => - editorPromise.then((editor) => { - setupCodeMirror(editor, code); - editor.on("change", () => dispatch("change", editor.getValue())); - editor.on("focus", () => dispatch("focus")); - editor.on("blur", () => dispatch("blur")); - }), - ); + onMount(async () => { + const editor = await editorPromise; + setupCodeMirror(editor, code); + editor.on("change", () => dispatch("change", editor.getValue())); + editor.on("focus", () => dispatch("focus")); + editor.on("blur", () => dispatch("blur")); + });
diff --git a/ts/tsconfig.json b/ts/tsconfig.json index b8e917aea..42a371ec7 100644 --- a/ts/tsconfig.json +++ b/ts/tsconfig.json @@ -17,7 +17,7 @@ "compilerOptions": { "declaration": true, "composite": true, - "target": "es6", + "target": "es2019", "module": "es2020", "lib": [ "es2017",