How we improved our apidocs with Typedoc groups and categories
This page has moved. If you are not redirected automatically, please click here.
This page has moved. If you are not redirected automatically, please click here.
This page has moved. If you are not redirected automatically, please click here.
Classes are a controversial topic in the Javascript/Typescript world. Are they a terrible idea? Are they really useful, when used sensibly? This post will make no attempt at answering either of these questions. This post is about a niche method that I first encountered many years ago in the world of Java - isAssignableFrom - and how you can go about writing it for use in Typescript/Javascript.
This is what the Javadocs have to say about it:
public boolean isAssignableFrom(Class<?> cls)
Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter. It returns true if so; otherwise it returns false.
So, given some class, you can use isAssignableFrom to figure out whether that class is a subclass of some other class.
If you're thinking it's a bit niche, yes, I agree. isAssignableFrom is one of those methods you don't use much. But when you need it, you need it.