flow error pass object w/ extra properties than parameter needs
up vote
0
down vote
favorite
I have the following code where defining a getByIds function that filters an array of objects, each of which has an id field and other fields.
// @flow
type X = {
id: string
};
type F = (Array<string>, Array<X>) => Array<X>;
import { curry } from "ramda";
const getByIds: F = curry((ids, xs) => xs.filter(x => ids.includes(x.id)));
export default getByIds;
when feeding a user = {id: 123, alias: 'foo'} to
getByIds
, flow warns that X doesn't have property alias
. I thought flow allows extra properties (covariant?) to be attached to object of a less restricting type.
Here is the eslintrc.js
module.exports = {
env: {
// browser: true ensures things like window, or localStorage won't get complained
browser: true,
es6: true
},
plugins: [
"react",
"flowtype"
// "prettier",
],
extends: [
"eslint:recommended",
// "plugin:react/recommended",
"plugin:flowtype/recommended"
],
// https://github.com/feross/standard/issues/447
parser: "babel-eslint",
parserOptions: {
ecmaFeatures: {
modules: true,
classes: true,
experimentalObjectRestSpread: true,
jsx: true
},
sourceType: "module"
},
rules: {
// "indent": [
// "error",
// 4
// ],
// "prettier/prettier": "error",
"linebreak-style": ["error", "unix"],
// "quotes": [
// "error",
// "double"
// ],
// "semi": [
// "error",
// "never"
// ],
// "jsx-space-before-closing": 1,
// "no-undef": "error",
"no-unused-vars": [2, { argsIgnorePattern: "_" }], //https://eslint.org/docs/rules/no-unused-vars#argsignorepattern
"flowtype/define-flow-type": 1,
"comma-dangle": [1, "always-multiline"],
"always-multiline": 0,
"no-console": 0,
"no-constant-condition": 0,
"no-case-declarations": 0,
"react/no-danger": 0,
"react/display-name": 1,
"react/jsx-key": 1,
"react/jsx-no-comment-textnodes": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-target-blank": 1,
"react/jsx-no-undef": 1,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-children-prop": 1,
"react/no-danger-with-children": 1,
"react/no-deprecated": 1,
"react/no-direct-mutation-state": 1,
"react/no-find-dom-node": 1,
"react/no-is-mounted": 1,
"react/no-render-return-value": 1,
"react/no-string-refs": 1,
"react/no-unescaped-entities": 1,
"react/no-unknown-property": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/require-render-return": 1,
"react/jsx-max-props-per-line": 1,
"react/jsx-first-prop-new-line": [1, "multiline-multiprop"],
"react/jsx-indent-props": [1, 2]
},
globals: {
module: true,
gon: true,
require: true,
__dirname: true,
_: true,
jest: true,
process: true,
it: true,
describe: true,
expect: true,
test: true,
SyntheticEvent: true,
SyntheticAnimationEvent: true,
SyntheticClipboardEvent: true,
SyntheticCompositionEvent: true,
SyntheticInputEvent: true,
SyntheticUIEvent: true,
SyntheticFocusEvent: true,
SyntheticKeyboardEvent: true,
SyntheticMouseEvent: true,
SyntheticDragEvent: true,
SyntheticWheelEvent: true,
SyntheticTouchEvent: true,
SyntheticTransitionEvent: true
},
settings: {
flowtype: {
onlyFilesWithFlowAnnotation: true
}
}
};
Any ideas?
flowtype
add a comment |
up vote
0
down vote
favorite
I have the following code where defining a getByIds function that filters an array of objects, each of which has an id field and other fields.
// @flow
type X = {
id: string
};
type F = (Array<string>, Array<X>) => Array<X>;
import { curry } from "ramda";
const getByIds: F = curry((ids, xs) => xs.filter(x => ids.includes(x.id)));
export default getByIds;
when feeding a user = {id: 123, alias: 'foo'} to
getByIds
, flow warns that X doesn't have property alias
. I thought flow allows extra properties (covariant?) to be attached to object of a less restricting type.
Here is the eslintrc.js
module.exports = {
env: {
// browser: true ensures things like window, or localStorage won't get complained
browser: true,
es6: true
},
plugins: [
"react",
"flowtype"
// "prettier",
],
extends: [
"eslint:recommended",
// "plugin:react/recommended",
"plugin:flowtype/recommended"
],
// https://github.com/feross/standard/issues/447
parser: "babel-eslint",
parserOptions: {
ecmaFeatures: {
modules: true,
classes: true,
experimentalObjectRestSpread: true,
jsx: true
},
sourceType: "module"
},
rules: {
// "indent": [
// "error",
// 4
// ],
// "prettier/prettier": "error",
"linebreak-style": ["error", "unix"],
// "quotes": [
// "error",
// "double"
// ],
// "semi": [
// "error",
// "never"
// ],
// "jsx-space-before-closing": 1,
// "no-undef": "error",
"no-unused-vars": [2, { argsIgnorePattern: "_" }], //https://eslint.org/docs/rules/no-unused-vars#argsignorepattern
"flowtype/define-flow-type": 1,
"comma-dangle": [1, "always-multiline"],
"always-multiline": 0,
"no-console": 0,
"no-constant-condition": 0,
"no-case-declarations": 0,
"react/no-danger": 0,
"react/display-name": 1,
"react/jsx-key": 1,
"react/jsx-no-comment-textnodes": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-target-blank": 1,
"react/jsx-no-undef": 1,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-children-prop": 1,
"react/no-danger-with-children": 1,
"react/no-deprecated": 1,
"react/no-direct-mutation-state": 1,
"react/no-find-dom-node": 1,
"react/no-is-mounted": 1,
"react/no-render-return-value": 1,
"react/no-string-refs": 1,
"react/no-unescaped-entities": 1,
"react/no-unknown-property": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/require-render-return": 1,
"react/jsx-max-props-per-line": 1,
"react/jsx-first-prop-new-line": [1, "multiline-multiprop"],
"react/jsx-indent-props": [1, 2]
},
globals: {
module: true,
gon: true,
require: true,
__dirname: true,
_: true,
jest: true,
process: true,
it: true,
describe: true,
expect: true,
test: true,
SyntheticEvent: true,
SyntheticAnimationEvent: true,
SyntheticClipboardEvent: true,
SyntheticCompositionEvent: true,
SyntheticInputEvent: true,
SyntheticUIEvent: true,
SyntheticFocusEvent: true,
SyntheticKeyboardEvent: true,
SyntheticMouseEvent: true,
SyntheticDragEvent: true,
SyntheticWheelEvent: true,
SyntheticTouchEvent: true,
SyntheticTransitionEvent: true
},
settings: {
flowtype: {
onlyFilesWithFlowAnnotation: true
}
}
};
Any ideas?
flowtype
yes, it's legit to have extra properties until you are using exact object types. Since flow sandbox also shows no errors/warnings I suppose there is something in config that make it behave in more strict way
– skyboyer
Nov 9 at 20:59
@skyboyer thanks, its eslint with flow that's complaining. will write back if I find some settings that account for this error message.
– Nik So
Nov 10 at 15:45
do you use eslint-plugin-flowtype to integrate them together?
– skyboyer
Nov 10 at 19:04
@skyboyer Yes, I do. I updated the original post with myeslintrc.js
– Nik So
Nov 12 at 13:24
I'm not sure why it's going this way. there is require-exact-type configuration entry that looks like has'always'
value by default. But your types are not exact... and it looks like plugin is fine with that.
– skyboyer
Nov 12 at 14:00
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have the following code where defining a getByIds function that filters an array of objects, each of which has an id field and other fields.
// @flow
type X = {
id: string
};
type F = (Array<string>, Array<X>) => Array<X>;
import { curry } from "ramda";
const getByIds: F = curry((ids, xs) => xs.filter(x => ids.includes(x.id)));
export default getByIds;
when feeding a user = {id: 123, alias: 'foo'} to
getByIds
, flow warns that X doesn't have property alias
. I thought flow allows extra properties (covariant?) to be attached to object of a less restricting type.
Here is the eslintrc.js
module.exports = {
env: {
// browser: true ensures things like window, or localStorage won't get complained
browser: true,
es6: true
},
plugins: [
"react",
"flowtype"
// "prettier",
],
extends: [
"eslint:recommended",
// "plugin:react/recommended",
"plugin:flowtype/recommended"
],
// https://github.com/feross/standard/issues/447
parser: "babel-eslint",
parserOptions: {
ecmaFeatures: {
modules: true,
classes: true,
experimentalObjectRestSpread: true,
jsx: true
},
sourceType: "module"
},
rules: {
// "indent": [
// "error",
// 4
// ],
// "prettier/prettier": "error",
"linebreak-style": ["error", "unix"],
// "quotes": [
// "error",
// "double"
// ],
// "semi": [
// "error",
// "never"
// ],
// "jsx-space-before-closing": 1,
// "no-undef": "error",
"no-unused-vars": [2, { argsIgnorePattern: "_" }], //https://eslint.org/docs/rules/no-unused-vars#argsignorepattern
"flowtype/define-flow-type": 1,
"comma-dangle": [1, "always-multiline"],
"always-multiline": 0,
"no-console": 0,
"no-constant-condition": 0,
"no-case-declarations": 0,
"react/no-danger": 0,
"react/display-name": 1,
"react/jsx-key": 1,
"react/jsx-no-comment-textnodes": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-target-blank": 1,
"react/jsx-no-undef": 1,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-children-prop": 1,
"react/no-danger-with-children": 1,
"react/no-deprecated": 1,
"react/no-direct-mutation-state": 1,
"react/no-find-dom-node": 1,
"react/no-is-mounted": 1,
"react/no-render-return-value": 1,
"react/no-string-refs": 1,
"react/no-unescaped-entities": 1,
"react/no-unknown-property": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/require-render-return": 1,
"react/jsx-max-props-per-line": 1,
"react/jsx-first-prop-new-line": [1, "multiline-multiprop"],
"react/jsx-indent-props": [1, 2]
},
globals: {
module: true,
gon: true,
require: true,
__dirname: true,
_: true,
jest: true,
process: true,
it: true,
describe: true,
expect: true,
test: true,
SyntheticEvent: true,
SyntheticAnimationEvent: true,
SyntheticClipboardEvent: true,
SyntheticCompositionEvent: true,
SyntheticInputEvent: true,
SyntheticUIEvent: true,
SyntheticFocusEvent: true,
SyntheticKeyboardEvent: true,
SyntheticMouseEvent: true,
SyntheticDragEvent: true,
SyntheticWheelEvent: true,
SyntheticTouchEvent: true,
SyntheticTransitionEvent: true
},
settings: {
flowtype: {
onlyFilesWithFlowAnnotation: true
}
}
};
Any ideas?
flowtype
I have the following code where defining a getByIds function that filters an array of objects, each of which has an id field and other fields.
// @flow
type X = {
id: string
};
type F = (Array<string>, Array<X>) => Array<X>;
import { curry } from "ramda";
const getByIds: F = curry((ids, xs) => xs.filter(x => ids.includes(x.id)));
export default getByIds;
when feeding a user = {id: 123, alias: 'foo'} to
getByIds
, flow warns that X doesn't have property alias
. I thought flow allows extra properties (covariant?) to be attached to object of a less restricting type.
Here is the eslintrc.js
module.exports = {
env: {
// browser: true ensures things like window, or localStorage won't get complained
browser: true,
es6: true
},
plugins: [
"react",
"flowtype"
// "prettier",
],
extends: [
"eslint:recommended",
// "plugin:react/recommended",
"plugin:flowtype/recommended"
],
// https://github.com/feross/standard/issues/447
parser: "babel-eslint",
parserOptions: {
ecmaFeatures: {
modules: true,
classes: true,
experimentalObjectRestSpread: true,
jsx: true
},
sourceType: "module"
},
rules: {
// "indent": [
// "error",
// 4
// ],
// "prettier/prettier": "error",
"linebreak-style": ["error", "unix"],
// "quotes": [
// "error",
// "double"
// ],
// "semi": [
// "error",
// "never"
// ],
// "jsx-space-before-closing": 1,
// "no-undef": "error",
"no-unused-vars": [2, { argsIgnorePattern: "_" }], //https://eslint.org/docs/rules/no-unused-vars#argsignorepattern
"flowtype/define-flow-type": 1,
"comma-dangle": [1, "always-multiline"],
"always-multiline": 0,
"no-console": 0,
"no-constant-condition": 0,
"no-case-declarations": 0,
"react/no-danger": 0,
"react/display-name": 1,
"react/jsx-key": 1,
"react/jsx-no-comment-textnodes": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-target-blank": 1,
"react/jsx-no-undef": 1,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-children-prop": 1,
"react/no-danger-with-children": 1,
"react/no-deprecated": 1,
"react/no-direct-mutation-state": 1,
"react/no-find-dom-node": 1,
"react/no-is-mounted": 1,
"react/no-render-return-value": 1,
"react/no-string-refs": 1,
"react/no-unescaped-entities": 1,
"react/no-unknown-property": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/require-render-return": 1,
"react/jsx-max-props-per-line": 1,
"react/jsx-first-prop-new-line": [1, "multiline-multiprop"],
"react/jsx-indent-props": [1, 2]
},
globals: {
module: true,
gon: true,
require: true,
__dirname: true,
_: true,
jest: true,
process: true,
it: true,
describe: true,
expect: true,
test: true,
SyntheticEvent: true,
SyntheticAnimationEvent: true,
SyntheticClipboardEvent: true,
SyntheticCompositionEvent: true,
SyntheticInputEvent: true,
SyntheticUIEvent: true,
SyntheticFocusEvent: true,
SyntheticKeyboardEvent: true,
SyntheticMouseEvent: true,
SyntheticDragEvent: true,
SyntheticWheelEvent: true,
SyntheticTouchEvent: true,
SyntheticTransitionEvent: true
},
settings: {
flowtype: {
onlyFilesWithFlowAnnotation: true
}
}
};
Any ideas?
flowtype
flowtype
edited Nov 12 at 13:25
asked Nov 9 at 19:25
Nik So
7,155196299
7,155196299
yes, it's legit to have extra properties until you are using exact object types. Since flow sandbox also shows no errors/warnings I suppose there is something in config that make it behave in more strict way
– skyboyer
Nov 9 at 20:59
@skyboyer thanks, its eslint with flow that's complaining. will write back if I find some settings that account for this error message.
– Nik So
Nov 10 at 15:45
do you use eslint-plugin-flowtype to integrate them together?
– skyboyer
Nov 10 at 19:04
@skyboyer Yes, I do. I updated the original post with myeslintrc.js
– Nik So
Nov 12 at 13:24
I'm not sure why it's going this way. there is require-exact-type configuration entry that looks like has'always'
value by default. But your types are not exact... and it looks like plugin is fine with that.
– skyboyer
Nov 12 at 14:00
add a comment |
yes, it's legit to have extra properties until you are using exact object types. Since flow sandbox also shows no errors/warnings I suppose there is something in config that make it behave in more strict way
– skyboyer
Nov 9 at 20:59
@skyboyer thanks, its eslint with flow that's complaining. will write back if I find some settings that account for this error message.
– Nik So
Nov 10 at 15:45
do you use eslint-plugin-flowtype to integrate them together?
– skyboyer
Nov 10 at 19:04
@skyboyer Yes, I do. I updated the original post with myeslintrc.js
– Nik So
Nov 12 at 13:24
I'm not sure why it's going this way. there is require-exact-type configuration entry that looks like has'always'
value by default. But your types are not exact... and it looks like plugin is fine with that.
– skyboyer
Nov 12 at 14:00
yes, it's legit to have extra properties until you are using exact object types. Since flow sandbox also shows no errors/warnings I suppose there is something in config that make it behave in more strict way
– skyboyer
Nov 9 at 20:59
yes, it's legit to have extra properties until you are using exact object types. Since flow sandbox also shows no errors/warnings I suppose there is something in config that make it behave in more strict way
– skyboyer
Nov 9 at 20:59
@skyboyer thanks, its eslint with flow that's complaining. will write back if I find some settings that account for this error message.
– Nik So
Nov 10 at 15:45
@skyboyer thanks, its eslint with flow that's complaining. will write back if I find some settings that account for this error message.
– Nik So
Nov 10 at 15:45
do you use eslint-plugin-flowtype to integrate them together?
– skyboyer
Nov 10 at 19:04
do you use eslint-plugin-flowtype to integrate them together?
– skyboyer
Nov 10 at 19:04
@skyboyer Yes, I do. I updated the original post with my
eslintrc.js
– Nik So
Nov 12 at 13:24
@skyboyer Yes, I do. I updated the original post with my
eslintrc.js
– Nik So
Nov 12 at 13:24
I'm not sure why it's going this way. there is require-exact-type configuration entry that looks like has
'always'
value by default. But your types are not exact... and it looks like plugin is fine with that.– skyboyer
Nov 12 at 14:00
I'm not sure why it's going this way. there is require-exact-type configuration entry that looks like has
'always'
value by default. But your types are not exact... and it looks like plugin is fine with that.– skyboyer
Nov 12 at 14:00
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232128%2fflow-error-pass-object-w-extra-properties-than-parameter-needs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232128%2fflow-error-pass-object-w-extra-properties-than-parameter-needs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
yes, it's legit to have extra properties until you are using exact object types. Since flow sandbox also shows no errors/warnings I suppose there is something in config that make it behave in more strict way
– skyboyer
Nov 9 at 20:59
@skyboyer thanks, its eslint with flow that's complaining. will write back if I find some settings that account for this error message.
– Nik So
Nov 10 at 15:45
do you use eslint-plugin-flowtype to integrate them together?
– skyboyer
Nov 10 at 19:04
@skyboyer Yes, I do. I updated the original post with my
eslintrc.js
– Nik So
Nov 12 at 13:24
I'm not sure why it's going this way. there is require-exact-type configuration entry that looks like has
'always'
value by default. But your types are not exact... and it looks like plugin is fine with that.– skyboyer
Nov 12 at 14:00