Skip to content

Commit

Permalink
feat!: refactor declarations to preserve type info
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Jun 27, 2023
1 parent 8b22739 commit 72ac2e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/// <reference types="@stdlib/types"/>

import * as random from '@stdlib/types/random';
import { Iterator } from '@stdlib/types/iter';
import { TypedIterator } from '@stdlib/types/iter';

/**
* Interface defining function options.
Expand Down Expand Up @@ -56,7 +56,7 @@ interface Options {
/**
* Interface for iterators of pseudorandom numbers drawn from a Bernoulli distribution.
*/
interface RandIter extends Iterator {
interface Iterator<T> extends TypedIterator<T> {
/**
* Underlying PRNG.
*/
Expand Down Expand Up @@ -112,7 +112,7 @@ interface RandIter extends Iterator {
*
* // ...
*/
declare function iterator( p: number, options?: Options ): RandIter;
declare function iterator( p: number, options?: Options ): Iterator<number>;


// EXPORTS //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import iterator = require( './index' );

// The function returns an iterator...
{
iterator( 0.3 ); // $ExpectType RandIter
iterator( 0.5, {} ); // $ExpectType RandIter
iterator( 0.5, { 'iter': 10 } ); // $ExpectType RandIter
iterator( 0.3 ); // $ExpectType Iterator<number>
iterator( 0.5, {} ); // $ExpectType Iterator<number>
iterator( 0.5, { 'iter': 10 } ); // $ExpectType Iterator<number>
}

// The compiler throws an error if the function is provided an invalid input argument...
Expand Down

0 comments on commit 72ac2e6

Please sign in to comment.