Skip to content

Commit 2a55b20

Browse files
authored
Merge branch 'master' into middleware-options
2 parents 8b30268 + c6791b8 commit 2a55b20

File tree

6 files changed

+49
-77
lines changed

6 files changed

+49
-77
lines changed

CHANGELOG.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
## [4.0.0-alpha.1] - 2020-01-18
10+
11+
### Breaking 💥
12+
13+
- Drop support for Node 8 ([#1017])
14+
- Don't configure Babel for TS transpilation ([#1018])
15+
16+
### Under the hood 🚗
17+
18+
- Upgrade [✨ Prettier ✨](https://prettier.io) to a version that supports optional chaining and nullish coalescing ([#1018])
19+
- Add test for optional chaining and nullish coalescing ([#1018])
20+
- Add test for class field declaration ([#1018])
21+
22+
[#1017]: https://github.com/typed-ember/ember-cli-typescript/pull/1017
23+
[#1018]: https://github.com/typed-ember/ember-cli-typescript/pull/1018
24+
925
## [3.1.4] - 2020-05-29
1026

1127
### Fixed 🔧
@@ -19,7 +35,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
1935
[#1153]: https://github.com/typed-ember/ember-cli-typescript/pull/1153
2036
[3.1.4-deps-bumps]: https://github.com/typed-ember/ember-cli-typescript/pulls?q=is%3Apr+is%3Amerged+base%3Amaster+merged%3A2020-01-22T13%3A00%3A00-0600..2020-05-29T11%3A00%3A00-0500+chore%28deps%29+in%3Atitle+
2137

22-
2338
## [3.1.3] - 2020-01-22
2439

2540
### Fixed 🔧
@@ -636,7 +651,12 @@ We now use Babel 7's support for TypeScript to build apps and addons. Most of th
636651
* Basic, semi-working functionality.
637652

638653
[ember-cli-typify]: https://github.com/winding-lines/ember-cli-typify
639-
[unreleased]: https://github.com/typed-ember/ember-cli-typescript/compare/v3.1.3...HEAD
654+
[unreleased]: https://github.com/typed-ember/ember-cli-typescript/compare/v4.0.0-alpha.1...HEAD
655+
<!--
656+
This is correctly compared against v3.1.3 because it was released on a branch
657+
before v3.1.4 was released.
658+
-->
659+
[4.0.0-alpha.1]: https://github.com/typed-ember/ember-cli-typescript/compare/v3.1.3...v4.0.0-alpha.1
640660
[3.1.4]: https://github.com/typed-ember/ember-cli-typescript/compare/v3.1.3...v3.1.4
641661
[3.1.3]: https://github.com/typed-ember/ember-cli-typescript/compare/v3.1.2...v3.1.3
642662
[3.1.2]: https://github.com/typed-ember/ember-cli-typescript/compare/v3.1.1...v3.1.2

blueprint-files/ember-cli-typescript/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es2017",
3+
"target": "es2020",
44
"allowJs": true,
55
"moduleResolution": "node",
66
"allowSyntheticDefaultImports": true,

package.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-cli-typescript",
3-
"version": "3.1.4",
3+
"version": "4.0.0-alpha.1",
44
"description": "Allow ember apps to use typescript files.",
55
"keywords": [
66
"ember-addon",
@@ -39,14 +39,10 @@
3939
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -u"
4040
},
4141
"dependencies": {
42-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
43-
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
44-
"@babel/plugin-transform-typescript": "~7.10.4",
4542
"ansi-to-html": "^0.6.6",
4643
"broccoli-stew": "^3.0.0",
4744
"debug": "^4.0.0",
48-
"ember-cli-babel-plugin-helpers": "^1.0.0",
49-
"execa": "^3.0.0",
45+
"execa": "^4.0.0",
5046
"fs-extra": "^9.0.1",
5147
"resolve": "^1.5.0",
5248
"rsvp": "^4.8.1",
@@ -138,13 +134,12 @@
138134
"hawk": "7"
139135
},
140136
"engines": {
141-
"node": "8.* || >= 10.*"
137+
"node": "10.* || >= 12.*"
142138
},
143139
"ember-addon": {
144140
"configPath": "tests/dummy/config",
145141
"before": [
146-
"broccoli-watcher",
147-
"ember-cli-babel"
142+
"broccoli-watcher"
148143
]
149144
},
150145
"husky": {

tests/unit/build-test.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,19 @@ module('Unit | Build', function () {
2828
assert.equal(fromTs, 'From test-support');
2929
});
3030

31-
test('property initialization occurs in the right order', function (assert) {
32-
class TestClass {
33-
// we shouldn't encourage folks to write code like this, but tsc ensures
34-
// that constructor param fields are set before field initializers run
35-
field = this.constructorParam;
36-
constructor(private constructorParam: string) {}
31+
test('optional chaining and nullish coalescing are transpiled correctly', function (assert) {
32+
let value = { a: 'hello' } as { a?: string; b?: string };
33+
assert.equal(value?.a, 'hello');
34+
assert.equal(value?.b, undefined);
35+
assert.equal(value?.a ?? 'ok', 'hello');
36+
assert.equal(value?.b ?? 'ok', 'ok');
37+
});
38+
39+
test('class field declarations work', function (assert) {
40+
class MyClass {
41+
declare foo: string;
3742
}
3843

39-
let instance = new TestClass('hello');
40-
assert.equal(instance.field, 'hello');
44+
assert.notOk('foo' in new MyClass());
4145
});
42-
43-
// TODO: enable once a release of Prettier comes out that supports this syntax
44-
// test('optional chaining and nullish coalescing are transpiled correctly', function(assert) {
45-
// let value = { a: 'hello' } as { a?: string; b?: string };
46-
// assert.equal(value?.a, 'hello');
47-
// assert.equal(value?.b, undefined);
48-
// assert.equal(value?.a ?? 'ok', 'hello');
49-
// assert.equal(value?.b ?? 'ok', 'ok');
50-
// });
5146
});

ts/addon.ts

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import semver from 'semver';
22
import { Remote } from 'stagehand';
33
import { connect } from 'stagehand/lib/adapters/child-process';
4-
import { hasPlugin, addPlugin, AddPluginOptions } from 'ember-cli-babel-plugin-helpers';
54
import Addon from 'ember-cli/lib/models/addon';
65
import PreprocessRegistry from 'ember-cli-preprocess-registry';
76
import { addon } from './lib/utilities/ember-cli-entities';
@@ -84,24 +83,6 @@ export default addon({
8483
if (this.parent === this.project) {
8584
this._registerCollisionDetectionPreprocessor(registry);
8685
}
87-
88-
// Normally this is the sort of logic that would live in `included()`, but
89-
// ember-cli-babel reads the configured extensions when setting up the
90-
// preprocessor registry, so we need to beat it to the punch.
91-
this._registerBabelExtension();
92-
93-
// As of 3.7, TS supports the optional chaining and nullish coalescing proposals.
94-
// https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/
95-
// Since we can't necessarily know what version of TS an addon was developed with,
96-
// we unconditionally add the Babel plugins for both proposals.
97-
this._addBabelPluginIfNotPresent('@babel/plugin-proposal-optional-chaining');
98-
this._addBabelPluginIfNotPresent('@babel/plugin-proposal-nullish-coalescing-operator');
99-
100-
// Needs to come after the class properties plugin (see tests/unit/build-test.ts -
101-
// "property initialization occurs in the right order")
102-
this._addBabelPluginIfNotPresent('@babel/plugin-transform-typescript', {
103-
after: ['@babel/plugin-proposal-class-properties'],
104-
});
10586
},
10687

10788
shouldIncludeChildAddon(addon) {
@@ -154,10 +135,11 @@ export default addon({
154135
_checkBabelVersion() {
155136
let babel = this.parent.addons.find((addon) => addon.name === 'ember-cli-babel');
156137
let version = babel && babel.pkg.version;
157-
if (!babel || !(semver.gte(version!, '7.7.3') && semver.lt(version!, '8.0.0'))) {
138+
139+
if (!babel || !(semver.gte(version!, '7.17.0') && semver.lt(version!, '8.0.0'))) {
158140
let versionString = babel ? `version ${babel.pkg.version}` : `no instance of ember-cli-babel`;
159141
this.ui.writeWarnLine(
160-
`ember-cli-typescript requires ember-cli-babel ^7.7.3, but you have ${versionString} installed; ` +
142+
`ember-cli-typescript requires ember-cli-babel ^7.17.0, but you have ${versionString} installed; ` +
161143
'your TypeScript files may not be transpiled correctly.'
162144
);
163145
}
@@ -218,31 +200,6 @@ export default addon({
218200
}
219201
},
220202

221-
_getConfigurationTarget() {
222-
// If `this.app` isn't present, we know `this.parent` is an addon
223-
return this.app || (this.parent as Addon);
224-
},
225-
226-
_registerBabelExtension() {
227-
let target = this._getConfigurationTarget();
228-
let options: Record<string, any> = target.options || (target.options = {});
229-
let babelAddonOptions: Record<string, any> =
230-
options['ember-cli-babel'] || (options['ember-cli-babel'] = {});
231-
let extensions: string[] =
232-
babelAddonOptions.extensions || (babelAddonOptions.extensions = ['js']);
233-
234-
if (!extensions.includes('ts')) {
235-
extensions.push('ts');
236-
}
237-
},
238-
239-
_addBabelPluginIfNotPresent(pluginName: string, pluginOptions?: AddPluginOptions) {
240-
let target = this._getConfigurationTarget();
241-
if (!hasPlugin(target, pluginName)) {
242-
addPlugin(target, require.resolve(pluginName), pluginOptions);
243-
}
244-
},
245-
246203
_addTypecheckMiddleware(app: Application) {
247204
let workerPromise = this._getTypecheckWorker();
248205
let middleware = new TypecheckMiddleware(this.project, workerPromise);

yarn.lock

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@
698698
dependencies:
699699
"@babel/helper-plugin-utils" "^7.10.4"
700700

701-
"@babel/plugin-transform-typescript@^7.10.1", "@babel/plugin-transform-typescript@~7.10.4":
701+
"@babel/plugin-transform-typescript@^7.10.1":
702702
version "7.10.4"
703703
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.10.4.tgz#8b01cb8d77f795422277cc3fcf45af72bc68ba78"
704704
integrity sha512-3WpXIKDJl/MHoAN0fNkSr7iHdUMHZoppXjf2HJ9/ed5Xht5wNIsXllJXdityKOxeA3Z8heYRb1D3p2H5rfCdPw==
@@ -14970,7 +14970,12 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semve
1497014970
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
1497114971
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
1497214972

14973-
semver@^7.0.0, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2:
14973+
semver@^7.0.0:
14974+
version "7.1.2"
14975+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.1.2.tgz#847bae5bce68c5d08889824f02667199b70e3d87"
14976+
integrity sha512-BJs9T/H8sEVHbeigqzIEo57Iu/3DG6c4QoqTfbQB3BPA4zgzAomh/Fk9E7QtjWQ8mx2dgA9YCfSF4y9k9bHNpQ==
14977+
14978+
semver@^7.1.3, semver@^7.2.1, semver@^7.3.2:
1497414979
version "7.3.2"
1497514980
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
1497614981
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==

0 commit comments

Comments
 (0)