Skip to content

Commit

Permalink
feat(types): add IAnyMap
Browse files Browse the repository at this point in the history
  • Loading branch information
vasiliilantratov authored and antongolub committed Mar 26, 2019
1 parent 2c06b81 commit dbca380
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/types/src/main/IAnyMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type IAnyMap = {
[key: string]: any
[key: number]: any
}
1 change: 1 addition & 0 deletions packages/types/src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { IStringMap } from './IStringMap'
export { IAnyMap } from './IAnyMap'
export { IEventEmitter } from './IEventEmitter'
export { ILogger, TLogLevel, ILoggerMethod } from './ILogger'
export { TUtilGet } from './IUtilGet'
22 changes: 22 additions & 0 deletions packages/types/src/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
IStringMap,
IAnyMap,
IEventEmitter,
ILoggerMethod,
ILogger,
Expand All @@ -12,6 +13,27 @@ const map: IStringMap = {
foo: 1 // $ExpectError
};

// IAnyMap
const anyMap1: IAnyMap = {
one: 1
};

const anyMap2: IAnyMap = {
1: 'two'
};

const anyMap3: IAnyMap = {
0.1: 2
};

const anyMap4: IAnyMap = {
true: 1
};

const anyMap5: IAnyMap = {
Symbol("qwe"): 1; // $ExpectError
};

// IEventEmitter
const brokenEmitter: IEventEmitter = { // $ExpectError
on(event: string, handler: (...args: any[]) => void) { handler(event); }
Expand Down

0 comments on commit dbca380

Please sign in to comment.