Comments (6)
Hi @edmundg, I just published a 15.1.4 version on NPM that should work now.
I haven't updated the boilerplate yet, I'll wait for you to confirm first.
Note that we still have a bunch of any
type declaration across the framework, but those should not cause this kind of issue. Anyway, if you find more causing problem, let us know !
from melonjs.
yes so, the issue seems to be that tsc
does not recognized/parse the below as an array of object, even though it is declared as of one (using {object[]} :
https://github.com/melonjs/melonJS/blob/master/src/loader/loader.js#L108-L114
as you can see below the corresponding definition just include the object definition and lacks the array part :
https://github.com/melonjs/melonJS/blob/master/dist/types/loader/loader.d.ts#L46-L51
I just played around a bit and changed the declaration to the below :
* @param {Array.<object>} res
* @param {string} res.name - internal name of the resource
* @param {string} res.type - "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
* @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
* @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
* @param {Function} [onloadcb=loader.onload] - function to be called when all resources are loaded
* @param {boolean} [switchToLoadState=true] - automatically switch to the loading screen
and then the TS typing is more correct, but then we loose the definition of the object itself
export function preload(res: Array<object>, onloadcb?: Function | undefined, switchToLoadState?: boolean | undefined): void;
from melonjs.
oh well I just realized that our documentation is also missing a bit of declaration, so I guess maybe we used/declared things the wrong way since the beginning here :
https://melonjs.github.io/melonJS/docs/melonjs/loader.html#preload
I need some searching on how to fix this the proper way now :)
from melonjs.
done, this works :
/**
* @typedef {object} loader.Asset
* @property {string} Asset.name - internal name of the resource
* @property {string} Asset.type - "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
* @property {string} Asset.src - path and/or file name of the resource (for audio assets only the path is required)
* @property {boolean} [Asset.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
* @memberof loader
*/
/**
* set all the specified game assets to be preloaded.
* @name preload
* @memberof loader
* @public
* @param {loader.Asset[]} assets - list of assets to load
export function preload(assets, onloadcb, switchToLoadState = true) {
...
}
*/
I just added a new Asset
typedef, and it properly works everywhere, and generate the below in TS :
/**
* an asset definition to be used with the loader
* @typedef {object} loader.Asset
* @property {string} name - name of the asset
* @property {string} type - the type of the asset : "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
* @property {string} src - path and/or file name of the resource (for audio assets only the path is required)
* @property {boolean} [stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
* @see loader.preload
* @see loader.load
*/
/**
* set all the specified game assets to be preloaded.
* @name preload
* @memberof loader
* @public
* @param {loader.Asset[]} assets - list of assets to load
* @param {Function} [onloadcb=loader.onload] - function to be called when all resources are loaded
* @param {boolean} [switchToLoadState=true] - automatically switch to the loading screen
*/
export function preload(assets: loader.Asset[], onloadcb?: Function | undefined, switchToLoadState?: boolean | undefined): void;
I will clean up everything look for other <any>
type declaration in the loader and publish a new version probably today.
from melonjs.
Thanks @obiot I can confirm the issue is now resolved, I have updated to the latest version.
I recreated the issue, updated and confirm the bug has been fixed.
I will leave the bug open for now in case you want to update the boiler plate first.
from melonjs.
awesome, thanks for confirming, and closing this one then :)
from melonjs.
Related Issues (20)
- Cache or optimize triangulation data used for drawing with fill operation
- `textImage2D` does not accept OffscreenCanvas anymore as a pixel source for texture
- optimize matrix operations using Strassen algorithm ? HOT 5
- compressed textures in WebGL HOT 3
- WebGPU renderer
- [Feature request] More realistic progress based on bytes for loader and preloader
- Texture is never removed from TextureCache
- TextureCache.length can't be decreased HOT 5
- support using SVG path data when creating a Path2D path HOT 1
- this.body is pointing to Dom type when using Typescript Boilerplate HOT 8
- Animation created from atlas: misaligned hitbox HOT 1
- Some of the Github pages examples are broken HOT 3
- Difficulties with UITextButton HOT 6
- Animation broken on WebGL if TextureAtlas has multiple textures HOT 10
- The result of the flip object vibrates
- Hyperlinks to source code within documentation contain absolute path on obiot's PC HOT 4
- withCredentials does not get set in fetch calls HOT 3
- [documentation] migrate to vitepress-jsdoc HOT 1
- fix remaining missing declarations in TS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from melonjs.