personal-pin/@types
.d.ts自体作ったことが無いので時間かかるMijikko.icon 自動生成できたとしても勉強にならないのでやらない
たくさん書いたけど、exportされているやつが2つしかないのでほとんど表示されていない
{types}は要らないと思うtakker.icon
なるほどMijikko.icon
助かります!
というか、型定義ファイルを別途作らないと型推論が効かなかったのですか?takker.icon
JSDocで書いたつもりだったのですが
自分のやり方が悪い可能性は十分ありますが
今ログを確認してみたけれど、型が駄目というよりはJSDocに書いたコメントが読み込まれなくて困っていたっぽい…?
.jsで読み込んだときの記録が残っていなかったので、後で検証しておきます
だめでしたね(意外にも引数の説明は読み込んでくれたけれど)
jsのみでdeno docした結果takker.icon
code:log
false None false
true None true
false None false
false None false
false None false
false None false
false None false
false None false
false None false
true None true
false None false
false None false
false None false
false None false
false None false
false None false
const launch: (titles, options) => unknown
ピン留め処理を開始する
@param {Iterable<string>|(()=>(Iterable<string>|Promise<Iterable<string>>))} titles
ピン留めしたいページのタイトル
@param {LaunchOptions} ? options オプション
@return {()=>void}
後始末用函数
@typedefで定義した型はexportしてくれないみたい
JSの型は読み取ってくれないのかなあtakker.icon
code:mod.d.ts
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference lib="dom" />
declare const scrapbox: Scrapbox;
export interface LaunchOptions {
/** ピン留めするプロジェクト名 既定は現在のプロジェクト名 */
project?: string;
/** ピン留め更新処理の間隔 既定は60000 */
interval?: number;
}
export type Titles =
| Iterable<string>
| (() => Iterable<string> | Promise<Iterable<string>>);
/**
* ピン留め処理を開始する
* @param {Iterable<string>|(()=>(Iterable<string>|Promise<Iterable<string>>))} titles ピン留めしたいページのタイトル
* @param {LaunchOptions} options オプション * @return {()=>void} 後始末用函数
*/
export declare const launch: (
titles: Titles,
option?: LaunchOptions,
) => {
(): void;
};
/**
* ピン留め処理
* @param {string} project プロジェクト名
* @param {Iterable<string>|(()=>(Iterable<string>|Promise<Iterable<string>>))} titles ピン留めしたいページのタイトル
*/
declare const updatePins: (project: string, titles: Titles) => Promise<void>;
/**
* 指定したカードをpinする
* @param {HTMLLIElement} card
* @return {void}
*/
declare const pin: (card: HTMLLIElement) => void;
declare const cardList: () => HTMLUListElement[];
declare const listPins: () => void;
declare const id: "personal-pin-card";
/**
* ページカードを作る
*
* ページリストにあるときはそれをコピーし、ないときは空のページカードを作る
* @param {string} project プロジェクト名
* @param {string} title ページタイトル
* @return {HTMLLIElement}
*/
declare const makePseudoCard: (project: string, title: string) => HTMLLIElement;
/** このscriptで作成したカードを全部消す */
declare const deletePseudoCards: () => void;
declare const noEncodeChars: '@$&+=:;",';
declare const noTailChars: ':;",';
/**
* titleをURIで使える形式にEncodeする
*
*
* @param {string} title 変換するtitle
* @return {string} 変換後の文字列
*/
declare const encodeTitleURI: (title: string) => string;