createInstance vs createInstanceWithArguments [closed]

asked 2017-08-28 19:39:12 +0200

Zev Spitz gravatar image

updated 2020-08-12 15:03:01 +0200

Alex Kemp gravatar image

I am trying to generate Typescript definitions from the LibreOffice IDL (via Doxygen-generated XML).

The XMultiServiceFactory interface has two methods for creating instances: createInstance and createInstanceWithArguments. However, I can't seem to find which types require arguments and what they are, and which types don't require arguments.

This would be of great value in creating these definitions, because Typescript supports multiple overloads based on different values of string parameters. For example, given the following definitions:

namespace {
    namespace lang {
        interface ServiceManager extends XMultiServiceFactory { }
        interface XMultiServiceFactory {
    namespace frame {
        interface theDesktop {
            // members defined here

// This is using the Automation bridge, but the definitions could be written just as easily
// for Javascript macros running via the Rhino interpreter
interface ActiveXObject {
    new(progid: ''):;

Typescript will recognize the appropriate types:

// automatically typed as
let objServiceManager = new ActiveXObject('');

// automatically typed as
let desktop = objServiceManager.createInstance('');

and will issue errors when trying to use a method via desktop that isn't available on the theDesktop singleton:

// will fail compilation

The alternative is to explicitly cast values to the appropriate type:

let desktop = objServiceManager.createInstance('') as;

How can I know from the documentation whether a given type needs arguments or not, and what those arguments are?

LibreOffice 5.3.5

Windows 10 64-bit

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2020-08-12 15:03:12.057937