Skip to content

Commit

Permalink
feature #75 Making enableTypeScriptLoader() options callback optional…
Browse files Browse the repository at this point in the history
… (weaverryan)

This PR was merged into the master branch.

Discussion
----------

Making enableTypeScriptLoader() options callback optional

The `enableTypeScriptLoader()` should allow for no callback function - it's probably not needed in most cases.

Ping @davidmpaz

Commits
-------

0e0f3de Making enableTypeScriptLoader() options callback optional
  • Loading branch information
weaverryan committed Jul 6, 2017
2 parents 1b28b3f + 0e0f3de commit 6d8099e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,19 @@ module.exports = {
/**
* Call this if you plan on loading TypeScript files.
*
* Encore.enableTypeScriptLoader()
*
* Or, configure the ts-loader options:
*
* Encore.enableTypeScriptLoader(function(tsConfig) {
* // change the tsConfig
* // https://github.com/TypeStrong/ts-loader/blob/master/README.md#loader-options
* // tsConfig.silent = false;
* });
*
* Supported configuration options:
* @see https://github.com/TypeStrong/ts-loader/blob/master/README.md#available-options
*
* @param {function} callback
* @return {exports}
*/
enableTypeScriptLoader(callback) {
enableTypeScriptLoader(callback = () => {}) {
webpackConfig.enableTypeScriptLoader(callback);
},

Expand Down
2 changes: 1 addition & 1 deletion lib/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class WebpackConfig {
this.useReact = true;
}

enableTypeScriptLoader(callback) {
enableTypeScriptLoader(callback = () => {}) {
this.useTypeScriptLoader = true;

if (typeof callback !== 'function') {
Expand Down
4 changes: 0 additions & 4 deletions test/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,6 @@ describe('WebpackConfig object', () => {
expect(() => {
config.enableTypeScriptLoader('FOO');
}).to.throw('must be a callback function');

expect(() => {
config.enableTypeScriptLoader();
}).to.throw('must be a callback function');
});
});

Expand Down

0 comments on commit 6d8099e

Please sign in to comment.