_InlineTrick

Packages > fluid-framework > InternalTypes > _InlineTrick

Use for trick to “inline” generic types.

This API is reserved for internal system use and should not be imported directly. It may change at any time without notice.

For more information about our API support guarantees, see here .

Signature

export type _InlineTrick = 0;

Remarks

The TypeScript compiler can be convinced to inline a generic type (so the result of evaluating the generic type show up in IntelliSense and error messages instead of just the invocation of the generic type) by creating an object with a field, and returning the type of that field.

For example:

type MyGeneric<T1, T2> = {x: T1 extends [] ? T1 : T2 };
type MyGenericExpanded<T1, T2> = [{x: T1 extends [] ? T1 : T2 }][_InlineTrick]
// Type is MyGeneric<5, string>
const foo: MyGeneric<5, string> = {x: "x"}
// Type is {x: "x"}
const foo2: MyGenericExpanded<5, string> = {x: "x"}

This constant is defined to provide a way to find this documentation from types which use this pattern, and to locate types which use this pattern in case they need updating for compiler changes.