`currentStack.If` is undefined. What's wrong with my TSL?

I’ve got what seems like a simple TSL setup:

import {smoothstep, fwidth, uv, If, Discard} from ‘three/tsl’
// …

const mat = new THREE.MeshPhysicalMaterial(params)
const nodeMat = new THREE.MeshPhysicalNodeMaterial().copy(mat)

const antiAliasClippingNode = () => {
	const mapUv = uv()
	const edgePos = mapUv.x
	const pixelWidth = fwidth(edgePos)
	const fade = pixelWidth.mul(1.5)
	const alphaFactor = smoothstep(fade.negate(), 0.0, edgePos)

	If(alphaFactor.lessThanEqual(0.0), () => Discard())

	return alphaFactor
}

nodeMat.opacityNode = antiAliasClippingNode()

When I run this, I get an error saying

TypeError: Cannot read properties of null (reading 'If')

on a line that looks like this,

export const If = ( ...params ) => currentStack.If( ...params );

from TSLCore.js.

What am I missing?

Oh, ok, looks like I was missing Fn (though not obvious from the error)

Before:

const antiAliasClippingNode = () => {...}

After:

const antiAliasClippingNode = Fn(() => {...})

Now I have another error:

Uncaught TypeError: Cannot read properties of undefined (reading 'context')

on a line looking like this,

    if ( this.positionNode !== null ) {

        positionLocal.assign( this.positionNode.context( { isPositionNodeInput: true } ) ); // here

    }

in NodeMaterial.js. :thinking:

Aaaaand, updating from 0.176 to 0.182 fixed the last error. Stuff is rendering!