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

Bug 489589

Summary: Express index given to Tern is not correct
Product: [ECD] Orion Reporter: Steve Northover <steve_northover>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: curtis.windatt.public, Michael_Rennie
Version: 12.0   
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Steve Northover CLA 2016-03-14 15:38:23 EDT
1) get https://github.com/snorthov/minesweeper-objects.git
2) Click on app.js
3) Ensure there is an /*eslint-env node, express */ directive
4) BUG: There are warnings about "use" and "static" and there should not be
Comment 1 Curtis Windatt CLA 2016-03-14 15:49:13 EDT
Try removing the libs entry from the .tern-project file and see if this fixes the issue.
Comment 2 Olivier Thomann CLA 2016-03-14 16:01:38 EDT
I guess you have some new validation enabled that I don't have. I don't get any warnings with this code. What are the warning's strings?
Could it be related to bug 488531?
Comment 3 Steve Northover CLA 2016-03-14 16:04:31 EDT
This was the first thing I tried.  Here is my file:

{
	"libs": ["ecma5"],
	"ecmaVersion": 5,
	"loadEagerly": [
		"public/index.html"
	]
}
Comment 4 Steve Northover CLA 2016-03-14 16:04:54 EDT
BTW, Curtis, can you make it happen?  Is it only me?
Comment 5 Curtis Windatt CLA 2016-03-14 16:22:07 EDT
Yes I can reproduce. This is my new cross file linting.  The type definition for app (result of express()) has a number of properties: disable, get, init, listen.  Use is not one of them so Tern thinks it is undeclared.  If you notice, it is not in the list of content assist proposals either.
Comment 6 Steve Northover CLA 2016-03-14 16:32:10 EDT
Thanks.  It's not happening for me on https://orion.eclipse.org but it is happening on beta3.
Comment 7 Curtis Windatt CLA 2016-03-14 17:43:27 EDT
There is an issue with our express index.  use() is defined on express.Router, but express.Application should include express.Router.  static() is defined inside the express type container, but is not part of any type (express.express or express.Application).

We can try:
1) Manually correct the index file.
2) Try re-running condense using the latest version of Tern (and the newest version of the DefinitelyTyped index).
Comment 8 Steve Northover CLA 2016-03-14 17:47:35 EDT
Not sure what is going on in that it is working in some places and not in others so it seems like a recent regression.
Comment 9 Curtis Windatt CLA 2016-03-14 18:02:27 EDT
(In reply to Steve Northover from comment #8)
> Not sure what is going on in that it is working in some places and not in
> others so it seems like a recent regression.

This is not a regression.  If you turn on the new cross file lint check 'Undeclared member expressions' it will surface the issue.  This happens on both beta3 and orion.eclipse.org.
Comment 10 Curtis Windatt CLA 2016-03-15 16:00:27 EDT
I created a new index using condense.  use() is now included properly (with Doc!), but there is no definition of static() anywhere.  Also, the app object (result of new express()) defines no properties so cross file lint just ignores it.  Might have to do some manual modifications to the index.
Comment 11 Curtis Windatt CLA 2016-03-15 16:07:19 EDT
This is how static is specified in express.js
exports.static = require('serve-static');
Comment 12 Curtis Windatt CLA 2016-03-15 17:18:14 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=c967947bb9bbde6c7e31802fb43c754cfbb535b9
I recreated the index for Express.  The new index has a lot more information in it including doc for many of the types.  However, I had to make some modifications to the index to make it work correctly.  It even defines toString() and hasOwnProperty() which override the functions on Object.

Marking as FIXED.

We can discuss whether we want to redo all of the indexes.
Comment 13 Michael Rennie CLA 2016-03-16 11:35:28 EDT
(In reply to Curtis Windatt from comment #9)
> (In reply to Steve Northover from comment #8)
> > Not sure what is going on in that it is working in some places and not in
> > others so it seems like a recent regression.
> 
> This is not a regression.  If you turn on the new cross file lint check
> 'Undeclared member expressions' it will surface the issue.  This happens on
> both beta3 and orion.eclipse.org.

That is really cool, that the first thing a new feature did was find a problem in our code :)