We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I would expect the following code to pass with no errors.
interface Baz { baz: string; } interface Foo extends Baz { bar: number; } const foo: Foo = {bar: 2, baz: ''}; const qux: Foo = {...foo};
However, it fails on the last line with
^ Cannot assign object literal to `qux` because property `baz` is missing in object literal [1] but exists in `Baz` [2].
I see comparable behaviour with Object.freeze and Object.assign.
Object.freeze
Object.assign
Recreate: https://flow.org/try/#0JYOwLgpgTgZghgYwgAgEJwF7IN4ChnIBGmAXMgM5hSgDmA3LgL666iSyIoBiA9j8hAAekEABNyaTDmT4icKGRABXALaFoDZrgQ8QlZDD5le-ALw5iC5ACYANHIxkA5E8YMdesMgCOSwcb5kc2wAOjDDHjcCaOigA
The text was updated successfully, but these errors were encountered:
I have seen similar issues concerning the spread operator in this repo, but they seem to focus on 'exact objects' and don't talk about interfaces.
Sorry, something went wrong.
FWIW, replacing the last line with this works:
const objectSafeClone: <S>(S) => S = function cloner<T>(o: T): T { return {...o}; }; const qux: Foo = objectSafeClone(foo);
No branches or pull requests
I would expect the following code to pass with no errors.
However, it fails on the last line with
I see comparable behaviour with
Object.freeze
andObject.assign
.Recreate: https://flow.org/try/#0JYOwLgpgTgZghgYwgAgEJwF7IN4ChnIBGmAXMgM5hSgDmA3LgL666iSyIoBiA9j8hAAekEABNyaTDmT4icKGRABXALaFoDZrgQ8QlZDD5le-ALw5iC5ACYANHIxkA5E8YMdesMgCOSwcb5kc2wAOjDDHjcCaOigA
The text was updated successfully, but these errors were encountered: