TS2717

error TS2717: Subsequent property declarations must have the same type. Property ‘verbose‘ must be of type ‘boolean‘, but here has type ‘string‘.

Broken Code ❌

1
2
3
4
5
6
7
8
9
10
11
declare namespace GreetingLib {
interface LogOptions {
verbose: boolean;
}
}

declare namespace GreetingLib {
interface LogOptions {
verbose: string;
}
}

Fixed Code ✔️

When declaring a property (in this case verbose) twice, then the second declaration must follow the typings of the first declaration:

1
2
3
4
5
6
7
8
9
10
11
declare namespace GreetingLib {
interface LogOptions {
verbose: boolean;
}
}

declare namespace GreetingLib {
interface LogOptions {
verbose: boolean;
}
}

Usually the error TS2717 shows up when you have multiple versions of typings (i.e. @types/react) for the same interfaces in your codebase. If you run into these kind of problems, you can inspect your typing resolutions using yarn why (i.e. yarn why @types/react) or npm explain (i.e. npm explain @types/react) to find out where you have conflicting typings.