Skip to content

Commit

Permalink
fix(Config): resolve compiler error introduced with latest bump of @t…
Browse files Browse the repository at this point in the history
…ypes/node at 21d711f
  • Loading branch information
smhxx committed Jan 18, 2018
1 parent 7bce871 commit f04c483
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ function readJSON(location: string): TsConfig {
}
}

function getParentConfig(config: TsConfig, location: string, descendants: Set<string>): TsConfig {
type ChildConfig = TsConfig & { extends: string };

function isChildConfig(config: TsConfig): config is ChildConfig {
return typeof config.extends === 'string';
}

// tslint:disable-next-line max-line-length
function getParentConfig(config: ChildConfig, location: string, descendants: Set<string>): TsConfig {
const parent = path.resolve(path.dirname(location), config.extends);
if (descendants.has(parent)) {
// tslint:disable-next-line max-line-length
Expand All @@ -45,9 +52,9 @@ function getParentConfig(config: TsConfig, location: string, descendants: Set<st
}
}

function loadConfig(location: string, descendants: Set<string> = new Set): TsConfig {
function loadConfig(location: string, descendants: Set<string> = new Set()): TsConfig {
const config = readJSON(location);
if (config.extends !== undefined) {
if (isChildConfig(config)) {
const parent = getParentConfig(config, location, descendants);
return Object.assign(compose(parent, config), { extends: undefined });
} else {
Expand Down

0 comments on commit f04c483

Please sign in to comment.