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

fix: refactor CopyData interface to have the correct structure #7344

Merged
merged 4 commits into from
Aug 1, 2023

Conversation

BeksOmega
Copy link
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Work on #7337

Proposed Changes

Changes the CopyData interface to ICopyData and changes it to only require the paster: string; property.

Updates everything using this type/downstream APIs to conform to the new interface.

Reason for Changes

Working toward more flexible copy pasting.

Test Coverage

Should be covered by existing tests!

Documentation

N/A

Additional Information

Best to review commit-wise due to renames =)

@BeksOmega BeksOmega requested a review from a team as a code owner July 31, 2023 23:33
@BeksOmega BeksOmega requested review from cpcallen and removed request for a team July 31, 2023 23:33
@github-actions github-actions bot added the PR: fix Fixes a bug label Jul 31, 2023
Copy link
Contributor

@cpcallen cpcallen left a comment

Choose a reason for hiding this comment

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

LGTM modulo comments below and some pedantry:

  • Do the first two commits (at least) not contain breaking changes? I note neither (nor the PR) is marked with "!" in the title nor "BREAKING CHANGE" in the description.

  • I think I'd have titled most of these commits, and the PR itself, as refactor: rather than chore: or fix:.

  • Changes the CopyData interface to ICopyData

    ಠ_ಠ for the usual style guide reasons (but I realise I am not going to win this).

core/clipboard/block_paster.ts Outdated Show resolved Hide resolved
@@ -22,15 +22,17 @@ export class BlockPaster implements IPaster<BlockCopyData, BlockSvg> {
): BlockSvg | null {
if (!workspace.isCapacityAvailable(copyData.typeCounts!)) return null;

const state = copyData.saveInfo as State;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curiosity: are you removing this just because it isn't a very useful temporary binding, or is there a type-checking reason?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The saveInfo used to be typed as Object | Element because blocks and workspace comments were using the same interface, which forced me to cast. But now they are using separate interfaces with proper types, so I could remove the cast =)

@BeksOmega
Copy link
Collaborator Author

  • Do the first two commits (at least) not contain breaking changes? I note neither (nor the PR) is marked with "!" in the title nor "BREAKING CHANGE" in the description.

The CopyData was only ever returned from an internal function. So since the type was inaccessible, I don't consider this a breaking change.

  • I think I'd have titled most of these commits, and the PR itself, as refactor: rather than chore: or fix:.

refactor is not one of our approved commit message prefixes :/ https://developers.google.com/blockly/guides/contribute/get-started/commits#type

The only approved ones are chore, fix, feat, deprecate or release.

  • Changes the CopyData interface to ICopyData

    ಠ_ಠ for the usual style guide reasons (but I realise I am not going to win this).

Haha I agree man. But consistency 🤷

@BeksOmega BeksOmega merged commit ce1678e into google:operation-copy-that Aug 1, 2023
@cpcallen
Copy link
Contributor

cpcallen commented Aug 2, 2023

refactor is not one of our approved commit message prefixes :/ https://developers.google.com/blockly/guides/contribute/get-started/commits#type

Huh. TIL. I've always worked from the Conventional Commits spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants