Skip to content

Commit

Permalink
Fix TypeScript 3.5 compatibility
Browse files Browse the repository at this point in the history
Fixes #20
  • Loading branch information
sindresorhus committed Jun 7, 2019
1 parent 783ca58 commit 501e173
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
declare namespace mapObject {
type Mapper<
SourceObjectType extends {[key: string]: unknown},
SourceObjectType extends {[key: string]: any},
MappedObjectKeyType extends string,
MappedObjectValueType extends unknown
MappedObjectValueType
> = (
sourceKey: keyof SourceObjectType,
sourceValue: SourceObjectType[keyof SourceObjectType],
Expand All @@ -22,14 +22,14 @@ declare namespace mapObject {
@default {}
*/
target?: {[key: string]: unknown};
target?: {[key: string]: any};
}

interface DeepOptions extends Options {
deep: true;
}

interface TargetOptions<TargetObjectType extends {[key: string]: unknown}> extends Options {
interface TargetOptions<TargetObjectType extends {[key: string]: any}> extends Options {
target: TargetObjectType;
}
}
Expand All @@ -50,9 +50,9 @@ const newObject = mapObject({foo: 'bar'}, (key, value) => [value, key]);
*/
declare function mapObject<
SourceObjectType extends object,
TargetObjectType extends {[key: string]: unknown},
TargetObjectType extends {[key: string]: any},
MappedObjectKeyType extends string,
MappedObjectValueType extends unknown = unknown
MappedObjectValueType
>(
source: SourceObjectType,
mapper: mapObject.Mapper<
Expand All @@ -65,7 +65,7 @@ declare function mapObject<
declare function mapObject<
SourceObjectType extends object,
MappedObjectKeyType extends string,
MappedObjectValueType extends unknown = unknown
MappedObjectValueType
>(
source: SourceObjectType,
mapper: mapObject.Mapper<
Expand All @@ -76,10 +76,10 @@ declare function mapObject<
options: mapObject.DeepOptions
): {[key: string]: unknown};
declare function mapObject<
SourceObjectType extends {[key: string]: unknown},
TargetObjectType extends {[key: string]: unknown},
SourceObjectType extends {[key: string]: any},
TargetObjectType extends {[key: string]: any},
MappedObjectKeyType extends string,
MappedObjectValueType extends unknown
MappedObjectValueType
>(
source: SourceObjectType,
mapper: mapObject.Mapper<
Expand All @@ -90,9 +90,9 @@ declare function mapObject<
options: mapObject.TargetOptions<TargetObjectType>
): TargetObjectType & {[K in MappedObjectKeyType]: MappedObjectValueType};
declare function mapObject<
SourceObjectType extends {[key: string]: unknown},
SourceObjectType extends {[key: string]: any},
MappedObjectKeyType extends string,
MappedObjectValueType extends unknown = unknown
MappedObjectValueType
>(
source: SourceObjectType,
mapper: mapObject.Mapper<
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"recursive"
],
"devDependencies": {
"ava": "^1.4.1",
"ava": "^2.0.0",
"tsd": "^0.7.3",
"xo": "^0.24.0"
}
Expand Down

0 comments on commit 501e173

Please sign in to comment.