Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 485693

Summary: [eslint] type-checked-consistent-return is incorrectly marking same return types
Product: [ECD] Orion Reporter: Michael Rennie <Michael_Rennie>
Component: JS ToolsAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public, Olivier_Thomann, steve_northover
Version: 11.0   
Target Milestone: 12.0   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 486577    
Bug Blocks:    

Description Michael Rennie CLA 2016-01-12 12:38:18 EST
Consider the following snippet:

/**
 * @param {Number} one 
 */
function foo(one) {
  if(one === 10) {
	return 0;
  }
  var two = one;
  return two;
}

The last return statement will be flagged saying: "Inconsistent return types: 'number', 'object'", but in fact, number is being returned in both cases.
Comment 1 Olivier Thomann CLA 2016-01-12 13:53:39 EST
I think the current implementation is too naive. We should revert the previous commit. We would need to know the "real" type of each return if we can. Using typeof is not sufficient.
Comment 2 Curtis Windatt CLA 2016-02-18 17:14:50 EST
Should be fixed with the work on Bug 486577
Comment 3 Olivier Thomann CLA 2016-02-26 13:17:51 EST
Fixed.