Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amend RFC 0821: add Resolver public type #853

Merged
merged 4 commits into from
Nov 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions text/0821-public-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Introduce public import locations for type-only imports which have previously ha
- [`getOwner` and `setOwner`](#getowner-and-setowner)
- [`RouteInfo`](#routeinfo)
- [`RouteInfoWithAttributes`](#routeinfowithattributes)
- [`Resolver`](#resolver)
- [How we teach this](#how-we-teach-this)
- [`Owner`](#owner-1)
- [`Transition`, `RouteInfo`, and `RouteInfoWithAttributes`](#transition-routeinfo-and-routeinfowithattributes)
Expand Down Expand Up @@ -392,6 +393,28 @@ function takesRouteInfoWithAttributes(routeInfoWithAttributes) {
```


### `Resolver`

The resolver is a contract implemented by libraries outside Ember itself, such as `ember-resolver`, `ember-strict-resolver`, and any number of custom resolvers which exist in apps across the ecosystem. It has never had public documentation, but is fully public API. It is a user-constructible interface with the following definition (using the `Factory` and `FullName` types exported from the new `@ember/owner` module), available as a new named type-only export from the `@ember/engine` package:
chriskrycho marked this conversation as resolved.
Show resolved Hide resolved

```ts
import EmberObject from '@ember/object';
import type { Factory, FullName } from '@ember/owner';

type KnownForTypeResult<Name extends string> = {
[fullName in `${Name}:${string}`]: boolean | undefined;
};

export interface Resolver extends EmberObject {
dfreeman marked this conversation as resolved.
Show resolved Hide resolved
knownForType?: <Name extends string>(type: Name) => KnownForTypeResult<Name>;
lookupDescription?: (fullName: FullName) => string;
makeToString?: (factory: Factory<object>, fullName: FullName) => string;
normalize?: (fullName: FullName) => string;
resolve(name: string): Factory<object> | object | undefined;
}
```


## How we teach this

These concepts all already exist, but need updates to and in some cases wholly new pages in Ember's API docs.
Expand Down