diff --git a/index.js b/index.js index 1b720528..295b7b6d 100644 --- a/index.js +++ b/index.js @@ -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); }, diff --git a/lib/WebpackConfig.js b/lib/WebpackConfig.js index f9956a4e..943ea0a0 100644 --- a/lib/WebpackConfig.js +++ b/lib/WebpackConfig.js @@ -226,7 +226,7 @@ class WebpackConfig { this.useReact = true; } - enableTypeScriptLoader(callback) { + enableTypeScriptLoader(callback = () => {}) { this.useTypeScriptLoader = true; if (typeof callback !== 'function') { diff --git a/test/WebpackConfig.js b/test/WebpackConfig.js index 1d19e8b1..5bd9ca10 100644 --- a/test/WebpackConfig.js +++ b/test/WebpackConfig.js @@ -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'); }); });