Skip to content

Commit 2a6236a

Browse files
committed
test: update for TS 3.7/Babel 7.7.0
* remove property initialization order test * upgrade prettier (so it understands class field declarations) * add test for class field declarations * enable optional chaining and nullish coalescing test (bonus)
1 parent 4cbf07e commit 2a6236a

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"in-repo-b": "link:tests/dummy/lib/in-repo-b",
119119
"loader.js": "4.7.0",
120120
"mocha": "6.2.2",
121-
"prettier": "1.18.2",
121+
"prettier": "1.19.1",
122122
"qunit-dom": "0.9.2",
123123
"testdouble": "3.12.4",
124124
"tmp": "0.1.0",

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
});

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13358,10 +13358,10 @@ prettier-linter-helpers@^1.0.0:
1335813358
dependencies:
1335913359
fast-diff "^1.1.2"
1336013360

13361-
prettier@1.18.2:
13362-
version "1.18.2"
13363-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
13364-
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==
13361+
prettier@1.19.1:
13362+
version "1.19.1"
13363+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
13364+
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
1336513365

1336613366
pretty-hrtime@^1.0.3:
1336713367
version "1.0.3"

0 commit comments

Comments
 (0)