Skip to content
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

refactor: enable TS strict mode #889

Merged
merged 28 commits into from
Sep 14, 2023
Merged

refactor: enable TS strict mode #889

merged 28 commits into from
Sep 14, 2023

Conversation

kanadgupta
Copy link
Member

@kanadgupta kanadgupta commented Sep 7, 2023

🧰 Changes

Enables the strict typescript flag in this repository. Any specific callouts will be flagged in the comments below.

🧬 QA & Testing

Doing this exercise likely added type safety and error handling around weird API edge cases but I'd rather write the tests and do the QA if these edge cases become a problem. There were basically no changes to our existing tests so if those pass then we should be in good shape.

@kanadgupta kanadgupta mentioned this pull request Sep 7, 2023
26 tasks
@kanadgupta kanadgupta added enhancement New feature or request refactor Issues about tackling technical debt labels Sep 12, 2023
Copy link
Member Author

Choose a reason for hiding this comment

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

the diff on this file is a bit wild but there aren't any actual changes to the code — just some refactoring to get rid of the unnecessary nested functions because TS doesn't like those (and neither do i lol)

@@ -222,11 +223,8 @@ export default class OpenAPICommand extends Command {
const options: RequestInit = {
headers: cleanHeaders(
Copy link
Member Author

Choose a reason for hiding this comment

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

I refactored the signature of our cleanHeaders function so the second parameter is a version which we use to construct our x-readme-version request header. You'll see a lot of refactors related to that in this PR.


export type ZeroAuthCommandOptions<T> = T & {
github?: boolean;
} & { key?: never };
Copy link
Member Author

Choose a reason for hiding this comment

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

split out our command options for commands that do and do not require auth so we could assert that commands with zero auth do not accept a key parameter. TS is cool sometimes

@kanadgupta kanadgupta requested a review from erunion September 14, 2023 19:56
@kanadgupta kanadgupta marked this pull request as ready for review September 14, 2023 19:56
src/lib/baseCommand.ts Outdated Show resolved Hide resolved
src/lib/baseCommand.ts Outdated Show resolved Hide resolved
src/lib/baseCommand.ts Outdated Show resolved Hide resolved
src/cmds/logout.ts Outdated Show resolved Hide resolved
src/cmds/oas.ts Outdated Show resolved Hide resolved
src/cmds/versions/index.ts Outdated Show resolved Hide resolved
src/cmds/whoami.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/lib/createGHA/index.ts Outdated Show resolved Hide resolved
src/lib/prompts.ts Outdated Show resolved Hide resolved
kanadgupta and others added 2 commits September 14, 2023 16:02
@kanadgupta kanadgupta merged commit 0007f4f into next Sep 14, 2023
10 checks passed
@kanadgupta kanadgupta deleted the ts-strict-mode branch September 14, 2023 21:17
@kanadgupta kanadgupta added this to the v9 milestone Sep 14, 2023
@kanadgupta
Copy link
Member Author

🎉 This PR is included in version 9.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Issues about tackling technical debt released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants