10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TypeScriptでJquery Pluginを使う

Posted at

TypesScriptでjquery Pluginの使用する場合のメモです。

jquery.dependをTypeScriptで使用する例です。
jquery.d.tsを拡張することで、Jquery Pluginのメソッドを追加できます。

extension.d.ts
interface JqueryBrowser{
    original?: string;
    version?: JQueryVersionInfo;
    opera?: bool;
    msie?: bool;
    firefox?: bool;
    chrome?: bool;
    browser?: bool;
    safari?: bool;
    silk?: bool;
    unknown?: bool;
    initialize( str:string ):void;
    is( str:string ):bool;
}



interface JQueryVersionInfo{
    original?: string;
    major? : number;
    minor? : number;
    builid? : number;
    revision? : number;
    isEqual( major:number , minor?:number , build?:number , revision?:number ):bool;
    isOrLess( major:number , minor?:number , build?:number , revision?:number ):bool;
}



interface JQueryStatic{
    browser: JqueryBrowser;
}

このように簡単に定義できるので、TypeScriptでも積極的にJqueryPluginを使うことができます。

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?