gajus / gajus/flow-runtime

flow-runtime ParameterType remember doesn't work with arrays

Open
#237 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
797
Forks
49
PR merge metrics
No merged PRs in 30d

Description

This is a:

- [X] Bug Report
- [ ] Feature Request
- [ ] Question
- [ ] Other

Which concerns:

- [X] flow-runtime
- [ ] babel-plugin-flow-runtime
- [ ] flow-runtime-validators
- [ ] flow-runtime-mobx
- [ ] flow-config-parser
- [ ] The documentation website

---

### What is the current behaviour?

````javascript
class TestClass {

do( ) {
const items : ValueType[] = JSON.parse( '[{ "a": null, "b": "b" }, { "a": "a", "b": null }]' );
console.log(items);
}

}

const testClass : TestClass = new TestClass();
testClass.do();
````
````
RuntimeTypeError: [1].a must be null
Expected: null
Actual Value: "a"
Actual Type: string
-------------------------------------------------
[1].b must be a string
Expected: string
Actual Value: null
Actual Type: null
````

---

### What is the expected behaviour?
Shall not throw an exception.

---

### Which package versions are you using?
````
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-decorators": "^7.4.4",
"@babel/preset-env": "^7.5.5",
"@babel/preset-flow": "^7.0.0",
"babel-plugin-flow-runtime": "^0.19.0",
"flow-runtime": "^0.17.0"
````
````javascript
{
"plugins": [
[ "flow-runtime", {
"assert": true,
"annotate": true
} ],
[ "@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true}],
"@babel/plugin-proposal-class-properties",
],
"presets": [
"@babel/preset-flow",
"@babel/preset-env",
]
}
````

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the supplied JavaScript example with the listed Babel, babel-plugin-flow-runtime, and flow-runtime versions, then trace ParameterType handling for the array annotation. Done means the example no longer throws a RuntimeTypeError for the parsed array values.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.