I personally stick to type aliases. interface comes in handy when it is necessary to augment existing classes with an interface merge:
interface
class MyClass { readonly #value: number; constructor(value: number) { this.#value = value; } get value(): number { return this.#value; } } interface MyClass { square(): number; } function square(this: MyClass): number { const value = this.value; return value * value; } MyClass.prototype.square = square; const container = new MyClass(42); console.assert(container.square() === 1764, "Square isn't 1764");
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I personally stick to type aliases.
interface
comes in handy when it is necessary to augment existing classes with an interface merge: