Skip to content

Fix browser launch crash and stale ES2023 hint - #4836

Open
DhruvilThummar wants to merge 3 commits into
microsoft:mainfrom
DhruvilThummar:fix/edge-tools-browser-launch-and-webhint
Open

Fix browser launch crash and stale ES2023 hint#4836
DhruvilThummar wants to merge 3 commits into
microsoft:mainfrom
DhruvilThummar:fix/edge-tools-browser-launch-and-webhint

Conversation

@DhruvilThummar

Copy link
Copy Markdown

This PR addresses two Edge Tools issues:

Validation:

  • npx jest --config package.json --runInBand test/extension.test.ts -t "can launch the browser with the default url when no file uri is provided"
  • npx jest --config package.json --runInBand test/webhintDiagnostics.test.ts

Copilot AI review requested due to automatic review settings July 29, 2026 07:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two user-facing issues in the Edge DevTools VS Code extension: (1) command-palette browser launch crashing when invoked without a file URI, and (2) a stale webhint typescript-config/is-valid diagnostic incorrectly flagging ES2023 in tsconfig*.json.

Changes:

  • Allow launchHtml / launchScreencast commands to be invoked without a fileUri, falling back to the configured default URL.
  • Add a handleDiagnostics middleware filter to suppress the specific stale ES2023 webhint diagnostic only for tsconfig*.json.
  • Add Jest coverage for both behaviors.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/extension.ts Makes launch commands accept optional URIs and adds webhint diagnostics filtering middleware.
src/webhintDiagnostics.ts Introduces a helper to identify/suppress the stale ES2023 typescript-config/is-valid diagnostic for tsconfig files.
test/extension.test.ts Adds a regression test ensuring default URL fallback works when no file URI is provided.
test/webhintDiagnostics.test.ts Adds tests verifying ES2023 suppression is scoped to tsconfig files and doesn’t suppress other diagnostics.
Comments suppressed due to low confidence (4)

src/extension.ts:314

  • Same issue here: file://${fileUri.fsPath} can generate an invalid file URL on Windows, which may prevent attach() from matching the launched target. Prefer fileUri.toString(true) for a correct, encoded file URL.
        const url = fileUri ? `file://${fileUri.fsPath}` : defaultUrl;
        edgeDebugConfig.url = url;
        void vscode.debug.startDebugging(undefined, edgeDebugConfig).then(() => attach(context, url, undefined, true, true));

test/webhintDiagnostics.test.ts:21

  • Casting the diagnostic object to never sidesteps type-checking. Cast to import('vscode').Diagnostic (type-only) so the test stays type-safe without introducing a runtime VS Code dependency.
        expect(shouldSuppressWebhintDiagnostic(tsConfigUri, {
            source: 'Microsoft Edge Tools',
            message: "'compilerOptions/target' must be equal to one of the allowed values 'ES3, ES5, ES6, ES2015, ES2016, ES2017, ES2018, ES2019, ES2020, ES2021, ES2022, ESNext'. Value found '\"ES2023\"'.",
            code: { value: 'typescript-config/is-valid' },
        } as never)).toBe(true);

test/webhintDiagnostics.test.ts:37

  • Same issue here: as never removes type safety in the test. Switch to a type-only cast to import('vscode').Diagnostic.
        expect(shouldSuppressWebhintDiagnostic(appConfigUri, {
            source: 'Microsoft Edge Tools',
            message: "'compilerOptions/target' must be equal to one of the allowed values 'ES3, ES5, ES6, ES2015, ES2016, ES2017, ES2018, ES2019, ES2020, ES2021, ES2022, ESNext'. Value found '\"ES2023\"'.",
            code: { value: 'typescript-config/is-valid' },
        } as never)).toBe(false);

test/webhintDiagnostics.test.ts:29

  • Same issue here: as never removes type safety in the test. Switch to a type-only cast to import('vscode').Diagnostic.
        expect(shouldSuppressWebhintDiagnostic(tsConfigUri, {
            source: 'Microsoft Edge Tools',
            message: "'compilerOptions/target' must be equal to one of the allowed values 'ES3, ES5, ES6, ES2015, ES2016, ES2017, ES2018, ES2019, ES2020, ES2021, ES2022, ESNext'. Value found '\"ES2022\"'.",
            code: { value: 'typescript-config/is-valid' },
        } as never)).toBe(false);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/extension.ts Outdated
Comment thread test/webhintDiagnostics.test.ts Outdated

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

1 similar comment

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Author

@microsoft-github-policy-service the CLA is complete and the review comments have been addressed. Could someone with write access please take a look and approve when convenient? The PR is otherwise ready apart from the maintainer-side workflow approvals.

@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

@DhruvilThummar the command you issued was incorrect. Please try again.

Examples are:

@microsoft-github-policy-service agree

and

@microsoft-github-policy-service agree company="your company"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command 'Microsoft Edge Tools: Open Browser' resulted in an error error about using ES2023

2 participants