Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(website): pass user defined compilerOptions to linter#5080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 3 commits intomainfromfix/playground-compiler-options-sync
May 26, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletionspackages/website/src/components/editor/LoadedEditor.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import type { WebLinter } from '../linter/WebLinter';
import { debounce } from '../lib/debounce';
import { lintCode, LintCodeAction } from '../linter/lintCode';
import { createProvideCodeActions } from './createProvideCodeActions';
import { createCompilerOptions } from '@site/src/components/editor/config';
import { parseMarkers } from '../linter/utils';

export interface LoadedEditorProps extends CommonEditorProps {
Expand DownExpand Up@@ -39,13 +40,7 @@ export const LoadedEditor: React.FC<LoadedEditorProps> = ({
const fixes = useRef(new Map<string, LintCodeAction[]>()).current;

useEffect(() => {
const config = {
noResolve: true,
target: main.languages.typescript.ScriptTarget.ESNext,
module: main.languages.typescript.ModuleKind.ESNext,
...tsConfig,
jsx: jsx ? main.languages.typescript.JsxEmit.React : undefined,
};
const config = createCompilerOptions(jsx, tsConfig);

webLinter.updateOptions(config);
sandboxInstance.setCompilerSettings(config);
Expand Down
16 changes: 16 additions & 0 deletionspackages/website/src/components/editor/config.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
import type Monaco from 'monaco-editor';

export function createCompilerOptions(
jsx = false,
tsConfig: Record<string, unknown> = {},
): Monaco.languages.typescript.CompilerOptions {
return {
noResolve: true,
lib: ['es2021', 'esnext'],
// ts and monaco has different type as monaco types are not changing base on ts version
target: window.ts.ScriptTarget.ESNext as number,
module: window.ts.ModuleKind.ESNext as number,
...tsConfig,
jsx: jsx ? window.ts.JsxEmit.Preserve : window.ts.JsxEmit.None,
};
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@ import { WebLinter } from '../linter/WebLinter';
import { sandboxSingleton } from './loadSandbox';
import { editorEmbedId } from './EditorEmbed';
import { useColorMode } from '@docusaurus/theme-common';
import { createCompilerOptions } from '@site/src/components/editor/config';

export interface SandboxServicesProps {
readonly jsx?: boolean;
Expand DownExpand Up@@ -51,13 +52,7 @@ export const useSandboxServices = (

sandboxSingleton(props.ts)
.then(async ({ main, sandboxFactory, ts, lintUtils }) => {
const compilerOptions: Monaco.languages.typescript.CompilerOptions = {
noResolve: true,
target: main.languages.typescript.ScriptTarget.ESNext,
jsx: props.jsx ? main.languages.typescript.JsxEmit.React : undefined,
lib: ['es2021', 'esnext'],
module: main.languages.typescript.ModuleKind.ESNext,
};
const compilerOptions = createCompilerOptions(props.jsx);

const sandboxConfig: Partial<SandboxConfig> = {
text: '',
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp