Backpack 5.2.2 creates a lot of type error with Blockly 10.2.0?!

86 views
Skip to first unread message

Seb Seb

unread,
Sep 29, 2023, 5:39:03 AM9/29/23
to Blockly
Hello,
I tried the backpack plugin in the sample-app-ts, I updated all the dependencies:

  "devDependencies": {
    "css-loader": "^6.8.1",
    "html-webpack-plugin": "^5.5.3",
    "source-map-loader": "^4.0.1",
    "style-loader": "^3.3.3",
    "ts-loader": "^9.4.4",
    "typescript": "^5.2.2",
    "webpack": "^5.88.2",
    "webpack-cli": "^5.1.4",
    "webpack-dev-server": "^4.15.1"
  },
  "dependencies": {
    "@blockly/block-plus-minus": "^6.0.4",
    "@blockly/workspace-backpack": "^5.2.2",
    "blockly": "^10.2.0"
  }
And when launching "npm run start" I have a lot of type error like:
[tsl] ERROR in F:\Logiciels\Arduino_graphique\blockly-samples\examples\sample-app-ts\node_modules\@blockly\workspace-backpack\src\backpack.ts(132,26)
      TS2345: Argument of type 'BackpackContextMenuOptions | undefined' is not assignable to parameter of type 'BackpackContextMenuOptions'.
  Type 'undefined' is not assignable to type 'BackpackContextMenuOptions'.
[tsl] ERROR in F:\Logiciels\Arduino_graphique\blockly-samples\examples\sample-app-ts\node_modules\@blockly\workspace-backpack\src\backpack.ts(163,7)
      TS2322: Type '{ [rendererConstant: string]: any; } | null' is not assignable to type '{ [rendererConstant: string]: any; } | undefined'.
  Type 'null' is not assignable to type '{ [rendererConstant: string]: any; } | undefined'.

Am I wrong ? Did anyone has same problem?
Thanks.

Beka Westberg

unread,
Sep 29, 2023, 12:07:47 PM9/29/23
to blo...@googlegroups.com
I'm not able to reproduce this error :/ Could you give more detailed reproduction steps?

Hopefully with a bit more info we can get this sorted out!

Best wishes,
--Beka

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/6273edf2-cad0-41d8-b847-e41db9ed28a8n%40googlegroups.com.

Seb Seb

unread,
Oct 1, 2023, 6:16:17 AM10/1/23
to Blockly
Hello,
thanks for trying, I copied sample-app-ts example, just installed backpack plugin and added it in index.ts:

import * as Blockly from 'blockly';
import {Backpack} from '@blockly/workspace-backpack';
import {blocks} from './blocks/text';
import {forBlock} from './generators/javascript';
import {javascriptGenerator} from 'blockly/javascript';
import {save, load} from './serialization';
import {toolbox} from './toolbox';
import './index.css';

// Register the blocks and generator with Blockly
Blockly.common.defineBlocks(blocks);
Object.assign(javascriptGenerator.forBlock, forBlock);

// Set up UI elements and inject Blockly
const codeDiv = document.getElementById('generatedCode')?.firstChild;
const outputDiv = document.getElementById('output');
const blocklyDiv = document.getElementById('blocklyDiv');
const ws = blocklyDiv && Blockly.inject(blocklyDiv, {toolbox});

const backpack = new Backpack(ws);
backpack.init();

 and updated all dependencies:

  "devDependencies": {
    "css-loader": "^6.8.1",
    "html-webpack-plugin": "^5.5.3",
    "source-map-loader": "^4.0.1",
    "style-loader": "^3.3.3",
    "ts-loader": "^9.4.4",
    "typescript": "^5.2.2",
    "webpack": "^5.88.2",
    "webpack-cli": "^5.1.4",
    "webpack-dev-server": "^4.15.1"
  },
  "dependencies": {
    "@blockly/workspace-backpack": "^5.2.2",
    "blockly": "^10.2.0"
  }

When launching 'npm run start', I have a type error:
[tsl] ERROR in index.ts(26,31)   (it's line with const backpack = new Backpack(ws); )
      TS2345: Argument of type 'WorkspaceSvg | null' is not assignable to parameter of type 'WorkspaceSvg'.
  Type 'null' is not assignable to type 'WorkspaceSvg'.
ts-loader-default_e3b0c44298fc1c14

It's for a clean sample-app-ts, but for my application I have 42 errors about backpack plugin like "TS18047: 'VerticalFlyout' is possibly 'null'." ; TS18047: 'parentNode' is possibly 'null'." and I have no idea what the pb is coming from...maybe my TS configuration?

Zoey Li

unread,
Oct 1, 2023, 7:02:11 PM10/1/23
to Blockly
Hi Seb,

Thank you for raising this issue, I was able to reproduce this.  Please pin the version to `"@blockly/workspace-backpack": "5.2.1"` for now until it is resolved. 

@Beka I've summarized the issues I'm seeing in this comment: https://github.com/google/blockly-samples/issues/1871#issuecomment-1742229188
Feel free to pin me if you have any additional questions.

Thanks
Zoey

Reply all
Reply to author
Forward
0 new messages