You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letblah: string|undefined;if(!blah)thrownewError('This error does not narrow type')export{blah// Returns type string | undefined, should be narrowed to string}
π Actual behavior
Expected the throwing of an error to type narrow the exported variable, but it instead held onto its initial typing.
π Expected behavior
Throwing an error should type narrow exported variables
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
This is the correct behavior. It's possible to observe blah before the if, e.g.:
// self-import in foo.mjsimport{blahasself_blah}from"./foo.mjs";letblah;// prints "undefined"console.log(self_blah);if(!blah)thrownewError('This error does not narrow type')export{blah}
π Search Terms
Narrowing Export
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?#code/DYUwLgBARsCGAWAuCBnMAnAlgOwOYQB8IBXbAExADMcQyBuAKAc0ogAoBCGBASgjHjoA9gHcI2EGICi6YejYByACrxMKCCFlD0EMkJDrsQyNlhaxYAJ4AHEAp5MQAD2vbIAbwYRoceBAD0-hAASuDE6NjqVraoGDj4RKQU1BJkADSo8ELEwGTQIOJmwiK0-EKxWHgMAL5AA
π» Code
π Actual behavior
Expected the throwing of an error to type narrow the exported variable, but it instead held onto its initial typing.
π Expected behavior
Throwing an error should type narrow exported variables
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: