-
-
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
chore: replace function types #10436
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,11 @@ | |
|
||
import chalk = require('chalk'); | ||
import prettyFormat = require('pretty-format'); | ||
import type {DeprecatedOptions} from 'jest-validate'; | ||
|
||
const format = (value: unknown) => prettyFormat(value, {min: true}); | ||
|
||
export default { | ||
const deprecatedOptions: DeprecatedOptions = { | ||
browser: () => ` Option ${chalk.bold( | ||
'"browser"', | ||
)} has been deprecated. Please install "browser-resolve" and use the "resolver" option in Jest configuration as follows: | ||
|
@@ -26,7 +27,7 @@ export default { | |
Please update your configuration.`, | ||
|
||
preprocessorIgnorePatterns: (options: { | ||
preprocessorIgnorePatterns: Array<string>; | ||
preprocessorIgnorePatterns?: Array<string>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While technically at runtime this isn't true (because whole logic is that these functions are being called when |
||
}) => ` Option ${chalk.bold( | ||
'"preprocessorIgnorePatterns"', | ||
)} was replaced by ${chalk.bold( | ||
|
@@ -43,7 +44,7 @@ export default { | |
Please update your configuration.`, | ||
|
||
scriptPreprocessor: (options: { | ||
scriptPreprocessor: string; | ||
scriptPreprocessor?: string; | ||
}) => ` Option ${chalk.bold( | ||
'"scriptPreprocessor"', | ||
)} was replaced by ${chalk.bold( | ||
|
@@ -60,7 +61,7 @@ export default { | |
Please update your configuration.`, | ||
|
||
setupTestFrameworkScriptFile: (_options: { | ||
setupTestFrameworkScriptFile: Array<string>; | ||
setupTestFrameworkScriptFile?: string; | ||
}) => ` Option ${chalk.bold( | ||
'"setupTestFrameworkScriptFile"', | ||
)} was replaced by configuration ${chalk.bold( | ||
|
@@ -70,7 +71,7 @@ export default { | |
Please update your configuration.`, | ||
|
||
testPathDirs: (options: { | ||
testPathDirs: Array<string>; | ||
testPathDirs?: Array<string>; | ||
}) => ` Option ${chalk.bold('"testPathDirs"')} was replaced by ${chalk.bold( | ||
'"roots"', | ||
)}. | ||
|
@@ -82,4 +83,6 @@ export default { | |
|
||
Please update your configuration. | ||
`, | ||
} as Record<string, Function>; | ||
}; | ||
|
||
export default deprecatedOptions; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,7 +11,9 @@ type Title = { | |||||
warning?: string; | ||||||
}; | ||||||
|
||||||
export type DeprecatedOptions = Record<string, Function>; | ||||||
export type DeprecatedOptionFunc = (arg: Record<string, any>) => string; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iirc no because then TS knows too much and would force us to properly type the deprecated types too - I think a good way to make this change would be to do it after the latest deprecated options are removed, so to require all future deprecated options to be more accurately typed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good 👍 |
||||||
|
||||||
export type DeprecatedOptions = Record<string, DeprecatedOptionFunc>; | ||||||
|
||||||
export type ValidationOptions = { | ||||||
comment?: string; | ||||||
|
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.
is this in
package.json
?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.
Yup :)