mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 20:37:00 -05:00
Fixed a crash when computing flow type of destructured never (#57586)
This commit is contained in:
committed by
GitHub
parent
e089896be4
commit
af0424c010
@@ -43214,7 +43214,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
function getIteratedTypeOrElementType(use: IterationUse, inputType: Type, sentType: Type, errorNode: Node | undefined, checkAssignability: boolean): Type | undefined {
|
||||
const allowAsyncIterables = (use & IterationUse.AllowsAsyncIterablesFlag) !== 0;
|
||||
if (inputType === neverType) {
|
||||
reportTypeNotIterableError(errorNode!, inputType, allowAsyncIterables); // TODO: GH#18217
|
||||
if (errorNode) {
|
||||
reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts(9,3): error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
|
||||
|
||||
==== autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts (1 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/57582
|
||||
|
||||
declare const b: null;
|
||||
let file;
|
||||
|
||||
if (b === null) {
|
||||
// empty
|
||||
} else {
|
||||
[file] = b;
|
||||
~~~~~~
|
||||
!!! error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
}
|
||||
|
||||
file; // request flow type here
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//// [tests/cases/compiler/autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts] ////
|
||||
|
||||
=== autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/57582
|
||||
|
||||
declare const b: null;
|
||||
>b : Symbol(b, Decl(autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts, 2, 13))
|
||||
|
||||
let file;
|
||||
>file : Symbol(file, Decl(autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts, 3, 3))
|
||||
|
||||
if (b === null) {
|
||||
>b : Symbol(b, Decl(autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts, 2, 13))
|
||||
|
||||
// empty
|
||||
} else {
|
||||
[file] = b;
|
||||
>file : Symbol(file, Decl(autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts, 3, 3))
|
||||
>b : Symbol(b, Decl(autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts, 2, 13))
|
||||
}
|
||||
|
||||
file; // request flow type here
|
||||
>file : Symbol(file, Decl(autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts, 3, 3))
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [tests/cases/compiler/autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts] ////
|
||||
|
||||
=== autoTypeAssignedUsingDestructuringFromNeverNoCrash.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/57582
|
||||
|
||||
declare const b: null;
|
||||
>b : null
|
||||
|
||||
let file;
|
||||
>file : any
|
||||
|
||||
if (b === null) {
|
||||
>b === null : boolean
|
||||
>b : null
|
||||
|
||||
// empty
|
||||
} else {
|
||||
[file] = b;
|
||||
>[file] = b : never
|
||||
>[file] : [any]
|
||||
>file : any
|
||||
>b : never
|
||||
}
|
||||
|
||||
file; // request flow type here
|
||||
>file : any
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// @strict: true
|
||||
// @noEmit: true
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/57582
|
||||
|
||||
declare const b: null;
|
||||
let file;
|
||||
|
||||
if (b === null) {
|
||||
// empty
|
||||
} else {
|
||||
[file] = b;
|
||||
}
|
||||
|
||||
file; // request flow type here
|
||||
Reference in New Issue
Block a user