// jQuery.d.ts// 定义全局变量declare var $: (param: () => void) => void// 定义全局函数interface JqueryInstance { html: (html: string) => JqueryInstance}// 函数重载declare function $(param: () => void): voiddeclare function $(param: string): { html: (html: string) => {}}// 使用 interface的语法,实现函数重载 interface JQuery { (readyFunc: () => void): void (selector: string): JqueryInstance}declare var $: JQuery// 如何对对象进行类型定义,以及对类进行类型定义,命名空间嵌套问题declare namespace $ { namespace fn { class init }}
$(function () { $('body').html('<div>123</div>')})$(function () { $('body').html('<div>123</div>') new $.fn.init()})