Skip to content

Commit 68be8e3

Browse files
authored
Merge branch 'master' into generate-package-typings
2 parents 89a10c1 + cad47e5 commit 68be8e3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Use TypeScript in your Ember 2.x and 3.x apps!
1313
* [Install other types!](#install-other-types)
1414
* [Environment configuration typings](#environment-configuration-typings)
1515
* [Service and controller injections](#service-and-controller-injections)
16-
* [Opt-in unsafety for Ember Data lookups](#opt-in-unsafety-for-ember-data-lookups)
16+
* [Ember Data lookups](#ember-data-lookups)
17+
* [Opt-in unsafety](#opt-in-unsafety)
1718
* [Type definitions outside `node_modules/@types`](#type-definitions-outside-node_modulestypes)
1819
* [ember-browserify](#ember-browserify)
1920
* ["TypeScript is complaining about multiple copies of the same types"](#typescript-is-complaining-about-multiple-copies-of-the-same-types)
@@ -203,7 +204,7 @@ You'll need to add that module and interface declaration to all your existing se
203204

204205
If you have a reason to fall back to just getting the `Service` or `Controller` types, you can always do so by just using the string-less variant: `service('session')` will check that the string is a valid name of a service; `session()` will not.
205206

206-
### Opt-in unsafety for Ember Data lookups
207+
### Ember Data lookups
207208

208209
The same basic approach is in play for Ember Data lookups. As a result, once you add the module and interface definitions for each model, serializer, and adapter in your app, you will automatically get type-checking and autocompletion and the correct return types for functions like `findRecord`, `queryRecord`, `adapterFor`, `serializerFor`, etc. No need to try to write out those (admittedly kind of hairy!) types; just write your Ember Data calls like normal and everything _should_ just work.
209210

@@ -261,6 +262,8 @@ In addition to the registry, note the oddly defined class for `DS.Model`s. This
261262

262263
[pt2]: http://www.chriskrycho.com/2018/typing-your-ember-update-part-2.html
263264

265+
#### Opt-in unsafety
266+
264267
Also notice that unlike with service and controller injections, there is no unsafe fallback method by default, because there isn't an argument-less variant of the functions to use as there is for `Service` and `Controller` injection. If for some reason you want to opt _out_ of the full type-safe lookup for the strings you pass into methods like `findRecord`, `adapterFor`, and `serializerFor`, you can add these declarations somewhere in your project:
265268

266269
```ts

0 commit comments

Comments
 (0)