Skip to content

Fix mapped type instantiation circularity #46586

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

Merged
merged 3 commits into from
Oct 29, 2021
Merged

Fix mapped type instantiation circularity #46586

merged 3 commits into from
Oct 29, 2021

Conversation

ahejlsberg
Copy link
Member

Fixes #46582.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Oct 29, 2021
@ahejlsberg
Copy link
Member Author

@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 29, 2021

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 7dc887f. You can monitor the build here.

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

Nice find 🪐

Comment on lines +16575 to +16576
if (isArrayType(t) || t.flags & TypeFlags.Any && findResolutionCycleStartIndex(typeVariable, TypeSystemPropertyName.ImmediateBaseConstraint) < 0 &&
(constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, or(isArrayType, isTupleType))) {
Copy link
Member

@DanielRosenwasser DanielRosenwasser Oct 29, 2021

Choose a reason for hiding this comment

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

One day, we should find an easy/reusable way to easily ask "is this true *assuming that there are no circularities?"

Today is not that day.

Comment on lines 58 to 64
export type Evolvable<E extends Evolver> = {
[P in keyof E]: never;
};
export type Evolver<T extends Evolvable<any> = any> = {
[key in keyof Partial<T>]: never;
};

Copy link
Member

Choose a reason for hiding this comment

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

Can you remove the export here, or make all of the types exported? This turned off .d.ts emit for the rest of the file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@ahejlsberg
Copy link
Member Author

DT tests look good, error in ramda is now gone.

@ahejlsberg ahejlsberg merged commit b0ab2a5 into main Oct 29, 2021
@ahejlsberg ahejlsberg deleted the fix46582 branch October 29, 2021 21:01
mprobst pushed a commit to mprobst/TypeScript that referenced this pull request Jan 10, 2022
* Don't obtain constraint if doing so would cause circularity

* Add regression test

* Address CR feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#46218 breaks ramda types on DT
5 participants