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

Migrate to TypeScript #59

Merged
merged 22 commits into from
May 19, 2021
Merged

Migrate to TypeScript #59

merged 22 commits into from
May 19, 2021

Conversation

rekmarks
Copy link
Member

Migrates the whole project to TypeScript. Care has been taken to change as little as possible, but in some places I had to add behavior-altering code to please tsc.

At the time of writing, there are a handful of type-related, outstanding TODOs, which I've highlighted with inline comments.

@rekmarks rekmarks requested a review from Gudahtt May 17, 2021 16:54
@rekmarks rekmarks requested a review from a team as a code owner May 17, 2021 16:54
.eslintrc.js Show resolved Hide resolved
src/cli.ts Outdated Show resolved Hide resolved
src/cli.ts Outdated Show resolved Hide resolved
src/parseChangelog.ts Outdated Show resolved Hide resolved
src/updateChangelog.ts Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/constants.ts Outdated Show resolved Hide resolved
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

Not quite through it all yet, but it looks good so far!

I did notice that types remain in most of the JSDoc comments. Now that we have real types, those are redundant and should probably be removed.

src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
@rekmarks
Copy link
Member Author

@Gudahtt re: JSDoc type annotations, I did a pass removing all of them (and updating some links for VS Code compatibility) in 69aae24. Note that TSDoc / TypeDoc / Whatever VS code uses is not compatible with @throws, so I removed those tags completely.

src/cli.ts Show resolved Hide resolved
src/cli.ts Outdated Show resolved Hide resolved
src/cli.ts Outdated Show resolved Hide resolved
* Handle undefined newChangelogContent in CLI update function

Co-authored-by: Mark Stacey <[email protected]>
src/generateDiff.ts Outdated Show resolved Hide resolved
src/runCommand.ts Show resolved Hide resolved
src/runCommand.ts Outdated Show resolved Hide resolved
src/updateChangelog.ts Outdated Show resolved Hide resolved
src/updateChangelog.ts Outdated Show resolved Hide resolved
src/updateChangelog.ts Outdated Show resolved Hide resolved
* Represents a formatting error in a changelog.
*/
export class ChangelogFormattingError extends InvalidChangelogError {
public data: Record<string, string>;
Copy link
Member

Choose a reason for hiding this comment

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

Curious that in cli.ts, when this is referenced, it's able to infer that it has entries for validChangelog and invalidChangelog 🤔 I don't quite follow how it knows those properties exist. Some kinda fancy type inference maybe.

Comment on lines 114 to 115
// TODO: Get rid of typecast?
mostRecentCategory = results[1] as ChangeCategory;
Copy link
Member Author

Choose a reason for hiding this comment

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

Curious about your thoughts here. I don't think we can be certain that this will be a valid change category?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, you're right. I think we should check, and throw if it's invalid.

Gudahtt
Gudahtt previously approved these changes May 19, 2021
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@rekmarks rekmarks merged commit 44986a3 into main May 19, 2021
@rekmarks rekmarks deleted the typescript branch May 19, 2021 19:45
@Gudahtt Gudahtt mentioned this pull request May 24, 2021
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