Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(website): update hash value if problem occurs due to ts version error #11292

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/website/src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function Playground(): React.JSX.Element {
onMarkersChange={setMarkers}
onSelect={setPosition}
selectedRange={selectedRange}
setState={setState}
/>
</Panel>
<PanelResizeHandle className={styles.PanelResizeHandle} />
Expand Down
9 changes: 8 additions & 1 deletion packages/website/src/components/editor/useSandboxServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import semverSatisfies from 'semver/functions/satisfies';
import type { createTypeScriptSandbox } from '../../vendor/sandbox';
import type { CreateLinter } from '../linter/createLinter';
import type { PlaygroundSystem } from '../linter/types';
import type { RuleDetails } from '../types';
import type { ConfigModel, RuleDetails } from '../types';
import type { CommonEditorProps } from './types';

import rootPackageJson from '../../../../../package.json';
Expand All @@ -23,6 +23,7 @@ export interface SandboxServicesProps {
ruleDetails: RuleDetails[],
tsVersions: readonly string[],
) => void;
readonly setState: (value: Partial<ConfigModel>) => void;
readonly ts: string;
}

Expand Down Expand Up @@ -140,6 +141,12 @@ export const useSandboxServices = (
})
.catch((err: unknown) => {
if (err instanceof Error) {
if (
err.message ===
'Could not get all the dependencies of sandbox set up!'
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Refactor] A couple issues with the implementation as-is:

But, stepping back, I think this is too wide of a check. Any error rejection from loadSandbox will run props.setState({ ts: process.env.TS_VERSION }); Even if it wasn't a TS version error in the first place!

Requesting changes:

  • The reset of ts state should only happen if:
    a. The existing ts version is an unsupported one
    b. The failure is specifically for the vs/editor/editor.main
  • Switch the return type of loadSandbox to be something like a discriminated union, so the failure state is captured in the type system

) {
props.setState({ ts: process.env.TS_VERSION });
}
setServices(err);
} else {
setServices(new Error(String(err)));
Expand Down