Scratch-vm: Request: Type definitions for extensions

Created on 26 Jul 2020  路  13Comments  路  Source: LLK/scratch-vm

It would be useful for there to be Typescript definitions so that Intellisense would work when developing extensions.

feature question

All 13 comments

Currently Scratch does not use TypeScript. Maybe you can convert https://github.com/LLK/scratch-vm/blob/develop/src/extension-support/extension-metadata.js to TypeScript definitions?

@apple502j Are there definitions for the Scratch variable exposed to global?

Also, where should I put the type definitions?

Currently Scratch does not use TypeScript.

this is example:

/**
 * @typedef {object} Scratch
 * Scratch object exposed to extensions
 * @property {object.<string, string>} ArgumentType - represents what can be inserted to the argument
 * @property {pbject.<string, string>} BlockType - represents the block's shape
 * @property {object.<string, string>} TargetType - represents the targets the block will be displayed on the toolbox
 * @property {object.<ExtensionWorkerSubset>} extensions - represents extension worker subset

* @typedef {object} ExtensionWorkerSubset
* @property {function} register - function to register extensions
**/

@apple502j And where should I put the typings?

@apple502j BlockType, ReporterScope and ArgumentType is not declared.

@Richienb They are all string enums.
Again, TypeScript is not supported, so there is no place to put typings.

@apple502j What are the possible values for the enums?

See argument-type.js, block-type.js and target-type.js at https://github.com/LLK/scratch-vm/tree/develop/src/extension-support

@apple502j Are ArgumentType, BlockType and TargetType all properties of Scratch?

@Richienb yes.

@types/scratch-env has been published! Thanks for all the help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CatsAreFluffy picture CatsAreFluffy  路  6Comments

thisandagain picture thisandagain  路  3Comments

LiFaytheGoblin picture LiFaytheGoblin  路  5Comments

rasmushaglund picture rasmushaglund  路  4Comments

ericrosenbaum picture ericrosenbaum  路  3Comments