'Infer type from tuple contents

Say I have a generic tuple type:

type MyTuple<A, B> = [A, B]

The following works, because I give it the generic types:

const thing2: MyTuple<number, string> = [20, 'hello']

I want to use it like this, but it gives an error:

const thing1: MyTuple = [20, 'hello'] // -> Generic type 'MyTuple' requires 2 type argument(s).

I don't understand why it needs the generic args in this instance - I rarely have to specify the generic type when using map for example.

Code here.



Solution 1:[1]

You defined a generic type without default values.

MyTuple has no meaning without its 2 generic parameter.


type MyTuple<A = number, B = string> = [A, B]

const thing1: MyTuple = [20, 'hello']

This example works for example, but it's probably not what you were loooking for.

Solution 2:[2]

you can use ASP.Net Core Data Protection Keys configuring in your client Applications (i.e SiteA and SiteB).

Have a look at this. https://github.com/openiddict/openiddict-core/issues/1109

and this https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-3.1

hope this helps

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matthieu Riegler
Solution 2 YeYintNaing