angular2-template-loader icon indicating copy to clipboard operation
angular2-template-loader copied to clipboard

Adding type assertion <string> option to fix issues with typescript type checks

Open julianosam opened this issue 9 years ago • 5 comments

Typescript complains about the return type of the require() function once A2 defines the component template field as type string. The correct A2 component annotation should be as follows:

@Component({
  selector: 'my-component',
  template: <string> require('./my-template.html'),
  styles: [<string> require('./my-style.css')]
})

This adds an option to include typeAssertion to the require() generation. It supports both passing it as a query param angular2-template-loader?typeAssertion=true or the via options plugin supported by Webpack 2. Right now, it leaves the type assertion inclusion defaulted to false. But I think it should be defaulted to true in a near future.

julianosam avatar Oct 31 '16 00:10 julianosam

Current coverage is 95.65% (diff: 100%)

Merging #37 into master will increase coverage by 1.53%

@@             master        #37   diff @@
==========================================
  Files             1          1          
  Lines            17         23     +6   
  Methods           5          5          
  Messages          0          0          
  Branches          3          6     +3   
==========================================
+ Hits             16         22     +6   
  Misses            1          1          
  Partials          0          0          

Powered by Codecov. Last update c411e90...866918e

codecov-io avatar Oct 31 '16 12:10 codecov-io

Current coverage is 95.65% (diff: 100%)

Merging #37 into master will increase coverage by 1.53%

@@             master        #37   diff @@
==========================================
  Files             1          1          
  Lines            17         23     +6   
  Methods           5          5          
  Messages          0          0          
  Branches          3          6     +3   
==========================================
+ Hits             16         22     +6   
  Misses            1          1          
  Partials          0          0          

Powered by Codecov. Last update c411e90...866918e

codecov-io avatar Oct 31 '16 12:10 codecov-io

Current coverage is 95.65% (diff: 100%)

Merging #37 into master will increase coverage by 1.53%

@@             master        #37   diff @@
==========================================
  Files             1          1          
  Lines            17         23     +6   
  Methods           5          5          
  Messages          0          0          
  Branches          3          6     +3   
==========================================
+ Hits             16         22     +6   
  Misses            1          1          
  Partials          0          0          

Powered by Codecov. Last update c411e90...866918e

codecov-io avatar Oct 31 '16 12:10 codecov-io

Current coverage is 95.65% (diff: 100%)

Merging #37 into master will increase coverage by 1.53%

@@             master        #37   diff @@
==========================================
  Files             1          1          
  Lines            17         23     +6   
  Methods           5          5          
  Messages          0          0          
  Branches          3          6     +3   
==========================================
+ Hits             16         22     +6   
  Misses            1          1          
  Partials          0          0          

Powered by Codecov. Last update c411e90...866918e

codecov-io avatar Oct 31 '16 12:10 codecov-io

Would you merge conflicts sorry I'm just getting to this. 😅

TheLarkInn avatar Nov 29 '16 13:11 TheLarkInn