disable typescript validation

This commit is contained in:
Luck
2022-01-08 22:59:01 +00:00
parent 65be041f77
commit b4690bf89d

View File

@@ -16,12 +16,23 @@ export default function EditorTextArea({
const [monaco, setMonaco] = useState(); const [monaco, setMonaco] = useState();
const [selected, toggleSelected] = useSelectedLine(); const [selected, toggleSelected] = useSelectedLine();
const editorAreaRef = useRef(); const editorAreaRef = useRef();
useLineNumberMagic(editorAreaRef, selected, toggleSelected, forcedContent, editor, monaco); useLineNumberMagic(
editorAreaRef,
selected,
toggleSelected,
forcedContent,
editor,
monaco
);
usePlaceholderText(actualContent, editor, monaco); usePlaceholderText(actualContent, editor, monaco);
function beforeMount(monaco) { function beforeMount(monaco) {
for (const [id, theme] of Object.entries(themes)) { for (const [id, theme] of Object.entries(themes)) {
monaco.editor.defineTheme(id, makeMonacoTheme(theme)); monaco.editor.defineTheme(id, makeMonacoTheme(theme));
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
noSyntaxValidation: true,
});
} }
} }
@@ -51,6 +62,7 @@ export default function EditorTextArea({
renderLineHighlight: 'none', renderLineHighlight: 'none',
detectIndentation: true, detectIndentation: true,
tabSize: 2, tabSize: 2,
renderValidationDecorations: false,
}} }}
beforeMount={beforeMount} beforeMount={beforeMount}
onMount={onMount} onMount={onMount}
@@ -142,13 +154,15 @@ function useLineNumberMagic(
} }
// apply a decoration // apply a decoration
const newDecorations = [{ const newDecorations = [
{
range: new monaco.Range(selected[0], 1, selected[1], 1), range: new monaco.Range(selected[0], 1, selected[1], 1),
options: { options: {
isWholeLine: true, isWholeLine: true,
linesDecorationsClassName: 'highlighted-line', linesDecorationsClassName: 'highlighted-line',
}, },
}]; },
];
const decorations = editor.deltaDecorations([], newDecorations); const decorations = editor.deltaDecorations([], newDecorations);
// scroll the selected line into view // scroll the selected line into view