@@ -12,18 +12,26 @@ function insertDebugNameIntoCallExpression(
12
12
callExpression : ts . CallExpression ,
13
13
debugName : string ,
14
14
) : ts . CallExpression {
15
- const signalExpressionHasNoArguments = callExpression . arguments . length === 0 ;
16
15
const signalExpressionIsRequired = isRequiredSignalFunction ( callExpression . expression ) ;
17
16
let configPosition = signalExpressionIsRequired ? 0 : 1 ;
18
17
19
- // If the call expression has no arguments, we pretend that the config object is at position 0.
18
+ const nodeArgs = Array . from ( callExpression . arguments ) ;
19
+
20
+ // 1. If the call expression has no arguments, we pretend that the config object is at position 0.
20
21
// We do this so that we can insert a spread element at the start of the args list in a way where
21
22
// undefined can be the first argument but still get tree-shaken out in production builds.
22
- if ( signalExpressionHasNoArguments ) {
23
+ // or
24
+ // 2. Since `linkedSignal` with computation uses a single object for both computation logic
25
+ // and options (unlike other signal-based primitives), we set the argument position to 0, i.e.
26
+ // reusing the computation logic object.
27
+ const signalExpressionHasNoArguments = callExpression . arguments . length === 0 ;
28
+ const isLinkedSignal = callExpression . expression . getText ( ) === 'linkedSignal' ;
29
+ const isComputationLinkedSignal =
30
+ isLinkedSignal && nodeArgs [ 0 ] . kind === ts . SyntaxKind . ObjectLiteralExpression ;
31
+ if ( signalExpressionHasNoArguments || isComputationLinkedSignal ) {
23
32
configPosition = 0 ;
24
33
}
25
34
26
- const nodeArgs = Array . from ( callExpression . arguments ) ;
27
35
let existingArgument = nodeArgs [ configPosition ] ;
28
36
29
37
if ( existingArgument === undefined ) {
@@ -96,12 +104,15 @@ function insertDebugNameIntoCallExpression(
96
104
97
105
let transformedSignalArgs : ts . NodeArray < ts . Expression > ;
98
106
99
- if ( signalExpressionIsRequired || signalExpressionHasNoArguments ) {
107
+ if ( signalExpressionIsRequired || signalExpressionHasNoArguments || isComputationLinkedSignal ) {
100
108
// 1. If the call expression is a required signal function, there is no args other than the config object.
101
109
// So we just use the spread element as the only argument.
102
110
// or
103
111
// 2. If the call expression has no arguments (ex. input(), model(), etc), we already added the undefined
104
112
// identifier in the spread element above. So we use that spread Element as is.
113
+ // or
114
+ // 3. We are transforming a `linkedSignal` with computation (i.e. we have a single object for both
115
+ // logic and options).
105
116
transformedSignalArgs = ts . factory . createNodeArray ( [ spreadElementContainingUpdatedOptions ] ) ;
106
117
} else {
107
118
// 3. Signal expression is not required and has arguments.
@@ -280,6 +291,7 @@ function expressionIsUsingAngularCoreImportedSymbol(
280
291
const signalFunctions : ReadonlySet < string > = new Set ( [
281
292
'signal' ,
282
293
'computed' ,
294
+ 'linkedSignal' ,
283
295
'input' ,
284
296
'model' ,
285
297
'viewChild' ,
0 commit comments