Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript - How to overide declaration in lib.d.ts

Is there any way to override a var declaration in d.ts file?

initTaggingControls() {
    RTE.CanvasEvents.registerListener(RTE.CanvasEvents.editableRegionChangedEvent,     Function.createDelegate(null, this.onCustomTextChanged));
    RTE.CanvasEvents.registerListener(RTE.CanvasEvents.editableRegionBlurEvent,        Function.createDelegate(null, this.onCustomTextChanged));
    RTE.CanvasEvents.registerListener(RTE.CanvasEvents.editableRegionFocusEvent, Function.createDelegate(null, this.onCustomTextChanged));
}

RTE is part of SharePoint. Line declare var RTE: any; does the trick. The problem lies in Function.createDelegate because I cannot declare, or redeclare it.

Function var is already declared in lib.d.ts. Is there any way to override var declaration to add custom methods?

Function.createDelegate is part of Microsoft ajax Library.

like image 708
ppatalong Avatar asked Nov 03 '22 19:11

ppatalong


1 Answers

I am afraid no. e.g. the following is an error:

declare var String: any;

You can only add features to interfaces / modules. Variables definitions are closed.

I have a work item regarding the same : https://typescript.codeplex.com/workitem/917

like image 171
basarat Avatar answered Nov 08 '22 04:11

basarat