S
S
SVAY2022-01-20 15:53:22
JavaScript
SVAY, 2022-01-20 15:53:22

Is it possible to type imports assigned to variables?

In normal JS, you can do things like this:

// У двух классов общий родитель
import MyClassOne from "./folder";
import MyClassTwo from "./folder";

const obj = {
  one: MyClassOne,
  two: MyClassTwo
};

// Где-то в другом файле который не знает какие классы установлены

const myClassInstance = new obj.one();
const myClassStaticProperty = obj.two.staticProperty;

Interested in whether this can somehow be typed, given that all classes have a common parent, and access is planned precisely to its inherited but overwritten properties.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question