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

Can't import generators in TypeScript in 11.0.0-beta.0 #7741

Closed
1 task done
clementcontet opened this issue Jan 3, 2024 · 1 comment · Fixed by #7750
Closed
1 task done

Can't import generators in TypeScript in 11.0.0-beta.0 #7741

clementcontet opened this issue Jan 3, 2024 · 1 comment · Fixed by #7750
Assignees
Labels
issue: bug Describes why the code or behaviour is wrong

Comments

@clementcontet
Copy link
Contributor

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

I can't figure out how to import generators with the new types in TypeScript.

Reproduction steps

If I keep the imports from the current implementation (with Blockly 10):

  • import {javascriptGenerator, JavascriptGenerator, Order} from 'blockly/javascript';
  • I get Error: node_modules/blockly/javascript.d.ts:7:15 - error TS2307: Cannot find module 'generators/javascript' or its corresponding type declarations.

If I try to fix the imports:

  • import {javascriptGenerator, JavascriptGenerator, Order} from 'blockly/generators/javascript';
  • I get Error: Module not found: Error: Can't resolve 'blockly/generators/javascript'

To fix the compilation, I had to keep the original imports and modify node_modules/blockly/javascript.d.ts

  • from export * from 'generators/javascript';
  • to export * from './generators/javascript';

Stack trace

No response

Screenshots

No response

Browsers

No response

@clementcontet clementcontet added issue: bug Describes why the code or behaviour is wrong issue: triage Issues awaiting triage by a Blockly team member labels Jan 3, 2024
@maribethb maribethb removed the issue: triage Issues awaiting triage by a Blockly team member label Jan 3, 2024
cpcallen added a commit to cpcallen/blockly that referenced this issue Jan 8, 2024
Add a missing ./ prefix to the imports in the generator wrapper
.d.ts files.

Fixes: google#7741
@cpcallen cpcallen linked a pull request Jan 8, 2024 that will close this issue
1 task
cpcallen added a commit that referenced this issue Jan 8, 2024
* test(generators): Add generator TS import/use tests

* fix(generators): Fix generator type declarations

  Add a missing ./ prefix to the imports in the generator wrapper
  .d.ts files.

  Fixes: #7741
@cpcallen
Copy link
Contributor

cpcallen commented Jan 8, 2024

Fixed in rc/v11.0.0 branch; new beta will be published presently.

@cpcallen cpcallen closed this as completed Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Describes why the code or behaviour is wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants