Skip to content

Commit 1f172f0

Browse files
authored
Merge pull request #51 from emberwatch/readme-and-ci-tweaks
CI info and updated README!
2 parents fed2a4a + e9a7e74 commit 1f172f0

File tree

3 files changed

+62
-47
lines changed

3 files changed

+62
-47
lines changed

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ script:
3535
# Usually, it's ok to finish the test scenario without reverting
3636
# to the addon's original dependency state, skipping "cleanup".
3737
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
38+
39+
# We build PRs, but don't trigger separate builds for the PR from the branch.
40+
branches:
41+
only:
42+
- master

README.md

+46-40
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ember-cli-typescript
22

3+
[![*nix build status](https://travis-ci.org/emberwatch/ember-cli-typescript.svg?branch=master)](https://travis-ci.org/emberwatch/ember-cli-typescript)
4+
[![Windows build status](https://ci.appveyor.com/api/projects/status/pjilqv1xo3o9auon/branch/master?svg=true)](https://ci.appveyor.com/project/chriskrycho/ember-cli-typescript/branch/master)
5+
36
Use TypeScript in your Ember 2.x apps!
47

58

@@ -50,16 +53,18 @@ to restart the server to take the changes into account.
5053
### Quirks with `tsconfig.json`
5154

5255
Additionally, depending on what you're doing, you may notice that your tweaks to
53-
`tsconfig.json` don't get picked up by the compiler at all.
56+
`tsconfig.json` aren't applied *exactly* as you might expect.
5457

5558
#### The Problem
5659

57-
The configuration file is used by both Ember CLI/[broccoli](http://broccolijs.com/)
58-
and `tsc` command line compiler (used by e.g. [VS Code](http://code.visualstudio.com/),
59-
JetBrains IDEs, etc.).
60+
The configuration file is used by both Ember CLI (via [broccoli]) and the `tsc`
61+
command line compiler (used by e.g. [VS Code], JetBrains IDEs, etc.).
62+
63+
[broccoli]: http://broccolijs.com/
64+
[VS Code]: http://code.visualstudio.com/
6065

6166
Broccoli controls the inputs and the output folder of the various build steps
62-
that make the Ember build pipeline. Its expectation are impacted by Typescript
67+
that make the Ember build pipeline. Its expectation are impacted by TypeScript
6368
configuration properties like "include", "exclude", "outFile", "outDir".
6469

6570
We want to allow you to change unrelated properties in the tsconfig file.
@@ -68,13 +73,18 @@ We want to allow you to change unrelated properties in the tsconfig file.
6873

6974
This addon takes the following approach to allow this dual use:
7075

71-
- it starts with the following [blueprint](https://github.com/emberwatch/ember-cli-typescript/blob/master/blueprints/ember-cli-typescript/files/tsconfig.json)
76+
- it starts with the default [blueprint].
7277

7378
- the generated tsconfig file does not set "outDir" and sets "noEmit" to true.
7479
This allows you to run vscode and tsc without creating `.js` files throughout
7580
your codebase.
7681

77-
- before calling broccoli the addon removes "outDir" and sets "noEmit" and "includes"
82+
- before calling broccoli the addon removes any configured `outDir`, sets the
83+
`noEmit` option to false (so that the compiler will emit files for consumption
84+
by your app!), and removes all values set for `include`, since we use Broccoli
85+
to manage the build pipeline directly.
86+
87+
[blueprint]: https://github.com/emberwatch/ember-cli-typescript/blob/master/blueprints/ember-cli-typescript/files/tsconfig.json
7888

7989
### Customization
8090

@@ -95,41 +105,33 @@ If you are porting an existing app to TypeScript, you can install this addon and
95105
migrate your files incrementally by changing their extensions from `.js` to
96106
`.ts`. A good approach is to start at your leaf files and then work your way
97107
up. As TypeScript starts to find errors, make sure to celebrate your (small)
98-
wins with your team, specially if some people are not convinced yet. We would also
99-
love to hear your stories.
108+
wins with your team, specially if some people are not convinced yet. We would
109+
also love to hear your stories!
100110

101-
## VSCode setup
111+
You may also find the blog series ["Typing Your Ember"][typing-your-ember]
112+
helpful as it walks you through not only how to install but how to most
113+
effectively use TypeScript in an Ember app today, and gives some important info
114+
on the background and roadmap for the project.
102115

103-
Create the file `.vscode/settings.json` with the following content:
104-
105-
```json
106-
// Place your settings in this file to overwrite default and user settings.
107-
{
108-
"typescript.tsdk" : "node_modules/typescript/lib"
109-
}
110-
```
116+
[typing-your-ember]: http://www.chriskrycho.com/typing-your-ember.html
111117

112118
## Not (yet) supported
113119

114120
While TS works nicely for many things in Ember, there are a number of corners
115-
where it *won't* help you out. These are worth being aware of. Some of them are
116-
just a matter of further work on updating the [typings]; others are a matter of
117-
further support landing in TypeScript itself.
121+
where it *won't* help you out. Some of them are just a matter of further work on
122+
updating the [typings]; others are a matter of further support landing in
123+
TypeScript itself.
118124

119125
[typings]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ember
120126

121127
Here is the short list of things which do *not* work yet.
122128

123-
### Extending from framework entities using `class` syntax
124-
125-
```js
126-
export default MyComponent extends Ember.Component {
127-
}
128-
```
129-
130129
### Type safety when invoking actions
131130

132-
```ts
131+
TypeScript won't detect a mismatch between this action and the corresponding
132+
call in the template:
133+
134+
```typescript
133135
actions: {
134136
turnWheel(degrees: number) {
135137
...
@@ -138,37 +140,44 @@ actions: {
138140
```
139141

140142
```hbs
141-
<!-- TypeScript compiler won't detect this type mismatch -->
142143
<button onclick={{action 'turnWheel' 'NOT-A-NUMBER'}}> Click Me </button>
143144
```
144145

145-
```js
146+
Likewise, it won't notice a problem when you use `send`:
147+
148+
```typescript
146149
// TypeScript compiler won't detect this type mismatch
147150
this.send('turnWheel', 'ALSO-NOT-A-NUMBER');
148151
```
149152

150153
### Type safety when invoking KVO compliant accessors or mutators
151154

152-
```ts
155+
When you use `Ember.get` or `Ember.set`, TypeScript won't (yet!) warn you that
156+
you're using the wrong type. So in `foo()` here, this will pass the compiler but
157+
be wrong at runtime:
158+
159+
```typescript
153160
Ember.Object.extend({
154161
urls: <string[]> null,
155-
port: 4200,
162+
port: 4200, // number
156163
init() {
157164
this._super(...arguments);
158165
this.set('urls', []);
159166
},
160167
foo() {
161168
// TypeScript won't detect these type mismatches
162169
this.get('urls').addObject(51);
163-
this.set('port', 3000);
170+
this.set('port', '3000');
164171
}
165172
});
166173
```
167174

168175

169-
### The TypeDefs I need to reference are not in node_modules/@types
176+
### The type definitions I need to reference are not in `node_modules/@types`
170177

171-
By default `ember-cli-typescript` loads up any type defs found in node_modules/@types. If the type defs you need are not found here you can register a custom `path` in the tsconfig.json file
178+
By default `ember-cli-typescript` loads up any type defs found in
179+
`node_modules/@types`. If the type defs you need are not found here you can
180+
register a custom `path` in the tsconfig.json file:
172181

173182
```json
174183
// tsconfig.json
@@ -178,9 +187,6 @@ By default `ember-cli-typescript` loads up any type defs found in node_modules/@
178187
"welp/*": ["app/*"],
179188
"redux": ["node_modules/redux/index.d.ts"]
180189
}
181-
},
182-
"include": [
183-
"**/*.ts"
184-
]
190+
}
185191
}
186192
```

appveyor.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,24 @@ install:
2121
- rename C:\Python27 Python27hidden
2222
# Typical npm stuff.
2323
- md C:\nc
24-
- npm config set cache C:\nc
25-
- npm version
26-
- npm install --no-optional
27-
- npm install -g bower
28-
- bower install
24+
- yarn --ignore-optional
25+
26+
cache:
27+
- "%LOCALAPPDATA%\\Yarn"
2928

3029
# Post-install test scripts.
3130
test_script:
3231
# Output useful info for debugging.
33-
- npm version
34-
- cmd: npm test
32+
- yarn versions
33+
- cmd: yarn run test
3534

3635
# Don't actually build.
3736
build: off
3837

3938
# Set build version format here instead of in the admin panel.
4039
version: "{build}"
40+
41+
# We build PRs, but don't trigger separate builds for the PR from the branch.
42+
branches:
43+
only:
44+
- master

0 commit comments

Comments
 (0)