Open p-bakker opened 9 years ago
Sample 1:
/**
* @param {Boolean|Number} state
* @param {String} [text]
*/
function test(state, text) {
}
test() //warning
test('hello') //warning
test(true, 'hello') //This one is ok
test(10, 'hello') //This one is ok
test(true, 5) //warning
test(5, 5) //warning
test(true, 'hello', 5) //warning
To support this issue, I need the following PR https://github.com/marijnh/tern/pull/525 to know tha type comes from comment.
@p-bakker tern-lint starts supporting your cases :
The only thing that I don't know how to support it is optional parameter (the first case says that test waits 2 parameters, but those parameters could be optional and I don't know how to tern support optional parameter). I must study that.
Produce a builder marker when a function is called with the incorrect number and/or type of arguments, based on the @param declarations in the JSDoc (needs to have support for optional parameters and parameters of multiple types (@param {type1|type2|type3} paramname ))