Skip to content

Commit

Permalink
Merge pull request #175 from rob-bateman/fix-interface-dts-files
Browse files Browse the repository at this point in the history
fix for declaration output to include d.ts files for interfaces
  • Loading branch information
jbrantly committed Apr 11, 2016
2 parents 5cc9fc5 + d22eb69 commit 6356367
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,21 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
}
});


// gather all declaration files from TypeScript and output them to webpack
Object.keys(instance.files)
.filter(filePath => !!filePath.match(/\.ts(x?)$/))
.forEach(filePath => {
let output = languageService.getEmitOutput(filePath);
let declarationFile = output.outputFiles.filter(filePath => !!filePath.name.match(/\.d.ts$/)).pop();
if (declarationFile) {
compilation.assets[declarationFile.name] = {
source: () => declarationFile.text,
size: () => declarationFile.text.length
};
}
});

callback();
});

Expand Down Expand Up @@ -583,9 +598,6 @@ function loader(contents) {

var sourceMapFile = output.outputFiles.filter(file => !!file.name.match(/\.js(x?)\.map$/)).pop();
if (sourceMapFile) { sourceMapText = sourceMapFile.text }

var declarationFile = output.outputFiles.filter(file => !!file.name.match(/\.d.ts$/)).pop();
if (declarationFile) { this.emitFile(path.relative(this.options.context, declarationFile.name), declarationFile.text); }
}

if (outputText == null) throw new Error(`Typescript emitted no output for ${filePath}`);
Expand Down

0 comments on commit 6356367

Please sign in to comment.