Merge pull request #34096 from ffflorian/nonogram-solver

Add types for nonogram-solver
This commit is contained in:
Sheetal Nandi
2019-03-22 15:44:18 -07:00
committed by GitHub
4 changed files with 74 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
// Type definitions for nonogram-solver 2.0
// Project: https://github.com/thomasr/nonogram-solver
// Definitions by: Florian Keller <https://github.com/me>
// 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<Input>;
}
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;
@@ -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
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }