Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #272 from glimmerjs/bugfix/fix-manager-api-return
Browse files Browse the repository at this point in the history
[BUGFIX] Fixes the types of manager return values
  • Loading branch information
Chris Garrett authored Apr 4, 2020
2 parents 9ebc07e + d9e6e60 commit 4fe1929
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions packages/@glimmer/core/src/managers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ const MANAGER_INSTANCES: WeakMap<

const getPrototypeOf = Object.getPrototypeOf;

export function setManager<Owner extends object, StateBucket = unknown>(
export function setManager<Def extends object, Owner extends object, StateBucket = unknown>(
wrapper: ManagerWrapper<Owner, StateBucket>,
obj: {}
): {} {
obj: Def
): Def {
MANAGERS.set(obj, wrapper);
return obj;
}
Expand Down Expand Up @@ -95,10 +95,11 @@ function getManagerInstanceForOwner<D extends ManagerDelegate>(

///////////

export function setModifierManager<StateBucket, Owner extends object = object>(
factory: ManagerFactory<Owner, ModifierManager<StateBucket>>,
definition: ModifierDefinition<StateBucket>
): {} {
export function setModifierManager<
StateBucket,
Def extends ModifierDefinition<StateBucket>,
Owner extends object = object
>(factory: ManagerFactory<Owner, ModifierManager<StateBucket>>, definition: Def): Def {
return setManager({ factory, type: 'modifier' }, definition);
}

Expand All @@ -113,10 +114,11 @@ export function getModifierManager<StateBucket = unknown>(
}
}

export function setHelperManager<StateBucket, Owner extends object = object>(
factory: ManagerFactory<Owner, HelperManager<StateBucket>>,
definition: HelperDefinition<StateBucket>
): {} {
export function setHelperManager<
StateBucket,
Def extends HelperDefinition<StateBucket>,
Owner extends object = object
>(factory: ManagerFactory<Owner, HelperManager<StateBucket>>, definition: Def): Def {
return setManager({ factory, type: 'helper' }, definition);
}

Expand All @@ -131,10 +133,11 @@ export function getHelperManager<StateBucket = unknown>(
}
}

export function setComponentManager<StateBucket, Owner extends object = object>(
factory: ManagerFactory<Owner, ComponentManager<StateBucket>>,
definition: ComponentDefinition<StateBucket>
): {} {
export function setComponentManager<
StateBucket,
Def extends ComponentDefinition<StateBucket>,
Owner extends object = object
>(factory: ManagerFactory<Owner, ComponentManager<StateBucket>>, definition: Def): Def {
return setManager({ factory, type: 'component' }, definition);
}

Expand Down

0 comments on commit 4fe1929

Please sign in to comment.