pxt-arcade: Can't load community game "bat dungeon", "jewel raider"; "Cannot redeclare block-scoped variable 'mySprite2'" error(s)

This was originally lumped as part of https://github.com/microsoft/pxt-arcade/issues/1978 but the issue is different.

https://forum.makecode.com/t/bat-dungeon/1004

This issue:

error: main.ts(286,5): error TS2451: Cannot redeclare block-scoped variable 'mySprite2'.
error: main.ts(301,5): error TS2451: Cannot redeclare block-scoped variable 'mySprite2'.

image

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 30 (30 by maintainers)

Most upvoted comments

I’ve got a fix. PR incoming

The bug that keeps on giving: the fix that would have worked 6 months ago after (microsoft/pxt#6568) doesn’t work on master today due to a regression in how we’re separating test files from regular files. Working on the fix for that too.

So I think the immediate fix is to stop the bundled api info from grabbing symbols from test files. But there’s another issue here too: if an extension and user project collide on symbols, we don’t give a good error. I think we should give the user a clear warning that they can’t use that symbol because it’s taken by X extension.

Do you mean because of

Yup! Now I gotta hunt down why test.ts isn’t being excluded.

Pretty sure the “pxtTargetBundle” has the wrong symbols, specifically it thinks “mySprite” is in libs/animation

Good (and confusing) news is that the issue is now reproducing on localhost using the branch & version I mention above!

The error reproduces with: https://arcade.makecode.com/app/0149037c97e7a52c74ad4f9cd99c63a0778dd7a2-4d496669bc Which is post microsoft/pxt#6568

Hurrah! Now to figure out what the right fix is

Yeah, that is almost certainly the change that would have caused (exposed?) it (https://github.com/microsoft/pxt/pull/6568), but I’m not sure how that’d break things / as far as I can tell that’s the ‘right behavior’ as we need to rename, so something wonky is causing it?

Also, sidenote, just realized when we push custom builds to test, it never uglifies it (e.g. https://aka.ms/jowunder-test) so might help on debugging?