DefinitelyTyped/types/amp/amp-tests.ts
Brian Crowell 21077b2657 [node]: Make stream destroy method signatures match (#27608)
* [node]: Make stream destroy method signatures match

The "destroy" option when creating streams has the same signature as the
_destroy method on the stream: a function accepting an optional error and a
callback which also takes an optional error.

* Fix tests affected by the change in stream definitions
2018-07-27 10:52:13 -07:00

45 lines
721 B
TypeScript

import { decode, encode, Stream } from 'amp';
// $ExpectType Buffer[]
decode(new Buffer('something'));
// $ExpectType Buffer
encode([new Buffer('something'), new Buffer('something')]);
// $ExpectError
decode('');
// $ExpectError
decode(1);
// $ExpectError
decode();
// $ExpectError
encode('');
// $ExpectError
encode(1);
// $ExpectError
encode();
// $ExpectType Stream
new Stream({});
// $ExpectType Stream
new Stream({
highWaterMark: 1,
decodeStrings: true,
objectMode: true,
destroy: (error: Error | null) => {
return 'handle error';
},
final: (callback: (error?: Error) => void) => {
// do nothing
}
});
// $ExpectError
new Stream({somethingNoneExisting: true});