FaasJS
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
Home
  • Guide
  • Documents
  • Templates
  • Changelog
  • Ecosystem

    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security

Documents / @faasjs/types / FaasData

Type Alias: FaasData<T>

FaasData<T> = T extends FaasActionPaths ? FaasActions[T]["Data"] : T extends string ? Record<string, unknown> : never

Infer the response data type for a given action path.

When T matches a declared action path, resolves to FaasActions[T]['Data']. Falls back to Record<string, unknown> for explicit unrecognized string paths. Returns never when T is not a string; the bare FaasData default uses unknown, so it also resolves to never.

Type Parameters

T

T = unknown

Candidate action path or response data type.

Returns

FaasActions[T]['Data'] when T is a registered action path, Record<string, unknown> for any unregistered string, or never when T is not a string.

Example

// Registered action — resolves to the declared Data type
type LoginData = FaasData<'user/login'>
// → { token: string }

// Unregistered string — falls back to a generic record
type UnknownData = FaasData<'some/action'>
// → Record<string, unknown>

// Non-string — resolves to never
type Invalid = FaasData<42>
// → never

See

  • FaasActionPaths
  • FaasParams