-
Notifications
You must be signed in to change notification settings - Fork 439
Api version limit for complex template expressions #5520
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
Changes from 12 commits
bd8aca0
9035b03
eb7a327
d496ca5
59e2002
db07237
3b9d43a
aaffccf
a8b5f88
a130ead
411b599
70e8971
c0cb49d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,10 +116,12 @@ export default function compileTemplate( | |
| (directive) => directive.name === 'PreserveComments' | ||
| )?.value?.value; | ||
| const experimentalComplexExpressions = Boolean(options.experimentalComplexExpressions); | ||
| const apiVersion = Number(options.apiVersion); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it not already a number? 🤔
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be undefined (goes to NaN) |
||
|
|
||
| const { addImport, getImports, statements, cxt } = templateIrToEsTree(root, { | ||
| preserveComments, | ||
| experimentalComplexExpressions, | ||
| apiVersion, | ||
| }); | ||
| addImport(['renderStylesheets', 'hasScopedStaticStylesheets']); | ||
| for (const [imports, source] of getStylesheetImports(filename)) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <template> | ||
| <section> | ||
| <x-child foo="{foo()}"></x-child> | ||
| </section> | ||
| </template> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "experimentalComplexExpressions": true, | ||
| "apiVersion": 59 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "warnings": [ | ||
| { | ||
| "code": 1210, | ||
| "message": "Invalid expression {foo()} - LWC1210: Template expression doesn't allow CallExpression. The current component API version (59) is insufficient and must be increased to at least 66 for this type of expression.", | ||
| "level": 1, | ||
| "location": { | ||
| "line": 3, | ||
| "column": 18, | ||
| "start": 42, | ||
| "length": 13 | ||
| } | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <template> | ||
| <section> | ||
| <x-child>{foo()}</x-child> | ||
| </section> | ||
| </template> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "experimentalComplexExpressions": true, | ||
| "apiVersion": 59 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "warnings": [ | ||
| { | ||
| "code": 1210, | ||
| "message": "Invalid expression {foo()} - LWC1210: Template expression doesn't allow CallExpression. The current component API version (59) is insufficient and must be increased to at least 66 for this type of expression.", | ||
| "level": 1, | ||
| "location": { | ||
| "line": 3, | ||
| "column": 18, | ||
| "start": 42, | ||
| "length": 7 | ||
| } | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <template> | ||
| <section> | ||
| <p class="{classNames[0]}"></p> | ||
| </section> | ||
| </template> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "experimentalComplexExpressions": true, | ||
| "apiVersion": 59 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "warnings": [ | ||
| { | ||
| "code": 1209, | ||
| "message": "Invalid expression {classNames[0]} - LWC1209: Template expression doesn't allow computed property access. The current component API version (59) is insufficient and must be increased to at least 66 for this type of expression.", | ||
| "level": 1, | ||
| "location": { | ||
| "line": 3, | ||
| "column": 12, | ||
| "start": 36, | ||
| "length": 23 | ||
| } | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <template> | ||
| {val[state.foo]} | ||
| </template> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "experimentalComplexExpressions": true, | ||
| "apiVersion": 59 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "warnings": [ | ||
| { | ||
| "code": 1209, | ||
| "message": "Invalid expression {val[state.foo]} - LWC1209: Template expression doesn't allow computed property access. The current component API version (59) is insufficient and must be increased to at least 66 for this type of expression.", | ||
| "level": 1, | ||
| "location": { | ||
| "line": 1, | ||
| "column": 11, | ||
| "start": 10, | ||
| "length": 22 | ||
| } | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,7 +24,7 @@ import { | |||||
| isExpression, | ||||||
| isPotentialExpression, | ||||||
| } from './expression'; | ||||||
| import { isComplexTemplateExpressionEnabled } from './expression-complex'; | ||||||
|
|
||||||
| import { | ||||||
| ATTR_NAME, | ||||||
| DATA_RE, | ||||||
|
|
@@ -111,7 +111,9 @@ export function normalizeAttributeValue( | |||||
| const isQuoted = isQuotedAttribute(rawAttrVal); | ||||||
| const isEscaped = isEscapedAttribute(rawAttrVal); | ||||||
| if (!isEscaped && isExpression(value)) { | ||||||
| if (isQuoted && !isComplexTemplateExpressionEnabled(ctx)) { | ||||||
| // Don't test for the API version here, just check if CTE is enabled. | ||||||
| // We can provide more specific errors WRT API versions after the expression has been parsed and we know what it is. | ||||||
|
||||||
| // We can provide more specific errors WRT API versions after the expression has been parsed and we know what it is. | |
| // We can provide more specific errors w.r.t API versions after the expression has been parsed and we know what it is. |
Otherwise I might think that MRT fell over.
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.
just cuz
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.
A default value isn't enough, still considered boolean | undefined and results in a type error. Gonna keep it as-is