Skip to content

Replace only local type parameters with any when creating prototype property type of a class #57323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Feb 7, 2024

fixes #57317
this is different from #49863 - that PR likely still has a bug that I'm fixing here because it would replace the outer type parameter with its constraint

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 7, 2024
@@ -10701,7 +10701,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter.
// It is an error to explicitly declare a static property member with the name 'prototype'.
const classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)!) as InterfaceType;
return classType.typeParameters ? createTypeReference(classType as GenericType, map(classType.typeParameters, _ => anyType)) : classType;
return classType.localTypeParameters ? createTypeReference(classType as GenericType, concatenate(classType.outerTypeParameters, map(classType.localTypeParameters, _ => anyType))) : classType;
Copy link
Contributor Author

@Andarist Andarist Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this doesn't create any type parameter leak or something like this but so far I couldn't recognize any unintended side-effect like this here.

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Feb 16, 2024
@sandersn sandersn requested a review from weswigham February 16, 2024 14:08
…yify-only-local-type-params

# Conflicts:
#	tests/baselines/reference/accessorsOverrideProperty9.types
#	tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.types
#	tests/baselines/reference/anonClassDeclarationEmitIsAnon.types
#	tests/baselines/reference/baseConstraintOfDecorator.types
#	tests/baselines/reference/declarationEmitLocalClassDeclarationMixin.types
#	tests/baselines/reference/declarationEmitPrivateNameCausesError.types
#	tests/baselines/reference/doubleMixinConditionalTypeBaseClassWorks.types
#	tests/baselines/reference/emitClassExpressionInDeclarationFile.types
#	tests/baselines/reference/emitClassExpressionInDeclarationFile2.types
#	tests/baselines/reference/exportClassExtendingIntersection.types
#	tests/baselines/reference/mixinAbstractClasses.2.types
#	tests/baselines/reference/mixinAbstractClasses.types
#	tests/baselines/reference/mixinAbstractClassesReturnTypeInference.types
#	tests/baselines/reference/mixinClassesAnnotated.types
#	tests/baselines/reference/mixinClassesAnonymous.types
#	tests/baselines/reference/mixinIntersectionIsValidbaseType.types
#	tests/baselines/reference/mixinOverMappedTypeNoCrash.types
#	tests/baselines/reference/mixinPrivateAndProtected.types
#	tests/baselines/reference/mixingApparentTypeOverrides.types
#	tests/baselines/reference/noCrashOnMixin.types
#	tests/baselines/reference/overrideBaseIntersectionMethod.types
#	tests/baselines/reference/typeAliasFunctionTypeSharedSymbol.types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

Make instanceof narrow better using an anonymous class returned from a function
3 participants