Skip to content

Use correct types where possible instead of any#3344

Merged
robertbrignull merged 8 commits intomainfrom
robertbrignull/correct-types
Feb 12, 2024
Merged

Use correct types where possible instead of any#3344
robertbrignull merged 8 commits intomainfrom
robertbrignull/correct-types

Conversation

@robertbrignull
Copy link
Copy Markdown
Contributor

This is all the cases I could find where we are using any but there exists some other type we can use instead that doesn't involve changing anything else. If everything still compiles then this should be safe to do so.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

This endpoint actually has the correct type already. We could explicitly
declare it as
RestEndpointMethodTypes["codeScanning"]["listCodeqlDatabases"]["response"]["data"][0]
but this seems unnecessary given how ugly that type is. If we just do nothing
then typescript already computes the correct type for us.
@robertbrignull robertbrignull requested review from a team as code owners February 12, 2024 15:41
});

const languages = response.data.map((db: any) => db.language);
const languages = response.data.map((db) => db.language);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In this case the correct type is inferred, so we're not just getting an implicit any type here.

Copy link
Copy Markdown
Contributor

@shati-patel shati-patel left a comment

Choose a reason for hiding this comment

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

Looks good, apart from the import [type] ... linter errors!

@robertbrignull robertbrignull merged commit f7731e2 into main Feb 12, 2024
@robertbrignull robertbrignull deleted the robertbrignull/correct-types branch February 12, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants