You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior: super(p) in HappyPerson's constructor should compile successfully. Actual behavior:
ts complains "No overload matches this call."
Though it can be fixed by replacing super(p) with
if(pinstanceofPerson){super(p)}else{super(p)}
But this feels strictly redundant.
I'm pretty sure there is already some ticket that described this, but I couldn't find it using the search term. Hope someone could link to it and I will close this one as a duplicate.
Also, having to use happiness! doesn't feel right, since it should be possible to deduce from the overloads that since p is a SadPerson, happiness can't be undefined.
Not sure if it relates to #22609, since this one is about optional parameters.
TypeScript Version: 4.1.2
Search Terms: polymorphism union
Code
Expected behavior:
super(p)
inHappyPerson
's constructor should compile successfully.Actual behavior:
ts complains "No overload matches this call."
Though it can be fixed by replacing
super(p)
withBut this feels strictly redundant.
I'm pretty sure there is already some ticket that described this, but I couldn't find it using the search term. Hope someone could link to it and I will close this one as a duplicate.
Playground Link:
https://www.typescriptlang.org/play?#code/IYIwzgLgTsDGEAJYBthjAgCgUymA9gHYIDeAUAgocALbYBcCA2pFAJaEDmANAqx5wC6ZCkiKsArvHxQAFAAdGOPEQCUo2OOhSIMhYxLU6jflwC+6ypsKTpcxVlwFiAH1JGGfaAIulRlNgAzBAUEDkhgQlhsfGDlZ1U-SmSECAALNjAAOg8EAF4EeRzabH8EMwRsZDBsJJSEZGxEeWAoCAwCoo8ssHlkNghZAHoAHTAAaiHLevTM4rp85ha2sCYABkEEFzcAIh3eZfamAEZN7YQ94RSzURubshQ0DABlYAATeKJKgA8IbEI3hhPsRyJQwO9CNh0IxCBIaCBcBotFAdHoHIYSiZvOZeOC3pDoVQ4QioIlQckwBJ5LgFNNKLNsniCR0+BCoWBbhooABPWRksrWAiNLLIfCcWQ7WA8gQ7aZ3ESPdAIAASwHk8m5wJ+fwBQKcX3JaTV8g47JhxMRVmRqPsjFeH31hGmgu0dn07kxXnYOIQRvVpsJsPhuGd1rdDntWrcGOMXp8vD9JuZAH5zcHSXUwVSafI6akMtlEwGWfIwjYIJForEEJHHQhkwgALRFJnshCMIvMgCEnLBNDYjT5mbENnwwtF4p2YH7-S4ss5ZiAA
Related Issues:
The text was updated successfully, but these errors were encountered: