installStmtSink
On this page

installStmtSink()

Function in IR

Installs the statement sink that Node.assign() writes through.

import { installStmtSink } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

const installStmtSink: (s: StmtSink) => void

Parameters

s StmtSink

Return value

void

Description

The node module cannot import the builder (the two would import each other), so the builder registers its own { assign } implementation here once, when it loads. Authoring code calls .assign() on a node and never calls this directly; a host that supplies its own statement builder is the only other caller.

Examples

Example

import { installStmtSink, typeKey } from 'typeshade'
// Record every `.assign()` instead of building a statement.
const log: string[] = []
installStmtSink({
assign: (target, value) => {
log.push(`${typeKey(target.type)} = ${typeKey(value.type)}`)
},
})

Source

src/core/ir/node.ts, line 204, at commit 26de7be8

Edit this page Report a problem