Skip to content

Commit 41a3e59

Browse files
captbaritonecpojer
authored andcommitted
Adding missing attribute to GlobalConfig type (jestjs#6464)
When we assign a variable to the result of `Object.assign({}, ...)` the typing for that variable is lost. Therefore we were able to access `globalConfig.coveragePathIgnorePatterns` even though it didn't exist in the type. Commenting these `Object.assign` cases revealed the missing type property.
1 parent 951ec51 commit 41a3e59

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

packages/jest-cli/src/run_jest.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,11 @@ export default (async function runJest({
200200
);
201201

202202
if (collectCoverageFrom.length) {
203-
globalConfig = Object.freeze(
204-
Object.assign({}, globalConfig, {collectCoverageFrom}),
205-
);
203+
// $FlowFixMe Object.assign
204+
const newConfig: GlobalConfig = Object.assign({}, globalConfig, {
205+
collectCoverageFrom,
206+
});
207+
globalConfig = Object.freeze(newConfig);
206208
}
207209

208210
allTests = sequencer.sort(allTests);
@@ -247,9 +249,11 @@ export default (async function runJest({
247249
globalConfig.silent !== true &&
248250
globalConfig.verbose !== false
249251
) {
250-
globalConfig = Object.freeze(
251-
Object.assign({}, globalConfig, {verbose: true}),
252-
);
252+
// $FlowFixMe Object.assign
253+
const newConfig: GlobalConfig = Object.assign({}, globalConfig, {
254+
verbose: true,
255+
});
256+
globalConfig = Object.freeze(newConfig);
253257
}
254258

255259
// When using more than one context, make all printed paths relative to the

types/Config.js

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ export type GlobalConfig = {|
189189
collectCoverageFrom: Array<Glob>,
190190
collectCoverageOnlyFrom: ?{[key: string]: boolean},
191191
coverageDirectory: string,
192+
coveragePathIgnorePatterns?: Array<string>,
192193
coverageReporters: Array<string>,
193194
coverageThreshold: {global: {[key: string]: number}},
194195
detectLeaks: boolean,

0 commit comments

Comments
 (0)