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

docs(website): add missing typescript options to playground#4768

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
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
53 changes: 50 additions & 3 deletionspackages/website/src/components/config/ConfigTypeScript.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
import React, { useCallback } from 'react';
import tsConfigOptions from '../tsConfigOptions.json';
import React, { useCallback, useEffect, useState } from 'react';

import ConfigEditor from './ConfigEditor';
import ConfigEditor, { ConfigOptionsType } from './ConfigEditor';
import type { CompilerFlags } from '../types';
import { shallowEqual } from '../lib/shallowEqual';

Expand All@@ -11,11 +10,59 @@ interface ModalTypeScriptProps {
readonly config?: CompilerFlags;
}

interface OptionDeclarations {
name: string;
type?: unknown;
category?: { message: string };
description?: { message: string };
}

function checkOptions(item: [string, unknown]): item is [string, boolean] {
return typeof item[1] === 'boolean';
}

function ConfigTypeScript(props: ModalTypeScriptProps): JSX.Element {
const [tsConfigOptions, updateOptions] = useState<ConfigOptionsType[]>([]);

useEffect(() => {
if (window.ts) {
updateOptions(
Object.values(
// @ts-expect-error: definition is not fully correct
(window.ts.optionDeclarations as OptionDeclarations[])
.filter(
item =>
item.type === 'boolean' &&
item.description &&
item.category &&
![
'Command-line Options',
'Modules',
'Projects',
'Compiler Diagnostics',
'Editor Support',
'Output Formatting',
'Watch and Build Modes',
'Source Map Options',
].includes(item.category.message),
)
.reduce<Record<string, ConfigOptionsType>>((group, item) => {
const category = item.category!.message;
group[category] = group[category] ?? {
heading: category,
fields: [],
};
group[category].fields.push({
key: item.name,
label: item.description!.message,
});
return group;
}, {}),
),
);
}
}, [props.isOpen]);

const onClose = useCallback(
(newConfig: Record<string, unknown>) => {
const cfg = Object.fromEntries(
Expand Down
7 changes: 6 additions & 1 deletionpackages/website/src/components/editor/LoadedEditor.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -139,8 +139,13 @@ export const LoadedEditor: React.FC<LoadedEditorProps> = ({

useEffect(() => {
sandboxInstance.setCompilerSettings({
noResolve: true,
strict: true,
target: main.languages.typescript.ScriptTarget.ESNext,
module: main.languages.typescript.ModuleKind.ESNext,
lib: ['ESNext'],
...tsConfig,
jsx: jsx ?2 :0,
jsx: jsx ?main.languages.typescript.JsxEmit.React :undefined,
});
}, [jsx, sandboxInstance, JSON.stringify(tsConfig) /* todo: better way? */]);

Expand Down
97 changes: 0 additions & 97 deletionspackages/website/src/components/tsConfigOptions.json
View file
Open in desktop

This file was deleted.


[8]ページ先頭

©2009-2025 Movatter.jp