Commit graph

154 commits

Author SHA1 Message Date
Nathan Shively-Sanders eb3a9d05df
Fix factorial jsdoc search:chained assignments (#23115) 2018-04-04 08:57:13 -07:00
Nathan Shively-Sanders 6d9a8250bd
Improve binding and jsdoc of chained special js assignments (#23038)
* Search for jsdoc on chained assignments

* Fix binding of chained binary expression js-assignments

* Test:chained jsdoc+chained prototype assignment

* Improve naming
2018-04-02 09:47:01 -07:00
Nathan Shively-Sanders eca3d68eb4
@typedef supports nested @property names (#22967)
Previously it did not, because this capability is not documented on
usejsdoc.org. However, several people requested this feature.
2018-03-29 09:39:23 -07:00
Nathan Shively-Sanders e16bb3e418
Improve behaviour of ... inside JSDoc functions (#22809)
* No error for ... on last param of jsdoc function

* ... is a rest param w/array type in jsdoc function

* Simplify getTypeFromJSDocVariadicType
2018-03-22 16:17:16 -07:00
Nathan Shively-Sanders ab8233c5d3
Two JSdoc parsing fixes (#22705)
* Correctly parse JSDoc type *=

* Allow `markdown` quoted param names in JSDoc

* Add tests and update baselines

* Get correct span for the type '*'

* Fix whitespace lint

* Add unbracketed type test
2018-03-20 09:23:08 -07:00
Nathan Shively-Sanders b56093f3ac
Fix type when annotated with a JSDoc function type (#22692)
* Fix type when annotated with a JSDoc function type

Previously,
1. A variable annotated with a JSDoc function type would not require all
its parameters to be provided. This should only apply to functions
without a type annotation.
2. A parameter in a function with a JSDoc function type annotation would
still have the type 'any'.
3. Two `var` declarations in a Typescript and Javascript file,
respectively, would error even when they had identical function types.

* Update baselines and add constructor test

* Handle ConstructorType too

* Add test:method sig inside literal type

* Contextually type parameters by parent sig's JSDoc

Instead of a syntactic check in getJSDocTag

* Remove redundant check:isUntypedSignatureInJSFile

* Positive check for value signatures

Instead of excluding type signatures piecemeal.
2018-03-19 16:00:45 -07:00
Nathan Shively-Sanders bb23e9601f
Parse JSDoc ...T and T= only at top-level JSDoc (#22661)
* Parse JSDoc ...T and T= only at top-level JSDoc

...T and T= should only be legal at the top level of a type, and only in
JSDoc, since at least T= is ambiguous elsewhere. This PR changes parsing
to make that happen. The resulting parse tree is now simpler, allowing
me to get rid of some code I had to add in the checker.

* Extract JSDoc type parsing into its own function

* PR comments:return from parseJSDocType
2018-03-16 16:08:42 -07:00
Nathan Shively-Sanders 3b6ae8536f
JSDoc ?Type adds optionality to parameters (#22646)
* jsdoc ?Type adds optionality to parameters

Chrome devtools expects that parameters with type `?T` (or `T?`) add
null to `T` and optionality to the parameter. Previously it only added
null to the type.

Currently the PR does *not* add undefined to the type of
`T`, which is expected by chrome-devtools-frontend, but is inconsistent
with typescript's rules. The implementation achieves this inconsistency by
exploiting the fact that checking the signature adds optionality and
checking the parameter adds `undefined`.

* Update chrome-devtools-frontend baseline

* Add optionality only for jsdoc postfix=

* Skip jsdoc prefix types in isJSDocOptionalParameter

Previously isJSDocOptionalParameter was incorrect for types like
`?number=`, which are optional but have JSDocNullableType as their root
type node.
2018-03-16 13:28:24 -07:00
Nathan Shively-Sanders 677d860b44
No error on unmatchable @param tags (#22510)
* No errr on unmatchable `@param` tags

Such as when the initializer is not a function, or when the function
mentions `arguments` in its body.

* Do not require dummy param for JS uses of arguments

1. JS functions that use `arguments` do not require a dummy parameter in
order to get a type for the synthetic `args` parameter if there is an
`@param` with a `...` type.
2.JS functions that use `arguments` and have an `@param` must have a
type that is a `...` type.

* Check for array type instead of syntactic `...`

* Address PR comments

* Update baselines
2018-03-14 10:17:54 -07:00
Nathan Shively-Sanders 0fa838a3ef
Brackets and postfix= in @param add undefined (#22514)
* Brackets and postfix= in `@param` add undefined

Previously they only added optionality.
Note that, unlike Typescript, when a parameter initializer is specified
in jsdoc, it does not remove undefined in the *body* of the function.
That's because TS will generate initialisation code, but JS won't, so
the author will have to manually write code to remove undefined from the
type.

```js
/** @param {number} [a=101] */
function f(a) {
  // a: number | undefined here
  if (!a) {
    a = 101
  }
  // a: number here
}
```

Note that we don't check that
1. the initializer value is actually assigned to the parameter.
2. the initializer's type matches the declared type of the parameter.

Pretty much we just parse it and leave it alone.

* Address PR comments
2018-03-13 15:56:38 -07:00
Nathan Shively-Sanders c01f0c0b9f Test:ts-ignore works on jsdoc syntax errors 2017-11-17 10:40:16 -08:00
Nathan Shively-Sanders 8cc2af59b1 More tests for getParameterSymbolFromJSDoc 2017-10-19 16:22:05 -07:00
Nathan Shively-Sanders ecdc4b363e Test:jsdoc @param errors on vardecls/assignments 2017-10-19 09:12:49 -07:00
Nathan Shively-Sanders 2473ffcaac Add a better test for jsdoc index signatures.
The test case shows that the errorenous error no longer appears.
2017-10-18 13:06:15 -07:00
Nathan Shively-Sanders 4d8663c378 Merge pull request #18117 from Microsoft/jsdoc-dotdotdot-binds-tighter-than-postfix
Jsdoc ... binds tighter than postfix ?!
2017-10-03 08:45:26 -07:00
Nathan Shively-Sanders 34a8c8423e Merge branch 'master' into jsdoc-dotdotdot-binds-tighter-than-postfix 2017-09-08 08:37:38 -07:00
Nathan Shively-Sanders 7aac67b9b4 Test: parsing of two-line @typedef jsdoc 2017-09-07 16:22:16 -07:00
Nathan Shively-Sanders e2d2f448e4 Add postfix [] ! ? type parsing tests 2017-08-30 08:41:34 -07:00
Nathan Shively-Sanders 3e3846dba4 Test jsdoc:... binds tighter than *n* postfix tokens 2017-08-29 13:02:06 -07:00
Nathan Shively-Sanders a025192ac0 Test:allow more jsdoc types in type parameter lists 2017-08-24 08:56:20 -07:00
Nathan Shively-Sanders ca86dc4deb Test:jsdoc nullable syntax legal in type arguments
And update baselines
2017-08-23 15:00:40 -07:00
Nathan Shively-Sanders 9e59dacbfa Update baselines 2017-07-26 10:59:08 -07:00
Nathan Shively-Sanders e942bbb6f2 Test: jsdoc @param type literals 2017-07-21 14:49:07 -07:00
Nathan Shively-Sanders 1b7faf10ac Merge pull request #17254 from Microsoft/generic-Object-jsdoc-creates-index-signature
JSDoc:Object<string, T> creates index signature
2017-07-18 08:48:56 -07:00
Wesley Wigham 8a1cd33451 Use jsdoc casts (#17251)
* Allow jsdoc casts of parenthesized expressions

* Feedback from #17211
2017-07-17 23:39:20 -07:00
Nathan Shively-Sanders 10a91c5426 JSDoc:Object<string, T> creates index signature
And `Object<number, T>` creates a numeric index signature. Other uses
still create `any` as before.
2017-07-17 16:14:42 -07:00
Nathan Shively-Sanders 3f60364a64 Improve test of jsdoc literal type parsing 2017-07-17 08:29:40 -07:00
Nathan Shively-Sanders 172db13306 Parse more types in JSDoc function() syntax
Also some cleanup from PR comments
2017-07-14 14:34:32 -07:00
Nathan Shively-Sanders bdc3f1f3f7 Address more PR comments 2017-07-14 13:29:44 -07:00
Nathan Shively-Sanders da5285e979 Update baselines 2017-07-14 09:34:35 -07:00
Nathan Shively-Sanders 91633cde5f Test JSDoc parsing using TS parser 2017-07-13 11:33:12 -07:00
Kanchalai Tanglertsampan 7ae4ff3b3d Add tests and update baselines 2017-07-10 15:24:03 -07:00
Kanchalai Tanglertsampan 9df2931aa3 Add tests and update baselines 2017-06-13 15:24:05 -07:00
Kanchalai Tanglertsampan 7dae8f73dd Merge branch 'master' into master-fix13306 2017-06-13 11:41:48 -07:00
Nathan Shively-Sanders b967bbb722 Test @typedef in @typedef-only JS files
Previously there was nothing for the @typedef to attach to, so the
comment was never parsed. Now these comments attach to the EOF token.
2017-06-13 10:37:04 -07:00
Nathan Shively-Sanders da83eb967a Returned generic function is instantiated correctly 2017-06-12 13:56:17 -07:00
Ron Buckton ff1f33729b Improve contextual types and return type checking 2017-06-08 16:44:42 -07:00
Yui 66b6d69c37 Merge pull request #16110 from Microsoft/master-refactorJsDocTest
[Master] Add more JSDoc tests and move them into one folder instead of spread between salsa and jsdoc conformance
2017-06-01 14:03:58 -07:00
Nathan Shively-Sanders 928da675ac Merge pull request #16156 from Microsoft/report-jsdoc-syntax-errors
Report JSDoc syntax errors
2017-05-31 16:21:32 -07:00
Kanchalai Tanglertsampan 1daff75d46 Update tests/baselines 2017-05-31 13:13:25 -07:00
Yui T 558cb2e2fa Add tests 2017-05-31 12:15:50 -07:00
Kanchalai Tanglertsampan 7815ccff1c Merge branch 'master' into master-refactorJsDocTest 2017-05-30 13:47:53 -07:00
Nathan Shively-Sanders 41e134529a Test reporting jsdoc syntax errors 2017-05-30 13:33:13 -07:00
Kanchalai Tanglertsampan d7c33713e4 Merge branch 'master' into master-refactorJsDocTest 2017-05-30 08:38:08 -07:00
Kanchalai Tanglertsampan 27078f995e Merge branch 'master' into master-fix16092 2017-05-30 08:25:53 -07:00
Yui T 5c7c113203 Update tests and baselines 2017-05-29 21:48:34 -07:00
Yui T 227198fae1 Add tests and update baselines 2017-05-27 19:11:08 -07:00
Yui T 0cbfc79ca7 Rename test files to be more consistent and move them into jsdoc folder 2017-05-26 11:20:57 -07:00
Yui T 8ae2fbadd0 Add tests and baselines 2017-05-25 22:35:15 -07:00
Yui T 4f791040fc Add tests and baselines 2017-05-25 20:16:52 -07:00
Nathan Shively-Sanders b14d7c7ebb Add more jsdoc tests 2016-09-01 09:25:49 -07:00
Nathan Shively-Sanders aa834d7f17 JSDoc supports null, undefined and never types 2016-08-17 15:49:57 -07:00
Nathan Shively-Sanders 3c32478b8f Support other (new) literal types in jsdoc 2016-08-04 13:01:17 -07:00
Nathan Shively-Sanders a6642d68c9 JSDoc understands string literal types
Unfortunately, I didn't find a way to reuse the normal string literal
type, so I had to extend the existing JSDoc type hierarchy. Otherwise,
this feature is very simple.
2016-07-27 13:21:42 -07:00