11618 Commits

Author SHA1 Message Date
王文璐
d470f32d8a Merge branch 'master' into add-braces 2018-05-24 18:03:02 +08:00
Mohamed Hegazy
10ac8b47e5
Merge pull request #22022 from Kingwl/enum-eval-div-zero
disallow nan and infinity in enum member
2018-05-23 15:32:35 -07:00
Wenlu Wang
4606709672 add code fix convert to mapped object type (#24286)
* add code fix convert to mapped object type

* add support for type literal and improve test

* fix typo

* add support for heritageClauses

* only determine declaration is not class
2018-05-23 14:09:49 -07:00
Andy
5983c45e24
Fix typo: seperate -> separate (#24338)
* Fix typo: seperate -> separate

* update tests
2018-05-23 09:36:17 -07:00
王文璐
b6669c93c0 revert wrong inline parameter 2018-05-23 10:27:10 +08:00
王文璐
0c06126d60 fix converter 2018-05-23 10:22:17 +08:00
王文璐
32be0c7099 add tests and fix 2018-05-23 10:19:08 +08:00
王文璐
5a69d9c255 add support for add or remove braces to arrow function 2018-05-23 10:16:59 +08:00
Wesley Wigham
0102f8050c
Check for keyof constraint type instead of syntactic check (#24098)
* Check for keyof constraint type instead of syntactic check

* Readopt older candidateType check, even though it shouldnt really matter

* OK. Just use maybetypeOfKind

* Remove redundant boolean check
2018-05-22 16:58:31 -07:00
Wesley Wigham
8b8cd31784
Use unknown serialization kind when type symbol isnt resolved (#24332)
* Use unknown serialization kind when type symbol isnt resolved

* Add test for the isolated modules case
2018-05-22 16:56:12 -07:00
Andy
e53e56cf82
Enable '--strictNullChecks' (#22088)
* Enable '--strictNullChecks'

* Fix API baselines

* Make sys.getEnvironmentVariable non-nullable

* make properties optional instead of using `| undefined` in thier type

* reportDiagnostics should be required

* Declare firstAccessor as non-nullable

* Make `some` a type guard

* Fix `getEnvironmentVariable` definition in tests

* Pretend transformFlags are always defined

* Fix one more use of sys.getEnvironmentVariable

* `requiredResponse` accepts undefined, remove assertions

* Mark optional properties as optional instead of using `| undefined`

* Mark optional properties as optional instead of using ` | undefined`

* Remove unnecessary null assertions

* Put the bang on the declaration instead of every use

* Make `createMapFromTemplate` require a parameter

* Mark `EmitResult.emittedFiles` and `EmitResult.sourceMaps` as optional

* Plumb through undefined in emitLsit and EmitExpressionList

* `ElementAccessExpression.argumentExpression` can not be `undefined`

* Add overloads for `writeTokenText`

* Make `shouldWriteSeparatingLineTerminator` argument non-nullable

* Make `synthesizedNodeStartsOnNewLine` argument required

* `PropertyAssignment.initializer` cannot be undefined

* Use one `!` at declaration site instead of on every use site

* Capture host in a constant and avoid null assertions

* Remove few more unused assertions

* Update baselines

* Use parameter defaults

* Update baselines

* Fix lint

* Make Symbol#valueDeclaration and Symbol#declarations non-optional to reduce assertions

* Make Node#symbol and Type#symbol non-optional to reduce assertions

* Make `flags` non-nullable to reduce assertions

* Convert some asserts to type guards

* Make `isNonLocalAlias` a type guard

* Add overload for `getSymbolOfNode` for `Declaration`

* Some more `getSymbolOfNode` changes

* Push undefined suppression into `typeToTypeNodeHelper`

* `NodeBuilderContext.tracker` is never `undefined`

* use `Debug.assertDefined`

* Remove unnecessary tag

* Mark `LiteralType.freshType` and `LiteralTupe.regularType` as required
2018-05-22 14:46:57 -07:00
Wesley Wigham
3fe946df78
Use symbolToTypeNode for class & interface references (#24330)
* Use merged symbols when calculating qualification, use symbolToTypeNode

* Accept baselines
2018-05-22 14:09:45 -07:00
Andy
7106a587cc
Add type for diagnostics where location is defined (#23686)
* Add type for diagnostics where location is defined

* getSemanticDiagnostics may return global diagnostics

* Reduce array creation
2018-05-22 11:01:18 -07:00
Anders Hejlsberg
a5029e3d4e
Merge pull request #23794 from Microsoft/fixDiscriminatedContextualType
Fix discriminant checking in contextual types
2018-05-22 10:35:29 -07:00
Andy
982c8d0af9
Add suggestion diagnostics for unused label and unreachable code (#24261)
* Add suggestion diagnostics for unused label and unreachable code

* Always error on unused left hand side of comma
2018-05-22 07:56:29 -07:00
Anders Hejlsberg
f52c4af448
Merge pull request #24310 from Microsoft/nonWideningLiteralInferences
Non-widening literal type inferences
2018-05-22 06:56:34 -07:00
Mohamed Hegazy
a9e89ce3f1
Merge pull request #24180 from Microsoft/updateVersion
Update version
2018-05-21 17:18:39 -07:00
Anders Hejlsberg
8528dbee76 Handle union types in getRegularTypeOfLiteralType 2018-05-21 16:17:56 -07:00
Andy
802dc2bb9b
fixUnusedIdentifier: If every VariableDeclaration is unused, remove the VariableStatement (#24231) 2018-05-21 15:54:33 -07:00
Anders Hejlsberg
c8ac085498 Infer non-widening literal types when type parameter constraint includes primitive types 2018-05-21 15:28:51 -07:00
Daniel Rosenwasser
3563a0576d Use single quotes around 'typeof' in message. 2018-05-18 23:44:38 -07:00
Wesley Wigham
02fe840732
Get constraint with this argument of the type parameter for comparisons (#21210)
* Get constraint with this argument of the type parameter for comparisons

* Also instantiate indexed accesses

* Add much simpler test
2018-05-18 18:30:23 -07:00
Andy
4c22bf786e
getEditsForFileRename: Do fresh module resolution instead of relying on cache (#24211)
* getEditsForFileRename: Do fresh module resolution instead of relying on cache

* Add host.resolveModuleNameWithFailedLookupLocations method

* Make host.resolveModuleNameWithFailedLookupLocations mandatory, and implement for Project

* Add test, and no need to check host.fileExists

* Change method name and always use cache

* Update name in string
2018-05-18 16:42:42 -07:00
Andy
3eb66da155
Add code fix to remove unused label (#24037)
* Add code fix to remove unused label

* Test with trivia and fix indentation with dedented label
2018-05-18 15:25:24 -07:00
Andy
1df7997014
getJSDocTypeParameterDeclarations: Avoid unnecessary array (#24257) 2018-05-18 13:53:27 -07:00
Sheetal Nandi
3bb9ccfa8e
Merge pull request #24234 from Microsoft/unusedIdentifierCorrectFile
Unused variable error reporting needs to handle nodes that could not belong to current source file
2018-05-18 13:25:19 -07:00
Andy
7f0258bcb9
getJSDocHost always returns a defined result (#24255) 2018-05-18 13:20:13 -07:00
Andy
76573c6520
getEffectiveTypeParameterDeclarations: Always return a defined result (#24251) 2018-05-18 10:17:35 -07:00
Sheetal Nandi
52e8c2d663 Unused variable error reporting needs to handle nodes that could not belong to current source file
Eg. when resolving module, the another file gets checked and its locals are added to potentiallyUnused list
Fixes #24215
2018-05-17 16:27:08 -07:00
Wesley Wigham
d82d35c7f5
Set startPos at EOF in jsdoc token scanner so node end positions for nodes terminated at EoF are right (#24184)
* Set startPos at EOF in jsdoc token scanner to node end positions for nodes terminated at EoF are right

* More complete nonwhitespace token check, fix syntactica jsdoc classifier

* Use loop and no nested lookahead

* Do thigns unrelated to the bug in the test

* Fix typo move return

* Patch up typedef end pos

* Fix indentation, make end pos target more obvious
2018-05-17 15:16:18 -07:00
Andy
75ab60f199
Improve ChangeTracker#deleteNodeInList (#24221) 2018-05-17 14:31:58 -07:00
Wesley Wigham
3800d7b246
More robust circularity detection in node builder (#24225) 2018-05-17 14:30:07 -07:00
Anders Hejlsberg
3fc3df3c3a
Merge pull request #24137 from Microsoft/fix23977
Optimize intersections of unions of unit types
2018-05-17 13:15:28 -07:00
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
Anders Hejlsberg
027829fbcd Properly handle edge cases 2018-05-16 16:26:37 -07:00
Mohamed Hegazy
3a00ac1d0b Merge branch 'master' into updateVersion 2018-05-16 14:21:19 -07:00
Mohamed Hegazy
21acf4f783
Merge pull request #24136 from Microsoft/inferFromUsageFixes
Remove assert in `symbolToParameterDeclaration`
2018-05-16 14:15:37 -07:00
Mohamed Hegazy
d55837175c Update version 2018-05-16 13:50:48 -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