Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix the TypeScript error: TS2234: All declarations of an interface must have identical type parameters

Tags:

typescript

In typescript v0.9.5 this code compiled.

interface Array {
    indexOfField : (propertyName: string, value: any) => number;
 }

After upgrading to typescript 1.0, I get the following error:

(2,11): error TS2234: All declarations of an interface must have identical type parameters.

Line number 2:11 is the keyword Array.

How do I fix this?

like image 624
user1426349 Avatar asked Sep 11 '25 02:09

user1426349


1 Answers

The other definition of Array is Array<T> (with a type parameter) in lib.d.ts. You need to declare yours as:

interface Array<T> {
    indexOfField : (propertyName: string, value: any) => number;
}

in order to have the same number of type parameters.

like image 161
Ryan Cavanaugh Avatar answered Sep 13 '25 22:09

Ryan Cavanaugh