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

typeof does not preserve exactness of an object #7853

Open
kangax opened this issue Jun 26, 2019 · 2 comments
Open

typeof does not preserve exactness of an object #7853

kangax opened this issue Jun 26, 2019 · 2 comments
Labels
bug Typing: object model Typing: soundness No false negatives (type checker claims that there is no error in the incorrect program)

Comments

@kangax
Copy link

kangax commented Jun 26, 2019

const initialState = { loading: false, loaded: false };
type State = typeof initialState;

// type State = $Exact<typeof initialState>; // <-- doesn't work either
// type State = {| ...typeof initialState |} // <-- doesn't work either

const f: (state: State) => State = state => {
  return {
    loading: true,
    loaded: true,
    nice: ""
  };
};

Flow version: 0.102.0

Expected behavior

It should error out on an extra property return from a function. Note that this works as expected in version 0.80 but not after.

Actual behavior

There is no error

https://flow.org/try/#0PTAEAEDMBsHsHcBQiDGsB2BnALqAluntngIbQDK2J2ApqALygDeocJAJgQOYBcokZTDQA0rWBxrs+A6ENABfANzJsATwAOdStTqM1m2JHyFiZbbWWoMOfnwAUOHX3M0AlAwB8oFw1CPansyIoKAATjTYAK6h6EEhIWyc6Lyg2KGRIsHxiZJ8aRnCWSGEKDR8AETlWUqINUA

@goodmind
Copy link
Contributor

Related #7526

@goodmind
Copy link
Contributor

Still an issue in 0.105.2

@goodmind goodmind added the Typing: soundness No false negatives (type checker claims that there is no error in the incorrect program) label Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Typing: object model Typing: soundness No false negatives (type checker claims that there is no error in the incorrect program)
Projects
None yet
Development

No branches or pull requests

2 participants