From 8aaf61e72259dc424b0ad24decc07ba519766b89 Mon Sep 17 00:00:00 2001 From: oh2o Date: Mon, 25 Dec 2023 22:12:07 +0900 Subject: [PATCH 1/2] Udate Object Types.md --- packages/documentation/copy/en/handbook-v2/Object Types.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/documentation/copy/en/handbook-v2/Object Types.md b/packages/documentation/copy/en/handbook-v2/Object Types.md index 091ba8e6002c..14e926761550 100644 --- a/packages/documentation/copy/en/handbook-v2/Object Types.md +++ b/packages/documentation/copy/en/handbook-v2/Object Types.md @@ -274,8 +274,8 @@ This index signature states that when a `StringArray` is indexed with a `number` Only some types are allowed for index signature properties: `string`, `number`, `symbol`, template string patterns, and union types consisting only of these.
- It is possible to support both types of indexers... -

It is possible to support both types of indexers, but the type returned from a numeric indexer must be a subtype of the type returned from the string indexer. This is because when indexing with a number, JavaScript will actually convert that to a string before indexing into an object. That means that indexing with 100 (a number) is the same thing as indexing with "100" (a string), so the two need to be consistent.

+ It is possible to support multiple types of indexers... +

It is possible to support multiple types of indexers. Note that when using both `number` and `string` indexers, the type returned from a numeric indexer must be a subtype of the type returned from the string indexer. This is because when indexing with a number, JavaScript will actually convert that to a string before indexing into an object. That means that indexing with 100 (a number) is the same thing as indexing with "100" (a string), so the two need to be consistent.

```ts twoslash // @errors: 2413 From 30d3e465a13b5e5141a01bc7f2a9c344904caebb Mon Sep 17 00:00:00 2001 From: oh2o Date: Mon, 25 Dec 2023 22:51:48 +0900 Subject: [PATCH 2/2] Fix typo --- packages/documentation/copy/en/handbook-v2/Object Types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/documentation/copy/en/handbook-v2/Object Types.md b/packages/documentation/copy/en/handbook-v2/Object Types.md index 14e926761550..682b179c52a2 100644 --- a/packages/documentation/copy/en/handbook-v2/Object Types.md +++ b/packages/documentation/copy/en/handbook-v2/Object Types.md @@ -275,7 +275,7 @@ Only some types are allowed for index signature properties: `string`, `number`,
It is possible to support multiple types of indexers... -

It is possible to support multiple types of indexers. Note that when using both `number` and `string` indexers, the type returned from a numeric indexer must be a subtype of the type returned from the string indexer. This is because when indexing with a number, JavaScript will actually convert that to a string before indexing into an object. That means that indexing with 100 (a number) is the same thing as indexing with "100" (a string), so the two need to be consistent.

+

It is possible to support multiple types of indexers. Note that when using both `number` and `string` indexers, the type returned from a numeric indexer must be a subtype of the type returned from the string indexer. This is because when indexing with a number, JavaScript will actually convert that to a string before indexing into an object. That means that indexing with 100 (a number) is the same thing as indexing with "100" (a string), so the two need to be consistent.

```ts twoslash // @errors: 2413