You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I read #280 & #857 and I'm still confused how can I extend an ambient module. Honestly I'm able to extend it neither nice way nor any other way :-(.
Let's say I have a library I wanna extend. It's not my library, I cannot touch it. It's written in javaScript, so I have .d.ts file for it, e.g.: AmbientModule.d.ts:
TS2322 Type '{ someField: string; additionalFiled: { someData: number; }; }' is not assignable to type 'SomeInterface'.
Object literal may only specify known properties, and 'someField' does not exist in type 'SomeInterface'. Extension.ts 13
TS2345 Argument of type '{ someField: string; additionalFiled: { someData: number; }; }' is not assignable to parameter of type 'SomeInterface'.
Object literal may only specify known properties, and 'additionalFiled' does not exist in type 'SomeInterface'. Consumer.ts 8
Build: Argument of type '{ someField: string; additionalFiled: { someData: number; }; }' is not assignable to parameter of type 'SomeInterface'. Consumer.ts 8
Build: Type '{ someField: string; additionalFiled: { someData: number; }; }' is not assignable to type 'SomeInterface'. Extension.ts 13
So, either I'm doing something wring, or this IMO important scenario is not supported.
If, you ask why am I doing this. I'm trying to extend the jQuery DataTables library with custom column filtering. For that I need to extend the ColumnSettings interface to add my own per-column configuration.
The text was updated successfully, but these errors were encountered:
This is not doable at the moment. we understand this is an important scenario and we are looking into supporting it. see 10/16/2015 design meeting notes for more information.
Hello, I read #280 & #857 and I'm still confused how can I extend an ambient module. Honestly I'm able to extend it neither nice way nor any other way :-(.
Let's say I have a library I wanna extend. It's not my library, I cannot touch it. It's written in javaScript, so I have .d.ts file for it, e.g.:
AmbientModule.d.ts:
I wanna add a new field to the
SomeInterface
interface. Not just some random field, but field of my type. Here's my extension:Extension.ts:
As you can see I also wanna use the extended interface in the extension itself.
This is the consumer of the extended library:
Consumer.ts:
For completenes, I have _global.ts
_global.ts:
When I try to compile this I get bunch of errors:
So, either I'm doing something wring, or this IMO important scenario is not supported.
If, you ask why am I doing this. I'm trying to extend the jQuery DataTables library with custom column filtering. For that I need to extend the
ColumnSettings
interface to add my own per-column configuration.The text was updated successfully, but these errors were encountered: