Skip to content

Commit

Permalink
WIP: Native Types Bonanza
Browse files Browse the repository at this point in the history
  • Loading branch information
gitKrystan committed Oct 14, 2024
1 parent 4563b16 commit 2bd0a11
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
2 changes: 2 additions & 0 deletions guides/release/typescript/additional-resources/gotchas.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- FIXME: Update this. -->

This section covers the common details and "gotchas" of using TypeScript with Ember.

## Registries
Expand Down
2 changes: 2 additions & 0 deletions guides/release/typescript/application-development/addons.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- FIXME: Update this. -->

Building addons in TypeScript offers many of the same benefits as building apps in TypeScript: it puts an extra tool at your disposal to help document your code and ensure its correctness. For addons, though, there's one additional bonus: publishing type information for your addons enables autocomplete and inline documentation for your consumers, even if they're not using TypeScript themselves.

## Create a New TypeScript Addon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ If you use the `--typescript` flag when generating your Ember app, we generate a
"my-app/tests/*": ["tests/*"],
"my-app/*": ["app/*"],
"*": ["types/*"]
}
},
"types": [
"ember-source/types",
"./node_modules/ember-data/unstable-preview-types",
// ...more ember-data types...
"./node_modules/@warp-drive/core-types/unstable-preview-types"
}
}
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- FIXME: Update this. -->

These directions are for converting an _existing_ Ember app to TypeScript. If you are starting a new app, you can use the directions in [Getting Started][].

## Enable TypeScript Features
Expand Down
2 changes: 2 additions & 0 deletions guides/release/typescript/core-concepts/ember-data.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- FIXME: Rewrite this. -->

In this section, we cover how to use TypeScript effectively with specific EmberData APIs (anything you'd find under the `@ember-data` package namespace).

We do _not_ cover general usage of EmberData; instead, we assume that as background knowledge. Please see the [EmberData Guides][ED-guides] and [API docs][ED-api-docs]!
Expand Down
24 changes: 7 additions & 17 deletions guides/release/typescript/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,20 @@ Project files will be generated with `.ts` extensions instead of `.js`.

In addition to the usual packages added with `ember new`, the following packages will be added at their current "latest" value:

- `typescript`
- `@tsconfig/ember`
- `@typescript-eslint/*`
- `@types/ember`
- `@types/ember-data`
- `@types/ember__*``@types/ember__object` for `@ember/object`, etc.
- `@types/ember-data__*``@types/ember-data__model` for `@ember-data/model`, etc.
- `@types/qunit`
- `@types/rsvp`

The `typescript` package provides tooling to support TypeScript type checking and compilation. The `@types` packages from [DefinitelyTyped][] provide TypeScript type definitions for all of the Ember and EmberData modules.
- `typescript` – tooling to support TypeScript type checking and compilation.
- `@tsconfig/ember` – a shared TypeScript configuration for Ember apps.
- `@typescript-eslint/*` – ESLint support for TypeScript.
- `@types/qunit` - TypeScript type definitions for QUnit.
- `@types/rsvp` - TypeScript type definitions for RSVP.
- `@warp-drive/core-types` - shared core types, type utilities and constants for the WarpDrive and EmberData packages.

<div class="cta">
<div class="cta-note">
<div class="cta-note-body">
<div class="cta-note-heading">Zoey says...</div>
<div class="cta-note-message">
<p>
Ember also publishes its own native types compiled directly from its source code. For now, we continue to use the <code>@types</code> packages in these guides for the sake of compatibility with EmberData, because the EmberData <code>@types</code> packages are not compatible with Ember's native official types.
</p>
<p>
If you do not use EmberData, or if you use <a href="https://github.com/emberjs/data/blob/main/guides/typescript/index.md">EmberData's alpha native types</a>, we <i>highly</i> recommend following the instructions <a href="https://blog.emberjs.com/stable-typescript-types-in-ember-5-1/">in this blog post</a> to switch to the native types, which are guaranteed to always be 100% correct and 100% up to date!
Ember and EmberData publish their own native types compiled directly from their source code, so you do not need to install any <code>@types/ember</code> or <code>@types/ember-data</code> packages. These packages should be considered legacy, are only lightly maintained, and will conflict with the native types.
</p>
</div>
</div>
Expand Down Expand Up @@ -73,5 +65,3 @@ To convert an existing app to TypeScript, you'll need to make the changes descri
[tsconfig]: ../application-development/configuration/#toc_tsconfigjson

<!-- External links -->

[DefinitelyTyped]: https://github.com/DefinitelyTyped/DefinitelyTyped

0 comments on commit 2bd0a11

Please sign in to comment.