Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/sxzz/typescript-go-playground. TypeScript Go Playground tsgo.sxzz.dev
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import * as monaco from 'monaco-editor'import editorWorker from 'monaco-editor/editor/editor.worker?worker'import jsonWorker from 'monaco-editor/language/json/json.worker?worker'import tsWorker from 'monaco-editor/language/typescript/ts.worker?worker'import { activeFile, files } from './composables/state'import { defineEditorThemes } from './composables/theme'
defineEditorThemes()
monaco.typescript.typescriptDefaults.setCompilerOptions({ target: monaco.typescript.ScriptTarget.ESNext, module: monaco.typescript.ModuleKind.ESNext, allowNonTsExtensions: true, allowImportingTsExtensions: true, moduleResolution: monaco.typescript.ModuleResolutionKind.NodeJs, noEmit: true, esModuleInterop: true, jsx: monaco.typescript.JsxEmit.Preserve, resolveJsonModule: true,})
monaco.json.jsonDefaults.setDiagnosticsOptions({ schemaValidation: 'warning', enableSchemaRequest: true, schemas: [ { fileMatch: ['tsconfig.json'], uri: 'https://www.schemastore.org/tsconfig.json', }, ],})
monaco.editor.registerEditorOpener({ openCodeEditor(_, resource) { if (resource.scheme !== 'file' || resource.path[0] !== '/') { return false } const path = resource.path.slice(1) if (!files.value.has(path)) { return false } activeFile.value = path return true },})
// eslint-disable-next-line unicorn/no-global-object-property-assignmentglobalThis.MonacoEnvironment = { getWorker(_: any, label: string) { if (label === 'json') { return new jsonWorker() } if (label === 'typescript' || label === 'javascript') { return new tsWorker() } return new editorWorker() },}