File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -27,4 +27,16 @@ module('Unit | Build', function() {
2727 assert . ok ( fromTs ) ;
2828 assert . equal ( fromTs , 'From test-support' ) ;
2929 } ) ;
30+
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 ) { }
37+ }
38+
39+ let instance = new TestClass ( 'hello' ) ;
40+ assert . equal ( instance . field , 'hello' ) ;
41+ } ) ;
3042} ) ;
Original file line number Diff line number Diff line change @@ -67,7 +67,6 @@ export default addon({
6767 // preprocessor registry, so we need to beat it to the punch.
6868 this . _registerBabelExtension ( ) ;
6969
70- this . _addPluginIfMissing ( '@babel/plugin-transform-typescript' ) ;
7170 this . _addPluginIfMissing (
7271 '@babel/plugin-proposal-class-properties' ,
7372 { loose : true } ,
@@ -76,6 +75,10 @@ export default addon({
7675 after : [ '@babel/plugin-proposal-decorators' ] ,
7776 }
7877 ) ;
78+
79+ // Needs to come after the class properties plugin (see tests/unit/build-test.ts -
80+ // "property initialization occurs in the right order")
81+ this . _addPluginIfMissing ( '@babel/plugin-transform-typescript' ) ;
7982 } ,
8083
8184 shouldIncludeChildAddon ( addon ) {
You can’t perform that action at this time.
0 commit comments