rot-js: Fix lint (#29103)

* rot-js: Fix lint

* Improve type
This commit is contained in:
Andy 2018-09-24 09:13:57 -07:00 committed by GitHub
parent a29ba1725d
commit 239dc996ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -2,6 +2,7 @@
// Project: https://github.com/ondras/rot.js
// Definitions by: Roger Ostrander <https://github.com/atiaxi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// Extensions (thanks, https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html )
declare global {
@ -353,7 +354,7 @@ export interface RNGable {
getUniformInt(lowerBound: number, upperBound: number): number;
getNormal(mean?: number, stddev?: number): number;
getPercentage(): number;
getWeightedValue<T>(data: { T: number }): T;
getWeightedValue<K extends string>(data: Record<K, number>): K;
getState(): [number, number, number, number];
setState(state: [number, number, number, number]): RNGable;
clone(): RNGable;

View File

@ -160,6 +160,9 @@ ROT.RNG.setSeed(123);
SHOW(ROT.RNG.getUniform());
SHOW(clone.getUniform());
clone.getWeightedValue({} as any); // $ExpectType string
clone.getWeightedValue({ a: 1, b: 2 }); // $ExpectType "a" | "b"
// RNG / Picking a weighted value
const monsters = {
orc: 3,