File tree Expand file tree Collapse file tree 4 files changed +22
-24
lines changed Expand file tree Collapse file tree 4 files changed +22
-24
lines changed Original file line number Diff line number Diff line change 126126 "testdouble" : " 3.12.4" ,
127127 "tmp" : " 0.1.0" ,
128128 "ts-node" : " 8.4.1" ,
129- "typescript" : " 3.6.4 "
129+ "typescript" : " 3.7.2 "
130130 },
131131 "resolutions" : {
132132 "@types/ember" : " 3.1.1" ,
Original file line number Diff line number Diff line change @@ -39,4 +39,13 @@ module('Unit | Build', function() {
3939 let instance = new TestClass ( 'hello' ) ;
4040 assert . equal ( instance . field , 'hello' ) ;
4141 } ) ;
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+ // });
4251} ) ;
Original file line number Diff line number Diff line change @@ -79,11 +79,10 @@ export default addon({
7979
8080 // As of 3.7, TS supports the optional chaining and nullish coalescing proposals.
8181 // https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/
82- let tsVersion = this . _getProjectTypeScriptVersion ( ) ;
83- if ( semver . gte ( tsVersion , '3.7.0-alpha.0' ) ) {
84- this . _addBabelPluginIfNotPresent ( '@babel/plugin-proposal-optional-chaining' ) ;
85- this . _addBabelPluginIfNotPresent ( '@babel/plugin-proposal-nullish-coalescing-operator' ) ;
86- }
82+ // Since we can't necessarily know what version of TS an addon was developed with,
83+ // we unconditionally add the Babel plugins for both proposals.
84+ this . _addBabelPluginIfNotPresent ( '@babel/plugin-proposal-optional-chaining' ) ;
85+ this . _addBabelPluginIfNotPresent ( '@babel/plugin-proposal-nullish-coalescing-operator' ) ;
8786
8887 // Needs to come after the class properties plugin (see tests/unit/build-test.ts -
8988 // "property initialization occurs in the right order")
@@ -190,17 +189,6 @@ export default addon({
190189 }
191190 } ,
192191
193- _getProjectTypeScriptVersion ( ) {
194- try {
195- let pkg = this . project . require ( 'typescript/package.json' ) as { version : string } ;
196- return pkg . version ;
197- } catch {
198- throw new Error (
199- `[ember-cli-typescript] Unable to determine project TypeScript version; is it installed?`
200- ) ;
201- }
202- } ,
203-
204192 _addTypecheckMiddleware ( app : Application ) {
205193 let workerPromise = this . _getTypecheckWorker ( ) ;
206194 let middleware = new TypecheckMiddleware ( this . project , workerPromise ) ;
Original file line number Diff line number Diff line change @@ -7572,7 +7572,6 @@ esdoc-ecmascript-proposal-plugin@^1.0.0:
75727572
75737573esdoc@pzuraq/esdoc#015a342:
75747574 version "1.0.4"
7575- uid "015a3426b2e53b2b0270a9c00133780db3f1d144"
75767575 resolved "https://codeload.github.com/pzuraq/esdoc/tar.gz/015a3426b2e53b2b0270a9c00133780db3f1d144"
75777576 dependencies:
75787577 babel-generator "6.26.0"
@@ -9516,10 +9515,12 @@ imurmurhash@^0.1.4:
95169515 integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
95179516
95189517"in-repo-a@link:tests/dummy/lib/in-repo-a":
9519- version "1.0.0"
9518+ version "0.0.0"
9519+ uid ""
95209520
95219521"in-repo-b@link:tests/dummy/lib/in-repo-b":
9522- version "1.0.0"
9522+ version "0.0.0"
9523+ uid ""
95239524
95249525include-path-searcher@^0.1.0:
95259526 version "0.1.0"
@@ -15718,10 +15719,10 @@ typescript-memoize@^1.0.0-alpha.3:
1571815719 dependencies:
1571915720 core-js "2.4.1"
1572015721
15721- typescript@3.6.4 :
15722- version "3.6.4 "
15723- resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.4 .tgz#b18752bb3792bc1a0281335f7f6ebf1bbfc5b91d "
15724- integrity sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg ==
15722+ typescript@3.7.2 :
15723+ version "3.7.2 "
15724+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2 .tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb "
15725+ integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ ==
1572515726
1572615727uc.micro@^1.0.0, uc.micro@^1.0.1, uc.micro@^1.0.5:
1572715728 version "1.0.6"
You can’t perform that action at this time.
0 commit comments