Skip to content

Commit 6d8099e

Browse files
committed
feature #75 Making enableTypeScriptLoader() options callback optional (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
2 parents 1b28b3f + 0e0f3de commit 6d8099e

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,19 @@ module.exports = {
345345
/**
346346
* Call this if you plan on loading TypeScript files.
347347
*
348+
* Encore.enableTypeScriptLoader()
349+
*
350+
* Or, configure the ts-loader options:
351+
*
348352
* Encore.enableTypeScriptLoader(function(tsConfig) {
349-
* // change the tsConfig
353+
* // https://github.com/TypeStrong/ts-loader/blob/master/README.md#loader-options
354+
* // tsConfig.silent = false;
350355
* });
351356
*
352-
* Supported configuration options:
353-
* @see https://github.com/TypeStrong/ts-loader/blob/master/README.md#available-options
354-
*
355357
* @param {function} callback
356358
* @return {exports}
357359
*/
358-
enableTypeScriptLoader(callback) {
360+
enableTypeScriptLoader(callback = () => {}) {
359361
webpackConfig.enableTypeScriptLoader(callback);
360362
},
361363

lib/WebpackConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class WebpackConfig {
226226
this.useReact = true;
227227
}
228228

229-
enableTypeScriptLoader(callback) {
229+
enableTypeScriptLoader(callback = () => {}) {
230230
this.useTypeScriptLoader = true;
231231

232232
if (typeof callback !== 'function') {

test/WebpackConfig.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,6 @@ describe('WebpackConfig object', () => {
292292
expect(() => {
293293
config.enableTypeScriptLoader('FOO');
294294
}).to.throw('must be a callback function');
295-
296-
expect(() => {
297-
config.enableTypeScriptLoader();
298-
}).to.throw('must be a callback function');
299295
});
300296
});
301297

0 commit comments

Comments
 (0)