-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
As briefly discussed in #19914, there is not (and to my knowledge has never been) a definition of the public API of the Owner
as expected by getOwner
and setOwner
. The API docs specify only Object
as the type for the owner object returned by getOwner
or expected as the second param to setOwner
:
Additionally, while the getOwner
docs include a short snippet showing the use of lookup
, there is no further documentation anywhere in Ember's API docs (as far as I can tell) of what exactly an Owner
is.
On #19914, @ef4 suggested that the types within Ember represent the intended public API:
ember.js/packages/@ember/-internals/owner/index.ts
Lines 30 to 39 in 6b77e9b
export interface Owner { | |
lookup<T>(fullName: string, options?: LookupOptions): T | undefined; | |
factoryFor<T, C>(fullName: string, options?: LookupOptions): Factory<T, C> | undefined; | |
factoryFor(fullName: string, options?: LookupOptions): Factory<any, any> | undefined; | |
buildChildEngineInstance(name: string, options?: EngineInstanceOptions): EngineInstance; | |
register<T, C>(fullName: string, factory: Factory<T, C>, options?: object): void; | |
hasRegistration(name: string, options?: LookupOptions): boolean; | |
mountPoint?: string; | |
routable?: boolean; | |
} |
If that is true, we should:
- Document that as a public type, so that we can
- Have something authoritative to point to when we open a PR to DefinitelyTyped addressing this.
Some context:
-
Past (verbal) discussions with various folks have never been conclusive here, so I’m opening this to get us as quickly as possible to an agreed-upon answer that we can document and publish—this is causing folks some pain as they upgrade to the v4 types. Earlier versions of the types returned
any
here, because they predated better tools likeunknown
, and in the absence of a publicly-documented API,unknown
(or perhaps the equally useless to end usersobject
) are the only options on offer. -
Typed Ember has always maintained a policy that we do not publish types on DefinitelyTyped which do not correspond to documented public API for Ember. We are absolutely not in the business of defining the public API for Ember! Rather, we are in the business of accurately representing it in the types.