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

docs: fix typos #1490

Merged
merged 3 commits into from
Mar 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/ember-data/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ The type returned by the `@attr` decorator is whatever [Transform](https://api.e
* If you supply no argument to `@attr`, the value is passed through without transformation.
* If you supply one of the built-in transforms, you will get back a corresponding type:
* `@attr('string')` → `string`
* `@attr(number)` → `number`,
* `@attr('number')` → `number`
* `@attr('boolean')` → `boolean`
* `@attr'date')` → `Date`
* `@attr('date')` → `Date`
* If you supply a custom transform, you will get back the type returned by your transform.

So, for example, you might write a class like this:
Expand All @@ -23,8 +23,8 @@ import Model, { attr } from '@ember-data/model';
import CustomType from '../transforms/custom-transform';

export default class User extends Model {
@attr()
name?: string;
@attr('string')
declare name?: string;
muziejus marked this conversation as resolved.
Show resolved Hide resolved

@attr('number')
declare age: number;
Expand All @@ -47,7 +47,7 @@ One way to make this safer is to supply a default value using the `defaultValue`
import Model, { attr } from '@ember-data/model';

export default class User extends Model {
@attr()
@attr('string')
declare name?: string;

@attr('number', { defaultValue: 13 })
Expand All @@ -62,7 +62,7 @@ export default class User extends Model {

Relationships between models in Ember Data rely on importing the related models, like `import User from './user';`. This, naturally, can cause a recursive loop, as `/app/models/post.ts` imports `User` from `/app/models/user.ts`, and `/app/models/user.ts` imports `Post` from `/app/models/post.ts`. Recursive importing triggers an [`import/no-cycle`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md) error from eslint.

To avoid these errors, use of [type-only imports](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html), available since TypeScript 3.8:
To avoid these errors, use [type-only imports](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html), available since TypeScript 3.8:

```ts
import type User from './user';
Expand Down