DefinitelyTypedのためのいくつかの宣言ファイルを作成することを願っています(したがって、それらが最高品質であることを確認したい)。chessboardjs(暗黙的インポート)のTypescript宣言ファイル
次のライブはhttps://github.com/oakmac/chessboardjs/です。私はそう
// WHAT WORKS
import * as ChessBoard from "chessboardjs";
のようにそれをインポートして、今私は、問題は、私は(import文を暗黙的になりたいES6スタイルです
const board = ChessBoard('board1', 'start');
を呼び出すことにより、LIBを使用することができる場合、私は実際にそれが働いてい)それを行うことで行く方法がわからない
// WHAT I WOULD LIKE
import { ChessBoard } from "chessboardjs";
私は可能な限りこれを行う方法に関するいくつかのガイダンスを希望します。私はまだ活字する新たなんだと宣言ファイルとして、多分libにはただ暗黙の輸入品のため
を内蔵していないこれは私がこれまでindex.d.tsに
declare namespace ChessBoardJS {
interface BoardConfig {
onDrop?: Function;
draggable?: boolean;
onChange?: Function;
onMoveEnd?: Function;
onSnapEnd?: Function;
sparePieces?: boolean;
onDragMove?: Function;
showNotation?: boolean;
onDragStart?: Function;
onSnapbackEnd?: Function;
onMouseoutSquare?: Function;
onMouseoverSquare?: Function;
pieceTheme?: string | Function;
orientation?: ChessBoardJS.Types.OrientationType;
showErrors?: boolean | string | Function;
moveSpeed?: number | ChessBoardJS.Types.SpeedType;
snapSpeed?: number | ChessBoardJS.Types.SpeedType;
trashSpeed?: number | ChessBoardJS.Types.SpeedType;
dropOffBoard?: ChessBoardJS.Types.DropOffBoardType;
appearSpeed?: number | ChessBoardJS.Types.SpeedType;
snapbackSpeed?: number | ChessBoardJS.Types.SpeedType;
position?: ChessBoardJS.Types.PositionType | string | object;
}
}
declare namespace ChessBoardJS.Types {
type PositionType = 'start';
type PositionFenType = 'fen';
type SpeedType = 'slow' | 'fast';
type OrientationFlipType = 'flip';
type OrientationType = 'white' | 'black';
type DropOffBoardType = 'snapback' | 'trash';
}
interface ChessBoardInstance {
clear(useAnimation?: boolean): void;
destroy(): void;
fen(): string;
flip(): void;
move(...args: string[]): object; // *FIND RETURN*
position(newPosition: object | string | ChessBoardJS.Types.PositionType, useAnimation?: boolean): void
position(fen?: ChessBoardJS.Types.PositionFenType): string | object;
orientation(side?: ChessBoardJS.Types.OrientationType | ChessBoardJS.Types.OrientationFlipType): string;
resize(): void;
start(useAnimation?: boolean): void;
}
interface ChessBoardFactory {
(containerElOrId: any, config: ChessBoardJS.BoardConfig): ChessBoardInstance
fenToObj(fen: string): any;
objToFen(obj: any): any;
}
declare var ChessBoard: ChessBoardFactory;
declare module "chessboardjs" {
export = ChessBoard;
}
感謝を提出したものです君は!!!
ねえ、ちょっと不思議なことですが、このライブラリのタイピングについてさらに進歩しましたか? –
私はやったと思います。私は確かにそれをプッシュしていないまだタイプ。私も同じことに取り組んでいるのなら、あなたと共有することができます –
私はチェスやチェス盤のタイピングの恩恵を受けるものに取り組んでいます。あなたはGmailのドットコムでrikkigibsonに私に連絡することができます。 (申し訳ありませんが、連絡先情報を伝える手段が他にありませんでした。) –