Solidt.eu
  • Home
  • Code snippets
  • News

Typescript extend any

Date: 2023-02-17

https://stackoverflow.com/questions/37325137/why-can-i-not-extend-any-in-typescript

// Example:
interface IPackagingInfoController {
    [prop: string]: any,
    selectedProductionGroup?: IProductionGroup;
}


// or:
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
739800cookie-checkTypescript extend anyno
Loading