-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Audit @flow and "use strict" #3451
Conversation
I reverted the removal of "use strict" from test and mock files. These files will not be processed by babel during the execution of integration tests, and will cause them to fail for Node 4 which does not permit the use of block-scoped declarations (let) outside of strict mode. |
Codecov Report
@@ Coverage Diff @@
## master #3451 +/- ##
==========================================
+ Coverage 62.28% 62.39% +0.11%
==========================================
Files 181 181
Lines 6714 6646 -68
Branches 6 6
==========================================
- Hits 4182 4147 -35
+ Misses 2529 2496 -33
Partials 3 3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good! I think we could further improve types in Jasmine, but maybe not in this diff. Also @wtgtybhertgeghgtwtg is probably working on that already.
|
||
function ReportDispatcher(methods) { | ||
function ReportDispatcher(methods: Object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
methods are an array, could you improve this type?
var result = true; | ||
|
||
var asymmetricResult = asymmetricMatch(a, b); | ||
if (!isUndefined(asymmetricResult)) { | ||
if (asymmetricResult !== void 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined
maybe?
Thanks @thymikee! I updated my pull request as per your suggestions. On a related note, would it be acceptable if I rebase my branch on top of jest/master while pull request is open? |
Of course it is acceptable! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just this one change and I can approve this :)
package.json
Outdated
@@ -14,6 +14,7 @@ | |||
"babel-preset-env": "^1.4.0", | |||
"babel-preset-react": "^6.24.1", | |||
"babel-preset-react-native": "^1.9.1", | |||
"babel-plugin-transform-strict-mode": "^6.22.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use version 6.24.1
? We already have that in our transitive deps (see yarn.lock
)
Generated by 🚫 dangerJS |
* 'use strict' removed from pacakges' sources * Strict mode is now enabled automatically by babel * 'use strict' check removed from dangerfile * Updated contributing guidelines
The node 7.3 thing, I don't care any more. That was reverted and we don't need it. We can tell people to either downgrade Jest or upgrade node if it happens. |
* Remove 'use strict' from all files * 'use strict' removed from pacakges' sources * Strict mode is now enabled automatically by babel * 'use strict' check removed from dangerfile * Updated contributing guidelines * Enable @flow for most files * Commit yarn.lock * Revert removal of "use strict" in test and mock files * Improve annotations for ReportDispatcher * Replace "void 0" with "undefined" * Update babel-plugin-transform-strict-mode to match transitive deps
* Remove 'use strict' from all files * 'use strict' removed from pacakges' sources * Strict mode is now enabled automatically by babel * 'use strict' check removed from dangerfile * Updated contributing guidelines * Enable @flow for most files * Commit yarn.lock * Revert removal of "use strict" in test and mock files * Improve annotations for ReportDispatcher * Replace "void 0" with "undefined" * Update babel-plugin-transform-strict-mode to match transitive deps
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
These changes address the proposal from #3169
Summary
transform-strict-mode
babel plugin.In regards to the use of "use strict" there remains to be an issue with following file:
https://github.com/facebook/jest/blob/master/packages/jest-util/src/setGlobal.js
Babel plugin is going to add "use strict" annotation to the compiled file which will break unit tests for Node 7.3.
Following files were left without @flow annotations. As far as I know typechecking them would require some changes to the codebase which I was hesitant to introduce without explicit instructions.
https://github.com/facebook/jest/blob/master/packages/jest-config/src/vendor/jsonlint.js
https://github.com/facebook/jest/blob/master/packages/jest-jasmine2/src/jasmine/createSpy.js
https://github.com/facebook/jest/blob/master/packages/jest-jasmine2/src/jasmine/Env.js
Test plan
Verify that typechecking produces no errors:
Find files processible by babel with "use strict" (should be no files)
Find package source files without @flow