Support Angular @let declaration syntax#16474
Conversation
| ); | ||
| } | ||
|
|
||
| function printAssignmentWithLayout( |
There was a problem hiding this comment.
A printAssignmentWithLayout function that allows you to pass rightDoc and layout directly.The logic is the same as the original printAssignment.
| @@ -0,0 +1,27 @@ | |||
| import { group } from "../../document/builders.js"; | |||
| import { printAssignmentWithLayout } from "../../language-js/print/assignment.js"; | |||
There was a problem hiding this comment.
We don't do this before, and I think we can move this to js printer by doing following:
- create a new
__ng_...parser - parse right part, then wrap the right node with a manually created
VariableDeclaration
Do you think it's reasonable?
There was a problem hiding this comment.
IMO, the answer is no. I think the current code is simpler.
First, let me confirm one thing. Is your concern that there will be a dependency from the code for HTML formatting to the code for JavaScript?
If so, would moving printAssignmentWithLayout to src/common solve the your concern? It is just a function that takes leftDoc, operator, rightDoc, and layout and returns a new doc, so it is not specific to JavaScript.
There was a problem hiding this comment.
Is your concern that there will be a dependency from the code for HTML formatting to the code for JavaScript?
Main concern is about plugin, let me check how prettier-plugin-pug works first.
There was a problem hiding this comment.
It simply call prettier.format as I thought.
There was a problem hiding this comment.
Sorry I still don't quite understand the problem, how does my change affect the plugin?
There was a problem hiding this comment.
It doesn't, but I mean if we move all print logic to js printer, it will be easier for plugin to use.
There was a problem hiding this comment.
Alright, I understood the logic wrong, so it's just one line?
group([group(leftDoc), operator, group(indent([line, rightDoc]))]);
Let's put it in HTML printer (maybe with a comment).
The file size grows by import the file https://github.com/prettier/prettier/actions/runs/9918259561/job/27402696804?pr=16474#step:4:298
There was a problem hiding this comment.
Sounds good to me
This comment was marked as outdated.
This comment was marked as outdated.
@let declration syntax@let declaration syntax
| @@ -0,0 +1,19 @@ | |||
| const snippets = ["@let foo = 'Hello' + ', World'; "]; | |||
Description
Adds support for Angular
@letdeclaration syntax1.Fixes: #16296
Checklist
changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.✨Try the playground for this PR✨
Footnotes
https://blog.angular.dev/introducing-let-in-angular-686f9f383f0f ↩