ember-cli-typescript
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -7,2 +7,4 @@ 'use strict'; | ||
const APP_DECLARATIONS = ` | ||
import Ember from 'ember'; | ||
declare global { | ||
@@ -12,2 +14,4 @@ interface Array<T> extends Ember.ArrayPrototypeExtensions<T> {} | ||
} | ||
export {}; | ||
`; | ||
@@ -30,5 +34,11 @@ | ||
let inRepoAddons = (this.project.pkg['ember-addon'] || {}).paths || []; | ||
let hasMirage = 'ember-cli-mirage' in (this.project.pkg.devDependencies || {}); | ||
let isAddon = this.project.isEmberCLIAddon(); | ||
let includes = [isAddon ? 'addon' : 'app', 'tests'].concat(inRepoAddons); | ||
// Mirage is already covered for addons because it's under `tests/` | ||
if (hasMirage && !isAddon) { | ||
includes.push('mirage'); | ||
} | ||
return { | ||
@@ -42,2 +52,6 @@ includes: JSON.stringify(includes, null, 2).replace(/\n/g, '\n '), | ||
if (hasMirage) { | ||
paths[`${appName}/mirage/*`] = [`${isAddon ? 'tests/dummy/' : ''}mirage/*`]; | ||
} | ||
if (isAddon) { | ||
@@ -44,0 +58,0 @@ paths[`${appName}/*`] = ['tests/dummy/app/*']; |
@@ -1,2 +0,4 @@ | ||
export function initialize(/* application */) { | ||
import Application from '@ember/application'; | ||
export function initialize(application: Application): void { | ||
// application.inject('route', 'foo', 'service:foo'); | ||
@@ -3,0 +5,0 @@ } |
@@ -1,2 +0,4 @@ | ||
export function initialize(/* appInstance */) { | ||
import ApplicationInstance from '@ember/application/instance'; | ||
export function initialize(appInstance: ApplicationInstance): void { | ||
// appInstance.inject('route', 'foo', 'service:foo'); | ||
@@ -3,0 +5,0 @@ } |
@@ -9,2 +9,17 @@ # Changelog | ||
## [1.1.3] - 2018-02-16 | ||
### Fixes | ||
* Fix default blueprint for `types/<my app>/index.d.ts`: add missing import and an export statement so ambient declarations work. | ||
* Add types to initializer and instance initializer blueprints. | ||
* Special-case handling for Mirage so that it works at all, and update generators so it works "out of the box". | ||
* Stop assuming the ember-cli-qunit version consumers have installed will be sufficiently high for our tests to pass. | ||
## [1.1.2] - 2018-02-13 | ||
### Fixed | ||
* _Actually_ resolve the problem of throwing when running generators if `ember-cli-version-checker` version too low: put it in `dependencies`. | ||
## [1.1.1] - 2018-02-12 | ||
@@ -14,3 +29,3 @@ | ||
* No longer throw when running generators if `ember-cli-version-checker` version too low. | ||
* No longer throw when running generators if `ember-cli-version-checker` version too low by putting it in `peerDependencies`. | ||
* Clarified some parts of the README that misled people on handling certain errors. | ||
@@ -147,3 +162,5 @@ | ||
[ember-cli-typify]: https://github.com/winding-lines/ember-cli-typify | ||
[unreleased]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.1.1...HEAD | ||
[unreleased]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.1.3...HEAD | ||
[1.1.3]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.1.2...v1.1.3 | ||
[1.1.2]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.1.1...v1.1.2 | ||
[1.1.1]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.1.0...v1.1.1 | ||
@@ -150,0 +167,0 @@ [1.1.0]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.0.6...v1.1.0 |
@@ -58,3 +58,8 @@ 'use strict'; | ||
let tree = new MergeTrees(addonAppTrees.concat([triggerTree, appTree]), { overwrite: true }); | ||
let mirage = this._mirageDirectory(); | ||
let mirageTree = mirage && new TypescriptOutput(this, { | ||
[mirage]: 'app/mirage', | ||
}); | ||
let tree = new MergeTrees(addonAppTrees.concat([triggerTree, appTree, mirageTree].filter(Boolean)), { overwrite: true }); | ||
return new Funnel(tree, { srcDir: 'app' }); | ||
@@ -163,2 +168,27 @@ } | ||
_mirageDirectory() { | ||
let mirage = this.project.addons.find(addon => addon.name === 'ember-cli-mirage'); | ||
if (mirage) { | ||
// Be a little defensive, since we're using an internal Mirage API | ||
if ( | ||
typeof mirage._shouldIncludeFiles !== 'function' || | ||
typeof mirage.mirageDirectory !== 'string' | ||
) { | ||
this.ui.writeWarnLine( | ||
`Couldn't determine whether to include Mirage files. This is likely a bug in ember-cli-typescript; ` + | ||
`please file an issue at https://github.com/typed-ember/ember-cli-typescript` | ||
); | ||
return; | ||
} | ||
if (mirage._shouldIncludeFiles()) { | ||
let source = mirage.mirageDirectory; | ||
if (source.indexOf(this.project.root) === 0) { | ||
source = source.substring(this.project.root.length + 1); | ||
} | ||
return source; | ||
} | ||
} | ||
} | ||
_touchRebuildTrigger() { | ||
@@ -165,0 +195,0 @@ debugAutoresolve('touching rebuild trigger.'); |
{ | ||
"name": "ember-cli-typescript", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Allow ember apps to use typescript files.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -25,2 +25,3 @@ # ember-cli-typescript | ||
* [ember-browserify](#ember-browserify) | ||
* [ember-cli-mirage](#ember-cli-mirage) | ||
* ["TypeScript is complaining about multiple copies of the same types"](#typescript-is-complaining-about-multiple-copies-of-the-same-types) | ||
@@ -53,3 +54,3 @@ * [Just tell me how to fix it](#just-tell-me-how-to-fix-it) | ||
* [`@types/ember`](https://www.npmjs.com/package/@types/ember) | ||
* [`@types/ember-data`](https://www.npmjs.com/package/@types/ember) | ||
* [`@types/ember-data`](https://www.npmjs.com/package/@types/ember-data) | ||
* [`@types/rsvp`](https://www.npmjs.com/package/@types/rsvp) | ||
@@ -415,3 +416,3 @@ * [`@types/ember-test-helpers`](https://www.npmjs.com/package/@types/ember-test-helpers) – these are the importable test helpers from [RFC #232](https://github.com/emberjs/rfcs/blob/master/text/0232-simplify-qunit-testing-api.md)-style tests | ||
```js | ||
import 'npm:my-module' from 'my-module'; | ||
import MyModule from 'npm:my-module'; | ||
``` | ||
@@ -432,2 +433,43 @@ | ||
### ember-cli-mirage | ||
Mirage adds files from a nonstandard location to your application tree, so you'll need to tell the TypeScript compiler about how that layout works. | ||
For an app, this should look roughly like: | ||
```js | ||
{ | ||
"compilerOptions": { | ||
"paths": { | ||
// ... | ||
"my-app-name/mirage/*": "mirage/*", | ||
} | ||
}, | ||
"include": [ | ||
"app", | ||
"tests", | ||
"mirage" | ||
] | ||
} | ||
``` | ||
And for an addon: | ||
```js | ||
{ | ||
"compilerOptions": { | ||
"paths": { | ||
// ... | ||
"dummy/mirage/*": "tests/dummy/mirage/*", | ||
} | ||
}, | ||
"include": [ | ||
"addon", | ||
"tests" | ||
] | ||
} | ||
``` | ||
Note that if Mirage was present when you installed ember-cli-typescript (or if you run `ember g ember-cli-typescript`), this configuration should be automatically set up for you. | ||
### "TypeScript is complaining about multiple copies of the same types!" | ||
@@ -434,0 +476,0 @@ |
157039
2117
590