ExternFn
타입, 작성 분류
정의를 다른 곳에서 제공하는 함수를 가리키는, 타입이 있고 호출만 가능한 핸들입니다. fn()의 전방 선언에 해당합니다.
import type { ExternFn } from 'typeshade'import type { ExternFn } from 'typeshade/core/ir'
설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.
구문
type ExternFn<P extends ParamSpec, R extends ShaderType> = { /** Typed object-param call, with the same argument union as {@link FnHandle}: arguments * are read, so read-only nodes (`Let` results, parameters) and raw numbers, lifted to the * declared parameter type, are accepted. */ (args: { readonly [K in keyof P]: ReadonlyNode<KeyOf<P[K]>> | number }): Node<KeyOf<R>>; /** Positional call. Arguments are matched to the parameters in declaration order. */ (...args: NodeLike[]): Node<KeyOf<R>>;};설명
호출 대상이 호출자의 모듈 로드 시점에 가져올 수 있는 FnHandle이 될 수 없을 때 씁니다. 예를 들어 호출자 모듈이 본문을 이미 작성한 뒤에 호스트가 설정값으로 만드는 함수가 여기에 해당합니다. 이 핸들은 시그니처(이름, 매개변수 타입, 반환 타입)만 담습니다. 그래서 호출자는 지금 타입이 지정된 호출을 만들 수 있습니다. 객체 매개변수 f({ a, b })를 쓰거나 위치 매개변수 f(a, b)를 씁니다. 호스트는 생성 시점에 본문을 연결합니다. 생성되는 노드는 이름으로 부르는 호출입니다.
함께 보기
소스
src/core/ir/builder.ts, 833행, 커밋 af54ddad5 기준