Skip to content

Commit

Permalink
feat(types): add ICloneable
Browse files Browse the repository at this point in the history
feat(types): add ICloneable

closes #8 #25
  • Loading branch information
vasiliilantratov authored and antongolub committed Mar 26, 2019
1 parent 4fbc1d5 commit f046a34
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/types/src/main/ICloneable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface ICloneable<T> {
clone (): T
}
1 change: 1 addition & 0 deletions packages/types/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { IAnyMap } from './IAnyMap'
export { IEventEmitter } from './IEventEmitter'
export { ILogger, TLogLevel, ILoggerMethod } from './ILogger'
export { TUtilGet } from './IUtilGet'
export { ICloneable } from './ICloneable'
12 changes: 11 additions & 1 deletion packages/types/src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
ILoggerMethod,
ILogger,
TLogLevel,
TUtilGet
TUtilGet,
ICloneable
} from '../main';

// IStringMap
Expand Down Expand Up @@ -77,3 +78,12 @@ const logger: ILogger = {

const brokenUtilGet: TUtilGet = (obj: object, path: any[], defaultValue?: any) => undefined; // $ExpectError
const utilGet: TUtilGet = (obj: object, path: Array<string | number> | string, defaultValue?: any) => obj || path || defaultValue;

// ICloneable
const cloneable: ICloneable<string> = {
clone(): string { return 'clone'; }
};

cloneable.clone("qwe"); // $ExpectError
cloneable.clone(123); // $ExpectError
cloneable.clone({ hello: "hello", world: "world"}); // $ExpectError

0 comments on commit f046a34

Please sign in to comment.