angelozerr / tern-lint

Tern plugin to validate JavaScripts files to collect semantic errors
http://ternjs.net/
MIT License
62 stars 13 forks source link

Tern lint shows warning when actual parameter is subtype of expected parameter. #59

Closed dmitriiKovchin closed 9 years ago

dmitriiKovchin commented 9 years ago

We have type definition for appendChild function from https://github.com/marijnh/tern/blob/master/defs/browser.json: "appendChild": { "!type": "fn(newElt: +Element) -> +Element", "!url": "https://developer.mozilla.org/en/docs/DOM/Node.appendChild", "!doc": "Adds a node to the end of the list of children of a specified parent node. If the node already exists it is removed from current parent node, then added to new parent node." }, Text.prototype = Node Node.prototype = Element So Text is subtype of Element. In parameter validation should we check that actual parameter is subtype of expected type rather than exact expected type?

screenshot from 2015-10-15 13 36 34

angelozerr commented 9 years ago

So Text is subtype of Element

No Text and Element are subtype of Node.

tern-lint is able to support heritage. This error is normal because the browser.json has an error. Node#appendChild waits an Element and not a Node although it should be wait a Node.

I have created a PR for that https://github.com/marijnh/tern/pull/665 which fix your error.

dmitriiKovchin commented 9 years ago

Thanks!

angelozerr commented 9 years ago

I close this issue. tern has accepted my PR. See https://github.com/marijnh/tern/pull/665