-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 8110 #8116
Fix 8110 #8116
Conversation
Diff for pulumi-kubernetes with merge commit 17a7d60 |
Diff for pulumi-kubernetes with merge commit f419abd |
Diff for pulumi-kubernetes with merge commit 7e61c54 |
Diff for pulumi-kubernetes with merge commit 58dec95 |
Diff for pulumi-random with merge commit 34245e7 |
Diff for pulumi-azuread with merge commit 34245e7 |
Diff for pulumi-kubernetes with merge commit 34245e7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like an annoying question, but how hard would it be to only generate the parens when they're necessary? It'd minimize the diffs and would keep the types a little less noisy.
Not annoying at all I was asking the same thing. It would also make diff checking easier. It's some work mostly to find TypeScript grammar precedence rules. If someone remembers how those work that could be a great help. |
Not seeing BNF in https://www.typescriptlang.org/docs/handbook/2/everyday-types.html But at first glance, |
Diff for pulumi-azure-native with merge commit 34245e7 |
Diff for pulumi-azuread with merge commit dd81529 |
Diff for pulumi-random with merge commit dd81529 |
Diff for pulumi-kubernetes with merge commit dd81529 |
Diff for pulumi-gcp with merge commit dd81529 |
"pgregory.net/rapid" | ||
) | ||
|
||
func TestParenInsert(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admittedly verbose but foolproof. Works on a simplified grammar but can be easily extended if we run into more grammar peculiarities. This checks that unparsing and auto-parenthesizing the AST into tokens gets parsed back into the same AST.
}) | ||
} | ||
|
||
func astGenerator() *rapid.Generator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lib remark: shrinking trees seems not entirely satisfactory, I'd like to compare to what Haskell has and if necessary send a patch upstream. Once a bad tree T has been found, I'd like it to be minimized heavily by pruning branches that do not matter for the test before presenting to the user.
Diff for pulumi-azure with merge commit dd81529 |
@@ -0,0 +1,64 @@ | |||
// *** WARNING: this file was generated by test. *** | |||
// *** Do not edit by hand unless you're certain you know what you are doing! *** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-node code noisy, relatively low value, we should probably support skipping codegen by lang.
Diff for pulumi-aws with merge commit dd81529 |
Diff for pulumi-azure-native with merge commit dd81529 |
Diff for pulumi-random with merge commit 3a908b3 |
Diff for pulumi-azuread with merge commit 3a908b3 |
Diff for pulumi-kubernetes with merge commit 3a908b3 |
Diff for pulumi-gcp with merge commit 3a908b3 |
Diff for pulumi-aws with merge commit 3a908b3 |
Diff for pulumi-azure with merge commit 3a908b3 |
|
||
type typeScriptTypeUnparser struct{} | ||
|
||
func (u *typeScriptTypeUnparser) unparse(ast TypeAst) []typeToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these methods just for scoping? if so, these can take a value receiver:
func (u *typeScriptTypeUnparser) unparse(ast TypeAst) []typeToken { | |
func (u typeScriptTypeUnparser) unparse(ast TypeAst) []typeToken { |
Diff for pulumi-azure-native with merge commit 3a908b3 |
Diff for pulumi-azuread with merge commit ede002f |
Diff for pulumi-random with merge commit ede002f |
Diff for pulumi-kubernetes with merge commit ede002f |
Diff for pulumi-gcp with merge commit ede002f |
Diff for pulumi-aws with merge commit ede002f |
Diff for pulumi-azure with merge commit ede002f |
Diff for pulumi-azure-native with merge commit ede002f |
Description
Fix Node codegen to not create incorrectly parsed type references for unions and optionals.
Fixes #8110
Based on discussion, some effort was put into minimally inserting parens, rather than inserting them everywhere.
Checklist