On TypeScript I do implementation of a plug-in

//plugin.js import * as jQuery from 'jquery'; (function($: JQueryStatic) { $.extend({ test: function(str: string) { alert(str); } }); })(jQuery); 

Create a declaration for this plugin

 // plugin.d.ts interface JQueryStatic { test(str: string); } 

How do I now import this declaration in the module?

If I write like this

 import * as $ from "./plugin"; $.test("AAA"); 

getting an error

Property 'test' doesn’t exist on type 'typeof import ("D: /....../ ts / plugin")'

If so

 import * as $ from "jquery"; $.test("AAA"); 

getting an error

Property 'test' does not exist on type JQueryStatic


And another question: is it possible to somehow use the type descriptions from plugin.d.ts in plugin.ts itself? To avoid re-declaration errors.

    1 answer 1

    Everything worked for me when I added the first line in the place of use

     /// <reference path="./plugin.d.ts" /> 

    Without any import