user1426349
user1426349

Reputation: 253

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

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?

Upvotes: 24

Views: 23409

Answers (1)

Ryan Cavanaugh
Ryan Cavanaugh

Reputation: 220904

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.

Upvotes: 32

Related Questions