ylliX - Online Advertising Network
Vertex AI - Antrophic and Mistral models: Why does it require Imegen access?

Why is generic not infered when specifying the function parameter


I have the following typing :

declare function linkedSignal<S, D>(options: {
  source: () => S;
  computation: (source: NoInfer<S>, previous?: {source: NoInfer<S>; value: NoInfer<D>}) => D;
}): D;

When using it this way :

linkedSignal({
    source: () => 3,
    computation: (source, previous) => {
        return 3;
    },
})

D is infered as unknown, even though the computation function returns a deterministic type.

Can you explain why this is happening and how we could improve the typing so the generic is correctly inferred.

Playground



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *