-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
014fc0e
commit 5907d7c
Showing
5 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/specialIntersectionsInMappedTypes.errors.txt
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,21 @@ | ||
tests/cases/compiler/specialIntersectionsInMappedTypes.ts(14,1): error TS2532: Object is possibly 'undefined'. | ||
|
||
|
||
==== tests/cases/compiler/specialIntersectionsInMappedTypes.ts (1 errors) ==== | ||
// Repro from #50683 | ||
|
||
type Alignment = (string & {}) | "left" | "center" | "right"; | ||
type Alignments = Record<Alignment, string>; | ||
|
||
const a: Alignments = { | ||
left: "align-left", | ||
center: "align-center", | ||
right: "align-right", | ||
other: "align-other", | ||
}; | ||
|
||
a.left.length; | ||
a.other.length; // Error expected here | ||
~~~~~~~ | ||
!!! error TS2532: Object is possibly 'undefined'. | ||
|
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/specialIntersectionsInMappedTypes.js
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,28 @@ | ||
//// [specialIntersectionsInMappedTypes.ts] | ||
// Repro from #50683 | ||
|
||
type Alignment = (string & {}) | "left" | "center" | "right"; | ||
type Alignments = Record<Alignment, string>; | ||
|
||
const a: Alignments = { | ||
left: "align-left", | ||
center: "align-center", | ||
right: "align-right", | ||
other: "align-other", | ||
}; | ||
|
||
a.left.length; | ||
a.other.length; // Error expected here | ||
|
||
|
||
//// [specialIntersectionsInMappedTypes.js] | ||
"use strict"; | ||
// Repro from #50683 | ||
var a = { | ||
left: "align-left", | ||
center: "align-center", | ||
right: "align-right", | ||
other: "align-other" | ||
}; | ||
a.left.length; | ||
a.other.length; // Error expected here |
41 changes: 41 additions & 0 deletions
41
tests/baselines/reference/specialIntersectionsInMappedTypes.symbols
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,41 @@ | ||
=== tests/cases/compiler/specialIntersectionsInMappedTypes.ts === | ||
// Repro from #50683 | ||
|
||
type Alignment = (string & {}) | "left" | "center" | "right"; | ||
>Alignment : Symbol(Alignment, Decl(specialIntersectionsInMappedTypes.ts, 0, 0)) | ||
|
||
type Alignments = Record<Alignment, string>; | ||
>Alignments : Symbol(Alignments, Decl(specialIntersectionsInMappedTypes.ts, 2, 61)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>Alignment : Symbol(Alignment, Decl(specialIntersectionsInMappedTypes.ts, 0, 0)) | ||
|
||
const a: Alignments = { | ||
>a : Symbol(a, Decl(specialIntersectionsInMappedTypes.ts, 5, 5)) | ||
>Alignments : Symbol(Alignments, Decl(specialIntersectionsInMappedTypes.ts, 2, 61)) | ||
|
||
left: "align-left", | ||
>left : Symbol(left, Decl(specialIntersectionsInMappedTypes.ts, 5, 23)) | ||
|
||
center: "align-center", | ||
>center : Symbol(center, Decl(specialIntersectionsInMappedTypes.ts, 6, 23)) | ||
|
||
right: "align-right", | ||
>right : Symbol(right, Decl(specialIntersectionsInMappedTypes.ts, 7, 27)) | ||
|
||
other: "align-other", | ||
>other : Symbol(other, Decl(specialIntersectionsInMappedTypes.ts, 8, 25)) | ||
|
||
}; | ||
|
||
a.left.length; | ||
>a.left.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
>a.left : Symbol(left) | ||
>a : Symbol(a, Decl(specialIntersectionsInMappedTypes.ts, 5, 5)) | ||
>left : Symbol(left) | ||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
|
||
a.other.length; // Error expected here | ||
>a.other.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
>a : Symbol(a, Decl(specialIntersectionsInMappedTypes.ts, 5, 5)) | ||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) | ||
|
45 changes: 45 additions & 0 deletions
45
tests/baselines/reference/specialIntersectionsInMappedTypes.types
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,45 @@ | ||
=== tests/cases/compiler/specialIntersectionsInMappedTypes.ts === | ||
// Repro from #50683 | ||
|
||
type Alignment = (string & {}) | "left" | "center" | "right"; | ||
>Alignment : (string & {}) | "left" | "center" | "right" | ||
|
||
type Alignments = Record<Alignment, string>; | ||
>Alignments : { [x: string & {}]: string; left: string; center: string; right: string; } | ||
|
||
const a: Alignments = { | ||
>a : Alignments | ||
>{ left: "align-left", center: "align-center", right: "align-right", other: "align-other",} : { left: string; center: string; right: string; other: string; } | ||
|
||
left: "align-left", | ||
>left : string | ||
>"align-left" : "align-left" | ||
|
||
center: "align-center", | ||
>center : string | ||
>"align-center" : "align-center" | ||
|
||
right: "align-right", | ||
>right : string | ||
>"align-right" : "align-right" | ||
|
||
other: "align-other", | ||
>other : string | ||
>"align-other" : "align-other" | ||
|
||
}; | ||
|
||
a.left.length; | ||
>a.left.length : number | ||
>a.left : string | ||
>a : Alignments | ||
>left : string | ||
>length : number | ||
|
||
a.other.length; // Error expected here | ||
>a.other.length : number | ||
>a.other : string | undefined | ||
>a : Alignments | ||
>other : string | undefined | ||
>length : number | ||
|
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,17 @@ | ||
// @strict: true | ||
// @noUncheckedIndexedAccess: true | ||
|
||
// Repro from #50683 | ||
|
||
type Alignment = (string & {}) | "left" | "center" | "right"; | ||
type Alignments = Record<Alignment, string>; | ||
|
||
const a: Alignments = { | ||
left: "align-left", | ||
center: "align-center", | ||
right: "align-right", | ||
other: "align-other", | ||
}; | ||
|
||
a.left.length; | ||
a.other.length; // Error expected here |