Skip to content

[Documentation] No documented public API for Owner #19916

@chriskrycho

Description

@chriskrycho

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:

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:

  1. Document that as a public type, so that we can
  2. Have something authoritative to point to when we open a PR to DefinitelyTyped addressing this.

Some context:

  1. 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 like unknown, and in the absence of a publicly-documented API, unknown (or perhaps the equally useless to end users object) are the only options on offer.

  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions