-
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
Showing
3 changed files
with
350 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
//// [tests/cases/conformance/expressions/typeGuards/typeGuardWeakTypes1.ts] //// | ||
|
||
=== typeGuardWeakTypes1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60979 | ||
|
||
export interface FilesCleanupCliFlags { | ||
>FilesCleanupCliFlags : Symbol(FilesCleanupCliFlags, Decl(typeGuardWeakTypes1.ts, 0, 0)) | ||
|
||
readonly dryRun?: boolean; | ||
>dryRun : Symbol(FilesCleanupCliFlags.dryRun, Decl(typeGuardWeakTypes1.ts, 2, 39)) | ||
|
||
readonly outputPath?: string; | ||
>outputPath : Symbol(FilesCleanupCliFlags.outputPath, Decl(typeGuardWeakTypes1.ts, 3, 28)) | ||
} | ||
|
||
function checkCliFlags( | ||
>checkCliFlags : Symbol(checkCliFlags, Decl(typeGuardWeakTypes1.ts, 5, 1)) | ||
|
||
flags: FilesCleanupCliFlags, | ||
>flags : Symbol(flags, Decl(typeGuardWeakTypes1.ts, 7, 23)) | ||
>FilesCleanupCliFlags : Symbol(FilesCleanupCliFlags, Decl(typeGuardWeakTypes1.ts, 0, 0)) | ||
|
||
): flags is | ||
>flags : Symbol(flags, Decl(typeGuardWeakTypes1.ts, 7, 23)) | ||
|
||
| { readonly dryRun: true; readonly outputPath: string } | ||
>dryRun : Symbol(dryRun, Decl(typeGuardWeakTypes1.ts, 10, 5)) | ||
>outputPath : Symbol(outputPath, Decl(typeGuardWeakTypes1.ts, 10, 28)) | ||
|
||
| { readonly dryRun?: false } { | ||
>dryRun : Symbol(dryRun, Decl(typeGuardWeakTypes1.ts, 11, 5)) | ||
|
||
if (flags.dryRun && !flags.outputPath) { | ||
>flags.dryRun : Symbol(FilesCleanupCliFlags.dryRun, Decl(typeGuardWeakTypes1.ts, 2, 39)) | ||
>flags : Symbol(flags, Decl(typeGuardWeakTypes1.ts, 7, 23)) | ||
>dryRun : Symbol(FilesCleanupCliFlags.dryRun, Decl(typeGuardWeakTypes1.ts, 2, 39)) | ||
>flags.outputPath : Symbol(FilesCleanupCliFlags.outputPath, Decl(typeGuardWeakTypes1.ts, 3, 28)) | ||
>flags : Symbol(flags, Decl(typeGuardWeakTypes1.ts, 7, 23)) | ||
>outputPath : Symbol(FilesCleanupCliFlags.outputPath, Decl(typeGuardWeakTypes1.ts, 3, 28)) | ||
|
||
throw new Error( | ||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
||
"The --outputPath option is required in dry-run mode and must specify the full file path.", | ||
); | ||
} | ||
return true; | ||
} | ||
|
||
function main() { | ||
>main : Symbol(main, Decl(typeGuardWeakTypes1.ts, 18, 1)) | ||
|
||
const options: FilesCleanupCliFlags = {}; | ||
>options : Symbol(options, Decl(typeGuardWeakTypes1.ts, 21, 7)) | ||
>FilesCleanupCliFlags : Symbol(FilesCleanupCliFlags, Decl(typeGuardWeakTypes1.ts, 0, 0)) | ||
|
||
if (checkCliFlags(options)) { | ||
>checkCliFlags : Symbol(checkCliFlags, Decl(typeGuardWeakTypes1.ts, 5, 1)) | ||
>options : Symbol(options, Decl(typeGuardWeakTypes1.ts, 21, 7)) | ||
|
||
const { dryRun, outputPath } = options; | ||
>dryRun : Symbol(dryRun, Decl(typeGuardWeakTypes1.ts, 24, 11)) | ||
>outputPath : Symbol(outputPath, Decl(typeGuardWeakTypes1.ts, 24, 19)) | ||
>options : Symbol(options, Decl(typeGuardWeakTypes1.ts, 21, 7)) | ||
} | ||
} | ||
|
||
function checkCliFlagsWithAsserts( | ||
>checkCliFlagsWithAsserts : Symbol(checkCliFlagsWithAsserts, Decl(typeGuardWeakTypes1.ts, 26, 1)) | ||
|
||
flags: FilesCleanupCliFlags, | ||
>flags : Symbol(flags, Decl(typeGuardWeakTypes1.ts, 28, 34)) | ||
>FilesCleanupCliFlags : Symbol(FilesCleanupCliFlags, Decl(typeGuardWeakTypes1.ts, 0, 0)) | ||
|
||
): asserts flags is | ||
>flags : Symbol(flags, Decl(typeGuardWeakTypes1.ts, 28, 34)) | ||
|
||
| { readonly dryRun: true; readonly outputPath: string } | ||
>dryRun : Symbol(dryRun, Decl(typeGuardWeakTypes1.ts, 31, 5)) | ||
>outputPath : Symbol(outputPath, Decl(typeGuardWeakTypes1.ts, 31, 28)) | ||
|
||
| { readonly dryRun?: false } { | ||
>dryRun : Symbol(dryRun, Decl(typeGuardWeakTypes1.ts, 32, 5)) | ||
|
||
if (flags.dryRun && !flags.outputPath) { | ||
>flags.dryRun : Symbol(FilesCleanupCliFlags.dryRun, Decl(typeGuardWeakTypes1.ts, 2, 39)) | ||
>flags : Symbol(flags, Decl(typeGuardWeakTypes1.ts, 28, 34)) | ||
>dryRun : Symbol(FilesCleanupCliFlags.dryRun, Decl(typeGuardWeakTypes1.ts, 2, 39)) | ||
>flags.outputPath : Symbol(FilesCleanupCliFlags.outputPath, Decl(typeGuardWeakTypes1.ts, 3, 28)) | ||
>flags : Symbol(flags, Decl(typeGuardWeakTypes1.ts, 28, 34)) | ||
>outputPath : Symbol(FilesCleanupCliFlags.outputPath, Decl(typeGuardWeakTypes1.ts, 3, 28)) | ||
|
||
throw new Error( | ||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
||
"The --outputPath option is required in dry-run mode and must specify the full file path.", | ||
); | ||
} | ||
} | ||
|
||
function mainWithAsserts() { | ||
>mainWithAsserts : Symbol(mainWithAsserts, Decl(typeGuardWeakTypes1.ts, 38, 1)) | ||
|
||
const options: FilesCleanupCliFlags = {}; | ||
>options : Symbol(options, Decl(typeGuardWeakTypes1.ts, 41, 7)) | ||
>FilesCleanupCliFlags : Symbol(FilesCleanupCliFlags, Decl(typeGuardWeakTypes1.ts, 0, 0)) | ||
|
||
checkCliFlagsWithAsserts(options); | ||
>checkCliFlagsWithAsserts : Symbol(checkCliFlagsWithAsserts, Decl(typeGuardWeakTypes1.ts, 26, 1)) | ||
>options : Symbol(options, Decl(typeGuardWeakTypes1.ts, 41, 7)) | ||
|
||
const { dryRun, outputPath } = options; | ||
>dryRun : Symbol(dryRun, Decl(typeGuardWeakTypes1.ts, 45, 9)) | ||
>outputPath : Symbol(outputPath, Decl(typeGuardWeakTypes1.ts, 45, 17)) | ||
>options : Symbol(options, Decl(typeGuardWeakTypes1.ts, 41, 7)) | ||
} | ||
|
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,183 @@ | ||
//// [tests/cases/conformance/expressions/typeGuards/typeGuardWeakTypes1.ts] //// | ||
|
||
=== typeGuardWeakTypes1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/60979 | ||
|
||
export interface FilesCleanupCliFlags { | ||
readonly dryRun?: boolean; | ||
>dryRun : boolean | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
|
||
readonly outputPath?: string; | ||
>outputPath : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
} | ||
|
||
function checkCliFlags( | ||
>checkCliFlags : (flags: FilesCleanupCliFlags) => flags is { readonly dryRun: true; readonly outputPath: string; } | { readonly dryRun?: false; } | ||
> : ^ ^^ ^^^^^ | ||
|
||
flags: FilesCleanupCliFlags, | ||
>flags : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
): flags is | ||
| { readonly dryRun: true; readonly outputPath: string } | ||
>dryRun : true | ||
> : ^^^^ | ||
>true : true | ||
> : ^^^^ | ||
>outputPath : string | ||
> : ^^^^^^ | ||
|
||
| { readonly dryRun?: false } { | ||
>dryRun : false | undefined | ||
> : ^^^^^^^^^^^^^^^^^ | ||
>false : false | ||
> : ^^^^^ | ||
|
||
if (flags.dryRun && !flags.outputPath) { | ||
>flags.dryRun && !flags.outputPath : boolean | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>flags.dryRun : boolean | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>flags : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
>dryRun : boolean | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>!flags.outputPath : boolean | ||
> : ^^^^^^^ | ||
>flags.outputPath : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
>flags : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
>outputPath : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
|
||
throw new Error( | ||
>new Error( "The --outputPath option is required in dry-run mode and must specify the full file path.", ) : Error | ||
> : ^^^^^ | ||
>Error : ErrorConstructor | ||
> : ^^^^^^^^^^^^^^^^ | ||
|
||
"The --outputPath option is required in dry-run mode and must specify the full file path.", | ||
>"The --outputPath option is required in dry-run mode and must specify the full file path." : "The --outputPath option is required in dry-run mode and must specify the full file path." | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
); | ||
} | ||
return true; | ||
>true : true | ||
> : ^^^^ | ||
} | ||
|
||
function main() { | ||
>main : () => void | ||
> : ^^^^^^^^^^ | ||
|
||
const options: FilesCleanupCliFlags = {}; | ||
>options : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
>{} : {} | ||
> : ^^ | ||
|
||
if (checkCliFlags(options)) { | ||
>checkCliFlags(options) : boolean | ||
> : ^^^^^^^ | ||
>checkCliFlags : (flags: FilesCleanupCliFlags) => flags is { readonly dryRun: true; readonly outputPath: string; } | { readonly dryRun?: false; } | ||
> : ^ ^^ ^^^^^ | ||
>options : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
const { dryRun, outputPath } = options; | ||
>dryRun : boolean | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>outputPath : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
>options : { readonly dryRun: true; readonly outputPath: string; } | (FilesCleanupCliFlags & { readonly dryRun?: false; }) | ||
> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ | ||
} | ||
} | ||
|
||
function checkCliFlagsWithAsserts( | ||
>checkCliFlagsWithAsserts : (flags: FilesCleanupCliFlags) => asserts flags is { readonly dryRun: true; readonly outputPath: string; } | { readonly dryRun?: false; } | ||
> : ^ ^^ ^^^^^ | ||
|
||
flags: FilesCleanupCliFlags, | ||
>flags : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
): asserts flags is | ||
| { readonly dryRun: true; readonly outputPath: string } | ||
>dryRun : true | ||
> : ^^^^ | ||
>true : true | ||
> : ^^^^ | ||
>outputPath : string | ||
> : ^^^^^^ | ||
|
||
| { readonly dryRun?: false } { | ||
>dryRun : false | undefined | ||
> : ^^^^^^^^^^^^^^^^^ | ||
>false : false | ||
> : ^^^^^ | ||
|
||
if (flags.dryRun && !flags.outputPath) { | ||
>flags.dryRun && !flags.outputPath : boolean | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>flags.dryRun : boolean | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>flags : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
>dryRun : boolean | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>!flags.outputPath : boolean | ||
> : ^^^^^^^ | ||
>flags.outputPath : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
>flags : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
>outputPath : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
|
||
throw new Error( | ||
>new Error( "The --outputPath option is required in dry-run mode and must specify the full file path.", ) : Error | ||
> : ^^^^^ | ||
>Error : ErrorConstructor | ||
> : ^^^^^^^^^^^^^^^^ | ||
|
||
"The --outputPath option is required in dry-run mode and must specify the full file path.", | ||
>"The --outputPath option is required in dry-run mode and must specify the full file path." : "The --outputPath option is required in dry-run mode and must specify the full file path." | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
); | ||
} | ||
} | ||
|
||
function mainWithAsserts() { | ||
>mainWithAsserts : () => void | ||
> : ^^^^^^^^^^ | ||
|
||
const options: FilesCleanupCliFlags = {}; | ||
>options : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
>{} : {} | ||
> : ^^ | ||
|
||
checkCliFlagsWithAsserts(options); | ||
>checkCliFlagsWithAsserts(options) : void | ||
> : ^^^^ | ||
>checkCliFlagsWithAsserts : (flags: FilesCleanupCliFlags) => asserts flags is { readonly dryRun: true; readonly outputPath: string; } | { readonly dryRun?: false; } | ||
> : ^ ^^ ^^^^^ | ||
>options : FilesCleanupCliFlags | ||
> : ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
const { dryRun, outputPath } = options; | ||
>dryRun : boolean | undefined | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
>outputPath : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
>options : { readonly dryRun: true; readonly outputPath: string; } | (FilesCleanupCliFlags & { readonly dryRun?: false; }) | ||
> : ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ | ||
} | ||
|
50 changes: 50 additions & 0 deletions
50
tests/cases/conformance/expressions/typeGuards/typeGuardWeakTypes1.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,50 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/60979 | ||
|
||
export interface FilesCleanupCliFlags { | ||
readonly dryRun?: boolean; | ||
readonly outputPath?: string; | ||
} | ||
|
||
function checkCliFlags( | ||
flags: FilesCleanupCliFlags, | ||
): flags is | ||
| { readonly dryRun: true; readonly outputPath: string } | ||
| { readonly dryRun?: false } { | ||
if (flags.dryRun && !flags.outputPath) { | ||
throw new Error( | ||
"The --outputPath option is required in dry-run mode and must specify the full file path.", | ||
); | ||
} | ||
return true; | ||
} | ||
|
||
function main() { | ||
const options: FilesCleanupCliFlags = {}; | ||
|
||
if (checkCliFlags(options)) { | ||
const { dryRun, outputPath } = options; | ||
} | ||
} | ||
|
||
function checkCliFlagsWithAsserts( | ||
flags: FilesCleanupCliFlags, | ||
): asserts flags is | ||
| { readonly dryRun: true; readonly outputPath: string } | ||
| { readonly dryRun?: false } { | ||
if (flags.dryRun && !flags.outputPath) { | ||
throw new Error( | ||
"The --outputPath option is required in dry-run mode and must specify the full file path.", | ||
); | ||
} | ||
} | ||
|
||
function mainWithAsserts() { | ||
const options: FilesCleanupCliFlags = {}; | ||
|
||
checkCliFlagsWithAsserts(options); | ||
|
||
const { dryRun, outputPath } = options; | ||
} |