Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: clean up types in jest.setup.ts#4285

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jsjoeio merged 1 commit intomainfromjsjoeio/eslint-cleanups
Oct 4, 2022

Conversation

jsjoeio
Copy link
Contributor

@jsjoeiojsjoeio commentedSep 30, 2022
edited
Loading

This PR cleans up some of the types injest.setup.ts.

@jsjoeiojsjoeio self-assigned thisSep 30, 2022
@@ -38,16 +38,12 @@ afterAll(() => server.close())
// For now, I limited this to just 'error' - but failing on warnings
// would be a nice next step! We may need to filter out some noise
// from material-ui though.
const CONSOLE_FAIL_TYPES = ["error" /* 'warn' */]
const CONSOLE_FAIL_TYPES = ["error" /* 'warn' */] as const
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Usingas const narrows the type to string literals which is more correct.

const consoleAsAny = global.console as any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
consoleAsAny[logType] = (format: string, ...args: any[]): void => {
CONSOLE_FAIL_TYPES.forEach((logType: typeof CONSOLE_FAIL_TYPES[number]) => {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

herelogType is limited to the options we specify inCONSOLE_FAIL_TYPES.

// eslint-disable-next-line @typescript-eslint/no-explicit-any
consoleAsAny[logType] = (format: string, ...args: any[]): void => {
CONSOLE_FAIL_TYPES.forEach((logType: typeof CONSOLE_FAIL_TYPES[number]) => {
global.console[logType] = <Type>(format: string, ...args: Type[]): void => {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Using the generic, we no longer need to useany.

@jsjoeiojsjoeio marked this pull request as ready for reviewSeptember 30, 2022 22:10
@jsjoeiojsjoeio requested a review froma team as acode ownerSeptember 30, 2022 22:10
@jsjoeiojsjoeio requested review fromKira-Pilot and removed request fora teamSeptember 30, 2022 22:10
Copy link
Member

@Kira-PilotKira-Pilot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice job! Thanks for the comments.

jsjoeio reacted with rocket emoji
@jsjoeiojsjoeio merged commitce95344 intomainOct 4, 2022
@jsjoeiojsjoeio deleted the jsjoeio/eslint-cleanups branchOctober 4, 2022 16:04
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@Kira-PilotKira-PilotKira-Pilot approved these changes

Assignees

@jsjoeiojsjoeio

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@jsjoeio@Kira-Pilot

[8]ページ先頭

©2009-2025 Movatter.jp