refactor(core): update `noSideEffects()` to return the result of the inner function (#35769)
This is useful for propagating return values without them being converted to a string. It still provides the same guarantees to Closure, which will assume that the function invoked is pure and can be tree-shaken accordingly. PR Close #35769
This commit is contained in:
parent
47a1811e0b
commit
4052dd8188
|
@ -15,6 +15,6 @@
|
||||||
* to something which is retained otherwise the call to `noSideEffects` will be removed by closure
|
* to something which is retained otherwise the call to `noSideEffects` will be removed by closure
|
||||||
* compiler.
|
* compiler.
|
||||||
*/
|
*/
|
||||||
export function noSideEffects(fn: () => void): string {
|
export function noSideEffects<T>(fn: () => T): T {
|
||||||
return '' + {toString: fn};
|
return {toString: fn}.toString() as unknown as T;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue