Skip to content
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

Regression in inference for keys of mapped type with empty object #22242

Closed
DanielRosenwasser opened this issue Feb 28, 2018 · 0 comments
Closed
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

interface Style {
  flashy: any;
}

declare function mergeStyleSets<K extends string>(
  ...cssSets: {[P in K]?: Style }[]): {[P in K]: Style };

// Expected:
//   let x: {
//       a: Style;
//       b: Style;
//   }
let x = mergeStyleSets(
  {},
  {
    a: { flashy: true },
  },
  {
    b: { flashy: true },
  },
)

This code currently causes an error, but previously would lead x to have the type { a: Style, b: Style }. Removing the {}` argument seems to restore the original behavior.

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Feb 28, 2018
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.8 milestone Feb 28, 2018
@DanielRosenwasser DanielRosenwasser changed the title Regression in inference for keys of mapped type Regression in inference for keys of mapped type with empty object Feb 28, 2018
@mhegazy mhegazy assigned weswigham and unassigned sandersn Feb 28, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 5, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants