-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "indexed properties" #956
Add "indexed properties" #956
Comments
This is already supported. Use an index signature: interface axType {
Values: { [index: string]: string };
} |
@RyanCavanaugh Can I define a signature with multiple parameters? Or with types other than |
@RyanCavanaugh Also, won't defining the indexers this way require the use of square brackets:
but the OP's Javascript uses invocation:
This seems to be a valid (although relatively unusual) pattern in ActiveX libraries, e.g.
|
@zspitz as far as I can see JScript indexer is something not supported in ECMA; also TypeScript is intended to compile to JavaScript (ecma). That's why this kind of indexes definitely will not be supported in TypeScript. In my project I ended up rewriting all calls like
into
and defining function
That trick worked good in JScript interpreter, but had terrible readability (((( |
@dmitryDemchenko You may be interested to know that I've written a tool to convert type libraries to Typescript definition files. https://github.com/zspitz/ts-activex-gen |
@zspitz Nice job! I did almost the same for our ActiveX libraries, or, to be more accurate, for .NET "interop" libraries. It was very similar, but I suppose a little bit easier thanks to "reflection" mechanism. |
@dmitryDemchenko I originally was using .NET reflection, but there were too many mismatches between the .NET reflection model and the COM object model. I am currently using tlbinf32.dll. |
In our project we use ActiveX objects accessible from JavaScript. I have .d.ts of COM library.
One of the external types has "indexed properties". As for now, it's TS declaration loks like
JS code like
works just fine in runtime, but TS compiler shows the message: "Invalid left-hand side of assignment expression".
I can't see the way how to define that interface in .d.ts.
As I can imagine, it should be something like
The text was updated successfully, but these errors were encountered: