Commit Graph

12038 Commits

Author SHA1 Message Date
Mohamed Hegazy 00a64172af Merge pull request #25680 from a-tarasyuk/bug/25667-getmodifiedtime-has-wrong-return-type
25667 - getModifiedTime has wrong return type
2018-07-20 16:35:43 -07:00
Anders Hejlsberg 7c512fbc41 Merge pull request #25817 from Microsoft/fixGenericRestTypes
Fix generic rest types
2018-07-20 10:57:21 -10:00
Alexander 8c7a1fad25 use missingFileModifiedTime instead check on undefined 2018-07-20 21:30:10 +03:00
Nathan Shively-Sanders 31d599abaf Check module.exports (#25732)
* Revert "Revert "Explicitly typed special assignments are context sensitive (#25619)""

This reverts commit 16676f2707.

* Revert "Revert "Explicitly typed prototype assignments are context sensitive (#25688)""

This reverts commit ff8c30d636.

* Initial, wasteful, solution

It burns a check flags. Probably necessary, but perhaps not.

I haven't accepted baselines, but they are a bit questionable. I'm not
sure the synthetic type is right, because I expected to see
{ "exports": typeof import("x") } but instead see { "x": typeof
import("x") }.

* Update some baselines

* module.exports= always uses lhs type

Conflicts between exports property assignments and exports assignments
should get a union type instead of an error.

* Fix lint and accept good user baselines

* Add tests based on user tests.

These currently fail.

* Fix all but 1 of user test bugs found by typing module.exports

Still quite messy and full of notes

* Follow merged symbols+allow any object type

This allows exports like `module.exports = new EE` to have properties
added to them.

Still messy, but I'm going to run user tests and look for regressions.

* Update improved user baselines

* Fix infinite recursion when checking module.exports

* Fix bogus use-before-def error

getExportSymbolOfValueSymbolIfExported should always merge its returned
symbol, whether it's symbol.exportSymbol or just symbol.

* Update user test baselines

* Cleanup

* More small cleanup

* Bind `module` of `module.exports` as a special symbol

Previously it was also special, but created during name resolution in
the checker. It made sense when there was only one special symbol for
all files, but now there is one `module` symbol per file.
2018-07-20 10:59:26 -07:00
Alexander T 8ae163a1cc Merge branch 'master' of https://github.com/Microsoft/TypeScript into bug/25667-getmodifiedtime-has-wrong-return-type 2018-07-20 10:18:22 +03:00
Alexander T 37add88b18 Update tests baselines 2018-07-20 10:17:27 +03:00
Anders Hejlsberg 5f2efc223d Properly handle all generic kinds of types in rest positions 2018-07-19 18:29:20 -07:00
Mohamed Hegazy feca91c67b Merge pull request #25809 from ajafff/verify-strict-options
correctly detect if strictNullChecks is enabled
2018-07-19 15:56:45 -07:00
Klaus Meinhardt 7031c43978 correctly detect if strictNullChecks is enabled
Fixes: #25808
2018-07-20 00:16:59 +02:00
Klaus Meinhardt d5b3a28608 API: expose CompilerOptions.stripInternal 2018-07-19 23:13:53 +02:00
Nathan Shively-Sanders 1cedab18be Fix parsing of parenthesized JSDoc parameters (#25799)
* Fix parsing of parenthesized JSDoc parameters

Parenthesis can start a jsdoc function parameter since it is just a
type, and parenthesis can start a type:

```js
/** @type {function(((string))): void} */
```

However, this is not legal in other parameter lists:

```ts
function x((((a))): string) { }
```

This change makes jsdoc function parameter lists parse differently than
normal parameter lists by allowing parenthesis as a start character of
jsdoc parameters.

* Parse nested uses of jsdoc function types

* Fix test
2018-07-19 12:50:36 -07:00
Daniel Rosenwasser 37277e86e6 Merge pull request #25752 from Microsoft/objectsAgainstArrays
Avoid elaborating object literals against array-likes
2018-07-18 15:29:47 -07:00
Wenlu Wang ed8b76424e add grammar check for labeled declaration (#25317)
* add grammar check for labeled function declaration

* fix debug failed on labeled class declaration

* move labeled statement check to binder and add more pattern for check

* update diagnostic message

* update baseline
2018-07-18 15:37:27 -06:00
Andy 751f20e8bc Don't bother trying to get the name of a default export (#25773)
* Don't bother trying to get the name of a default export

* Fix lint
2018-07-18 11:43:13 -07:00
Daniel Rosenwasser 649f294413 Elaborate on the first non-array type when object literals are compared against 'T | T[]'. 2018-07-17 21:54:33 -07:00
Andy 6d8a5f6288 Fix invalid cast: JSDocSignature is not a SignatureDeclaration (#25734) 2018-07-17 13:35:55 -07:00
Andy d28fb65a1f Fix type of TypeParameterDeclaration#parent (#25737) 2018-07-17 13:35:34 -07:00
Mohamed Hegazy 57a72f507d Merge pull request #25733 from mattmccutchen/issue-25683
Check for optional type parameters before issuing a "wrong number of type arguments" error on a function call.
2018-07-17 12:51:19 -07:00
Matt McCutchen bd84179d82 Check for optional type parameters before issuing a "wrong number of
type arguments" error on a function call.

Fixes #25683.
2018-07-17 13:25:46 -04:00
Nathan Shively-Sanders 1edc975f15 Revert the revert of explicitly typed special assignments (#25727)
* Revert "Revert "Explicitly typed special assignments are context sensitive (#25619)""

This reverts commit 16676f2707.

* Revert "Revert "Explicitly typed prototype assignments are context sensitive (#25688)""

This reverts commit ff8c30d636.
2018-07-17 10:02:51 -07:00
Mohamed Hegazy 204ce175dd Merge pull request #25612 from Microsoft/updateVersionTo3.1
Update version
2018-07-16 14:33:25 -07:00
Nathan Shively-Sanders 16676f2707 Revert "Explicitly typed special assignments are context sensitive (#25619)"
This reverts commit 32e60a9647.
2018-07-16 12:39:08 -07:00
Nathan Shively-Sanders ff8c30d636 Revert "Explicitly typed prototype assignments are context sensitive (#25688)"
This reverts commit 5b21cbc0c9.
2018-07-16 12:38:27 -07:00
Nathan Shively-Sanders 5b21cbc0c9 Explicitly typed prototype assignments are context sensitive (#25688)
* Explicitly typed prototype assignments:ctx sensitive

Follow up to #25619: Add the necessary code to type `prototype`
correctly in prototype assignments so that code like
`F.prototype = { ... }` properly makes the object literal context
sensitive.

* Fix lint
2018-07-16 10:03:39 -07:00
Alexander T bf567b8a40 Change getModifiedTime type 2018-07-16 11:10:09 +03:00
Daniel Rosenwasser 60986adee5 Merge pull request #25507 from ajafff/leftmost-expr-tagged-template
getLeftmostExpression: handle TaggedTemplateExpression
2018-07-13 23:56:32 -07:00
Andy e25a23bb3c Fix Buffer.from uses to handle node 5.4.1 bug (#25659) 2018-07-13 17:08:25 -07:00
Sheetal Nandi 49ac60f286 Support resolveJsonModule option when files contain the json file
Fixes #25636
2018-07-13 12:21:51 -07:00
Sheetal Nandi 47e513e151 Merge pull request #25627 from Microsoft/preserveOutputInConfig
Fix incorrect handling of preserveWatchOutput flag is in config file
2018-07-13 10:56:53 -07:00
Sheetal Nandi ca083809a4 Fix incorrect handling of preserveWatchOutput flag is in config file
Fixes #25620
2018-07-12 18:29:02 -07:00
Andy 1fb050bcca Don't report unused diagnostics when the unused node has a parse error (#25598)
* Don't report unused diagnostics when the unused node has a parse error

* Update test
2018-07-12 17:24:59 -07:00
Nathan Shively-Sanders 32e60a9647 Explicitly typed special assignments are context sensitive (#25619)
* Explicitly typed js assignments: context sensitive

Explicitly typed special assignments should be context sensitive if they
have an explicit type tag. Previously no special assignments were
context sensitive because they are declarations, and in the common,
untyped, case we inspect the right side of the assignment to get the
type of the left side, and inspect the right side of the assignment to
get the type of the left side, etc etc.

Note that some special assignments still return `any` from
checkExpression, so still don't get the right type.

Fixes #25571

* Change prototype property handling+update bselines

* Fix indentation in test

* Update baselines
2018-07-12 15:28:53 -07:00
Andy f500289a44 Stricter test that JSDoc @type tag matches function signature (#25615) 2018-07-12 14:02:02 -07:00
Ryan Cavanaugh 6a2ffec53d Merge pull request #25610 from RyanCavanaugh/buildOnWatchStartup
When running with -w, do an initial compilation
2018-07-12 12:51:16 -07:00
Mohamed Hegazy ec6e37ec62 Update version 2018-07-12 11:37:19 -07:00
Anders Hejlsberg 5822a8c923 Merge branch 'master' into genericRestArityCheck
# Conflicts:
#	src/compiler/checker.ts
2018-07-12 08:20:48 -10:00
Nathan Shively-Sanders bd7b97ce61 Get return type from @type tag (#25580)
* Get return type from `@type` tag

This only happens in the checker, where the type is easily accessible.
The syntax-based check in getEffectiveReturnTypeNode as a fast path, and
for other uses that don't want to make a call to getTypeFromTypeNode.

Fixes #25525

* Implement PR suggestions

* Error when type tag isn't callable

* Fix lint
2018-07-12 10:49:41 -07:00
Ryan Cavanaugh 08d7b8fd10 When running with -w, do an initial compilation 2018-07-12 10:36:58 -07:00
Anders Hejlsberg 87ad612e70 Additional arity check following instantiation of generic rest parameter 2018-07-11 17:26:35 -10:00
rflorian 66e9aaac18 Issue 19220 function parameter arity (#24031)
* Added reference test case and diagnostics message

* Adjusted arity checks to account for non-contiguous overloads

* Code cleanup, baseline not yet commited

* Accepted test baselines and minor implementation changes

* Cleaned up baseline tracking the now renamed arity check test

* Add range response when range contains only 2 values

* Added recent baseline

* Refined arity error messages when available overloads can be grouped

* Rolled back code formatting

* WIP cleanup needed in a few edge cases

* Finished adding new more descriptive error messages

* Code cleanup

* Added simplified version of bugfix for #19220

* Rebased onto master

* Removed whitespace after type assertion

* Code review simplifications

* Use correct diagnostic name

* Code review changes and simplification of diagnostic message

* Revert formatting changes
2018-07-11 17:19:56 -07:00
Andy 5f4a03c408 Ensure TypeChecker#getTypeAtLocation returns a defined result (#25583)
* Ensure TypeChecker#getTypeAtLocation returns a defined result

* Update additional baseline
2018-07-11 16:33:56 -07:00
Mohamed Hegazy 2d0d655fea Merge pull request #25561 from ajafff/multiple-prologue-directives
handle multiple prologue directives
2018-07-11 11:38:01 -07:00
Nathan Shively-Sanders 42a2d9e568 Excess property understands conditional types (#25584)
Previously it did not, causing misleading excess property errors. Note
that assignability errors with conditional types are still usually
confusing. This PR doesn't address that.

Also, make sure that exact matches in getSpellingSuggestion are skipped.
2018-07-11 11:24:40 -07:00
Andy 19993a5408 When import("foo") has module resolution error, error span should be "foo" (#25569)
* When `import("foo")` has module resolution error, error span should be "foo"

* Update more tests
2018-07-11 10:06:08 -07:00
Klaus Meinhardt 2a960011d7 Merge branch 'master' of github.com:Microsoft/TypeScript into multiple-prologue-directives 2018-07-11 18:47:23 +02:00
Klaus Meinhardt 0de903ea17 rename function 2018-07-11 18:43:58 +02:00
Andy 8a3090bc35 Improve test for 'symbol.exports' (#25523)
* Improve test for 'symbol.exports'

* Remove SymbolFlags.HasExports and SymbolFlags.HasMembers

* Update baseline
2018-07-11 09:37:32 -07:00
Andy 990d445bb6 In services, when overload resolution fails, create a union signature (2) (#25100) 2018-07-11 08:54:47 -07:00
Sheetal Nandi 527093c758 Merge pull request #25566 from Microsoft/nonCommonJsResolveJsonIsError
Report errors for module generation other than "commonjs" with --resolveJsonModule
2018-07-10 15:30:23 -07:00
Sheetal Nandi 4dc3cd3773 Use getEmitModuleKind to check module generation kind 2018-07-10 15:28:21 -07:00