Skip to content

Home > @unseenco/backstage-dataverse > Pointer

Pointer type

The type of Atom pointers. See pointer() for an explanation of pointers.

Signature:

typescript
export type Pointer<O> = PointerType<O> & PointerInner<Exclude<O, undefined>, undefined extends O ? undefined : never>;

References: PointerType

Remarks

The Pointer type is quite tricky because it doesn't play well with any and other inexact types. Here is an example that one would expect to work, but currently doesn't:

ts
declare function expectAnyPointer(pointer: Pointer<any>): void

expectAnyPointer(null as Pointer<{}>) // this shows as a type error because Pointer<{}> is not assignable to Pointer<any>, even though it should

The current solution is to just avoid using any with pointer-related code (or type-test it well). But if you enjoy solving typescript puzzles, consider fixing this 😃 Potentially, [TypeScript variance annotations in 4.7+](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/\#optional-variance-annotations-for-type-parameters) might be able to help us.