3

I have problem finding the type of an imported module in typescript, could someone help me? To clarify my question I have a module module.ts

export class RSL1 {};

Then I load it in my index.ts with

const script =  await import('module.js');

It loads correctly and in a browser in debug console it is printed out as Module {Symbol(Symbol.toStringTag): "Module"}

But what is the typescript type of the script variable? The Module class is not known to the compiler. I need just the generic abstract type of the module, not the "runtime" instance. I guess the members of the module depend on what is actually exported in the module. But I don't need that.

Jared Smith
  • 19,721
  • 5
  • 45
  • 83
Jiří Lechner
  • 750
  • 6
  • 19

1 Answers1

1

For now it's 'object', as stated in this GitHub issue:

We currently don't have a way to represent values with properties that aren't inherited from Object. A solution for this would ideally also be usable to fix Object.create(null)

This affects all exotic objects that deviate from default prototype inheritance.

cachius
  • 1,743
  • 1
  • 8
  • 21