Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support key remapping via
as
(#1174)
- Loading branch information
Showing
6 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
interface Message { | ||
id: number; | ||
name: string; | ||
title: string; | ||
} | ||
|
||
export type MyObject = { | ||
[K in keyof Message as `message${Capitalize<K>}`]: Message[K]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"$ref": "#/definitions/MyObject", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"definitions": { | ||
"MyObject": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"messageId": { | ||
"type": "number" | ||
}, | ||
"messageName": { | ||
"type": "string" | ||
}, | ||
"messageTitle": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"messageId", | ||
"messageName", | ||
"messageTitle" | ||
], | ||
"type": "object" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
interface SomeInterface { | ||
foo: 12; | ||
bar: "baz"; | ||
} | ||
|
||
export type MyObject = { | ||
[K in keyof SomeInterface as Capitalize<K>]: `${K}.${SomeInterface[K]}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$ref": "#/definitions/MyObject", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"definitions": { | ||
"MyObject": { | ||
"additionalProperties": false, | ||
"properties": { | ||
"Bar": { | ||
"const": "bar.baz", | ||
"type": "string" | ||
}, | ||
"Foo": { | ||
"const": "foo.12", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"Foo", | ||
"Bar" | ||
], | ||
"type": "object" | ||
} | ||
} | ||
} |