# Error: Generic type 'Array\<T\>' requires 1 type argument(s)

**URL:** <https://forum.makecode.com/t/error-generic-type-array-t-requires-1-type-argument-s/16780>\
**Category:** Help\
**Tags:** javascript\
**Created:** [December 7, 2022, 6:10pm UTC](https://forum.makecode.com/t/error-generic-type-array-t-requires-1-type-argument-s/16780 "2022-12-07T18:10:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vegz78](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vegz78/32/1201_2.png) [@Vegz78](https://forum.makecode.com/u/Vegz78)\
**Post date:** [December 7, 2022, 6:10pm UTC](https://forum.makecode.com/t/error-generic-type-array-t-requires-1-type-argument-s/16780/1 "2022-12-07T18:10:02Z")

</div>

Hi,

I forgot about this one earlier…

When switching from JavaScript to blocks, MakeCode generates an error when trying to convert multidimensional arrays to blocks. The multidimensional arrays compile and run fine directly from JavaScript.

The error message is:  
`Generic type 'Array<T>' requires 1 type argument(s)`

When switching back again to JavaScript the multidimensional array is changed to:

```auto
let tracks: Array[] = [[hihat], [drums], [b1]]

```

So it seems to infer and add a one-dimensional `Array[]` type to the variable, where a two- or multidimensional `Array[][]` type does not exist, and where the multidimensional array works fine in JavaScript without any added type specification to the variable.

Is this a bug in the conversion from JavaScript to blocks, or is it just not part of the feature set, where this should be solved in another recommended and equally performant way instead?

This can be replicated by opening the following code in the editor, then switching to blocks and then switching back to JavaScript, and finally observing e.g. line number 764:

> **[Magic bossfight](https://arcade.makecode.com/S34918-44258-84875-59292)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Updates:

1. I am not sure if this recent topic about array trees is similar or related?  
[https://forum.makecode.com/t/arcade-throws-error-without-any-identifiable-source-in-blocks-after-creating-array-trees/16764](https://forum.makecode.com/t/arcade-throws-error-without-any-identifiable-source-in-blocks-after-creating-array-trees/16764)
2. I was expecting grey/black blocks with custom JavaScript code instead of this failed/not complete attempt at converting from JavaScript multidimensional arrays to array blocks.

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [December 7, 2022, 8:16pm UTC](https://forum.makecode.com/t/error-generic-type-array-t-requires-1-type-argument-s/16780/2 "2022-12-07T20:16:21Z")

</div>

Hm, I played around for a bit and got a min repro (slightly different end result, but I’m guessing it’s the same and it’s just specific details e.g. 2d arrays + slightly different usage that is resulting in a different badly generated type):

> **[min repro](https://arcade.makecode.com/54877-81433-43746-56842)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

It looks like it’s a bad interaction between typing of variable in gray block & type inference in arrays (also perhaps some further edge cases with fixedInstance sneaking in, as music.Melody is one of those); I’d have to poke around, definitely a bug but it’s also very much an edge case – e.g. in this case there’s no real reason not to fix this to not have gray blocks in the first place by defining a little helper function in custom.ts

```typescript

namespace myHelper {
    //% block
    export function whatIsThatMelody(a: string) {
        return new music.Melody(a);
    }
}

```

and it should work fine again:

> **[min repro](https://arcade.makecode.com/48571-14461-85142-19889)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Here’s magic bossfight with a block swapped in for the direct `new music.Melody()`

> **[Magic bossfight](https://arcade.makecode.com/S83132-71239-98201-32710)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

(also will go ahead and tag @richard in case he has different opinions on how important this is to prioritize a fix for~)

---

<div class="post-metadata">

**Author:** ![Vegz78](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vegz78/32/1201_2.png) [@Vegz78](https://forum.makecode.com/u/Vegz78)\
**Post date:** [December 7, 2022, 9:00pm UTC](https://forum.makecode.com/t/error-generic-type-array-t-requires-1-type-argument-s/16780/3 "2022-12-07T21:00:09Z")

</div>

Wow, that was quick and thorough, @jwunderl!!

Interesting, I thought it had something to do with the basic multidimensional array handling, and not type inference from the specific music.Melody, since it inferred `Array<T>[]`.

But I see the same now in your one dimensional example, where it infers `number[]`, and it works if manually set/hinted to `any[]` or `music.Melody[]`. So I guess the _inner_ array was the problem in the Magic Bossfight, and that this did not come up in the error message and/or I did not connect the dots…

Definitely edge for the time being, but maybe getting more mainstream now that @kwx has opened up pandoras’s box and shown us that it probably is possible to get near C64-quality music, and maybe even voice synthesis, in MakeCode with all the possibilities the envelopes give(programatically today and in the future with tools/extensions) and even more channels than the C64… 😉

So if the fix is small, it might be a good investment!

Anyhow:

1. Do you or I create the issue on GitHub, if this is really necessary now?
2. In the future, report stuff like this here or in an issue on GitHub. My impression is that it gets quicker @makecode response here and more community support, while they tend to drown away on GitHub…  
(…and here the users can more easily organize and gather around ad hoc user movements/campaigns, hehe…)

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [December 7, 2022, 9:36pm UTC](https://forum.makecode.com/t/error-generic-type-array-t-requires-1-type-argument-s/16780/4 "2022-12-07T21:36:36Z")

</div>

Whichever works fine, I personally watch issues on github more carefully than forum (in pxt-arcade repo at least) but questions / non-bugs probably get more attention overall here. Also fine to do both (just crossreference them in the posts) so that more people can see it / pile on if they’re facing the the same issue!

Feel free to file an issue on github / reference this thread if you do, though I’ll say I find it unlikely that it’s a particularly quick fix – it feels like it’s in the “edge case upon edge case” scenario where tracking down a proper fix might be tough, but it’s good to track the issue for sure.

re: playing good music, we do have the upcoming song editor as well 🙂 (richard and I played around with it here [https://www.youtube.com/watch?v=Tqs-m0RhoUM](https://www.youtube.com/watch?v=Tqs-m0RhoUM)) – I would suggest that if people really want to use any of those it’s best to make a quick extension wrapping it as gray blocks are always a bit annoying / it’s easy to make blocks 🙂

---

<div class="post-metadata">

**Author:** ![Vegz78](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vegz78/32/1201_2.png) [@Vegz78](https://forum.makecode.com/u/Vegz78)\
**Post date:** [December 8, 2022, 12:45am UTC](https://forum.makecode.com/t/error-generic-type-array-t-requires-1-type-argument-s/16780/5 "2022-12-08T00:45:36Z")

</div>

Thanks again and forgot to thank you for the specific fix of my son’s _Magic Bossfight_, as well, which I kludged up the blocks on, attempting to help him with a little music just before the multiplayer mini game jam deadline… 😉

On that note and good night from the old world:  
[Living on the edge](https://www.youtube.com/watch?v=9Jh5xAng3gM&t=78s)

---

<div class="post-metadata">

**Author:** ![Vegz78](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vegz78/32/1201_2.png) [@Vegz78](https://forum.makecode.com/u/Vegz78)\
**Post date:** [October 10, 2023, 4:33pm UTC](https://forum.makecode.com/t/error-generic-type-array-t-requires-1-type-argument-s/16780/6 "2023-10-10T16:33:09Z")

</div>

Filed:

> <https://github.com/microsoft/pxt-arcade/issues/6114>
>
> \*\*Describe the bug\*\*
> When switching from JavaScript to blocks, MakeCode generat…es the error \_Generic type 'Array\<T\>' requires 1 type argument(s)\_ when trying to convert multidimensional arrays of \_music.Melody\_ objects to blocks. The multidimensional arrays compile and run fine directly from JavaScript.
> 
> As discussed with @jwunderl on the forum here:
> https://forum.makecode.com/t/error-generic-type-array-t-requires-1-type-argument-s/16780
> 
> \*\*To Reproduce\*\*
> Full example with this error message if switched to blocks from JavaScript:
> https://arcade.makecode.com/S34918-44258-84875-59292
> 
> Minimum reproduction with error when switching to blocks from JavaScript(array of \_music.Melody()\_ is inferred as number):
> https://arcade.makecode.com/54877-81433-43746-56842
> 
> Minimum working reproduction with helper, which switches ok between JS and blocks:
> https://arcade.makecode.com/48571-14461-85142-19889
> 
> Helper function:
> \_namespace myHelper {
> //% block
> export function whatIsThatMelody(a: string) {
> return new music.Melody(a);
> }
> }\_
> 
> \*\*Expected behavior\*\*
> Either work correctly in or convert correctly to blocks from JavaScript, minimally as working grey blocks.
> 
> \*\*Desktop (please complete the following information):\*\*
> - OS: any
> - Browser: any
> - Version: any
> 
> \*\*Smartphone (please complete the following information):\*\*
> - Device: any
> - OS: any
> - Browser any
> - Version any

Sorry that I forgot to file it sooner, @jwunderl. I forgot.

Thanks again for all the help here!
