diff --git a/types/nonogram-solver/index.d.ts b/types/nonogram-solver/index.d.ts new file mode 100644 index 0000000000..a7bb4e7a26 --- /dev/null +++ b/types/nonogram-solver/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for nonogram-solver 2.0 +// Project: https://github.com/thomasr/nonogram-solver +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +declare namespace solve { + class Puzzle { + columnHints: number[][]; + height: number; + rowHints: number[][]; + snapshot: number[]; + width: number; + readonly isFinished: boolean; + readonly isSolved: boolean; + readonly svg: string; + + constructor(data: string | Input); + + import(puzzle: Puzzle): void; + toJSON(): Required; + } + + interface Result { + puzzle: Puzzle; + status: State; + } + + interface Input { + columns: number[][]; + content?: State[]; + rows: number[][]; + } + + type State = 0 | 1 | -1; +} + +declare function solve(filename: string): solve.Result; + +export = solve; diff --git a/types/nonogram-solver/nonogram-solver-tests.ts b/types/nonogram-solver/nonogram-solver-tests.ts new file mode 100644 index 0000000000..5850711fab --- /dev/null +++ b/types/nonogram-solver/nonogram-solver-tests.ts @@ -0,0 +1,10 @@ +import solve = require('nonogram-solver'); + +const { status, puzzle } = solve('input.json'); + +puzzle; // $ExpectType Puzzle +puzzle.columnHints; // $ExpectType number[][] +puzzle.isFinished; // $expectType boolean +puzzle.svg; // $expectType string + +status; // $ExpectType State diff --git a/types/nonogram-solver/tsconfig.json b/types/nonogram-solver/tsconfig.json new file mode 100644 index 0000000000..688aea0d5e --- /dev/null +++ b/types/nonogram-solver/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "nonogram-solver-tests.ts" + ] +} diff --git a/types/nonogram-solver/tslint.json b/types/nonogram-solver/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/nonogram-solver/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }