Skip to content

Commit

Permalink
fix for declaration output to include d.ts files for interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-bateman committed Mar 27, 2016
1 parent 0ef920e commit d22eb69
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 d22eb69

Please sign in to comment.