Skip to content

Commit

Permalink
Make Get helper interop with DT and preview types
Browse files Browse the repository at this point in the history
In the `intrinsics` module for the `@glint/environment-ember-loose`,
add a declaration for the `ComputedPropertyMarker`. If using the DT
types, this acts as a declaration merge for a module which is then
integrated via the rest of the DT types. If using the stable/preview
types, this ends up being a no-op.
  • Loading branch information
chadhietala authored and chriskrycho committed Nov 23, 2022
1 parent 433c240 commit dfcac1f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/environment-ember-loose/-private/intrinsics/get.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { DirectInvokable } from '@glint/template/-private/integration';
import ObjectProxy from '@ember/object/proxy';
import { UnwrapComputedPropertyGetter } from '@ember/object/-private/types';
import '@ember/object/-private/types';

declare const GetSetMarker: unique symbol;
declare module '@ember/object/-private/types' {
interface ComputedPropertyMarker<Get, Set = Get> {
[GetSetMarker]: [Get, Set];
}
}

type UnwrapComputedPropertyGetter<T> = T extends { [GetSetMarker]: [infer U, any] } ? U : T;

export type GetHelper = DirectInvokable<{
<T, K extends keyof T>(obj: T, key: K): UnwrapComputedPropertyGetter<T[K]>;
Expand Down

0 comments on commit dfcac1f

Please sign in to comment.