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'.

About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 30 (30 by maintainers)
I’ve got a fix. PR incoming
Ah ha! I min repro: https://arcade.makecode.com/beta#pub:72219-39728-01065-46406
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.
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?
Doing some delta debugging, we (thanks @livcheerful!) found that the issue
Which corresponds to pxt versions 5.34.13 - 5.34.16.
There are 11 pxt PRs between those versions: https://github.com/microsoft/pxt/commits/master?after=f05e2050f9797548a1a5237e4f19d2f37f9b2a86+944
These are the ones I think could plausibly cause it: https://github.com/microsoft/pxt/pull/6600 https://github.com/microsoft/pxt/pull/6592 https://github.com/microsoft/pxt/pull/6590 https://github.com/microsoft/pxt/pull/6589 https://github.com/microsoft/pxt/pull/6568
@abchatra FYI