Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript unhappy with 'blockly/javascript' exports #7283

Closed
root-goblin opened this issue Jul 12, 2023 · 2 comments · Fixed by #7295
Closed

TypeScript unhappy with 'blockly/javascript' exports #7283

root-goblin opened this issue Jul 12, 2023 · 2 comments · Fixed by #7295
Labels
issue: triage Issues awaiting triage by a Blockly team member

Comments

@root-goblin
Copy link

TL;DR

import { Order } from 'blockly/javascript';

Fails to compile without // @ts-ignore flag

Temporary fix

Adding // @ts-ignore comment will allow it to compile and run without any noted errors

// @ts-ignore
import { Order } from 'blockly/javascript';

Details

Didn't have time to look too deeply into the issue, but this is what I've dug up from a cursory look:

Looks like Order is not being exported in the javascript.d.ts file - https://github.com/google/blockly/blob/blockly-v10.0.1/typings/javascript.d.ts

Might be because typescript does not like the export * from ... syntax in original javascript.js source - https://github.com/google/blockly/blob/blockly-v10.0.1/generators/javascript.js

@maribethb maribethb added the issue: triage Issues awaiting triage by a Blockly team member label Jul 13, 2023
@cpcallen
Copy link
Contributor

Yes: the .d.ts files did not get updated, and they should have.

I think this slipped my mind because the intention was (and remains) to get these fully converted to TypeScript and actually generate the .d.ts files rather than maintain them manually.

(Aside: same for library blocks, where I think we may be overwriting the generated .d.ts files with the manually-curated ones before publication.)

cpcallen added a commit to cpcallen/blockly that referenced this issue Jul 17, 2023
Remove the protected declaration on provideFunction_ and
FUNCITON_NAME_PLACEHOLDER_ so they can be used from generator
functions written in TypeScript.

Not strictly part of google#7283, but closely related and required to
fixing the related issue google/blockly-samples#1785.
cpcallen added a commit that referenced this issue Jul 17, 2023
…t compatibility (#7295)

* fix(generators): Add missing declarations for Order enums

* chore(generators): Remove spurious whitespace

* fix(generators): Make provideFunction_ etc. public

  Remove the protected declaration on provideFunction_ and
  FUNCTION_NAME_PLACEHOLDER_ so they can be used from generator
  functions written in TypeScript.

  Not strictly part of #7283, but closely related and required to
  fixing the related issue google/blockly-samples#1785.

* chore(generators): format
ericblackmonGoogle pushed a commit that referenced this issue Jul 17, 2023
…t compatibility (#7295)

* fix(generators): Add missing declarations for Order enums

* chore(generators): Remove spurious whitespace

* fix(generators): Make provideFunction_ etc. public

  Remove the protected declaration on provideFunction_ and
  FUNCTION_NAME_PLACEHOLDER_ so they can be used from generator
  functions written in TypeScript.

  Not strictly part of #7283, but closely related and required to
  fixing the related issue google/blockly-samples#1785.

* chore(generators): format

(cherry picked from commit d503fbb)
ericblackmonGoogle added a commit that referenced this issue Jul 17, 2023
* fix(generators): Changes to exports and access controls for TypeScript compatibility (#7295)

* fix(generators): Add missing declarations for Order enums

* chore(generators): Remove spurious whitespace

* fix(generators): Make provideFunction_ etc. public

  Remove the protected declaration on provideFunction_ and
  FUNCTION_NAME_PLACEHOLDER_ so they can be used from generator
  functions written in TypeScript.

  Not strictly part of #7283, but closely related and required to
  fixing the related issue google/blockly-samples#1785.

* chore(generators): format

(cherry picked from commit d503fbb)

* fix: Correct errors in `HSV_SATURATION`, `HSV_VALUE` accessors (#7297)

* fix: Correct errors in HSV_SATURATION, HSV_VALUE accessors

  Fix the comment / message errors noted in
  #7249 (comment)

* chore: Add renamings for HSV_SATURATION, HSV_VALUE

(cherry picked from commit 1bc4f67)

* release: Update version number to 10.0.2

---------

Co-authored-by: Christopher Allen <cpcallen+git@google.com>
ericblackmonGoogle added a commit that referenced this issue Jul 17, 2023
* fix(generators): Changes to exports and access controls for TypeScript compatibility (#7295)

* fix(generators): Add missing declarations for Order enums

* chore(generators): Remove spurious whitespace

* fix(generators): Make provideFunction_ etc. public

  Remove the protected declaration on provideFunction_ and
  FUNCTION_NAME_PLACEHOLDER_ so they can be used from generator
  functions written in TypeScript.

  Not strictly part of #7283, but closely related and required to
  fixing the related issue google/blockly-samples#1785.

* chore(generators): format

(cherry picked from commit d503fbb)

* fix: Correct errors in `HSV_SATURATION`, `HSV_VALUE` accessors (#7297)

* fix: Correct errors in HSV_SATURATION, HSV_VALUE accessors

  Fix the comment / message errors noted in
  #7249 (comment)

* chore: Add renamings for HSV_SATURATION, HSV_VALUE

(cherry picked from commit 1bc4f67)

* release: Update version number to 10.0.2

---------

Co-authored-by: Christopher Allen <cpcallen+git@google.com>
@pavi2410
Copy link

pavi2410 commented Nov 14, 2023

I'm still unable to import the Order enum with Blockly v10.2.2 on NodeJS 21

import { javascriptGenerator, Order } from "blockly/javascript";
                              ^
SyntaxError: The requested module 'blockly/javascript' does not provide an export named 'Order'

Workaround:

import JavaScript from "blockly/javascript";
const { javascriptGenerator, Order } = JavaScript;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: triage Issues awaiting triage by a Blockly team member
Projects
None yet
4 participants