Skip to content
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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ install:
- npm install
- npm install $TYPESCRIPT
env:
- TYPESCRIPT=typescript@1.5.3
- TYPESCRIPT=typescript
- TYPESCRIPT=typescript@next
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ build system using the [Node.js API](http://webpack.github.io/docs/node.js-api.h

### Compatibility

The current version is compatible with TypeScript 1.5, 1.6 and with the [nightly build](http://blogs.msdn.com/b/typescript/archive/2015/07/27/introducing-typescript-nightlies.aspx).
The current version is compatible with TypeScript 1.6 and with the [nightly build](http://blogs.msdn.com/b/typescript/archive/2015/07/27/introducing-typescript-nightlies.aspx).
You may experience issues using the nightly build due to its nature, but a full test suite runs
against the latest nightly every day to catch incompatibilites early. Please report any issues
you experience with the nightly so that they can be fixed promptly.
Expand Down
29 changes: 8 additions & 21 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
var motd = `ts-loader: Using ${loaderOptions.compiler}@${compiler.version}`,
compilerCompatible = false;
if (loaderOptions.compiler == 'typescript') {
if (compiler.version && semver.gte(compiler.version, '1.5.3-0')) {
if (compiler.version && semver.gte(compiler.version, '1.6.2-0')) {
// don't log yet in this case, if a tsconfig.json exists we want to combine the message
compilerCompatible = true;
}
Expand Down Expand Up @@ -240,7 +240,7 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {

var configParseResult;
if (typeof (<any>compiler).parseJsonConfigFileContent === 'function') {
// parseConfigFile was renamed in nightly 1.8
// parseConfigFile was renamed between 1.6.2 and 1.7
configParseResult = (<TSCompatibleCompiler><any>compiler).parseJsonConfigFileContent(
configFile.config,
compiler.sys,
Expand Down Expand Up @@ -377,11 +377,6 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
}
else resolutionResult = tsResolution.resolvedModule;
}
// this is for legacy compatibility purposes and can eventually be removed
else if (hasOwnProperty(tsResolution, 'resolvedFileName')) {
if (resolvedFileName) resolutionResult = resolvedFileName;
else resolutionResult = tsResolution.resolvedFileName;
}

resolvedModules.push(resolutionResult);
}
Expand Down Expand Up @@ -530,21 +525,13 @@ function loader(contents) {

if (options.transpileOnly) {
var fileName = path.basename(filePath);
// if transpileModule is available, use it (TS 1.6+)
if (instance.compiler.transpileModule) {
var transpileResult = instance.compiler.transpileModule(contents, {
compilerOptions: instance.compilerOptions,
reportDiagnostics: true,
fileName
});
var transpileResult = instance.compiler.transpileModule(contents, {
compilerOptions: instance.compilerOptions,
reportDiagnostics: true,
fileName
});

({ outputText, sourceMapText, diagnostics } = transpileResult);
} else {
outputText = instance.compiler.transpile(
contents,
instance.compilerOptions,
fileName, diagnostics);
}
({ outputText, sourceMapText, diagnostics } = transpileResult);

pushArray(this._module.errors, formatErrors(diagnostics, instance, {module: this._module}));
}
Expand Down
9 changes: 2 additions & 7 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,14 @@ fs.readdirSync(__dirname).forEach(function(test) {
var testPath = path.join(__dirname, test);
if (fs.statSync(testPath).isDirectory()) {

if (test == 'aliasResolution' && semver.lt(typescript.version, '1.6.0-0')) return;
if (test == 'jsx' && semver.lt(typescript.version, '1.6.0-0')) return;
if (test == 'jsxPreserve' && semver.lt(typescript.version, '1.6.0-0')) return;
if (test == 'es6codeSplitting' && semver.lt(typescript.version, '1.6.0-0')) return;
if (test == 'nodeResolution' && semver.lt(typescript.version, '1.6.0-0')) return;
if (test == 'issue71' && semver.lt(typescript.version, '1.6.0-0')) return;
if (test == 'tsconfigInvalid' && semver.gte(typescript.version, '1.8.0-0')) return;
if (test == 'tsconfigInvalid-1.8' && semver.lt(typescript.version, '1.8.0-0')) return;

describe(test, function() {
it('should have the correct output', createTest(test, testPath, {}));

if (test == 'declarationOutput') { return; }
if (test == 'declarationWatch') { return; }
if (test == 'sourceMaps' && semver.lt(typescript.version, '1.6.0-0')) return;
if (test == 'issue71') { return; }
it('should work with transpile', createTest(test, testPath, {transpile: true}));
});
Expand Down
Empty file added test/tsconfigInvalid-1.8/app.ts
Empty file.
9 changes: 9 additions & 0 deletions test/tsconfigInvalid-1.8/expectedOutput/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

ERROR in tsconfig.json
error TS6047: Argument for '--target' option must be 'ES3', 'ES5', or 'ES2015'.

ERROR in tsconfig.json
error TS5024: Compiler option 'sourceMap' requires a value of type boolean.

ERROR in ./.test/tsconfigInvalid-1.8/app.ts
Module build failed: error while parsing tsconfig.json
6 changes: 6 additions & 0 deletions test/tsconfigInvalid-1.8/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"target": "es2",
"sourceMap": "maybe"
}
}
17 changes: 17 additions & 0 deletions test/tsconfigInvalid-1.8/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
entry: './app.ts',
output: {
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.ts', '.js']
},
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader' }
]
}
}

// for test harness purposes only, you would not need this in a normal project
module.exports.resolveLoader = { alias: { 'ts-loader': require('path').join(__dirname, "../../index.js") } }