Why can I not extend 'any' in Typescript?

2020 TLDR:

instead of extends any try extends Record<string, any>.

Long version:

In certain cases extends any still works in TypeScript. However, in TypeScript 3.9, it is interpreted in a more conservative way.

@Paleo creates AnyProperties interface in his answer. That can now be rewritten with Record as extends Record<string, any>.


With an alias for any

I want to make a placeholder interface

Use an alias:

type IDatabaseModel = any;

Or with an index signature [Edit from August, 2017]

Since TypeScript 2.2, the property access syntax obj.propName is allowed with an index signature:

interface AnyProperties {
    [prop: string]: any
}

type MyType = AnyProperties & {
    findAll(): string[]
}

let a: MyType
a.findAll() // OK, with autocomplete
a.abc = 12 // OK, but no autocomplete