Skip to content

Commit c9dcf39

Browse files
authored
Merge branch 'master' into known-typings
2 parents 48618a2 + fe59313 commit c9dcf39

31 files changed

+6022
-138
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
/libpeerconnection.log
1616
npm-debug.log*
1717
testem.log
18-
yarn.lock
1918

2019
# TypeScript
2120
jsconfig.json

README.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Just run:
1414
ember install ember-cli-typescript@1
1515
```
1616

17-
All dependencies will be added to your `package.json`, and you're ready to roll! (If you're upgrading from a previous release, you should check to merge any tweaks you've made to `tsconfig.json`.
17+
All dependencies will be added to your `package.json`, and you're ready to roll!
18+
(If you're upgrading from a previous release, you should check to merge any
19+
tweaks you've made to `tsconfig.json`.
1820

1921
In addition to ember-cli-typescript, the following are installed:
2022

@@ -91,11 +93,17 @@ on the background and roadmap for the project.
9193

9294
[typing-your-ember]: http://www.chriskrycho.com/typing-your-ember.html
9395

96+
## Environment configuration typings
97+
98+
Along with the @types/ files mentioned above, ember-cli-typescript adds a
99+
starter interface for `config/environment.js` in `config/environment.d.ts`.
100+
This interface will likely require some changes to match your app.
101+
94102
## :construction: Using ember-cli-typescript with Ember CLI addons
95103

96-
**:warning: Warning: this is *not* currently recommended. This is a WIP part of the
97-
add-on, and it *will* make a dramatic difference in the size of your add-on in
98-
terms of installation. The upcoming 1.1 release will enable a much better
104+
**:warning: Warning: this is *not* currently recommended. This is a WIP part of
105+
the add-on, and it *will* make a dramatic difference in the size of your add-on
106+
in terms of installation. The upcoming 1.1 release will enable a much better
99107
experience for consumers of your addon.**
100108

101109
We're working on making a solution that lets us ship generated typings and
@@ -108,12 +116,6 @@ give users fair warning about the increased size. To enable TypeScript for your
108116
addon, simple move `ember-cli-typescript` from `devDependencies` to
109117
`dependencies` in your `package.json`.
110118

111-
## New modules API
112-
113-
Note: the new modules API is not yet supported by the official typings (which
114-
are distinct from this addon, though we install them). We hope to have support
115-
for them shortly!
116-
117119
## Not (yet) supported
118120

119121
While TS already works nicely for many things in Ember, there are a number of
@@ -123,15 +125,23 @@ landing in TypeScript itself.
123125

124126
[existing typings]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ember
125127

126-
We are hard at work (and would welcome your help!) [writing new typings] for
127-
Ember which can give correct types for Ember's custom object model. If you'd
128-
like to try those out, please see instructions in that repo!
128+
We are hard at work (and would welcome your help!) [writing new
129+
typings][ember-typings] for Ember and the surrounding ecosystem, which can give
130+
correct types for Ember's custom object model and things which build on it (e.g.
131+
ember-data). If you'd like to try those out, please see instructions in [that
132+
repo][ember-typings]!
129133

130-
[writing new typings]: https://github.com/typed-ember/ember-typings
134+
[ember-typings]: https://github.com/typed-ember/ember-typings
131135

132136
Here is the short list of things which do *not* work yet in the version of the
133137
typings published on DefinitelyTyped.
134138

139+
### New modules API
140+
141+
Note: the new modules API is not yet supported by the official typings (which
142+
are distinct from this addon, though we install them). We do have experimental
143+
support for them in the [ember-typings] repository, and it works quite well!
144+
135145
### Some `import`s don't resolve
136146

137147
You'll frequently see errors for imports which TypeScript doesn't know how to

blueprints/ember-cli-typescript/files/app/config/environment.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export default config;
88
* since different ember addons can materialize new entries.
99
*/
1010
declare namespace config {
11-
export var environment: any;
12-
export var modulePrefix: string;
13-
export var podModulePrefix: string;
14-
export var locationType: string;
11+
var environment: any;
12+
var modulePrefix: string;
13+
var podModulePrefix: string;
14+
var locationType: string;
15+
var rootURL: string;
1516
}

blueprints/ember-cli-typescript/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828

2929
locals() {
3030
return {
31-
inRepoAddons: (this.project.pkg['ember-addon'] || {}).paths || []
31+
inRepoAddons: (this.project.pkg['ember-addon'] || {}).paths || [],
3232
};
3333
},
3434

@@ -38,10 +38,10 @@ module.exports = {
3838

3939
afterInstall() {
4040
return this.addPackagesToProject([
41-
{ name: 'typescript', target: '^2.4.2' },
42-
{ name: '@types/ember', target: '^2.7.43' },
43-
{ name: '@types/rsvp', target: '^3.3.0' },
44-
{ name: '@types/ember-testing-helpers' },
41+
{ name: 'typescript', target: 'latest' },
42+
{ name: '@types/ember', target: 'latest' },
43+
{ name: '@types/rsvp', target: 'latest' },
44+
{ name: '@types/ember-testing-helpers', target: 'latest' },
4545
]);
4646
},
4747
};

config/ember-try.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,87 +5,87 @@ module.exports = {
55
name: 'ember-lts-2.4',
66
bower: {
77
dependencies: {
8-
'ember': 'components/ember#lts-2-4'
8+
ember: 'components/ember#lts-2-4',
99
},
1010
resolutions: {
11-
'ember': 'lts-2-4'
12-
}
11+
ember: 'lts-2-4',
12+
},
1313
},
1414
npm: {
1515
devDependencies: {
16-
'ember-source': null
17-
}
18-
}
16+
'ember-source': null,
17+
},
18+
},
1919
},
2020
{
2121
name: 'ember-lts-2.8',
2222
bower: {
2323
dependencies: {
24-
'ember': 'components/ember#lts-2-8'
24+
ember: 'components/ember#lts-2-8',
2525
},
2626
resolutions: {
27-
'ember': 'lts-2-8'
28-
}
27+
ember: 'lts-2-8',
28+
},
2929
},
3030
npm: {
3131
devDependencies: {
32-
'ember-source': null
33-
}
34-
}
32+
'ember-source': null,
33+
},
34+
},
3535
},
3636
{
3737
name: 'ember-release',
3838
bower: {
3939
dependencies: {
40-
'ember': 'components/ember#release'
40+
ember: 'components/ember#release',
4141
},
4242
resolutions: {
43-
'ember': 'release'
44-
}
43+
ember: 'release',
44+
},
4545
},
4646
npm: {
4747
devDependencies: {
48-
'ember-source': null
49-
}
50-
}
48+
'ember-source': null,
49+
},
50+
},
5151
},
5252
{
5353
name: 'ember-beta',
5454
bower: {
5555
dependencies: {
56-
'ember': 'components/ember#beta'
56+
ember: 'components/ember#beta',
5757
},
5858
resolutions: {
59-
'ember': 'beta'
60-
}
59+
ember: 'beta',
60+
},
6161
},
6262
npm: {
6363
devDependencies: {
64-
'ember-source': null
65-
}
66-
}
64+
'ember-source': null,
65+
},
66+
},
6767
},
6868
{
6969
name: 'ember-canary',
7070
bower: {
7171
dependencies: {
72-
'ember': 'components/ember#canary'
72+
ember: 'components/ember#canary',
7373
},
7474
resolutions: {
75-
'ember': 'canary'
76-
}
75+
ember: 'canary',
76+
},
7777
},
7878
npm: {
7979
devDependencies: {
80-
'ember-source': null
81-
}
82-
}
80+
'ember-source': null,
81+
},
82+
},
8383
},
8484
{
8585
name: 'ember-default',
8686
npm: {
87-
devDependencies: {}
88-
}
89-
}
90-
]
87+
devDependencies: {},
88+
},
89+
},
90+
],
9191
};

config/environment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
'use strict';
33

44
module.exports = function(/* environment, appConfig */) {
5-
return { };
5+
return {};
66
};

index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const path = require('path');
55
const SilentError = require('silent-error');
66
const TsPreprocessor = require('./lib/typescript-preprocessor');
77

8-
98
module.exports = {
109
name: 'ember-cli-typescript',
1110

@@ -18,18 +17,23 @@ module.exports = {
1817

1918
this.ui.writeInfoLine(
2019
'Skipping TypeScript preprocessing as there is no tsconfig.json. ' +
21-
'(If this is during installation of the add-on, this is as expected. If it is ' +
22-
'while building, serving, or testing the application, this is an error.)'
20+
'(If this is during installation of the add-on, this is as expected. If it is ' +
21+
'while building, serving, or testing the application, this is an error.)'
2322
);
2423
return;
2524
}
2625

2726
try {
28-
registry.add('js', new TsPreprocessor({
29-
ui: this.ui
30-
}));
27+
registry.add(
28+
'js',
29+
new TsPreprocessor({
30+
ui: this.ui,
31+
})
32+
);
3133
} catch (ex) {
32-
throw new SilentError(`Failed to instantiate TypeScript preprocessor, probably due to an invalid tsconfig.json. Please fix or run \`ember generate ember-cli-typescript\`.\n${ex}`);
34+
throw new SilentError(
35+
`Failed to instantiate TypeScript preprocessor, probably due to an invalid tsconfig.json. Please fix or run \`ember generate ember-cli-typescript\`.\n${ex}`
36+
);
3337
}
3438
},
3539
};

lib/typescript-preprocessor.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ class TypeScriptPreprocessor {
5050
});
5151
tsc.setDiagnosticWriter(this.ui.writeWarnLine.bind(this.ui));
5252

53-
const ts = debugTree(
54-
tsc,
55-
`${this._tag}`
56-
);
53+
const ts = debugTree(tsc, `${this._tag}`);
5754

5855
// Put everything together.
5956
return mergeTrees([js, ts], {

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const path = require('path');
55
const {
66
setupTestHooks,
77
emberNew,
8-
emberGenerate
8+
emberGenerate,
99
} = require('ember-cli-blueprint-test-helpers/helpers');
1010
const { expect, file } = require('ember-cli-blueprint-test-helpers/chai');
1111

@@ -23,10 +23,10 @@ describe('Acceptance: ember-cli-typescript generator', function() {
2323

2424
const json = JSON.parse(tsconfig.content);
2525
expect(json.compilerOptions.paths).to.deep.equal({
26-
'my-app/tests/*': [ 'tests/*' ],
27-
'my-app/*': [ 'app/*' ]
26+
'my-app/tests/*': ['tests/*'],
27+
'my-app/*': ['app/*'],
2828
});
29-
});
29+
});
3030
});
3131

3232
it('in-repo addons', function() {
@@ -37,10 +37,7 @@ describe('Acceptance: ember-cli-typescript generator', function() {
3737
const packagePath = path.resolve(process.cwd(), 'package.json');
3838
const contents = JSON.parse(fs.readFileSync(packagePath, { encoding: 'utf8' }));
3939
contents['ember-addon'] = {
40-
paths: [
41-
'lib/my-addon-1',
42-
'lib/my-addon-2'
43-
]
40+
paths: ['lib/my-addon-1', 'lib/my-addon-2'],
4441
};
4542
fs.writeFileSync(packagePath, JSON.stringify(contents, null, 2));
4643
})
@@ -51,14 +48,9 @@ describe('Acceptance: ember-cli-typescript generator', function() {
5148

5249
const json = JSON.parse(tsconfig.content);
5350
expect(json.compilerOptions.paths).to.deep.equal({
54-
'my-app/tests/*': [ 'tests/*' ],
55-
'my-app/*': [
56-
'app/*',
57-
'lib/my-addon-1/app/*',
58-
'lib/my-addon-2/app/*',
59-
]
51+
'my-app/tests/*': ['tests/*'],
52+
'my-app/*': ['app/*', 'lib/my-addon-1/app/*', 'lib/my-addon-2/app/*'],
6053
});
6154
});
6255
});
63-
6456
});

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"broccoli-plugin": "^1.2.1",
3636
"broccoli-source": "^1.1.0",
3737
"broccoli-stew": "^1.4.0",
38-
"broccoli-typescript-compiler": "^2.0.0",
38+
"broccoli-typescript-compiler": "^2.1.0",
3939
"debug": "^2.2.0",
4040
"ember-cli-babel": "^6.3.0",
4141
"silent-error": "^1.1.0"
@@ -45,7 +45,7 @@
4545
"broccoli-asset-rev": "^2.4.5",
4646
"ember-cli": "^2.13.3",
4747
"ember-cli-app-version": "^2.0.0",
48-
"ember-cli-blueprint-test-helpers": "^0.17.2",
48+
"ember-cli-blueprint-test-helpers": "^0.18.3",
4949
"ember-cli-dependency-checker": "^1.3.0",
5050
"ember-cli-eslint": "^3.0.0",
5151
"ember-cli-htmlbars": "^1.1.1",
@@ -76,5 +76,12 @@
7676
"before": [
7777
"ember-cli-babel"
7878
]
79+
},
80+
"prettier": {
81+
"printWidth": 100,
82+
"semi": true,
83+
"singleQuote": true,
84+
"trailingComma": "es5",
85+
"tabWidth": 2
7986
}
8087
}

0 commit comments

Comments
 (0)