-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr): throw compile-time error on @wire-decorated getter/setter/m…
…ethod (#5175) * fix(ssr): throw compile-time error on @wire-decorated getter/setter/method * fix(ssr): disallow @wire on computed props
- Loading branch information
Showing
39 changed files
with
169 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
6 changes: 6 additions & 0 deletions
6
...e-server/src/__tests__/fixtures/wire/errors/computed-prop-updates-incorrectly/config.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"ssrFiles": { | ||
"error": "error-ssr.txt", | ||
"expected": "expected-ssr.html" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...server/src/__tests__/fixtures/wire/errors/computed-prop-updates-incorrectly/error-ssr.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Unknown state: property definition has no key |
File renamed without changes.
Empty file.
10 changes: 10 additions & 0 deletions
10
...server/src/__tests__/fixtures/wire/errors/computed-prop-updates-incorrectly/expected.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<x-wire> | ||
<template shadowrootmode="open"> | ||
<p> | ||
Prop named symbol that should not be used: wire data | ||
</p> | ||
<p> | ||
Prop with symbol key that should be used: unset | ||
</p> | ||
</template> | ||
</x-wire> |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
..._tests__/fixtures/wire/errors/computed-prop-updates-incorrectly/modules/x/wire/adapter.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export class adapter { | ||
constructor(dataCallback) { | ||
this.dc = dataCallback; | ||
} | ||
|
||
connect() {} | ||
|
||
update(config) { | ||
this.dc(config.value); | ||
} | ||
|
||
disconnect() {} | ||
} |
4 changes: 4 additions & 0 deletions
4
...__tests__/fixtures/wire/errors/computed-prop-updates-incorrectly/modules/x/wire/wire.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<template> | ||
<p>Prop named symbol that should not be used: {symbol}</p> | ||
<p>Prop with symbol key that should be used: {symbolValue}</p> | ||
</template> |
14 changes: 14 additions & 0 deletions
14
...c/__tests__/fixtures/wire/errors/computed-prop-updates-incorrectly/modules/x/wire/wire.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { LightningElement, wire } from 'lwc'; | ||
import { adapter } from './adapter'; | ||
|
||
const symbol = Symbol("I'm a symbol!"); | ||
export default class extends LightningElement { | ||
symbol = 'accidentally overwritten'; | ||
|
||
@wire(adapter, { value: 'wire data' }) | ||
[symbol] = 'unset'; | ||
|
||
get symbolValue() { | ||
return this[symbol] ?? 'unset'; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...wc/engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-getter/config.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"ssrFiles": { | ||
"error": "error-ssr.txt", | ||
"expected": "expected-ssr.html" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-getter/error-ssr.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@wire cannot be used on computed properties in SSR context. |
File renamed without changes.
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions
3
.../@lwc/engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-getter/index.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const tagName = 'x-wire'; | ||
export { default } from 'x/wire'; | ||
export * from 'x/wire'; |
File renamed without changes.
File renamed without changes.
This file contains 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
6 changes: 6 additions & 0 deletions
6
...wc/engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-method/config.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"ssrFiles": { | ||
"error": "error-ssr.txt", | ||
"expected": "expected-ssr.html" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-method/error-ssr.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[7:13]: Unexpected token: '{' |
1 change: 1 addition & 0 deletions
1
...@lwc/engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-method/error.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
An empty error occurred?! |
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions
3
.../@lwc/engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-method/index.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const tagName = 'x-wire'; | ||
export { default } from 'x/wire'; | ||
export * from 'x/wire'; |
13 changes: 13 additions & 0 deletions
13
...er/src/__tests__/fixtures/wire/errors/throws-on-computed-method/modules/x/wire/adapter.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export class adapter { | ||
constructor(dataCallback) { | ||
this.dc = dataCallback; | ||
} | ||
|
||
connect() {} | ||
|
||
update(config) { | ||
this.dc(config.name); | ||
} | ||
|
||
disconnect() {} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ver/src/__tests__/fixtures/wire/errors/throws-on-computed-method/modules/x/wire/wire.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
{exposedSymbol} | ||
</template> |
14 changes: 14 additions & 0 deletions
14
...erver/src/__tests__/fixtures/wire/errors/throws-on-computed-method/modules/x/wire/wire.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { LightningElement, wire } from 'lwc'; | ||
import { adapter } from './adapter'; | ||
const sym = Symbol('computed prop'); | ||
|
||
export default class Wire extends LightningElement { | ||
@wire(adapter, { name: 'symbol' }) | ||
[sym]() { | ||
return 'john was here'; | ||
} | ||
|
||
get exposedSymbol() { | ||
return this[sym](); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...wc/engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-setter/config.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"ssrFiles": { | ||
"error": "error-ssr.txt", | ||
"expected": "expected-ssr.html" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-setter/error-ssr.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@wire cannot be used on computed properties in SSR context. |
1 change: 1 addition & 0 deletions
1
...@lwc/engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-setter/error.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
setter should not be called |
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions
3
.../@lwc/engine-server/src/__tests__/fixtures/wire/errors/throws-on-computed-setter/index.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const tagName = 'x-wire'; | ||
export { default } from 'x/wire'; | ||
export * from 'x/wire'; |
13 changes: 13 additions & 0 deletions
13
...er/src/__tests__/fixtures/wire/errors/throws-on-computed-setter/modules/x/wire/adapter.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export class adapter { | ||
constructor(dataCallback) { | ||
this.dc = dataCallback; | ||
} | ||
|
||
connect() {} | ||
|
||
update(config) { | ||
this.dc(config.name); | ||
} | ||
|
||
disconnect() {} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ver/src/__tests__/fixtures/wire/errors/throws-on-computed-setter/modules/x/wire/wire.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
{exposedSymbol} | ||
</template> |
15 changes: 15 additions & 0 deletions
15
...erver/src/__tests__/fixtures/wire/errors/throws-on-computed-setter/modules/x/wire/wire.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { LightningElement, wire } from 'lwc'; | ||
import { adapter } from './adapter'; | ||
const sym = Symbol('computed prop'); | ||
|
||
export default class Wire extends LightningElement { | ||
@wire(adapter, { name: 'symbol' }) | ||
set [sym](_) { | ||
throw new Error('setter should not be called'); | ||
} | ||
|
||
get exposedSymbol() { | ||
this[sym] = 123; | ||
return 123; | ||
} | ||
} |
This file contains 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
This file contains 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