Commit Graph
1406 Commits
Author SHA1 Message Date
AndyandGitHub 024b1fd913 Make it a parse error for an @augments jsdoc tag to not include a type (#18745) 2017-09-25 09:26:59 -07:00
AndyandGitHub 2399bac377 Make it a parse error for an @type jsdoc tag to not include a type (#18664)
* Make it a parse error for an `@type` jsdoc tag to not include a type

* Rename parameter
2017-09-22 10:45:43 -07:00
AndyandGitHub 1a383ec290 Remove unnecessary "@internal" (#18665) 2017-09-22 07:09:29 -07:00
AndyandGitHub 30839378ac Remove unnecessary 'tryParse' (#18663) 2017-09-21 14:42:13 -07:00
Armando AguirreandGitHub 1989b70374 Merge pull request #18192 from armanio123/FixExpressionExpectedAtEOF
Added logic to check for EOF when creating a missing node.
2017-09-19 10:13:20 -07:00
Nathan Shively-SandersandGitHub b934c8bcbd Merge pull request #18417 from Microsoft/fail-spec-lambda-parsing-on-parameter-initialiser-missing-=
Fail speculative parsing of arrow functions when their parameter initialisers are missing a =
2017-09-14 13:01:51 -07:00
AndyandGitHub e91af7d30d Allow template string with no substitutions to be used as a string literal type (#18452) 2017-09-14 11:19:54 -07:00
Nathan Shively-Sanders 5d51a42030 Use createMissingNode for sentinel node 2017-09-13 10:26:11 -07:00
Nathan Shively-Sanders d8ace9ddfb Don't parse param init when = is required but missing
Makes another test case pass that was taking exponential time to parse,
because now it notices that the = is not present and doesn't even try to
parse the initialiser expression.
2017-09-12 14:41:51 -07:00
Nathan Shively-Sanders 4c4316da72 Fail spec parsing lambdas on parameter missing a =
Fail speculative parsing of arrow function expressions whenever it has a
parameter with an initialiser that is missing '='. Ordinarily this is
allowed for better error recovery in the language service, but for
speculative parsing, the errors can compound. When the initialiser is an
error, and when the '=>' is missing (which is also allowed), what is
putatively an arrow function may actually be something else.

For example, `(a / 8) + function ()
{ }` is currently parsed as if someone had intended to write

`(a = /8)+function()/) => { }` but they forgot the `=` of the
initialiser, the `=>` of the lambda, forgot to close the regular
expression, and mistakenly inserted a newline right after the regular
expression.
2017-09-12 14:01:49 -07:00
Nathan Shively-SandersandGitHub d4e3e19763 Merge pull request #18333 from Microsoft/fix-forEachChild-JSDocTypedefTag
Fix forEachChild jsdoc `@typedef` tag
2017-09-08 08:52:46 -07:00
Nathan Shively-Sanders cab05ddd3f Inline variable to aid control flow 2017-09-08 08:33:17 -07:00
Nathan Shively-Sanders fb5e8c6110 Fix forEachChild's visit of JSDocTypedefTag
Also remove JSDocTypeLiteral.jsdocTypeTag, which made no sense since it
was only useful when storing information for its parent `@typedef` tag.
2017-09-07 16:37:13 -07:00
Anders HejlsbergandGitHub 8c64937888 Merge pull request #18153 from Microsoft/optimizeArrays
Optimize array operations to reduce memory footprint
2017-09-07 22:26:48 +01:00
Nathan Shively-SandersandGitHub 2bc9ecb4fd Merge pull request #18296 from Microsoft/disable-lookahead-isStartOfParameter
Disable isStartOfType's lookahead when called from isStartOfParameter
2017-09-07 13:57:28 -07:00
Wesley WighamandGitHub c1f2afd645 Add typedef declaration space, unify typedef name gathering (#18172)
* Add typedef declaration space, unify typedef name gathering, strengthen errorUnusedLocal

* Bonus round: make jsdoc presence way mroe typesafe

* Be exhaustive in nameForNamelessJSDocTypedef

* Remove nonrequired casts

* Replace more casts with guards

* Cannot be internal

* Debug.fail returns never, assert never no longer needs unreachable throw to satisfy checker

* Rename type

* Add replacement message as in 18287
2017-09-07 10:28:58 -07:00
Nathan Shively-Sanders 90d9f3d4ba Rename isStartOfType parameter used by isStartOfParameter 2017-09-07 09:07:59 -07:00
Nathan Shively-Sanders a5c2eac2ee Test:disable lookahead in isStartOfParameter 2017-09-06 15:54:14 -07:00
Nathan Shively-Sanders 7c69dd84b9 Disable lookahead in isStartOfParameter/isStartOfType 2017-09-06 13:11:35 -07:00
Nathan Shively-SandersandGitHub 541920eb31 Merge pull request #18014 from Microsoft/allow-bang+dotdotdot-as-start-of-type
Allow bang+dotdotdot as start of type
2017-09-01 14:26:16 -07:00
AndyandGitHub 7a4c3da239 Simplify return type parsing (#18206)
* Simplify return type parsing

* Make control flow clearer
2017-09-01 10:58:49 -07:00
Armando Aguirre c2168cb94a Added logic to check for EOF when creating a missing node. 2017-08-31 14:05:41 -07:00
Anders Hejlsberg 3f090114ff Optimize array operations to reduce memory footprint 2017-08-30 09:44:51 -07:00
Nathan Shively-Sanders 377ac06050 Allow ! and ... as start-of-type tokens
Which allows the rest of the jsdoc types to be used in type argument
lists
2017-08-24 08:56:36 -07:00
Nathan Shively-Sanders 71c5b1b354 Parsing:Allow QuestionToken as start of type 2017-08-23 15:00:12 -07:00
AndyandGitHub b3f3f336ad Use hasModifier and hasModifiers helper functions (#17724) 2017-08-11 07:15:15 -07:00
AndyandGitHub 08fbcd8b80 Fix many no-object-literal-type-assertion lint errors (#17278)
* Fix many no-object-literal-type-assertion lint errors

* Simple fixes

* Use a union for FlowNode

* PR feedback and remove remaining `id()` uses

* Use a union for CodeBlock

* Discriminate CodeBlock by CodeBlockKind
2017-08-10 12:52:15 -07:00
Ron BucktonandGitHub 75c8ecb2f1 Merge pull request #17517 from tinganho/IgnoredCatchParameter
Ignored catch parameter
2017-08-08 16:15:18 -07:00
Wesley WighamandGitHub a453eff575 Restrict parsing of literals and their expressions a _lot_ more (#17628) 2017-08-07 09:16:12 -07:00
Wesley WighamandGitHub c06a30ae68 JSDoc Instantiation Fixes (#17553)
* Fix #17383 - issue an error when jsdoc attempts to instantiate a builtin as a generic

* Fix comment

* Fix #17377 - only get type parameters from reference target if the type is a reference

* Fix #17525 - Add SyntaxKind.AsteriskToken to isStartOfType
2017-08-02 13:55:14 -07:00
Daniel RosenwasserandGitHub 3da1a53d7e Amend comment about explicitly setting catch clause variables to 'undefined'. 2017-08-02 12:50:04 -07:00
Tingan Ho d5c24f3cd3 Addresses CR comment 2017-08-02 20:13:43 +02:00
Tingan Ho b917eb0225 Adds optional catch parameter into the compiler 2017-07-30 23:26:47 +02:00
AndyandGitHub 70e5c6b1e5 Add some missing | undefined in parser.ts (#17407) 2017-07-27 11:25:48 -07:00
AndyandGitHub 977d907417 createMissingNode: Only assign '.text' or '.escapedText' on nodes of the correct type (#17439)
* createMissingNode: Only assign '.text' or '.escapedText' on nodes of the correct type

* Revert to having only createMissingNode
2017-07-27 10:34:08 -07:00
Wesley WighamandGitHub b9fe9964d2 Change isStartOfParameter to be more general (#17431) 2017-07-26 15:21:21 -07:00
Nathan Shively-Sanders 9fd90e7e02 Merge branch 'master' into jsdoc-param-type-literals 2017-07-26 11:09:24 -07:00
Nathan Shively-Sanders fde4c188ac Address more PR comments 2017-07-26 10:57:29 -07:00
Wesley WighamandGitHub 5b77ef8b4d Fix infinite loop in jsdoc parsing (#17420)
* Test case

* Move parameter fix to apply to jsdoc (and all lists)

* Inline function, generalize comment
2017-07-26 10:12:59 -07:00
Nathan Shively-Sanders c55a043767 Address PR comments from Andy
I'll take a look at Wesley's next and see if those require any changes.
2017-07-25 14:14:12 -07:00
AndyandGitHub eadd084c82 Add 'name' property to Identifier (#17329)
* Add 'name' property to Identifier

* Rename to unescapedText

* Rename 'id.text' to 'id.escapedText'

* Rename 'id.unescapedText' to 'id.text'

* Make escapeIdentifier and unescapeIdentifier do nothing
2017-07-25 13:16:34 -07:00
Wesley Wigham 98d5830831 Use scanner position instead of node members 2017-07-24 17:51:35 -07:00
Wesley Wigham 06beee1cc8 Much simpler fix, rolls in really old fix, removed unused comment 2017-07-24 15:16:21 -07:00
Wesley Wigham e7bf44e820 Fix for loop which retains jsdoc behaviors 2017-07-21 17:20:56 -07:00
Nathan Shively-Sanders 59961394cb @param parsing:const enum to improve readability 2017-07-21 15:07:20 -07:00
Nathan Shively-Sanders 7ff91c1e1c Parse jsdoc type literals in params
Now Typescript supports the creation of anonymous types using successive
`@param` lines in JSDoc:

```js
/**
 * @param {object} o - has a string and a number
 * @param {string} o.s - the string
 * @param {number} o.n - the number
 */
function f(o) { return o.s.length + o.n; }
```

This is equivalent to the Typescript syntax `{ s: string, n: number }`,
but it allows per-property documentation, even for types that only need
to be used in one place. (`@typedef` can be used for reusable types.)

If the type of the initial `@param` is `{object[]}`, then the resulting
type is an array of the specified anonymous type:

```js
/**
 * @param {Object[]} os - has a string and a number
 * @param {string} os[].s - the string
 * @param {number} os[].n - the number
 */
function f(os) { return os[0].s; }
```

Finally, nested anonymous types can be created by nesting the pattern:

```js
/**
 * @param {Object[]} os - has a string and a number
 * @param {string} os[].s - the string
 * @param {object} os[].nested - it's nested because of the object type
 * @param {number} os[].nested.length - it's a number
 */
function f(os) { return os[0].nested.length; }
```

Implementation notes:

1. I refactored JSDocParameterTag and JSDocPropertyTag to
JSDocPropertyLikeTag and modified its parsing to be more succinct. These
changes make the overall change easier to read but are not strictly
required.
2. parseJSDocEntityName accepts postfix[] as in `os[].nested.length`,
but it doesn't check that usages are correct. Such checking would be
easy to add but tedious and low-value.
3. `@typedef` doesn't support nested `@property` tags, but does support
`object[]` types. This is mostly a practical decision, backed up by the
fact that usejsdoc.org doesn't document nested types for `@typedef`.
2017-07-21 14:04:14 -07:00
AndyandGitHub 194c2bc2ca Make NodeArray readonly (#17213)
* Make NodeArray readonly

* Fix bug: use emptyArray instead of undefined

* Fix bug: Don't expose MutableNodeArray

* Undo trailing whitespace changes
2017-07-18 10:38:21 -07:00
Wesley WighamandGitHub 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 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