chore: rename derived_call to derived_by (#12689)

pull/12691/head
Rich Harris 3 months ago committed by GitHub
parent 038754bfc6
commit 44a1324a2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -74,7 +74,7 @@ export interface ComponentClientTransformState extends ClientTransformState {
} }
export interface StateField { export interface StateField {
kind: 'state' | 'frozen_state' | 'derived' | 'derived_call'; kind: 'state' | 'frozen_state' | 'derived' | 'derived_by';
id: PrivateIdentifier; id: PrivateIdentifier;
} }

@ -56,7 +56,7 @@ export function ClassBody(node, context) {
: rune === '$state.frozen' : rune === '$state.frozen'
? 'frozen_state' ? 'frozen_state'
: rune === '$derived.by' : rune === '$derived.by'
? 'derived_call' ? 'derived_by'
: 'derived', : 'derived',
// @ts-expect-error this is set in the next pass // @ts-expect-error this is set in the next pass
id: is_private ? definition.key : null id: is_private ? definition.key : null
@ -123,7 +123,7 @@ export function ClassBody(node, context) {
? b.call('$.freeze', init) ? b.call('$.freeze', init)
: init : init
) )
: field.kind === 'derived_call' : field.kind === 'derived_by'
? b.call('$.derived', init) ? b.call('$.derived', init)
: b.call('$.derived', b.thunk(init)); : b.call('$.derived', b.thunk(init));
} else { } else {
@ -167,7 +167,7 @@ export function ClassBody(node, context) {
); );
} }
if (dev && (field.kind === 'derived' || field.kind === 'derived_call')) { if (dev && (field.kind === 'derived' || field.kind === 'derived_by')) {
body.push( body.push(
b.method( b.method(
'set', 'set',

@ -39,7 +39,7 @@ export function ClassBody(node, context) {
if (rune === '$derived' || rune === '$derived.by') { if (rune === '$derived' || rune === '$derived.by') {
/** @type {StateField} */ /** @type {StateField} */
const field = { const field = {
kind: rune === '$derived.by' ? 'derived_call' : 'derived', kind: rune === '$derived.by' ? 'derived_by' : 'derived',
// @ts-expect-error this is set in the next pass // @ts-expect-error this is set in the next pass
id: is_private ? definition.key : null id: is_private ? definition.key : null
}; };
@ -86,7 +86,7 @@ export function ClassBody(node, context) {
context.visit(definition.value.arguments[0], child_state) context.visit(definition.value.arguments[0], child_state)
); );
const value = const value =
field.kind === 'derived_call' ? b.call('$.once', init) : b.call('$.once', b.thunk(init)); field.kind === 'derived_by' ? b.call('$.once', init) : b.call('$.once', b.thunk(init));
if (is_private) { if (is_private) {
body.push(b.prop_def(field.id, value)); body.push(b.prop_def(field.id, value));
@ -98,7 +98,7 @@ export function ClassBody(node, context) {
// get foo() { return this.#foo; } // get foo() { return this.#foo; }
body.push(b.method('get', definition.key, [], [b.return(b.call(member))])); body.push(b.method('get', definition.key, [], [b.return(b.call(member))]));
if (dev && (field.kind === 'derived' || field.kind === 'derived_call')) { if (dev && (field.kind === 'derived' || field.kind === 'derived_by')) {
body.push( body.push(
b.method( b.method(
'set', 'set',

Loading…
Cancel
Save