// This is a typescript file which defines utilities used in the output of the typescript extractor. declare global { namespace Marko { export interface Directives {} // Extend the Body type to keep track of what is yielded (used for scope hoisted types). export interface Body< in Params extends readonly any[] = [], out Return = void, > { (...params: Params): MarkoReturn; } /** * Do not use or you will be fired. */ namespace _ { export const voidReturn = new (class Void { readonly [Marko._.scope] = Marko._.never; declare return: void; })(); export const scope: unique symbol; export const never: never; export const any: any; export function getGlobal( override: Override, ): [0] extends [1 & Override] ? Marko.Global : Override; export function returned( rendered: () => T, ): T extends { return: { value: infer Returned } } ? Returned : never; export function hoist( value: () => T, ): T extends () => infer R ? T & Iterable : never; // TODO: hoist should really be the below implementation which accounts for hoisting from unknown // sections causing the getter to return undefined. Right now the type says it always has a value. // export function hoist( // value: () => T, // ): T extends () => infer R // ? (T | (U extends undefined ? () => undefined : never)) & Iterable // : never; export function attrTagNames( tag: Tag, fn: (input: AttrTagNames>) => void, ): void; export function nestedAttrTagNames( input: Input, fn: (input: AttrTagNames) => void, ): void; export const content: DefaultBodyContentKey; export function el( name: Name, ): Marko.NativeTags[Name]["return"]["value"]; export function contentFor(tag: Name): ContentFor; export const Template: new () => { [K in Exclude< keyof Marko.Template, keyof Overrides >]: Marko.Template[K]; } & Overrides; export function noop(value: any): void; export function tuple(...v: T): T; export function interpolated( strs: TemplateStringsArray, ...exprs: (string | number | void | null | false)[] ): string; export function state( component: Component, ): Component extends { state: infer State extends object; } ? State : never; export type ReturnWithScope = ReturnAndScope< Scopes, Return >; export function instance( constructor: Constructor, ): Constructor extends abstract new (...args: any) => infer Instance ? Instance : never; export function readScopes(rendered: Rendered): MergeScopes< { [K in keyof Rendered]: Rendered[K] extends infer Value ? undefined extends Value ? Value extends { scope: infer Scope } ? [0] extends [1 & Scope] ? never : Partial : never : Value extends { scope: infer Scope } ? [0] extends [1 & Scope] ? never : Scope : never : never; }[keyof Rendered] >; export function readScope( value: Value, ): MergeScopes< undefined extends Value ? Value extends { scope: infer Scope } ? [0] extends [1 & Scope] ? never : Partial : never : Value extends { scope: infer Scope } ? [0] extends [1 & Scope] ? never : Scope : never >; export function change( ...item: Item ): UnionToIntersection< Item extends | readonly [infer LocalName extends string, infer Data] | readonly [ infer LocalName extends string, infer SourceName, infer Data, ] ? Data extends { [K in `${SourceName extends string ? SourceName : LocalName}Change`]: (value: infer V, ...args: any[]) => any; } ? { [K in LocalName]: V } : { readonly [K in LocalName]: unknown } : never >; export function bind< Owner extends Marko.Component, OwnerHandlers extends ComponentEventHandlers, Handler extends | keyof OwnerHandlers | ((...args: any) => any) | false | void, Args extends readonly any[], >( owner: Owner, handler: Handler, ...args: Args ): Args extends readonly [] ? Handler extends keyof OwnerHandlers ? OwnerHandlers[Handler] : Handler : (...args: any) => any; // If typescript ever actually supports partial application maybe we do this. export function renderTemplate( template: Name, ): TemplateRenderer; export function renderNativeTag( tag: Name, ): NativeTagRenderer; export const missingTag: DefaultRenderer; export function resolveTemplate