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: Keep type annotations in syntacticPlaceholders mode #16905

Merged
merged 2 commits into from
Oct 19, 2024

Conversation

liuxingbaoyu
Copy link
Member

Q                       A
Fixed Issues? Fixes #16904
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@liuxingbaoyu liuxingbaoyu added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: types pkg: template labels Oct 14, 2024
@babel-bot
Copy link
Collaborator

babel-bot commented Oct 14, 2024

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58137

}

if (hasOwn(node, "typeAnnotation")) {
newNode.typeAnnotation = deep
Copy link
Member

Choose a reason for hiding this comment

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

Can we declare these various extra properties in the type definitions of Placehodler?

Copy link
Member Author

Choose a reason for hiding this comment

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

export const PLACEHOLDERS = [
  "Identifier",
  "StringLiteral",
  "Expression",
  "Statement",
  "Declaration",
  "BlockStatement",
  "ClassBody",
  "Pattern",
] as const;

I'm afraid there are other properties that should be here, which would result in a large number of properties in the Placehodler type definition.
However, I haven't thought of a better way so far.

Copy link
Member

Choose a reason for hiding this comment

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

Can they, though? For example, a placeholder will never have a .body because it's "inside" the node.

The identifier properties are special because they are not really inside the identifier, so they are not hidden by the placeholder.

@JLHwung JLHwung force-pushed the fix-placeholder-type branch from 4f835bd to d703353 Compare October 18, 2024 17:22
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

Approving assuming that CI will be green

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: template pkg: types PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Template parser erases function argument type annotation when using syntactic placeholder
4 participants