Skip to content

convert JSDoc typedef to type, issue 50644 #51430

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

Merged
merged 12 commits into from
Mar 1, 2023

Conversation

brendaHuang
Copy link
Contributor

@brendaHuang brendaHuang commented Nov 7, 2022

Fixes #50644

This PR converts JSDoc typedef to type. It converts two common use cases of @typedef as listed in the JSDoc documentation and other variations, such as nested object types and using @typedef to define primitive types.

Of the five test files, one one addresses the union type, and one primitive type.
The other three addresses object types (index signatures), including nested object types and object types that have comments attached to the properties.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 7, 2022
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 7, 2022
@brendaHuang
Copy link
Contributor Author

brendaHuang commented Nov 8, 2022

@microsoft-github-policy-service agree company="LinkedIn"

1 similar comment
@brendaHuang
Copy link
Contributor Author

@microsoft-github-policy-service agree company="LinkedIn"

@brendaHuang brendaHuang force-pushed the main branch 2 times, most recently from be1417c to 1281a38 Compare November 8, 2022 23:20
@brendaHuang brendaHuang changed the title convert JSDoc typedef to type, issue#50644 convert JSDoc typedef to type, issue 50644 Nov 9, 2022
@brendaHuang
Copy link
Contributor Author

@andrewbranch Would you take a look at this PR? Thanks.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

This is a first past skim review; I think I'd need to think of some edge cases here. Probably @andrewbranch and @sandersn know more.

@brendaHuang brendaHuang force-pushed the main branch 3 times, most recently from fc00ee7 to 9c4a249 Compare January 14, 2023 01:04
@jakebailey
Copy link
Member

It's too late now, but if you can avoid it, I'd appreciate merges from main and additional commits (instead of force pushing) as it's hard to follow what changed in the PR and what comments have been addressed. We squash on PR merge so no need to keep the PR clean. (See our contributing guide: https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#force-pushing)

@brendaHuang brendaHuang force-pushed the main branch 3 times, most recently from d63d7d4 to 20eda98 Compare January 14, 2023 03:07
@brendaHuang
Copy link
Contributor Author

brendaHuang commented Jan 14, 2023

It's too late now, but if you can avoid it, I'd appreciate merges from main and additional commits (instead of force pushing) as it's hard to follow what changed in the PR and what comments have been addressed. We squash on PR merge so no need to keep the PR clean. (See our contributing guide: https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#force-pushing)

Okay. Will do.

@brendaHuang
Copy link
Contributor Author

brendaHuang commented Feb 26, 2023

@jakebailey @andrewbranch After I rebased yesterday, the newly added tests failed, which passed before.

As I ran the debugger, the type alias declaration was successfully created. Then node.modifiers is passed into Line 1280 of src/compiler/visitorPublic.ts, then assignPositionsToNodeArray() of src/services/textChanges.ts, then eventually failed at Line 178 in the getPos() function of src/services/textChanges.ts. The value of node.modifiers is [pos: -1, end: -1, hasTrailingComma: false, transformFlags: 0].

Please see screenshots attached. Thank you very much for your help!

Screenshot 2023-02-26 at 7 25 33 AM
Screenshot 2023-02-26 at 7 29 00 AM
Screenshot 2023-02-26 at 7 34 14 AM
Screenshot 2023-02-26 at 7 58 02 AM

@jakebailey
Copy link
Member

I checked, and it's because you're passing in an empty array for modifiers to createTypeAliasDeclaration. I would recheck all of your create functions to see if you could actually just pass in undefined instead.

@brendaHuang
Copy link
Contributor Author

@jakebailey Thank you very much! The tests now passed. Please review again.

@brendaHuang brendaHuang requested review from jakebailey and andrewbranch and removed request for jakebailey and andrewbranch February 26, 2023 22:10
@brendaHuang
Copy link
Contributor Author

brendaHuang commented Mar 1, 2023

@jakebailey @andrewbranch Would you take another look at this PR? Thanks.

@brendaHuang brendaHuang requested review from andrewbranch and jakebailey and removed request for andrewbranch and jakebailey March 1, 2023 03:44
Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

Seems reasonable, I think? Still not an expert, but it seems about as concise as I can imagine.

@brendaHuang
Copy link
Contributor Author

@andrewbranch Would you take a look? Thank you very much.

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

Nice work, thanks @brendaHuang!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

JSDoc to Type Annotations Codefix And @typedef
4 participants