Skip to content

Commit adb53ab

Browse files
committed
docs: replace asides with hints or warnings
1 parent 1622992 commit adb53ab

File tree

7 files changed

+25
-27
lines changed

7 files changed

+25
-27
lines changed

docs/cookbook/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
This “cookbook” section contains recipes for various scenarios you may encounter while working on your app or addon.
44

5-
<aside>
5+
{% hint style="info" %}
66

77
Have an idea for an item that should fit here? [Open an issue for it!][gh-issue] We'd love to help you help us make this experience more awesome for everyone.
88

99
[gh-issue]: https://github.com/typed-ember/ember-cli-typescript/issues/new/choose
1010

11-
</aside>
11+
{% endhint %}
1212

1313
- <LinkTo @route='docs.cookbook.working-with-route-models'>Working with route models</LinkTo>

docs/ember/components.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Components
22

3-
<aside>
3+
{% hint style="info" %}
44

55
New to Ember or the Octane edition specifically? You may want to read [the Ember Guides’ material on `Component`s](https://guides.emberjs.com/release/components/) first!
66

7-
</aside>
8-
7+
{% endhint %}
98

109
Glimmer Components are defined in one of three ways: with templates only, with a template and a backing class, or with only a backing class (i.e. a `yield`-only component). When using a backing class, you get a first-class experience using TypeScript! Unfortunately, we don’t yet support type-checking for templates, but we hope to build that out eventually. Don’t let that stop you, though: types in your component classes make for a great experience, so let’s dig in and see how it works in practice.
1110

@@ -84,11 +83,11 @@ The types for `owner` here and `args` line up with what the `constructor` for Gl
8483
8584
If we used `object`, we could end up with TypeScript thinking `args` were an array, or a `Set`, or anything else that isn’t a primitive. Since we have `{}`, we *know* that it's an object.
8685

87-
<aside>
86+
{% hint style="info" %}
8887

8988
For some further details, check out [this blog post](https://mariusschulz.com/blog/the-object-type-in-typescript).
9089

91-
</aside>
90+
{% endhint %}
9291

9392
The `args` passed to a Glimmer Component [are available on `this`](https://github.com/glimmerjs/glimmer.js/blob/2f840309f013898289af605abffe7aee7acc6ed5/packages/%40glimmer/component/src/component.ts#L12), so we could change our definition to return the names of the arguments from a getter:
9493

docs/ember/helpers.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
Helpers in Ember are just functions or classes with a well-defined interface, which means they largely Just Work™ with TypeScript. However, there are a couple things you’ll want to watch out for.
44

5-
<aside>
5+
{% hint style="info" %}
66

77
As always, you should start by reading and understanding the [Ember Guide on Helpers][guide]!
88

9-
</aside>
10-
119
[guide]: https://guides.emberjs.com/release/templates/writing-helpers/
1210

11+
{% endhint %}
12+
13+
1314
## Function-based helpers
1415

1516
The basic type of a helper function in Ember is:

docs/ember/services.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
Ember Services are global singleton classes that can be made available to different parts of an Ember application via dependency injection. Due to their global, shared nature, writing services in TypeScript gives you a build-time-enforcable API for some of the most central parts of your application.
44

5-
<aside>
5+
{% hint style="info" %}
66

77
If you are not familiar with Services in Ember, first make sure you have read and understood the [Ember Guide on Services][guide]!
88

9-
</aside>
10-
119
[guide]: https://guides.emberjs.com/release/services/
1210

11+
{% endhint %}
12+
1313
## A basic service
1414

1515
Let's take this example from the [Ember Guide][guide]:

docs/ember/testing.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ One major difference when working with TypeScript in *app* code is that once you
1212

1313
First, the function we're testing might look like this.
1414

15-
<aside>
15+
{% hint style="info" %}
1616

1717
Here we’re using the `assert` from `@ember/debug`. If you’re not familiar with it, you might want to take a look at its [API docs][debug-assert]! It’s a development-and-test-only helper that gets stripped from production builds, and is very helpful for this kind of thing!
1818

1919
[debug-assert]: https://api.emberjs.com/ember/3.14/functions/@ember%2Fdebug/assert
2020

21-
</aside>
21+
{% endhint %}
2222

2323
```js
2424
// app/utils/math.js
@@ -212,13 +212,13 @@ export default class Profile extends Component<User> {
212212
}
213213
```
214214

215-
<aside>
215+
{% hint style="info" %}
216216

217217
Not familiar with how we define a Glimmer `Component` and its arguments? Check out [our guide][glimmer-component]!
218218

219219
[glimmer-component]: ./components/
220220

221-
</aside>
221+
{% endhint %}
222222

223223
Now, with that setup out of the way, let’s get back to talking about the text context! We need to set up a `User` to pass into the test. With TypeScript on our side, we can even make sure that it actually matches up to the type we want to use!
224224

@@ -343,10 +343,10 @@ module('Integration | Component | Profile', function(hooks) {
343343

344344
Now everything type-checks again, and we get the nice auto-completion we’re used to when dealing with `this.user` in the test body.
345345

346-
<aside>
346+
{% hint style="info" %}
347347

348348
If you’ve been around TypeScript a little, and you look up the type of the `TestContext` and realize its an interface, you might be tempted to reach for declaration merging here. Don’t! If you do that, *every single test in your entire application* will now have a `user: User` property on it!
349349

350-
</aside>
350+
{% endhint %}
351351

352352
There are still a couple things to be careful about here, however. First, we didn’t specify that the `this.user` property was *optional*. That means that TypeScript won’t complain if you do `this.user` *before* assigning to it. Second, every test in our module gets the same `Context`. Depending on what you’re doing, that may be fine, but you may end up needing to define multiple distinct test context extensions. If you *do* end up needing to define a bunch of different test context extension, that may be a sign that this particular set of tests is doing too much. That in turn is probably a sign that this particular *component* is doing too much!

docs/index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
This guide is designed to help you get up and running with TypeScript in an Ember app.
44

5-
<aside>
5+
{% hint style="warning" %}
66

77
**This is *not* an introduction to TypeScript *or* Ember. Throughout this guide, we’ll link back to [The TypeScript Docs](https://www.typescriptlang.org/docs/home.html) and [the Ember Guides](https://guides.emberjs.com/release/) when there are specific concepts that we will not explain here but which are important for understanding what we’re covering!**
88

9-
</aside>
9+
{% endhint %}
1010

1111
To get started, check out the instructions in [Getting Started: Installation](./getting-started/installation)
1212

@@ -16,8 +16,6 @@ To get started, check out the instructions in [Getting Started: Installation](./
1616

1717
## Why TypeScript?
1818

19-
<aside>Just want to dive in? {{docs-link (html-safe 'Click here &rarr;') 'docs.index'}}</aside>
20-
2119
What is TypeScript, and why should you adopt it?
2220

2321
> TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

docs/legacy/ember-object.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ When working with the legacy Ember object model, `EmberObject`, there are a numb
1212

1313
Additionally, Ember’s mixin system is deeply linked to the semantics and implementation details of `EmberObject`, *and* it has the most caveats and limitations.
1414

15-
<aside>
15+
{% hint style="info" %}
1616

1717
In the future, some of these may be able to drop their `EmberObject` base class dependency, but that will not happen till at least the next major version of Ember, and these guides will be updated when that happens.
1818

19-
</aside>
19+
{% endhint %}
2020

2121

2222
## Mixins and classic class syntax
@@ -25,11 +25,11 @@ The Ember mixin system is the legacy Ember construct TypeScript supports *least*
2525

2626
While we describe here how to use types with classic (mixin-based) classes insofar as they *do* work, there are many failure modes. As a result, we strongly recommend moving away from both classic classes and mixins, and as quickly as possible. This is the direction the Ember ecosystem as a whole is moving, but it is *especially* important for TypeScript users.
2727

28-
<aside>
28+
{% hint style="info" %}
2929

3030
The [Ember Atlas] includes guides for migrating [from classic classes to native classes][classic to native], along with [a variety of patterns][mixin patterns] for dealing with specific kinds of mixins in your codebase.
3131

32-
</aside>
32+
{% endhint %}
3333

3434
[Ember Atlas]: https://emberatlas.com
3535
[classic to native]: https://www.notion.so/Native-Classes-55bd67b580ca49f999660caf98aa1897

0 commit comments

Comments
 (0)