PromiseOr<T, sync>

PromiseOr<T, sync extends "sync" | "async">: sync extends "async"
    ? T | Promise<T>
    : T

Ein Hilfstyp zur Auswahl zwischen synchronen und asynchronen Rückgabewerten.

Dies wird als Rückgabewert für Plugins wie CustomFunction, Importer und FileImporter verwendet, damit TypeScript sicherstellt, dass asynchrone Plugins nur an compileAsync und compileStringAsync übergeben werden und nicht an compile oder compileString.

Typenparameter

  • T

  • sync extends "sync" | "async"

    Wenn dies 'sync' ist, kann dies nur ein T sein. Wenn es 'async' ist, kann dies entweder ein T oder ein Promise<T> sein.