-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Big UnionsThe root cause is ultimately that big unions interact poorly with complex structuresThe root cause is ultimately that big unions interact poorly with complex structuresRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
TypeScript Version: 3.4.0-dev.20190216
Search Terms: hang higher order union strictFunctionTypes
Code
Note that this code has compilation errors, but that's not important. When invoking tsc or loading in an editor that uses tsserver, the compilation hangs/never completes.
import * as React from "react";
const animated: {
[Tag in keyof JSX.IntrinsicElements]: React.ForwardRefExoticComponent<
React.ComponentPropsWithRef<Tag>
>
} = {};
function makeAnimated<T extends React.ReactType>(
comp: T
): React.ForwardRefExoticComponent<React.ComponentPropsWithRef<T>> {
return null as any; // not important
}
export interface UpgradedProps {
show: boolean;
}
export function test<P>(
component: React.ComponentType<P> | keyof React.ReactHTML
): React.ComponentType<P & UpgradedProps> {
// changing to `const Comp: any` un-hangs tsserver
const Comp =
typeof component === "string"
? animated[component]
: makeAnimated(component);
return React.forwardRef<any, P & UpgradeProps>((props, ref) => {
const { show, ...ownProps } = props; // addition of this line causes the hang
return show ? <Comp {...ownProps} ref={ref} /> : null;
});
}Expected behavior:
Compilation completes (optionally with errors).
Actual behavior:
Compilation hangs.
Repro Link: https://github.com/jgoz/typescript-bug
Related Issues: Didn't find anything recent
Fonger, LuigiClaudio, aleclarson, fforres, alexandrudanpop and 6 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Big UnionsThe root cause is ultimately that big unions interact poorly with complex structuresThe root cause is ultimately that big unions interact poorly with complex structuresRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone