Skip to content

Conversation

@cpcallen
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

Part of #6828.

Not running clang-format on this as for some reason it decides
half way through the file to indent everything after that by
an extra four spaces (and then has to re-wrap a bunch of lines
that are consequently too long).
It turns out that the way I originally specified the types for
the mixins meant that they were all 'any', which is a bit
useless.  Change them so that tsc actually typechecks
properties (including method calls) on the mixed-in blocks,
and then fix the numerous additional type errors which
doing this revealed.

(By "fix", I mean apply "as" casts and "!"s as required to
suppress type errors from tsc.  Actually fixing the code in a
way that makes the blocks meaningfully more bulletproof is
left as an exercise to the reader - sorry, I mean: will be
dealt with in a future PR.)
Copy link
Contributor

@BeksOmega BeksOmega left a comment

Choose a reason for hiding this comment

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

One comment, also question: did you want this to go into the upcoming release? If so, have you tested that the blocks actually function correctly?

/** Type of a 'lists_create_with' block. */
type CreateWithBlock = Block&ListCreateWithMixin;
interface ListCreateWithMixin extends ListCreateWithMixinType {
itemCount_: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is because this is added in the init function? Could we just define it in the mixin instead of defining it in the constructor?

Here & below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was wondering about that. I admit I am not 100% sure about the mechanics of block creation, so I thought it was safer to leave this as-is for now, but I'll add a note to #6920 to consider that.

Just to confirm: do you believe it is safe to init properties via (primitive-valued) properties on the mixin, instead of in the init method?

Copy link
Contributor

Choose a reason for hiding this comment

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

I do believe that that is safe. We actually do that in the procedure blocks (eg). All of the values get mixed into the block before the init method is called. So it's safe!

@cpcallen cpcallen marked this pull request as draft March 27, 2023 17:26
@cpcallen cpcallen marked this pull request as ready for review April 18, 2023 11:43
@cpcallen cpcallen merged commit 0177dff into RaspberryPiFoundation:develop Apr 18, 2023
@cpcallen cpcallen deleted the fix/6828/blocks/lists branch March 15, 2024 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants