feat: export FieldProto#8052
Closed
maribethb wants to merge 1 commit intoRaspberryPiFoundation:developfrom
Closed
Conversation
cpcallen
reviewed
Apr 26, 2024
Collaborator
cpcallen
left a comment
There was a problem hiding this comment.
Overall I think exporting this type is probably a bad idea—but I'm also aware that I don't have the full picture here, so let's discuss via VC if we have the chance, so I might better understand what Code.org are up to.
In summary my thoughts (in no particular order) are:
FieldProtois a weird and possibly confusing name.- It's hard to understand what a
FieldProtovalue is and what one might use it for, and the description in the JSDoc is probably more misleading than helpful. - The
protectedfunctions that currently take aFieldProtowould probably have been better written to take atypeof Field.prototypeinstead (i.e., the actual prototype object itself, rather than the constructor). That's a breaking change, but now would be a convenient time to make it. - Surely TypeScript has some provision for "class types" that does not tie them to the specific calling convention of the constructor???
- External developers who need a shorthand alias for
Pick<typeof Field, 'prototype'>should probably just declare one themselves.
Collaborator
|
Further notes after discussion:
|
Contributor
Author
|
Closing because we need a different solution, filed #8059 to track |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The basics
The details
Resolves
Fixes unexported type
Proposed Changes
Exports the
FieldPrototype and removes the@internalannotation.Reason for Changes
FieldProtois used in places where you need to reference a type that refers to a field or any subclass ofField. Since constructors in field subclasses do not all have the same signature,typeof Fieldis not sufficient as it does not satisfy the TS compiler.When we added this type, we decided not to export it unless we found that external developers needed it. Code.org is using TypeScript and they have a couple places where they need to refer to "a field or any subclass" so they're currently using this by deep importing the type from
blockly/core/field.jsbut that has never been supported and will throw an error if building with webpack in v11.Test Coverage
Documentation
This will automatically be added to the reference docs since I removed the
@internalannotation.Additional Information