1631 Commits

Author SHA1 Message Date
Alexander T
702dc59b36 no-fallthrough 2019-06-22 10:50:25 +03:00
Klaus Meinhardt
0c9db717ad fix parsing of leading union/intersection operator (#31265)
* fix parsing of leading union/intersection operator

Fixes: #30995

* test declaration emit
2019-05-08 14:09:11 -07:00
Klaus Meinhardt
4ee0084fa1 avoid more useless type assertions (#31239) 2019-05-03 14:51:54 -07:00
Klaus Meinhardt
5bc8a8dddf JSDocTypeTag.typeExpression is not optional (#30452) 2019-04-30 09:46:32 -07:00
Klaus Meinhardt
de9b91f46a simplify pragma comment parsing (#31144)
* simplify pragma parsing

* use emptyArray
2019-04-29 14:17:48 -07:00
Wesley Wigham
d7f03fb0fa
Parse generic function types in import type argument lists (#31079)
* Parenthesize in import type node factory

* And now parse unparenthesized generic functions so we can handle parsing the older output
2019-04-23 14:48:31 -07:00
Nathan Shively-Sanders
c3a9429420
Handle JSDoc backticks in the parser, not scanner (#30939)
* Scan backticks in jsdoc as a single token less often

Previously, matching backticks in jsdoc would always be scanned as one
token to aid parsing incorrect jsdoc that uses backticks for parameter
names:

``js
/** @param {string} `nope`
 * @param {number} `not needed`
 */
```

However, this is wrong for code fences, which use triple backticks. This
fix parses a single backtick as a single token if it's immediately
followed by another backtick or by a newline. It retains the
questionable tokenisation of backticks-as-pairs in other cases, however.
A better fix might be to have the parser ignore backticks in jsdoc
instead.

* Add test case

* Handle jsdoc backticks in the parser, not scanner

Previously, the jsdoc scanner had ad-hoc handling of backticks that was
similar in structure to the normal scanner's handling, but much simpler.
This was a smaller code change, but is handled backwards: the special
case of backtick-quoted parameter names was handled in the scanner
instead of in the jsdoc identifier parsing code. That made it overapply
and block correct handling of asterisks across newlines, which was most
obvious in code fences inside jsdoc, as in #23517.

Fixes #23517

* More cleanup
2019-04-18 09:35:40 -07:00
Andrew
13d9f08976 Gracefully parse 'super' with type arguments (#10677) (#30913) 2019-04-15 13:06:29 -07:00
Anders Hejlsberg
6cd229b4b9
Merge pull request #30769 from Microsoft/saferIndexedAccessTypes
Improve soundness of indexed access types
2019-04-12 07:33:50 -10:00
Nathan Shively-Sanders
ff959096df
Fix some bad jsdoc comment indent (#30838)
* First draft

Solves the initial problem but breaks commentCommentParsing. I also
found a couple more interesting cases.

* Add more tests and fix their bugs

* Another test case

* Some cleanup

I may try do a little more; `margin += tag.end - tag.pos` bothers me a
bit.

* More cleanup
2019-04-10 08:22:09 -07:00
Anders Hejlsberg
e1fd5e5225 Fix unsafe parameter coercions related to PragmaPseudoMap 2019-04-06 06:29:59 -10:00
Andrew Branch
3f3444be80
Merge pull request #30699 from andrewbranch/bug/30635
Fix ternaries where "true" is a parenthesized variable and "false" is a function expression
2019-04-02 14:03:11 -07:00
Wesley Wigham
ca98a50574
Use const contexts and tuple mapped types to simplify some explicitly elucidated types (#30654)
* Use const contexts and tuple mapped types to simplify some explicitly elucidated types

* Fix lint

* Further cleanup - refactor mapped type into its own alias for readability

* Slightly more cleanup - PragmaPsuedoMap neednt be partial, thus removing tons of nonull assertions

* Remove GH#18217 comments
2019-04-02 13:04:51 -07:00
Andrew Branch
96660f6c00
Just look at the current node instead of context 2019-04-02 11:31:05 -07:00
Andrew Branch
d198c5906f
Be stricter while parsing arrow function heads in conditional expressions 2019-04-02 11:17:21 -07:00
Wenlu Wang
b97b1a8de6 add jsx factory and hold text in jsxtext node (#29439)
* add jsx factory and hold text in jsxtext node

* update jsxtext prop name and factory
2019-03-11 16:00:18 -07:00
Sheetal Nandi
9fa28158bb Enable building typescript.d.ts with current source 2019-02-22 18:11:27 -08:00
Anders Hejlsberg
4706a060a5 Merge branch 'master' into readonlyArrayTuple 2019-01-26 14:44:15 -08:00
kingwl
e8497096d8 Merge branch 'master' into improve_type_arguments_parser_1 2019-01-20 01:54:49 +08:00
Anders Hejlsberg
bb8378fddf Support 'readonly' type modifier on array and tuple types 2019-01-15 09:43:39 -08:00
Wesley Wigham
fadd95f72b
Fix unneeded cast lints (#29383) 2019-01-11 14:24:49 -08:00
Anders Hejlsberg
92a8cc9f5f Fix logic that bails out of incremental parsing in certain contexts 2018-11-29 10:19:42 -08:00
Klaus Meinhardt
1ad7b0fe69 forEachToken: correctly handle JSDocTag (#28369)
* forEachChild: handle JSDocTags and all their children

* fix codefix for unused identifier

* fix lint

* fix build

* Fix test failures
2018-11-15 13:22:25 -08:00
Andy
772f6cdf48
Remove JSDocTag#atToken (#28376) 2018-11-06 09:54:23 -08:00
Caleb Sander
28e9ec497c Address review comments 2018-11-05 11:36:32 -08:00
Caleb Sander
188c07865a Scan bigint literals 2018-11-05 11:36:31 -08:00
Andy
36dfd775b3
Parse an object literal property as shorthand unless followed by '(' or ':' (#28121) 2018-10-26 15:00:31 -07:00
Andy
efc831e0ba
At '.' in array literal, don't close the array (#28120) 2018-10-25 12:25:33 -07:00
Andy
54a5be1860
At '.' in object literal, don't close the object (#27850)
* At '.' in object literal, don't close the object

* Include diagnostics test
2018-10-12 08:49:04 -07:00
Andy
f6ca10565d
Fix bug: Ensure JSDoc type range is valid (#27343) 2018-10-08 17:09:48 -07:00
Andy
dd9b8cab34
Have scanJsDocToken scan keywords (#27162)
* Have scanJsDocToken scan keywords

* Update API
2018-10-08 14:42:51 -07:00
Andy
deeb40129d
Remove duplicate case in parseJsDocCommentWorker (#27164) 2018-10-04 15:44:01 -07:00
Nathan Shively-Sanders
21148b3b0a
Fix typo in PseudoPragma* types (#27437) 2018-09-28 10:39:30 -07:00
Andy
f71d6005a2
Use nextToken() after parsing a tag name so we can parse type keywords (#26915)
* Use nextToken() after parsing a tag name so we can parse type keywords

* Make callback to skipWhitespaceOrAsterisk non-optional
2018-09-13 15:49:06 -07:00
Andy
2b888c30f9
Consistently pass indent to 'parseTagComments' (#27055)
* Consistently pass indent to 'parseTagComments'

* Update baselines
2018-09-12 17:44:06 -07:00
王文璐
f396a2c7a8 rename rescan function 2018-09-07 11:39:50 +08:00
王文璐
0e97ce57e4 Merge branch 'master' into improve_type_arguments_parser_1 2018-09-07 11:36:02 +08:00
Ryan Cavanaugh
5d65e86756
Merge pull request #23253 from Kingwl/definite-assignment-assertion-improve
improve parser and error message if definite assignment assertions in…
2018-09-05 11:49:13 -07:00
Tim Schaub
262ea5b06e Skip asterisks after newline when parsing JSDoc types (#26528)
* Skip asterisks after newline when parsing JSDoc types

* Single boolean expression

* Test for parsing and printing multiline function signatures with *
2018-09-04 15:41:08 -07:00
Tim Schaub
20a2b0cade Ignore newline and asterisk when parsing JSDoc typedef (#26775) 2018-08-30 10:01:33 -07:00
Andy
cff04e6050
Ensure JsonSourceFile has all the non-optional properties of SourceFile (#26162)
* Ensure JsonSourceFile has all the non-optional properties of SourceFile

* Set properties in parseSourceFile
2018-08-28 16:43:14 -07:00
王文璐
78444bb724 improve test case 2018-08-27 11:47:10 +08:00
王文璐
268dbfe093 parse less than token rather than left shift in context of type arguments 2018-08-24 11:00:59 +08:00
Tim Schaub
6fd725f3ea Skip whitespace or asterisk in JSDoc param type and name (#26067) 2018-08-16 16:16:09 -07:00
Andy
08f5edbd03
Treat NoSubstitutionTemplateLiteral like StringLiteral in more places (#26330)
* Treat NoSubstitutionTemplateLiteral like StringLiteral in more places

* Move isStringOrNumericLiteral closer to its only use
2018-08-10 16:00:08 -07:00
Nathan Shively-Sanders
a6c5d50749
Allow type predicates in JSDoc (#26343)
* Allow type predicates

1. Parse type predicates. Note that they are parsed everywhere, and get
the appropriate error when used places besides a return type.
2. When creating a type predicate, correctly find the function's parameters
starting from the jsdoc return type.

* Fix type of TypePredicateNode.parent: add JSDocTypeExpression

* Update API baselines

* Handle JSDoc signature inside @type annotations

* Fix circularity when getting type predicates

Also move createTypePredicateFromTypePredicateNode closer to its use

* More cleanup based on review comments
2018-08-10 15:31:39 -07:00
Andy
a73161e9d5
Don't store @template constraint in a TypeParameterDeclaration node (#26283)
* Don't store @template constraint in a TypeParameterDeclaration node

* Code review

* Update API
2018-08-09 17:39:15 -07:00
Tim Schaub
960800d1fe Remove trailing whitespace from JSDoc comments 2018-07-28 10:36:10 -06:00
Nathan Shively-Sanders
25fb5419c0
Support the JSDoc @enum tag (#26021)
* Support the JSDoc @enum tag

`@enum` is used on a variable declaration with an object literal
initializer. It does a number of things:

1. The object literal has a closed set of properties, unlike other
object literals in Javascript.
2. The variable's name is resolvable as a type, but it just has the
declared type of the enum tag.
3. Each property's type must be assignable to the enum tag's declared type,
which can be any type.

For example,

```js
/** @enum {string} */
const Target = {
  START: "START",
  END: "END",
  MISTAKE: 0, // error 'number' is not assignable to 'string' -- see (3)
}

Target.THIS_IS_AN_ERROR; // See (1)
/** @type {Target} See (2) */
var target = Target.START;
```

* Fix lint, add new test case, update API baselines
2018-07-28 07:53:08 -07:00
Andy
d40d54984e
Support deleting all unused type parameters in a list, and deleting @template tag (#25748)
* Support deleting all unused type parameters in a list, and deleting @template tag

* Support type parameter in 'infer'
2018-07-27 11:55:31 -07:00