diff --git a/src/store.ts b/src/store.ts index 2508b679..6fdaebe2 100644 --- a/src/store.ts +++ b/src/store.ts @@ -10,7 +10,7 @@ import { } from 'vue' import * as defaultCompiler from 'vue/compiler-sfc' import { compileFile } from './transform' -import { atou, utoa } from './utils' +import { atou, hasScriptLangChanged, utoa } from './utils' import type { SFCAsyncStyleCompileOptions, SFCScriptCompileOptions, @@ -68,6 +68,18 @@ export function useStore( compileFile(store, activeFile.value).then((errs) => (errors.value = errs)) }) + // Temporary workaround for https://github.com/vuejs/repl/issues/321 + // which is related to https://github.com/microsoft/TypeScript/issues/57631 + // TODO: remove this when the issue is fixed + watch( + () => activeFile.value.code, + (newCode, oldCode) => { + if (activeFile.value.language !== 'vue') return + if (hasScriptLangChanged(newCode, oldCode)) + reloadLanguageTools.value?.() + }, + ) + watch( () => [ files.value[tsconfigFile]?.code, diff --git a/src/utils.ts b/src/utils.ts index 3b453ca1..801176cb 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -31,3 +31,13 @@ export function atou(base64: string): string { // https://base64.guru/developers/javascript/examples/unicode-strings return decodeURIComponent(escape(binary)) } + +// compares the `lang` attribute of the `