feat(examples): resolve code editor autocomplete, go-to-definition and peek#8826
Merged
Conversation
…d peek
Example files are ES modules but the engine types were registered under a
non-resolvable extra-lib name, so `import * as pc from 'playcanvas'` never
resolved and only word-based completions showed (e.g. pc.StandardMaterial
was missing in the Hello World example).
- add an ambient `declare module 'playcanvas' { export = pc }` shim so the
bare specifier resolves to the pc namespace
- shim `examples/context`, `playcanvas/scripts/*` and the asset modules
(*.vert/*.frag/*.wgsl/*.glsl/*.html/*.css/*.txt/*.json)
- model every file of a multi-file example in a shared virtual dir so
relative sibling imports (./gizmo-handler.mjs) resolve, with an editor
opener that switches tabs and reveals the definition
- fetch real playcanvas/scripts sources on demand for member autocomplete,
and peek engine scripts / the playcanvas typings inline
- give the engine typings a clean file:/// URI so pc.* definitions peek
- annotate Example.renderCredit children to clear two tsc errors
kpal81xd
added a commit
that referenced
this pull request
Jun 3, 2026
…d peek (#8826) Example files are ES modules but the engine types were registered under a non-resolvable extra-lib name, so `import * as pc from 'playcanvas'` never resolved and only word-based completions showed (e.g. pc.StandardMaterial was missing in the Hello World example). - add an ambient `declare module 'playcanvas' { export = pc }` shim so the bare specifier resolves to the pc namespace - shim `examples/context`, `playcanvas/scripts/*` and the asset modules (*.vert/*.frag/*.wgsl/*.glsl/*.html/*.css/*.txt/*.json) - model every file of a multi-file example in a shared virtual dir so relative sibling imports (./gizmo-handler.mjs) resolve, with an editor opener that switches tabs and reveals the definition - fetch real playcanvas/scripts sources on demand for member autocomplete, and peek engine scripts / the playcanvas typings inline - give the engine typings a clean file:/// URI so pc.* definitions peek - annotate Example.renderCredit children to clear two tsc errors
kpal81xd
added a commit
that referenced
this pull request
Jun 3, 2026
…d peek (#8826) Example files are ES modules but the engine types were registered under a non-resolvable extra-lib name, so `import * as pc from 'playcanvas'` never resolved and only word-based completions showed (e.g. pc.StandardMaterial was missing in the Hello World example). - add an ambient `declare module 'playcanvas' { export = pc }` shim so the bare specifier resolves to the pc namespace - shim `examples/context`, `playcanvas/scripts/*` and the asset modules (*.vert/*.frag/*.wgsl/*.glsl/*.html/*.css/*.txt/*.json) - model every file of a multi-file example in a shared virtual dir so relative sibling imports (./gizmo-handler.mjs) resolve, with an editor opener that switches tabs and reveals the definition - fetch real playcanvas/scripts sources on demand for member autocomplete, and peek engine scripts / the playcanvas typings inline - give the engine typings a clean file:/// URI so pc.* definitions peek - annotate Example.renderCredit children to clear two tsc errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The examples code editor (Monaco) only autocompleted
pc.*members that were already typed in the file — e.g.pc.StandardMaterialnever appeared in the Hello World example. Example files are ES modules (import * as pc from 'playcanvas'), but the engine type definitions were registered under a non-resolvable extra-lib name, so the import resolved toanyand only Monaco's word-based suggestions showed.This wires up proper IntelliSense for the editor:
pc.*namespace — an ambientdeclare module 'playcanvas' { export = pc }shim makesimport * as pc from 'playcanvas'resolve to thepcnamespace.examples/context,playcanvas/scripts/*, and the asset modules (*.vert/*.frag/*.wgsl/*.glsl/*.html/*.css/*.txt/*.json)../gizmo-handler.mjs) resolve, and a registered editor opener makes Go to Definition switch tabs and reveal the target.playcanvas/scripts/*sources are fetched on demand and modelled, soCameraControls,Grid, etc. get real member autocomplete and can be previewed.playcanvastypings peek inline (read-only);pc.*definitions peek the engine.d.ts(given a cleanfile:///URI).tscerrors inExample.renderCredit.Verified live against the Monaco language worker (autocomplete, go-to-definition, peek) for
misc/editorand shader examples.npm run type:check:appandeslintpass.Checklist