-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# This is a combination of 3 commits.
# This is the 1st commit message: # This is a combination of 2 commits. # This is the 1st commit message: # This is a combination of 3 commits. # This is the 1st commit message: init # This is the commit message #2: isIdentifier # This is the commit message #3: baselines # This is the commit message #2: rebase # This is the commit message #2: isIdentifier # This is the commit message #3: baselines
- Loading branch information
Showing
11 changed files
with
238 additions
and
13 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
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
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/narrowingByNonLiteralIndexedAccess.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,28 @@ | ||
tests/cases/compiler/narrowingByNonLiteralIndexedAccess.ts(14,1): error TS2532: Object is possibly 'undefined'. | ||
tests/cases/compiler/narrowingByNonLiteralIndexedAccess.ts(17,1): error TS2532: Object is possibly 'undefined'. | ||
|
||
|
||
==== tests/cases/compiler/narrowingByNonLiteralIndexedAccess.ts (2 errors) ==== | ||
interface IEye { | ||
visibility: number | undefined | ||
} | ||
|
||
interface IPirate { | ||
hands: number | undefined, | ||
eyes: IEye[] | ||
} | ||
|
||
const pirates: IPirate[] = []; | ||
|
||
const index: number = 1; | ||
|
||
pirates[index].hands++; | ||
~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2532: Object is possibly 'undefined'. | ||
if (pirates[index].hands) pirates[index].hands++; | ||
|
||
pirates[index].eyes[index].visibility++; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2532: Object is possibly 'undefined'. | ||
if (pirates[index].eyes[index].visibility) pirates[index].eyes[index].visibility++; | ||
|
31 changes: 31 additions & 0 deletions
31
tests/baselines/reference/narrowingByNonLiteralIndexedAccess.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,31 @@ | ||
//// [narrowingByNonLiteralIndexedAccess.ts] | ||
interface IEye { | ||
visibility: number | undefined | ||
} | ||
|
||
interface IPirate { | ||
hands: number | undefined, | ||
eyes: IEye[] | ||
} | ||
|
||
const pirates: IPirate[] = []; | ||
|
||
const index: number = 1; | ||
|
||
pirates[index].hands++; | ||
if (pirates[index].hands) pirates[index].hands++; | ||
|
||
pirates[index].eyes[index].visibility++; | ||
if (pirates[index].eyes[index].visibility) pirates[index].eyes[index].visibility++; | ||
|
||
|
||
//// [narrowingByNonLiteralIndexedAccess.js] | ||
"use strict"; | ||
var pirates = []; | ||
var index = 1; | ||
pirates[index].hands++; | ||
if (pirates[index].hands) | ||
pirates[index].hands++; | ||
pirates[index].eyes[index].visibility++; | ||
if (pirates[index].eyes[index].visibility) | ||
pirates[index].eyes[index].visibility++; |
67 changes: 67 additions & 0 deletions
67
tests/baselines/reference/narrowingByNonLiteralIndexedAccess.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,67 @@ | ||
=== tests/cases/compiler/narrowingByNonLiteralIndexedAccess.ts === | ||
interface IEye { | ||
>IEye : Symbol(IEye, Decl(narrowingByNonLiteralIndexedAccess.ts, 0, 0)) | ||
|
||
visibility: number | undefined | ||
>visibility : Symbol(IEye.visibility, Decl(narrowingByNonLiteralIndexedAccess.ts, 0, 16)) | ||
} | ||
|
||
interface IPirate { | ||
>IPirate : Symbol(IPirate, Decl(narrowingByNonLiteralIndexedAccess.ts, 2, 1)) | ||
|
||
hands: number | undefined, | ||
>hands : Symbol(IPirate.hands, Decl(narrowingByNonLiteralIndexedAccess.ts, 4, 19)) | ||
|
||
eyes: IEye[] | ||
>eyes : Symbol(IPirate.eyes, Decl(narrowingByNonLiteralIndexedAccess.ts, 5, 30)) | ||
>IEye : Symbol(IEye, Decl(narrowingByNonLiteralIndexedAccess.ts, 0, 0)) | ||
} | ||
|
||
const pirates: IPirate[] = []; | ||
>pirates : Symbol(pirates, Decl(narrowingByNonLiteralIndexedAccess.ts, 9, 5)) | ||
>IPirate : Symbol(IPirate, Decl(narrowingByNonLiteralIndexedAccess.ts, 2, 1)) | ||
|
||
const index: number = 1; | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
|
||
pirates[index].hands++; | ||
>pirates[index].hands : Symbol(IPirate.hands, Decl(narrowingByNonLiteralIndexedAccess.ts, 4, 19)) | ||
>pirates : Symbol(pirates, Decl(narrowingByNonLiteralIndexedAccess.ts, 9, 5)) | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
>hands : Symbol(IPirate.hands, Decl(narrowingByNonLiteralIndexedAccess.ts, 4, 19)) | ||
|
||
if (pirates[index].hands) pirates[index].hands++; | ||
>pirates[index].hands : Symbol(IPirate.hands, Decl(narrowingByNonLiteralIndexedAccess.ts, 4, 19)) | ||
>pirates : Symbol(pirates, Decl(narrowingByNonLiteralIndexedAccess.ts, 9, 5)) | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
>hands : Symbol(IPirate.hands, Decl(narrowingByNonLiteralIndexedAccess.ts, 4, 19)) | ||
>pirates[index].hands : Symbol(IPirate.hands, Decl(narrowingByNonLiteralIndexedAccess.ts, 4, 19)) | ||
>pirates : Symbol(pirates, Decl(narrowingByNonLiteralIndexedAccess.ts, 9, 5)) | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
>hands : Symbol(IPirate.hands, Decl(narrowingByNonLiteralIndexedAccess.ts, 4, 19)) | ||
|
||
pirates[index].eyes[index].visibility++; | ||
>pirates[index].eyes[index].visibility : Symbol(IEye.visibility, Decl(narrowingByNonLiteralIndexedAccess.ts, 0, 16)) | ||
>pirates[index].eyes : Symbol(IPirate.eyes, Decl(narrowingByNonLiteralIndexedAccess.ts, 5, 30)) | ||
>pirates : Symbol(pirates, Decl(narrowingByNonLiteralIndexedAccess.ts, 9, 5)) | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
>eyes : Symbol(IPirate.eyes, Decl(narrowingByNonLiteralIndexedAccess.ts, 5, 30)) | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
>visibility : Symbol(IEye.visibility, Decl(narrowingByNonLiteralIndexedAccess.ts, 0, 16)) | ||
|
||
if (pirates[index].eyes[index].visibility) pirates[index].eyes[index].visibility++; | ||
>pirates[index].eyes[index].visibility : Symbol(IEye.visibility, Decl(narrowingByNonLiteralIndexedAccess.ts, 0, 16)) | ||
>pirates[index].eyes : Symbol(IPirate.eyes, Decl(narrowingByNonLiteralIndexedAccess.ts, 5, 30)) | ||
>pirates : Symbol(pirates, Decl(narrowingByNonLiteralIndexedAccess.ts, 9, 5)) | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
>eyes : Symbol(IPirate.eyes, Decl(narrowingByNonLiteralIndexedAccess.ts, 5, 30)) | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
>visibility : Symbol(IEye.visibility, Decl(narrowingByNonLiteralIndexedAccess.ts, 0, 16)) | ||
>pirates[index].eyes[index].visibility : Symbol(IEye.visibility, Decl(narrowingByNonLiteralIndexedAccess.ts, 0, 16)) | ||
>pirates[index].eyes : Symbol(IPirate.eyes, Decl(narrowingByNonLiteralIndexedAccess.ts, 5, 30)) | ||
>pirates : Symbol(pirates, Decl(narrowingByNonLiteralIndexedAccess.ts, 9, 5)) | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
>eyes : Symbol(IPirate.eyes, Decl(narrowingByNonLiteralIndexedAccess.ts, 5, 30)) | ||
>index : Symbol(index, Decl(narrowingByNonLiteralIndexedAccess.ts, 11, 5)) | ||
>visibility : Symbol(IEye.visibility, Decl(narrowingByNonLiteralIndexedAccess.ts, 0, 16)) | ||
|
76 changes: 76 additions & 0 deletions
76
tests/baselines/reference/narrowingByNonLiteralIndexedAccess.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,76 @@ | ||
=== tests/cases/compiler/narrowingByNonLiteralIndexedAccess.ts === | ||
interface IEye { | ||
visibility: number | undefined | ||
>visibility : number | undefined | ||
} | ||
|
||
interface IPirate { | ||
hands: number | undefined, | ||
>hands : number | undefined | ||
|
||
eyes: IEye[] | ||
>eyes : IEye[] | ||
} | ||
|
||
const pirates: IPirate[] = []; | ||
>pirates : IPirate[] | ||
>[] : never[] | ||
|
||
const index: number = 1; | ||
>index : number | ||
>1 : 1 | ||
|
||
pirates[index].hands++; | ||
>pirates[index].hands++ : number | ||
>pirates[index].hands : number | undefined | ||
>pirates[index] : IPirate | ||
>pirates : IPirate[] | ||
>index : number | ||
>hands : number | undefined | ||
|
||
if (pirates[index].hands) pirates[index].hands++; | ||
>pirates[index].hands : number | undefined | ||
>pirates[index] : IPirate | ||
>pirates : IPirate[] | ||
>index : number | ||
>hands : number | undefined | ||
>pirates[index].hands++ : number | ||
>pirates[index].hands : number | ||
>pirates[index] : IPirate | ||
>pirates : IPirate[] | ||
>index : number | ||
>hands : number | ||
|
||
pirates[index].eyes[index].visibility++; | ||
>pirates[index].eyes[index].visibility++ : number | ||
>pirates[index].eyes[index].visibility : number | undefined | ||
>pirates[index].eyes[index] : IEye | ||
>pirates[index].eyes : IEye[] | ||
>pirates[index] : IPirate | ||
>pirates : IPirate[] | ||
>index : number | ||
>eyes : IEye[] | ||
>index : number | ||
>visibility : number | undefined | ||
|
||
if (pirates[index].eyes[index].visibility) pirates[index].eyes[index].visibility++; | ||
>pirates[index].eyes[index].visibility : number | undefined | ||
>pirates[index].eyes[index] : IEye | ||
>pirates[index].eyes : IEye[] | ||
>pirates[index] : IPirate | ||
>pirates : IPirate[] | ||
>index : number | ||
>eyes : IEye[] | ||
>index : number | ||
>visibility : number | undefined | ||
>pirates[index].eyes[index].visibility++ : number | ||
>pirates[index].eyes[index].visibility : number | ||
>pirates[index].eyes[index] : IEye | ||
>pirates[index].eyes : IEye[] | ||
>pirates[index] : IPirate | ||
>pirates : IPirate[] | ||
>index : number | ||
>eyes : IEye[] | ||
>index : number | ||
>visibility : 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
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
20 changes: 20 additions & 0 deletions
20
tests/cases/compiler/narrowingByNonLiteralIndexedAccess.ts
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,20 @@ | ||
// @strict: true | ||
|
||
interface IEye { | ||
visibility: number | undefined | ||
} | ||
|
||
interface IPirate { | ||
hands: number | undefined, | ||
eyes: IEye[] | ||
} | ||
|
||
const pirates: IPirate[] = []; | ||
|
||
const index: number = 1; | ||
|
||
pirates[index].hands++; | ||
if (pirates[index].hands) pirates[index].hands++; | ||
|
||
pirates[index].eyes[index].visibility++; | ||
if (pirates[index].eyes[index].visibility) pirates[index].eyes[index].visibility++; |