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

No error for callback returned value wrong field #21869

Closed
artaommahe opened this issue Feb 11, 2018 · 2 comments
Closed

No error for callback returned value wrong field #21869

artaommahe opened this issue Feb 11, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@artaommahe
Copy link

TypeScript Version: 2.7.1

Code

interface IState {
  smth: string;
}

let state: IState = { smth: '' };

function update(callback: (state: IState) => IState): void {
  state = callback(state);
}

// no error here for wrong field
update(state => ({ ...state, smth2: '' }));
// and here too
update(state => ({ smth: '', smth2: '' }));

// this will mark an error
update(state => {
  state = { ...state, smth2: '' };
  return state;
});

Expected behavior:
Mark an error for wrong field

Actual behavior:
No error for wrong field

Playground Link:
https://stackblitz.com/edit/typescript-callback-return-type-error?file=index.ts

@ghost
Copy link

ghost commented Feb 11, 2018

Duplicate of #12632.

@ghost ghost added the Duplicate An existing issue was already created label Feb 11, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants