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

Blockly Locale Typescript Issues with Latest Release #5818

Closed
reece-berens opened this issue Dec 14, 2021 · 4 comments
Closed

Blockly Locale Typescript Issues with Latest Release #5818

reece-berens opened this issue Dec 14, 2021 · 4 comments
Assignees
Labels
component: TypeScript issue: bug Describes why the code or behaviour is wrong type: regression

Comments

@reece-berens
Copy link

Describe the bug
A couple typescript errors appear in my project when attempting to set the locale of Blockly.

When attempting to import the correct language module, the following error appears:

Could not find a declaration file for module 'blockly/msg/en'. '<myfilepath>/node_modules/blockly/msg/en.js' implicitly has an 'any' type.
If the 'blockly' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module 'blockly/msg/en';`

When attempting to use the Blockly.setLocale() function, the following error appears:
Property 'setLocale' does not exist on type 'typeof import("blockly")'

This code was working fine with version 6.20210701.0, but appeared when I upgraded to version 7.20211209.0 from NPM. I didn't see anything in the release notes related to this issue, so I'm assuming this is not intended.

To Reproduce
Below is the code I am using. It has not changed between the two versions.

import React from 'react';
import './App.css';
import BlocklyComponent from "./blocklyComponent";
import Blockly from "blockly";
import CustomBlocklyBlocks from "./customBlockly/blockDef";
import enLocale from "blockly/msg/en"; //error on this line

function App() {
    Blockly.setLocale(enLocale); //error on this line
    Blockly.defineBlocksWithJsonArray(CustomBlocklyBlocks);
    return (
        <div>
            <p>Test paragraph</p>
            <BlocklyComponent />
        </div>
    );
}

export default App;

Expected behavior
The user should not receive any typescript errors when attempting to set the locale for their specific Blockly instance.

Additional context
I am using typescript version 4.5.2 and React version 17.0.2. I am using Visual Studio Code (version 1.63.0) as my IDE.
This isn't super important for me as I just need the English messages, but I thought I'd open this issue just in case this is an issue for anyone who does need to change languages.
Feel free to let me know if you need any other information.
Thank you!

@rachel-fenichel rachel-fenichel added component: TypeScript issue: bug Describes why the code or behaviour is wrong type: regression labels Dec 15, 2021
@rachel-fenichel rachel-fenichel self-assigned this Jan 6, 2022
@bidinzky
Copy link

bidinzky commented Mar 7, 2022

some update on this?

@Amboryus
Copy link

Amboryus commented Mar 9, 2022

Hi i am looking for a update too.
Blockly.setLocale(LANGUAGE-MODULE) is missing inside "blockly.d.ts"

I append it myself to test.
I need this realy.

I hope we get any informations to solve this with updated npm package. ;-)

Have a nice day.

@bonellia
Copy link

Also started a new project using blockly-react from official samples repository as a reference and have this problem.

@zz-james
Copy link

Hi, same problem, typescript v4.3.4 / blockly v8.0.3
TS7016: Could not find a declaration file for module 'blockly/msg/en'.

I used // @ts-ignore for now but cool if you could fix it
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TypeScript issue: bug Describes why the code or behaviour is wrong type: regression
Projects
None yet
Development

No branches or pull requests

7 participants