Skip to content

fix declare const enum not inlined by esbuild, fixes #295046#295149

Merged
jrieken merged 1 commit intomainfrom
joh/no-declare-const-enum
Feb 13, 2026
Merged

fix declare const enum not inlined by esbuild, fixes #295046#295149
jrieken merged 1 commit intomainfrom
joh/no-declare-const-enum

Conversation

@jrieken
Copy link
Member

@jrieken jrieken commented Feb 13, 2026

fixes #295046

Copilot AI review requested due to automatic review settings February 13, 2026 11:56
@jrieken jrieken enabled auto-merge (squash) February 13, 2026 11:56
@jrieken jrieken self-assigned this Feb 13, 2026
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 13, 2026
Copy link
Contributor

Copilot AI left a comment

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 issue #295046 where declare const enum declarations were not being inlined by esbuild, causing ReferenceError at runtime. The esbuild bundler doesn't handle declare const enum correctly, leaving enum identifiers in the output instead of inlining the constant values. The solution removes the declare keyword from const enum declarations and adds an ESLint rule to prevent this issue in the future.

Changes:

  • Removed declare keyword from two const enums (PromptNodeType and PieceCtorKind) in promptTsxTypes.ts
  • Added a new auto-fixable ESLint rule (code-no-declare-const-enum) to prevent future occurrences
  • Registered the new ESLint rule in eslint.config.js

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/vs/workbench/contrib/chat/common/tools/promptTsxTypes.ts Removed declare keyword from PromptNodeType and PieceCtorKind const enums and added explanatory comment about esbuild limitation
.eslint-plugin-local/code-no-declare-const-enum.ts Added new ESLint rule to detect and auto-fix declare const enum declarations
eslint.config.js Registered the new code-no-declare-const-enum rule in the ESLint configuration

@jrieken jrieken merged commit 970fb63 into main Feb 13, 2026
24 checks passed
@jrieken jrieken deleted the joh/no-declare-const-enum branch February 13, 2026 12:09
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.

ReferenceError: PromptNodeType is not defined. TypeScript const enum not converted to a constant

2 participants