Skip to content

Commit

Permalink
Support TypeScript 1.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
chancancode committed Nov 4, 2015
1 parent 30b3b86 commit 989c0fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,27 @@ function replaceExtensions(extensionsRegex, name) {
function parseOptions(tsconfigPath) {
try {
var configFile = fs.readFileSync(tsconfigPath, 'utf8');
var rawConfig = ts.parseConfigFileText(tsconfigPath, configFile);
var rawConfig;

if (typeof ts.parseConfigFileText === 'function') {
rawConfig = ts.parseConfigFileText(tsconfigPath, configFile);
} else {
// >= 1.8
rawConfig = ts.parseConfigFileTextToJson(tsconfigPath, configFile);
}

if (rawConfig.error) {
throw new Error(rawConfig.error.messageText);
}

var parsedConfig = ts.parseConfigFile(rawConfig.config, ts.sys, path.dirname(tsconfigPath));
var parsedConfig;

if (typeof ts.parseConfigFile === 'function') {
parsedConfig = ts.parseConfigFile(rawConfig.config, ts.sys, path.dirname(tsconfigPath));
} else {
// >= 1.8
parsedConfig = ts.convertCompilerOptionsFromJson(rawConfig.config.compilerOptions, path.dirname(tsconfigPath));
}

if (parsedConfig.errors && parsedConfig.errors.length) {
throw new Error(parsedConfig.errors.join(', '));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"json-stable-stringify": "^1.0.0"
},
"peerDependencies": {
"typescript": "^1.6.2 || ^1.7.0-dev"
"typescript": "^1.6.2 || ^1.7.0-dev || ^1.8.0-dev"
},
"devDependencies": {
"broccoli": "^0.16.3",
Expand Down

0 comments on commit 989c0fc

Please sign in to comment.