Commit Graph

1507 Commits

Author SHA1 Message Date
Andy
6d82a20109 Combine getLastChild helpers (#22418) 2018-03-22 09:32:05 -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
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
Wesley Wigham
19ec83fcdf Refactor declaration emitter into declaration transformer (#21930)
* Refactor declaration emitter into declaration transformer

* Slight cleanup from code review feedback

* Incorporate fix for new test

* Swaths of PR feedback

* Merge public methods

* Per-file output

* Preserve input import ordering more often

* Unify jsdoc comment start detection under more lenient rule

* Move to per-file transformations to reduce the memory that msut be retained

* Fix typo
2018-03-15 22:23:10 -07:00
Andy
0c6ef348ce Simplify parseJsxChildren (#22511) 2018-03-13 12:28:21 -07:00
Josh Goldberg
7826b38426 Apply 'no-unnecessary-initializer' lint rule (#22014)
* Apply 'no-unnecessary-initializer' lint rule

Forbids `let`/`const` statements to be initialized to `undefined`, since that's the initial value by default anyway.
The auto-fixer also happened to remove two unnecessary `as number` casts in `src/harness/parallel/worker.ts`.

For historical data: to run with `--fix`, I modified the line in `Jakefile.js` that declared the `cmd` for running TSLint.

* Moved worker.ts type assertions to parameters
2018-03-06 07:30:40 -08:00
Andy
4ddf045d6a For <div a= >, after =, do not try to parse an expression (#21373) 2018-03-05 14:38:55 -08:00
Benjamin Lichtman
dfa1a90b25 Merge pull request #22135 from uniqueiniquity/jsxFragmentHash
Allow characters in JsxText inside JsxFragment that usually don't scan
2018-03-01 16:50:09 -08:00
Andy
a564912d9a Apply 'no-unnecessary-qualifier' lint rule (#22009) 2018-03-01 14:20:18 -08:00
Wesley Wigham
32c63a2628 Add support for transpiling per-file jsx pragmas (#21218)
* Add support for per-file jsx pragmas

* Add error for using jsx factory pragma with fragments

* More tests, use different regex class for pragma capture

* Unify all pragma parsing machinery
2018-02-26 16:10:00 -08:00
uniqueiniquity
71ff6dd91e Allow characters in JsxText inside JsxFragment that would not normally scan 2018-02-22 15:56:34 -08:00
Andy
b3edc8f9f4 Apply 'no-unnecessary-type-assertion' lint rule (#22005)
* Apply 'no-unnecessary-type-assertion' lint rule

* Fix type error

* Fix tsconfig.json

* Add --format back
2018-02-16 18:38:00 -08:00
Anders Hejlsberg
a629acd8fd Allow +/- to prefix 'readonly' and '?' modifiers in mapped types 2018-02-12 16:20:49 -08:00
Anders Hejlsberg
0d3f2166e3 Automatic semicolon insertion before 'extends' in conditional type 2018-02-05 13:56:10 -08:00
Anders Hejlsberg
7c241ba2f7 Merge branch 'conditionalTypes' into inferTypes
# Conflicts:
#	src/compiler/checker.ts
#	tests/cases/fourslash/completionInJSDocFunctionNew.ts
#	tests/cases/fourslash/completionInJSDocFunctionThis.ts
2018-01-30 13:40:16 -08:00
Anders Hejlsberg
4f2b5f32f9 Merge branch 'master' into conditionalTypes 2018-01-30 06:42:14 -08:00
Anders Hejlsberg
ef0c3b7667 Change precedence of 'infer T' to match 'keyof T' 2018-01-25 12:43:07 -08:00
Anders Hejlsberg
d608941480 Implement type inference in conditional types 2018-01-25 12:25:00 -08:00
Anders Hejlsberg
0e73240ea4 Disallow conditional type following 'extends' 2018-01-19 14:44:48 -08:00
Anders Hejlsberg
c360c24b9b Fix parsing 2018-01-19 13:01:27 -08:00
Andy
9436b1cc0b Fix formatter crash for const { ...a: b } = {};: forEachChild and emitBindingElement should handle ... before the propertyName (#21268) 2018-01-18 10:36:41 -08:00
Andy
466557cafb Support parsing @template {T} in addition to @template T (#21270) 2018-01-18 09:45:29 -08:00
Anders Hejlsberg
4ec6fdd96f Merge branch 'master' into conditionalTypes
# Conflicts:
#	src/compiler/checker.ts
#	src/compiler/types.ts
#	tests/baselines/reference/api/tsserverlibrary.d.ts
#	tests/baselines/reference/api/typescript.d.ts
2018-01-17 13:12:36 -08:00
Anders Hejlsberg
5094f7677c Remove 'T extends U' type constructor 2018-01-15 08:11:05 -08:00
Anders Hejlsberg
53b1572ed6 Revert to extends check being part of conditional type 2018-01-15 07:59:46 -08:00
Andy
a77c6014b3 Parse comment on @property tag and use as documentation comment (#21119)
* Parse comment on @property tag and use as documentation comment

* Fix comment parsing bug -- back up after seeing `@` character

* Add test for indent

* Don't default comment to ""
2018-01-11 10:49:39 -08:00
Andy
7a1deae6aa AsteriskToken should always have length 1 (#21126) 2018-01-10 12:52:35 -08:00
Andy
102368332e Use 'append' helper more (#21125) 2018-01-10 11:31:13 -08:00
Andy
ddd8e759c1 Use 'append' helper (#21101) 2018-01-10 11:13:47 -08:00
Andy
191b9750c3 Clear jsDocCache for reused nodes (#21099) 2018-01-09 11:22:15 -08:00
Andy
a23bbe65e6 Use substring instead of substr (#20578)
* Use substring instead of substr

* Remove unused scanning of SyntaxKind.DotDotDotToken in jsdoc

* Remove other unnecessary jsdoc syntax kinds

* Move all pos++ together
2018-01-08 14:54:18 -08:00
Wenlu Wang
0ecdc876f3 imporve conditional operator if missing colon token (#20498)
f2
2018-01-08 13:16:17 -08:00
Andy
f83283c068 Improve parse error for double comma somewhere inside a call expression (#20399) 2018-01-08 10:38:55 -08:00
Andy
6f2ba15446 Start linting for double spaces (#20820)
* Start linting for double spaces

* Code review

* Fix cases that were excluded by countDoubleSpaces

* Remove extraneous closing parenthesis
2018-01-08 08:52:13 -08:00
Anders Hejlsberg
abc8110e9b Merge branch 'master' into conditionalTypes
# Conflicts:
#	src/compiler/checker.ts
2018-01-03 10:56:45 -08:00
Anders Hejlsberg
c5fd2f14f3 Parse xxx? as JSDoc type when not followed by token that starts type 2017-12-18 18:30:34 -08:00
Wesley Wigham
dd933f4413 Fix get symbol at location to behave correctly for parameter assignments and jsx attributes (#20706)
* Fix get symbol at location to behave correctly got parameter assignments and jsx attributes

* Handle all those edge cases that weren;t explicitly handled

* Fix part of bug WRT getTypeAtLocation and for loops

* Baseline corrections pursuant to #20710

* Restore jsdoc tag interpretation

* Clean up some code, revert fourslash tests

* Cleanup types used by PR feedback
2017-12-15 15:50:22 -08:00
Anders Hejlsberg
ec2bdfdb8b Add 'T extends U' type operator 2017-12-12 09:52:14 -08:00
Andy
484758a3d3 Handle ! following a keyword in isClassMemberStart (#20617)
* Handle `!` following a keyword in isClassMemberStart

* Fix test
2017-12-11 09:45:36 -08:00
Anders Hejlsberg
57ca7680c9 Initial implementation of conditional type operator 2017-12-05 14:18:11 -08:00
Anders Hejlsberg
b4b9edc04c Make sure 'async' isn't treated as a parameter modifier 2017-11-21 18:39:01 -08:00
Anders Hejlsberg
9abb72d920 Merge pull request #20166 from Microsoft/definiteAssignmentAssertions
Definite assignment assertions
2017-11-21 06:27:56 -08:00
Wesley Wigham
a551c4cd64 Allow curly around @type jsdoc to be optional (#20074)
* Allow curly around `@type` jsdoc to be optional

* Incorporate restructuring from @andy-ms
2017-11-20 16:10:50 -08:00
Anders Hejlsberg
272076391b Allow '!' only on variable declarations within variable statements 2017-11-20 09:31:11 -08:00
Anders Hejlsberg
1624e1bc1a Definite assignment assertion '!' on variable and property declarations 2017-11-19 16:48:43 -08:00
Anders Hejlsberg
b6f96052d8 Merge pull request #19976 from Microsoft/optimizeParser
Optimize parsing
2017-11-16 10:19:10 -08:00
Ron Buckton
a21a129abb Merge branch 'master' into dynamicNames 2017-11-15 15:24:05 -08:00
Andy
4b96edf72f Treat ... in jsdoc type as creating a synthetic rest parameter -- not as an array type (#19483)
* Treat `...` in jsdoc type as creating a synthetic rest parameter -- not as an array type

* Change type parsing so `...T[]` parses as `...(T[])` and not `(...T)[]`

* Replace the last parameter with ...args, and make access to it potentially undefined

* Code review
2017-11-15 13:04:08 -08:00
Anders Hejlsberg
ee851784a6 Remove dead code that didn't get removed in #19979 2017-11-14 14:03:56 -08:00
Anders Hejlsberg
dbeb68274f Merge branch 'master' into optimizeParser
# Conflicts:
#	src/compiler/parser.ts
2017-11-14 09:22:18 -08:00