Skip to content

Convert blocks/ and generators/ to TypeScript #6828

@cpcallen

Description

@cpcallen

This is a tracking bug for the remaining work to migrate the Blockly codebase to TypeScript, following the successful migration of core/.

This is part of #5857, and will resolve #6248 and probably also #2995.

Work to be done

  • Update scripts/gulpfiles/build_tasks.js to feed the contents of blocks/ and generators/ through tsc.
  • Update tests/bootstrap.js, playgrounds, etc. to load blocks and generators from build/src/ when loading uncompressed.
    • Turned out to be ~no work for now as they use goog.require so don't care about file location.
  • Create script to assist with migration (esp. of imports).
  • [OPTIONAL:] Refine type of BlockDefinition (in core/blocks.ts) to make defining blocks easier and preferably less error prone.
    • At the moment BlockDefinition is AnyDuringMigration; this works but means that tsc provides no assistance in verifying block definitions—for example, it does not check to make sure that Block methods are being called (or overridden) correctly.
    • @cpcallen has asked a question on Stack Overflow but this has not elicited an answer yet.
    • @btw17 has made some useful suggestions, including in particular defining BlockDefinition as {[Property in keyof Block]?: Block[Property]} & {[key: string]: unknown}, but this is not perfect: e.g. mixin methods do not get the correct type for this.
  • Create a model PR, migrating one file in blocks/, to verify that the above works as intended.

blocks/

generators/

  • Provide more user-friendly generator APIs #7326

  • Make CodeGenerator abstract #7401

  • dart.js

    • dart/dart_generator.js
    • dart/colour.js
    • dart/lists.js
    • dart/logic.js
    • dart/loops.js
    • dart/math.js
    • dart/procedures.js
    • dart/text.js
    • dart/variables.js
    • dart/variables_dynamic.js
  • javascript.js

    • javascript/javascript_generator.js
    • javascript/colour.js
    • javascript/lists.js
    • javascript/logic.js
    • javascript/loops.js
    • javascript/math.js
    • javascript/procedures.js
    • javascript/text.js
    • javascript/variables.js
    • javascript/variables_dynamic.js
  • lua.js

    • lua/lua_generator.js
    • lua/colour.js
    • lua/lists.js
    • lua/logic.js
    • lua/loops.js
    • lua/math.js
    • lua/procedures.js
    • lua/text.js
    • lua/variables.js
    • lua/variables_dynamic.js
  • php.js

    • php/php_generator.js
    • php/colour.js
    • php/lists.js
    • php/logic.js
    • php/loops.js
    • php/math.js
    • php/procedures.js
    • php/text.js
    • php/variables.js
    • php/variables_dynamic.js
  • python.js

    • python/python_generator.js
    • python/colour.js
    • python/lists.js
    • python/logic.js
    • python/loops.js
    • python/math.js
    • python/procedures.js
    • python/text.js
    • python/variables.js
    • python/variables_dynamic.js

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions