Skip to content

Commit 74a9d14

Browse files
committed
Improve ergonomics when installing from git
1 parent 20a9143 commit 74a9d14

File tree

3 files changed

+1201
-3
lines changed

3 files changed

+1201
-3
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Use TypeScript in your Ember 2.x and 3.x apps!
3535
* [Linking Addons](#linking-addons)
3636
* [In-Repo Addons](#in-repo-addons)
3737
* [Gotchas](#gotchas)
38+
* [Installing from git](#installing-from-git])
3839
* [Current limitations](#current-limitations)
3940
* [Some `import`s don't resolve](#some-imports-dont-resolve)
4041
* [Type safety when invoking actions](#type-safety-when-invoking-actions)
@@ -708,6 +709,10 @@ A few things to look out for when working with TypeScript in addons:
708709
* Normally, addons under development automatically return `true` from their `isDevelopingAddon()` hook, which `ember-cli-typescript` relies on to determine whether to process the addon's `.ts` files. However, if the name field in your `package.json` doesn't match the name in your `index.js`, this default behavior will fail and you'll need to override the method yourself.
709710
* TypeScript has very particular rules when generating declaration files to avoid letting private types leak out unintentionally. You may find it useful to run `ember ts:precompile` yourself as you're getting a feel for these rules to ensure everything will go smoothly when you publish.
710711

712+
## Installing from git
713+
714+
This addon uses TypeScript for its own implementation, so if you install `ember-cli-typescript` from git rather than from the npm registry, you won't get compiled `.js` files. To get everything working, you can install `ts-node` as a project dependency, and `ember-cli-typescript` will ensure it's registered correctly to transpile source files as needed.
715+
711716
## Current limitations
712717

713718
While TS already works nicely for many things in Ember, there are a number of corners where it _won't_ help you out. Some of them are just a matter of further work on updating the [existing typings]; others are a matter of further support landing in TypeScript itself, or changes to Ember's object model.

register-ts-node.js

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

33
// eslint-disable-next-line node/no-deprecated-api
44
if (!require.extensions['.ts']) {
5+
let options = { project: `${__dirname}/ts/tsconfig.json` };
6+
7+
// If we're operating in the context of another project, which might happen
8+
// if someone has installed ember-cli-typescript from git, only perform
9+
// transpilation and skip the default ignore glob (which prevents anything
10+
// in node_modules from being transpiled)
11+
if (process.cwd() !== __dirname) {
12+
options.skipIgnore = true;
13+
options.transpileOnly = true;
14+
}
15+
516
// eslint-disable-next-line node/no-unpublished-require
6-
require('ts-node').register({
7-
project: `${__dirname}/ts/tsconfig.json`
8-
});
17+
require('ts-node').register(options);
918
}

0 commit comments

Comments
 (0)