-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
TypeScript Version: 3.7.2, Nightly
Search Terms: super control flow analysis never, super returning never
Expected behavior: No error on SuperThrowable.err, or an error on both SuperThrowable.err and SuperThrowable.ok
Actual behavior: A function returning 'never' cannot have a reachable end point.(2534)
Related Issues: Quite a few regarding CFA, but none related to super vs this. Discovered from this SO question
Code
class MyThrowable {
throw(): never {
throw new Error();
}
}
class SuperThrowable extends MyThrowable {
/// A function returning 'never' cannot have a reachable end point.(2534)
err(msg: string): never {
super.throw()
}
// Ok
ok(): never {
this.throw()
}
}Output
"use strict";
class MyThrowable {
throw() {
throw new Error();
}
}
class SuperThrowable extends MyThrowable {
/// A function returning 'never' cannot have a reachable end point.(2534)
err(msg) {
super.throw();
}
// Ok
ok() {
this.throw();
}
}Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"useDefineForClassFields": false,
"alwaysStrict": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"downlevelIteration": false,
"noEmitHelpers": false,
"noLib": false,
"noStrictGenericChecks": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"esModuleInterop": true,
"preserveConstEnums": false,
"removeComments": false,
"skipLibCheck": false,
"checkJs": false,
"allowJs": false,
"declaration": true,
"experimentalDecorators": false,
"emitDecoratorMetadata": false,
"target": "ES2017",
"module": "ESNext"
}
}Playground Link: Provided
fatcerberus, simonwep and jcalz
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue