Repository navigation
fix: accept Asset attributes with engine 2.23+ generic Asset type - #76
Merged
Merged
Conversation
1 task done
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.
Fixes #75
Engine 2.23 made
Assetgeneric (Asset<K extends AssetType | (string & {}) = string>), so@type {Asset}resolves to an instantiatedAsset<string>reference rather than the declared class type the parser registers as supported. Asset attributes were therefore rejected with"{Asset}" is not a valid attribute type.Changes
getTypenow resolves generic class instances (e.g.Asset<string>,Asset<'texture'>) to their declared class type and uses the class name as the type name, so they outputtype: 'asset'. Arrays, tuples and generic interfaces are unaffected.playcanvasdevDependency to2.23.3so the existing Asset tests exercise the generic declaration (12 of them fail on these types without the fix). The newer engine no longer depends oncanvas, which accounts for the lockfile shrink.Manual smoke test
/** @attribute @type {Asset} */ myAsset = null;and/** @attribute @type {Entity} */ myEntity = null;, then parse it./** @attribute @type {Asset} @resource texture */ tex = null;and parse.