Skip to content

Commit bb39523

Browse files
authored
Merge pull request #164 from typed-ember/environment-declaration
Move `environment.d.ts` back into `app/` so it resolves correctly out of the box
2 parents 503830f + 7e3b265 commit bb39523

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
1919
### Fixed
2020

2121
* Addon components need to manually set their layout property to the imported compiled template.
22+
* The declaration file for the `<app-name>/config/environment` module now resolves correctly from app code. If you have a version of this file previously generated at `types/<app-name>/config/environment.d.ts`, you'll likely want to move it to `app/config/environment.d.ts`.
2223

2324
## [1.1.6] - 2018-02-23
2425

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ In addition to ember-cli-typescript, we make the following changes to your proje
6161

6262
* [`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html)
6363
* `types/<app name>/index.d.ts` – the location for any global type declarations you need to write for you own application; see [Global types for your package](#global-types-for-your-package) for information on its default contents and how to use it effectively
64-
* `types/<app name>/config/environment.d.ts` – a basic set of types defined for the contents of the `config/environment.js` file in your app; see [Environment and configuration typings](#environment-and-configuration-typings) for details
64+
* `app/config/environment.d.ts` – a basic set of types defined for the contents of the `config/environment.js` file in your app; see [Environment and configuration typings](#environment-and-configuration-typings) for details
6565

6666
### Ember support
6767

@@ -147,9 +147,9 @@ In the case of applications (but not for addons), we also automatically include
147147

148148
#### Environment configuration typings
149149

150-
Along with the @types/ files mentioned above, ember-cli-typescript adds a starter interface for `config/environment.js` in `config/environment.d.ts`. This interface will likely require some changes to match your app.
150+
Along with the @types/ files mentioned above, ember-cli-typescript adds a starter interface for `config/environment.js` in `app/config/environment.d.ts`. This interface will likely require some changes to match your app.
151151

152-
We install this file because the actual `config/environment.js` is (a) not actually identical with the types as you inherit them in the content of an application, but rather a superset of what an application has access to, and (b) not in a the same location as the path at which you look it up. We map it to the lookup path within your `types` directory, and TypeScript resolves it correctly.
152+
We install this file because the actual `config/environment.js` is (a) not actually identical with the types as you inherit them in the content of an application, but rather a superset of what an application has access to, and (b) not in a the same location as the path at which you look it up. The actual `config/environment.js` file executes in Node during the build, and Ember CLI writes its result as `<my-app>/config/environment` into your build for consumption at runtime.
153153

154154
### String-keyed lookups
155155

blueprints/ember-cli-typescript/files/types/__app_name__/config/environment.d.ts renamed to blueprints/ember-cli-typescript/files/__root__/config/environment.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export default config;
77
* For now these need to be managed by the developer
88
* since different ember addons can materialize new entries.
99
*/
10-
declare namespace config {
11-
var environment: any;
12-
var modulePrefix: string;
13-
var podModulePrefix: string;
14-
var locationType: string;
15-
var rootURL: string;
16-
}
10+
declare const config: {
11+
environment: any;
12+
modulePrefix: string;
13+
podModulePrefix: string;
14+
locationType: string;
15+
rootURL: string;
16+
};

node-tests/blueprints/ember-cli-typescript-test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('Acceptance: ember-cli-typescript generator', function() {
7777
expect(projectTypes).to.exist;
7878
expect(projectTypes).to.include(ects.APP_DECLARATIONS);
7979

80-
const environmentTypes = file('types/my-app/config/environment.d.ts');
80+
const environmentTypes = file('app/config/environment.d.ts');
8181
expect(environmentTypes).to.exist;
8282

8383
const emberDataCatchallTypes = file('types/ember-data.d.ts');
@@ -122,6 +122,9 @@ describe('Acceptance: ember-cli-typescript generator', function() {
122122
expect(projectTypes).to.exist;
123123
expect(projectTypes).not.to.include(ects.APP_DECLARATIONS);
124124

125+
const environmentTypes = file('tests/dummy/app/config/environment.d.ts');
126+
expect(environmentTypes).to.exist;
127+
125128
const emberDataCatchallTypes = file('types/ember-data.d.ts');
126129
expect(emberDataCatchallTypes).not.to.exist;
127130
});

0 commit comments

Comments
 (0)