Skip to content

Commit

Permalink
Rename to enableTypeScriptLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
David Paz committed Jun 26, 2017
1 parent facc132 commit f6bc6e7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ module.exports = {
/**
* Call this if you plan on loading TypeScript files.
*
* Encore.configureTypeScript(function(tsConfig) {
* Encore.enableTypeScriptLoader(function(tsConfig) {
* // change the tsConfig
* });
*
Expand All @@ -354,8 +354,8 @@ module.exports = {
* @param {function} callback
* @return {exports}
*/
configureTypeScript(callback) {
webpackConfig.configureTypeScript(callback);
enableTypeScriptLoader(callback) {
webpackConfig.enableTypeScriptLoader(callback);

return this;
},
Expand Down
4 changes: 2 additions & 2 deletions lib/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ class WebpackConfig {
this.useReact = true;
}

configureTypeScript(callback) {
enableTypeScriptLoader(callback) {
this.useTypeScriptLoader = true;

if (typeof callback !== 'function') {
throw new Error('Argument 1 to configureTypeScript() must be a callback function.');
throw new Error('Argument 1 to enableTypeScriptLoader() must be a callback function.');
}

this.tsConfigurationCallback = callback;
Expand Down
2 changes: 1 addition & 1 deletion lib/loader-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const loaderFeatures = {
description: 'process React JS files'
},
typescript: {
method: 'configureTypeScript()',
method: 'enableTypeScriptLoader()',
packages: ['typescript', 'ts-loader'],
description: 'process TypeScript files'
}
Expand Down
10 changes: 7 additions & 3 deletions test/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,23 @@ describe('WebpackConfig object', () => {
});
});

describe('configureTypeScript', () => {
describe('enableTypeScriptLoader', () => {
it('Calling method sets it', () => {
const config = createConfig();
const testCallback = () => {};
config.configureTypeScript(testCallback);
config.enableTypeScriptLoader(testCallback);
expect(config.tsConfigurationCallback).to.equal(testCallback);
});

it('Calling with non-callback throws an error', () => {
const config = createConfig();

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

expect(() => {
config.enableTypeScriptLoader();
}).to.throw('must be a callback function');
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ module.exports = {
config.setPublicPath('/build');
config.addEntry('main', ['./js/render.ts', './js/index.ts']);
const testCallback = () => {};
config.configureTypeScript(testCallback);
config.enableTypeScriptLoader(testCallback);

testSetup.runWebpack(config, (webpackAssert) => {
// check that ts-loader transformed the ts file
Expand Down
4 changes: 2 additions & 2 deletions test/loaders/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function createConfig() {
describe('loaders/typescript', () => {
it('getLoaders() basic usage', () => {
const config = createConfig();
config.configureTypeScript(function(config) {
config.enableTypeScriptLoader(function(config) {
config.foo = 'bar';
});

Expand All @@ -37,7 +37,7 @@ describe('loaders/typescript', () => {

it('getLoaders() check defaults configuration values', () => {
const config = createConfig();
config.configureTypeScript(function(config) {
config.enableTypeScriptLoader(function(config) {
config.foo = 'bar';
});

Expand Down

0 comments on commit f6bc6e7

Please sign in to comment.