You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(directive): @Input({transform: window ? atob : btoa}) / atob || btoa reports a false "must be a function" #517
ngtsc evaluates ambient globals (from lib.dom.d.ts) as references, which count as truthy. So window ? atob : btoa and atob || btoa resolve to atob. OXC treats the globals as unknown values, so the transform stays dynamic. The transform validation added in #494 then reports an error.
Error: Input transform must be a function Value could not be determined statically.
OXC main
No error. The expression is emitted as written: inputs:{a:[2,"a","a",(window? atob: btoa)]} ((atob || btoa)). This works at runtime but doesn't match ngtsc.
ngtsc 22.1.7
inputs: {a: [2,"a","a",atob]}
Where
crates/oxc_angular_compiler/src/directive/evaluator.rs at the #504 tip. The global identifier evaluates to Value::Dynamic. The transform check (~L2640, added by #494feat/validate-input-transforms, commit 58b12f7) then reports "must be a function".
In ngtsc, partial_evaluator/src/interpreter.ts turns a declared-only variable (isVariableDeclarationDeclared, e.g. declare var window in lib.dom) into a Reference. A Reference is truthy, so visitConditionalExpression and || take the atob branch.
On main?
No. This false error comes with #494. Main has no check here.
Direction
Either treat a known ambient global identifier (one not declared in the file) as a truthy opaque reference for ?:, ||, && and ??, as ngtsc does. Or, more simply, don't report "must be a function" when the dynamic part is only a global, and emit the expression as main does.
Activity