Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making enableTypeScriptLoader() options callback optional #75

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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