3 ms·
That would defeat the point of 'any', right? It's for variables that you want to allow to do anything (including be a T) without the compiler complaining. If y
by pimterry 10y ago
That would defeat the point of 'any', right? It's for variables that you want to allow to do anything (including be a T) without the compiler complaining.
If you don't want that behaviour, don't given x 'any' type. In that case there I'd probably use '{}' instead, and then use type guards (https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types https://www.typescriptlang.org/docs/handbook/advanced-types.... to convince TypeScript that it's a T (whatever that means).