DefinitelyTyped/types/configurable/configurable-tests.ts
Vilim Stubičan 41b75d423c Configurable type definitions (#24008)
* Configurable type definitionsπ

* Updated tests

* Added tests for errorsπ

* Updated project link

* Changed definitions to the proposed structure
2018-03-01 14:29:57 -08:00

51 lines
712 B
TypeScript

import configurable = require('configurable');
// Arrange
class A {
something(): void {
// nothing
}
}
const obj = new A();
const c = configurable(obj);
// $ExpectType A & Configurable<A>
c.set('first', 'first as a string');
// $ExpectType any
c.get('first');
// $ExpectType A & Configurable<A>
c.enable('first');
// $ExpectType boolean
c.enabled('first');
// $ExpectType A & Configurable<A>
c.disable('first');
// $ExpectType boolean
c.disabled('first');
// $ExpectError
c.set(5, 'first as a string');
// $ExpectError
c.set('first');
// $ExpectError
c.get(5);
// $ExpectError
c.enable(5);
// $ExpectError
c.enabled(5);
// $ExpectError
c.disable(5);
// $ExpectError
c.disabled(5);