Skip to content

3.5 regression concerning type inference for non-inferable types #31735

Description

TypeScript Version: typescript@3.6.0-dev.20190603

Search Terms:
3.5, infer

Code

// mocked CssProperties typetypeCssProperties={position: "absolute"|"relative"};typeStylesObject<ClassKeyextendsstring>=Record<ClassKey,CssProperties>;typePropsBasedstyles<ClassKeyextendsstring,Propsextendsobject>=(props: Props)=>StylesObject<ClassKey>;typeStyles<ClassKeyextendsstring,Propsextendsobject>=|StylesObject<ClassKey>|PropsBasedstyles<ClassKey,Props>;functioncreateStyles<ClassKeyextendsstring,Propsextendsobject>(styles: Styles<ClassKey,Props>): Styles<ClassKey,Props>{returnstyles;}conststyles=createStyles({root: {position: "absolute"}});

Expected behavior:
Behavior in 3.4.5
typeof styles = Styles<'root', {}>

Actual behavior:
Behavior in >=3.5.0
typeof styles = Styles<'root', object>

Playground Link:
playground

Related Issues: Did not find any

Notes:

Seems like the playground is still using 3.4.

Usage of this behavior is showcased in https://github.com/eps1lon/ts-inference-3.5/blob/master/index.ts with a fix for 3.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions