Skip to content

Commit

Permalink
Use stricter type for createPrimitiveRef (#1483)
Browse files Browse the repository at this point in the history
The expectation is that `createPrimitiveRef` is to be used with primitives only.

If that causes type errors, then either:

* The calling side is using this inappropriately and it will cause them problems
* The calling side is missing some assertions to ensure it actually is a primitive
* The assumptions/expectations for this PR is wrong, in which case, please revert

Co-authored-by: Godfrey Chan <[email protected]>
  • Loading branch information
NullVoxPopuli and chancancode authored Nov 20, 2023
1 parent cdd5b3f commit 13d595c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@glimmer/reference/lib/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ReferenceImpl<T = unknown> implements Reference<T> {
}
}

export function createPrimitiveRef<T>(value: T): Reference<T> {
export function createPrimitiveRef<T extends string| symbol | number | boolean | null | undefined>(value: T): Reference<T> {
const ref = new ReferenceImpl<T>(UNBOUND);

ref.tag = CONSTANT_TAG;
Expand Down

1 comment on commit 13d595c

@chancancode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.