Inferring Type for `known` in Tagged Enum Function Argument
hi i have this tagged enum
export type PayloadDataSource<T = unknown> = Data.TaggedEnum<{ /** * The data is explicitly typed and known. */ known: { data: T }; /** * The data type is not specified and can be anything. */ unknown: { data: unknown };}>export interface PayloadDataSourceDefinition extends Data.TaggedEnum.WithGenerics<1> { readonly taggedEnum: PayloadDataSource<this['A']>;}/** * Represents the source of a payload's data. * * - `known`: The data is explicitly typed and known. * - `unknown`: The data type is not specified and can be anything. */export const PayloadDataSource = Data.taggedEnum<PayloadDataSourceDefinition>()
export type PayloadDataSource<T = unknown> = Data.TaggedEnum<{ /** * The data is explicitly typed and known. */ known: { data: T }; /** * The data type is not specified and can be anything. */ unknown: { data: unknown };}>export interface PayloadDataSourceDefinition extends Data.TaggedEnum.WithGenerics<1> { readonly taggedEnum: PayloadDataSource<this['A']>;}/** * Represents the source of a payload's data. * * - `known`: The data is explicitly typed and known. * - `unknown`: The data type is not specified and can be anything. */export const PayloadDataSource = Data.taggedEnum<PayloadDataSourceDefinition>()
and i have this function
test(source: PayloadDataSource<{ a: number }>)
test(source: PayloadDataSource<{ a: number }>)
and i want
known
known
to be inferred from
source
source
in test function so that when i do
test(PayloadDataSource.known({ data: <- this should be typed as '{ a: number }' })
test(PayloadDataSource.known({ data: <- this should be typed as '{ a: number }' })