Giter VIP home page Giter VIP logo

Comments (6)

obiot avatar obiot commented on July 3, 2024 1

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.

obiot avatar obiot commented on July 3, 2024

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.

obiot avatar obiot commented on July 3, 2024

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.

obiot avatar obiot commented on July 3, 2024

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.

edmundg avatar edmundg commented on July 3, 2024

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.

obiot avatar obiot commented on July 3, 2024

awesome, thanks for confirming, and closing this one then :)

from melonjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.