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
However, this was the first time that there was even a distinction between a generic and non-generic class during inference to my knowledge. This likely means this has existed ever since the ability to infer a generic class has existed.
typeAnyConstructor=new(...args: any[])=>object;functionRenderFlagsMixin<BaseClassextendsAnyConstructor|undefined=undefined>(Base?: BaseClass,){};classContainer<T>{}// ^ Only happens when the class is generic.RenderFlagsMixin(Container)// ^ Argument of type 'typeof Container' is not assignable to parameter of type 'undefined'.
🙁 Actual behavior
BaseClass is inferred as undefined despite the call being the value Container.
🙂 Expected behavior
BaseClass should be inferred as typeof Container.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
It doesn't appear the t?: T is strictly necessary.
The traceback on 5.8.3 is:
TypeError: Cannot read properties of undefined (reading '0')
at getObjectTypeInstantiation (.data/TypeScript/lib/_tsc.js:62220:175)
at instantiateTypeWorker (.data/TypeScript/lib/_tsc.js:62479:16)
at instantiateTypeWithAlias (.data/TypeScript/lib/_tsc.js:62459:20)
at instantiateType (.data/TypeScript/lib/_tsc.js:62437:29)
at instantiateList (.data/TypeScript/lib/_tsc.js:62061:24)
at instantiateTypes (.data/TypeScript/lib/_tsc.js:62075:12)
at chooseOverload (.data/TypeScript/lib/_tsc.js:75485:39)
at resolveCall (.data/TypeScript/lib/_tsc.js:75253:16)
at resolveCallExpression (.data/TypeScript/lib/_tsc.js:75690:12)
at resolveSignature (.data/TypeScript/lib/_tsc.js:76118:16)
tsc when run alone will crash but tsc index.ts will not.
When running tsc index.ts it won't use your local tsconfig, so strictNullChecks has the default value (false). Without this flag the type undefined doesn't exist anymore.
🔎 Search Terms
class inference, optional class, broken inference
🕗 Version & Regression Information
This changed in PR #31116
However, this was the first time that there was even a distinction between a generic and non-generic class during inference to my knowledge. This likely means this has existed ever since the ability to infer a generic class has existed.
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBAggdiAwgezgZ2AJwK4GNjKZQC8UcEA7lABQB09AhpgOZoBcUDCA2gLoCUJAHxRkAIwBWEfAG4AUHIBm2OPgCWqKACUIcACYRMAMQA2DVgFk1ADzVwAPACEGaCIjNo0UCNeC69XvBIqBg4+IRQAD5QKgaKdhB6JDH6EPHkekLUclC5UM6uAPwcBW4eaAA0coIA3gC+8nK45VAocMAMCZj2ACoi9Qo6qcZmljZ21G0dXfxyAPRzeUvLeQB6sCzYALa6wKKKUKCQUADkRxDIB1Od5JgnUGpecMh7LmhqzHAMYibQBFBgJgMHZ+IiXQ7gaAnWJpBJ6E60IA
💻 Code
🙁 Actual behavior
BaseClass
is inferred asundefined
despite the call being the valueContainer
.🙂 Expected behavior
BaseClass
should be inferred astypeof Container
.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: