11578 Commits

Author SHA1 Message Date
Wesley Wigham
3fc727b256
Use import types to refer to declarations in declaration emit (#24071)
* Stand up a simple implementation using import types for exports of modules which are otherwise inaccessible

* Ensure references exist to link to modules containing utilized ambient modules

* Accept baselines with new import type usage

* Fix lint
2018-05-17 13:08:22 -07:00
Mohamed Hegazy
a9660f3c5e
Merge pull request #24212 from Microsoft/Fix24199
Add undefined guard
2018-05-17 12:27:55 -07:00
Mohamed Hegazy
8dc9b76b6d Add undefined guard 2018-05-17 11:45:34 -07:00
Nathan Shively-Sanders
6450490844
Fix jsdoc type resolution [merge to master] (#24204)
* Fix JSDoc type resolution

Breaks type parameter resolution that is looked up through prototype
methods, though. I need to fix that still.

* Check for prototype method assignments first

* Undo dedupe changes to getJSDocTags

* JS Type aliases can't refer to host type params

Previously, js type aliases (@typedef and @callback) could refer to
type paremeters defined in @template tags in a *different* jsdoc tag, as
long as both tags were hosted on the same signature.

* Reduce dedupe changes+update baseline

The only reason I had undone them was to merge successfully with an
older state of master.
2018-05-17 10:46:10 -07:00
Andy
2b5ff29254
Reduce map lookups (#24203) 2018-05-17 10:02:10 -07:00
Andy
176e35b9c3
moveToNewFile: Don't move imports (#24177) 2018-05-17 09:54:47 -07:00
Nathan Shively-Sanders
aa7e2b0f07
Add callback tag, with type parameters (#23947)
* Add initial tests

* Add types

* Half of parsing (builds but does not pass tests)

* Parsing done; types are uglier; doesn't crash but doesn't pass

* Bind callback tag

Builds but tests still don't pass

* Only bind param tags inside callback tags

* Fix binding switch to only handle param tags once

* Checking is 1/3 done or so.

Now I'm going to go rename some members to be more uniform. I hate
unnnecessary conditionals.

* Rename typeExpression to type (for some jsdoc)

(maybe I'll rename more later)

* Rename the rest of typeExpressions

Turns out there is a constraint in services such that they all need to
be named the same.

* Few more checker changes

* Revert "Rename the rest of typeExpressions"

This reverts commit f41a96b24d44a6b696d39eee9e91ef7f606bea52.

* Revert "Rename typeExpression to type (for some jsdoc)"

This reverts commit 7d2233a00e5c6d794c1de32c03802e8ccce1914c.

* Finish undoing typeExpression rename

* Rename and improve getTypeParametersForAliasSymbol

Plus some other small fixes

* Core checking works, but is flabbergastingly messy

I'm serious.

* Callback return types work now

* Fix crash in services

* Make github diff smaller

* Try to make github diff even smaller

* Fix rename for callback tag

* Fix nav bar for callback tag

Also clean up some now-redundant code there to find the name of typedefs.

* Handle ooorder callback tags

Also get rid of redundant typedef name code *in the binder*. It's
everywhere!

* Add ooorder callback tag test

* Parse comments for typedef/callback+display param comments

* Always export callbacks

This requires almost no new code since it is basically the same as
typedefs

* Update baselines

* Fix support for nested namespaced callbacks

And add test

* Callbacks support type parameters

1. Haven't run it with all tests
2. Haven't tested typedef tags yet
3. Still allows shared symbols when on function or class declarations.

* Template tags are now bound correctly

* Test oorder template tags

It works.

* Parser cleanup

* Cleanup types and utilities

As much as possible, and not as much as I would like.

* Handle callback more often in services

* Cleanup of binder and checker

* More checker cleanup

* Remove TODOs and one more cleanup

* Support parameter-less callback tags

* Remove extra bind call on template type parameters

* Bind template tag containers

Doesn't quite work with typedefs, but that's because it's now stricter,
without the typedef fixes. I'm going to merge with jsdoc/callback and
see how it goes.

* Fix fourslash failures

* Stop pre-binding js type aliases

Next up, stop pre-binding js type parameters

* Further cleanup of delayed js type alias binding

* Stop prebinding template tags too

This gets rid of prebinding entirely

* Remove TODO

* Fix lint

* Finish merge with use-jsdoc-aliases

* Update callback tag baselines

* Rename getTypeParametersForAliasSymbol

The real fix is *probably* to rename Type.aliasTypeArguments to
aliasTypeParameters, but I want to make sure and then put it in a
separate PR.
2018-05-17 09:28:11 -07:00
王文璐
5d233054c3 add quick fix for import type missing typeof 2018-05-17 16:35:20 +08:00
Mohamed Hegazy
21acf4f783
Merge pull request #24136 from Microsoft/inferFromUsageFixes
Remove assert in `symbolToParameterDeclaration`
2018-05-16 14:15:37 -07:00
Wesley Wigham
e01c7d23e1
Correctly show instantiated signatures for JSX element signature help and quick info (#23492)
* Correctly show instantiated signatures for JSX element signature help

* Also bundle fix for quickinfo

* Use more complete cache to avoid duplicate errors
2018-05-16 13:09:54 -07:00
Wesley Wigham
5bf6e30f8e
Use jsdoc aliases if visible when printing types (#24153)
* Use jsdoc aliases if visible when printing types

* Modify implementation a bit, add test that aughta change in the new future

* Accept baselines- hold off on typedef template lookup change
2018-05-16 12:58:36 -07:00
Wesley Wigham
60df4671d0
Fix jsx element parsing within ternary (#24149) 2018-05-16 09:28:22 -07:00
Mohamed Hegazy
6f4ed3afa6 Handel synthetic rest parameter declarations 2018-05-15 22:08:01 -07:00
Andy
2200c94a43
Fix unused diagnostic for rename-destructuring { a: b } (#24145) 2018-05-15 16:22:13 -07:00
Nathan Shively-Sanders
339a56fbf0
Avoid duplicates when finding jsdoc (#24086)
* Avoid duplicates when finding jsdoc

1. Add a cheap assert for detecting duplicates. getJSDocTags must find
either [1] 0 or 1 comments or [2] the first two comments must not be
identical. This does not always find duplicates for nodes with 3 or more
comments, but these nodes are exceptionally rare.

This assert fired for over 20 of the around 250 tests we have that
retrieve JSDoc at all. So I fixed the asserts in [2] and [3].

2. There were overlapping cases from calls to getSourceOfAssignment and
getSpecialPropertyAssignment. getSpecialPropertyAssignment is too
restrictive, but was in the correct location (parent vs parent.parent),
so I removed the getSourceOfAssignment call and replaced the
getSpecialPropertyAssignment calls with a less restrictive check.

3. When a node's parent is a PropertyDeclaration,
getJSDocCOmmentsAndTags would check the parent for jsdoc. But when the
*node* is a PropertyDeclaration, getJSDocCommentsAndTags would use the
jsdoc from the initializer. This second case is useful to make sure that
property declarations get all their jsdoc, but results in duplicates for
their initializers. I couldn't think of a better fix than tracking the
previous node in the recursive lookup of getJSDocCommentsAndTags, which
is a little clunky.

* Fix lint; remove new context parameter

* Update importJsNodeModule3 with fix
2018-05-15 15:12:29 -07:00
Sheetal Nandi
77168e5d50
Merge pull request #24112 from Microsoft/packageJsonWithMainInSubDirectory
Resolve using package json's "main" field when resolving typescript extensions
2018-05-15 14:18:27 -07:00
Wesley Wigham
86dce41ec0
Move synthetic comments from arrow body expressions to return statement (#24135) 2018-05-15 13:11:38 -07:00
Nathan Shively-Sanders
0ba8998c82
Fix stack overflow in merge symbol (#24134)
* JS initializers use original valueDecl, not mutated

target's valueDeclaration is set to the source's if it is not present.
This makes it incorrect to use getJSInitializerSymbol because it relies
on the symbol's valueDeclaration.

This fix just saves the original valueDeclaration before mutating and
uses that.

* Compare merged targetInitializer to target

Instead of the unmerged one

* Add test of stack overflow
2018-05-15 12:49:54 -07:00
Mohamed Hegazy
0bda862cca Remove assert 2018-05-14 22:49:50 -07:00
Sheetal Nandi
dc50fe5e40 Apart from typing, use main field in package json to resolve typescript files
Fixes #23502
2018-05-14 14:52:11 -07:00
Sheetal Nandi
22d5b0e19f Do not remove extension js or jsx from the subModuleName if the subModule doesnt have js or jsx extension 2018-05-14 14:21:08 -07:00
Wesley Wigham
ba4bf21ead
Cache simplified indexed accesses to better handle circularly constrained indexed acceses (#24072) 2018-05-14 12:54:26 -07:00
Andy
9b6378b938
Use SHA256 hash for project info telemetry (#24099)
* Use SHA256 hash for project info telemetry

* Update API baselines
2018-05-14 11:32:16 -07:00
Wesley Wigham
b58e4e1fa1
Reduce aggression of parenthesis removal in ts transform (#24073) 2018-05-14 11:20:04 -07:00
Ron Buckton
f5281d62cc Fix async generator rejection handling 2018-05-12 02:07:31 -07:00
Mohamed Hegazy
b0c67fd023
Merge pull request #24056 from a-tarasyuk/bug/23891-declarationDir-needs-to-be-handled-in-excludeSpecs
Add declarationDir to excludeSpec
2018-05-11 12:56:15 -07:00
Alexader
60d39d7f18 add tests 2018-05-11 21:27:40 +03:00
Mohamed Hegazy
cc36cfc834
Merge pull request #24050 from Microsoft/fix-js-initializer-merging
Fix js initializer merging
2018-05-11 10:45:20 -07:00
Nathan Shively-Sanders
de9ff1b004 Assert:only merge into transient symbols 2018-05-11 09:12:25 -07:00
Alexander T
bb615ac3f9 Add declarationDir to excludeSpec 2018-05-11 13:47:44 +03:00
Nathan Shively-Sanders
904f8df9c1 Fix repeated merging of js initializers 2018-05-10 20:58:59 -07:00
Nathan Shively-Sanders
c49ef36964 First half of fix
Still doesn't work correctly for multiple merges
2018-05-10 16:51:46 -07:00
Andy
6ae4d3a516
Add code fix to remove unreachable code (#24028)
* Add code fix to remove unreachable code

* Code review

* Preserve more kinds of statements
2018-05-10 16:44:48 -07:00
Andy
fd17f77cc9
Improvements to find-all-references for import types (#23998)
* Improvements to find-all-references for import types

* Add JS test
2018-05-10 15:31:06 -07:00
Andy
5cf491715a
Fix comment (#24035) 2018-05-10 14:59:15 -07:00
Ron Buckton
f7311ef84a
Merge pull request #23956 from Kingwl/emit-var-at-top
emit temporary vars at the top of the scope
2018-05-10 12:20:13 -07:00
Andy
7271ec1240
Add 'move to new file' refactor (#23726)
* Add 'move to new file' refactor

* Code review, and support commonjs

* Compute movedSymbols completely before using, and support `export import`

* Fix assertion error: sort empty change before non-empty change

* Remove extra newline

* Add allowTextChangesInNewFiles preference

* Add the new file to 'files' in tsconfig

* Avoid parameter initializer

* Update API baselines

* Use path relative to tsconfig.json

* Code review

* Fix error where node in tsconfig file was missing a source file
2018-05-10 11:17:04 -07:00
Wesley Wigham
6149b41469
Generate names for type parameter declarations in inferred types (#23902)
* Generate names for type parameter declarations in inferred types

* Fix lint

* Merge functions, make overload private

* Handle some edge cases better (nodes in differing files than current emit)

* Account for transformed nodes
2018-05-10 11:16:27 -07:00
Mohamed Hegazy
3e08c4174e
Merge pull request #24000 from ajafff/regex-factory
Add createRegularExpressionLiteral and expose createStringLiteral
2018-05-10 09:56:46 -07:00
王文璐
ad5a4c7097 add prependRange and move more variable declaration 2018-05-10 15:54:51 +08:00
Wesley Wigham
20f9493f04
Allow all private declarations to be emitted in declaration output (#23351)
* Mostly functional WIP

* Fix accessors, symbol stringification

* Accept/update changed baselines

* Move type definition so file build order doesnt matter

* Accept post-merge test update

* Rename function, add doc
2018-05-09 19:53:44 -07:00
Klaus Meinhardt
fc3ba76ab7 Add createRegularExpressionLiteral and expose createStringLiteral
Fixes: #23992
2018-05-09 22:22:46 +02:00
Mohamed Hegazy
9ea4d93823
Merge pull request #23957 from paulkoerbitz/16675-better-error-message-for-dynamic-import
Fix #16675: Better error message for dynamic import with ES2015 modules
2018-05-09 09:42:58 -07:00
Nathan Shively-Sanders
e27fb0651b
Fix crash in recursive declared type resolution (#23950)
When one type has a type parameter with a default
2018-05-09 09:25:00 -07:00
Paul Koerbitz
89d2baede7 Adress review comments 2018-05-09 10:53:27 +02:00
Ron Buckton
f17bf54bfe
Merge pull request #23887 from agentcooper/async-generator-resolve-promise
Resolve promise inside async generator
2018-05-09 00:23:47 -07:00
Artem Tyurin
d88210b270 Do not check for await expression and always output yield await 2018-05-09 09:09:49 +02:00
Mohamed Hegazy
030b8fc8a6
Merge pull request #23976 from ialexryan/patch-3
Fix comment typo in program.ts
2018-05-08 22:08:56 -07:00
Alex Ryan
f9bd3afb8f
Fix comment typo in types.ts 2018-05-08 14:51:49 -07:00
Alex Ryan
01351d43e4
Fix comment typo in program.ts 2018-05-08 14:36:32 -07:00