Skip to content

fix: set Code Editor TypeScript target to ES2020#1738

Merged
willeastcott merged 2 commits intomainfrom
fix/code-editor-es2020-target
Feb 11, 2026
Merged

fix: set Code Editor TypeScript target to ES2020#1738
willeastcott merged 2 commits intomainfrom
fix/code-editor-es2020-target

Conversation

@willeastcott
Copy link
Contributor

@willeastcott willeastcott commented Feb 10, 2026

Summary

image
  • setCompilerOptions in the Code Editor's Monaco setup was missing target and lib, causing Monaco's TypeScript language service to fall back to ES5/ES6 defaults. This meant modern APIs like Array.prototype.includes() (ES2016) and Object.entries() (ES2017) showed type errors.
  • Explicitly sets target to ScriptTarget.ES2020 and lib to ['es2020', 'dom'] to match the engine's build target.

Fixes #1731

Test plan

  • Open the Code Editor
  • Use Array.prototype.includes() in a script -- verify no type error
  • Use Object.entries() in a script -- verify no type error
  • Verify general IntelliSense and type checking still works correctly

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 pull request aims to fix TypeScript type errors in the Code Editor by setting the Monaco TypeScript compiler target to ES2020. However, the PR also includes unrelated changes for signed URL handling in asset loading.

Changes:

  • Sets Monaco TypeScript compiler options to target ES2020 with 'es2020' and 'dom' libraries to support modern JavaScript APIs like Array.prototype.includes() and Object.entries()
  • Adds signed URL support for asset files and variants (unrelated to PR description)
  • Adds signedUrls type definition to LaunchConfig (unrelated to PR description)

Reviewed changes

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

File Description
src/code-editor/monaco/document.ts Adds target: ES2020 and lib: ['es2020', 'dom'] to Monaco TypeScript compiler options to fix type errors for modern JS APIs
src/launch/assets/assets-sync.ts Adds logic to use pre-signed CloudFront URLs for asset files and variants (unrelated to PR description)
modules/editor-api/external/types/config.d.ts Adds optional signedUrls property to LaunchConfig type (unrelated to PR description)
Comments suppressed due to low confidence (1)

src/code-editor/monaco/document.ts:183

  • The setCompilerOptions call is executed every time a document is loaded (in the 'documents:load' event handler). While the dynamic 'paths' option may need to be recalculated per document due to import map changes, the 'target' and 'lib' settings are static and don't need to be reset on every document load. Consider moving the static compiler options (target, lib, allowJs, checkJs, allowNonTsExtensions, esModuleInterop) to a one-time initialization outside this event handler, and only update the dynamic 'paths' option inside the handler. This would improve performance by avoiding unnecessary reconfiguration of Monaco's TypeScript language service.
        monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
            allowJs: true,
            checkJs: true,
            allowNonTsExtensions: true,
            esModuleInterop: true,
            target: monaco.languages.typescript.ScriptTarget.ES2020,
            lib: ['es2020', 'dom'],
            paths: {
                'playcanvas': ['playcanvas.d.ts'],
                ...monacoImportPaths
            }
        });

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

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


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

willeastcott and others added 2 commits February 11, 2026 11:28
setCompilerOptions replaces Monaco's defaults entirely, so omitting
target and lib caused the language service to fall back to ES5/ES6.
This made modern APIs like Array.prototype.includes() and
Object.entries() show type errors.

Explicitly set target to ES2020 and lib to ['es2020', 'dom'] to
match the engine's build target.

Fixes #1731

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@kpal81xd kpal81xd force-pushed the fix/code-editor-es2020-target branch from 9e56e7f to 6ee5edb Compare February 11, 2026 11:28
@willeastcott willeastcott merged commit 4a360a0 into main Feb 11, 2026
3 checks passed
@willeastcott willeastcott deleted the fix/code-editor-es2020-target branch February 11, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: code editor bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Editor] target es2020

2 participants