Commit Graph

5893 Commits

Author SHA1 Message Date
Wesley Wigham
84f5aa540e Put error spans deep on nested object literals (#25140)
* Add ncie deep elaborations

* Nice stuff

* Modify tuple error to use length error mroe often

* Accept good baselines

* Accept meh baselines

* Fix literal types

* Calculate elaborations like it was the very first time again~

* Use tristate for enum relationship to ensure elaborations are printed at least once

* Update message text, nits

* move some functions back to where they were

* Add test of deep JSX elaboration

* Add elaboration test with parenthesized expressions, comma expressions, and assignments

* Move check to allow elaborations on more anonymous types

* Fix nits

* Add specialized error to elaborations of nonliteral computed named-members

* Update error message
2018-07-03 19:40:58 -07:00
Andy
204b70d7af Don't add completions from a discriminated union type when the discriminant doesn't match (#24770)
* Don't add completions from a discriminated union type when the discriminant doesn't match

* Move code to checker

* Update API (#24966)

* Use isTypeIdenticalTo
2018-07-03 17:05:51 -07:00
Anders Hejlsberg
eb7ff43f95 Merge pull request #25408 from Microsoft/contextualTupleTypes
Infer tuple types for contextually typed rest parameters
2018-07-03 14:02:48 -10:00
Mohamed Hegazy
17b10e8293 Merge pull request #25397 from a-tarasyuk/bug/25356-instance-property-is-not-a-block-scoped-variable
25356 - Instance property is not a block scoped variable
2018-07-03 14:11:28 -07:00
Wesley Wigham
cb4cb7a75f Check if module reference requires type reference before path reference (#25385) 2018-07-03 11:41:07 -07:00
Anders Hejlsberg
e8d64a9c7c Merge pull request #25336 from Microsoft/fixResolveTypeMembers
Fix runaway recursion in object type member resolution
2018-07-03 07:53:02 -10:00
Anders Hejlsberg
b87a723f25 Remove outdated comment 2018-07-03 07:21:15 -10:00
Alexander T
6ff0ba644b Add new error message - Property {0} is used before its initialization. 2018-07-03 14:39:58 +03:00
Daniel Rosenwasser
c3b81b3e10 Merge pull request #25377 from Microsoft/addressWesleyFeedback20180702
Use `addRelatedInfo`.
2018-07-02 18:10:11 -07:00
Wesley Wigham
65655f2c6b Change import type determination to not use a RE on the symbol name (#25381) 2018-07-02 17:43:39 -07:00
Daniel Rosenwasser
69d1f58e62 Use addRelatedInfo. 2018-07-02 16:09:20 -07:00
Anders Hejlsberg
c172314ba2 Infer contextual tuple types 2018-07-02 10:38:30 -10:00
Daniel Rosenwasser
c4500bd442 Addressed code review feedback. 2018-07-02 12:06:42 -07:00
Daniel Rosenwasser
4459730e5b Give related error on declaration location for used-before-declared errors. 2018-07-02 11:32:20 -07:00
Wesley Wigham
7084e6cf47 Adds related spans and error grouping for duplicate identifier errors (#25328)
* Adds related spans and error grouping for duplicate identifier errors

* Trim trailing whitespace

* Record related info in error baselines

* Make error more whimsical
2018-07-02 10:47:52 -07:00
Anders Hejlsberg
4bca0a40b9 Guard against recursion in resolveAnonymousTypeMembers 2018-06-29 16:59:55 -10:00
Wesley Wigham
18e3f487a4 Support LibraryManagedAttributes<TComponent, TAttributes> JSX namespace type (#24422)
* WIP

* Allow type alias for managed type

* Add a large test

* Accept updatedbaselines

* Fix typo in test, add one more example
2018-06-29 18:45:29 -07:00
Wesley Wigham
313a0b8990 Remove deprecated SymbolDisplayBuilder API (#25331)
* Remove deprecated API

* Accept API baseline updates
2018-06-29 18:37:50 -07:00
Andy
c5bd0405c4 JsxTagNameExpression can only be Identifier | ThisExpression, not any PrimaryExpression (#21555)
* JsxTagNameExpression can only be Identifier | ThisExpression, not any PrimaryExpression

* Use a type similar to PropertyAccessEntityNameExpression

* Fix lint errors
2018-06-29 16:50:44 -07:00
Andy
48d31eddc8 Split isConst into isVarConst and isEnumConst (#25312) 2018-06-29 16:47:11 -07:00
Daniel Rosenwasser
b5f386eb6e Merge pull request #25311 from Microsoft/betterAlwaysTrueFalseErrors
Even better "always true/false" errors
2018-06-29 14:07:04 -07:00
Daniel Rosenwasser
f23c180a38 Merge pull request #25287 from Microsoft/skipToNonNullTargets
Skip to non null targets in error messages
2018-06-28 22:26:36 -07:00
Daniel Rosenwasser
6f06fd0d46 Use a more direct error. 2018-06-28 16:06:55 -07:00
Daniel Rosenwasser
c853d7c048 Don't elaborate on primitives at all. 2018-06-28 15:34:27 -07:00
Wesley Wigham
2a19580144 Introduce more caching and deferral into jsx checking (#25302)
* Introduce more caching and deferral into jsx checking

* Accept baseline with removed duplicated error
2018-06-28 14:43:20 -07:00
Nathan Shively-Sanders
5c2eeb20b1 Destructuring declaration prefers type annotation type (#25282)
* Destructuring declaration prefers type annotation type

Previously, getTypeForBindingElement would always union the declarations type and
the type of the default initializer. Now, if the declaration has a type
annotation, it does not union with the initializer type. The type
annotation's type is the one used.

* Small cleanup in parentDeclarationHasTypeAnnotation

* Refactoring based on PR comments

* Combine getCombined*Flags into a single helper function

Retain the individual functions since they are used a lot.

* Remove unneeded temp
2018-06-28 10:41:38 -07:00
Daniel Rosenwasser
35e9e165b1 Strip null and undefined from targets when relating from certain atomic types. 2018-06-28 00:11:44 -07:00
Daniel Rosenwasser
950593b669 Merge pull request #25251 from Microsoft/betterAlwaysTrueFalseErrors
Better "always true/false" errors
2018-06-27 21:57:25 -07:00
Daniel Rosenwasser
1f8ad2d318 indicates -> indicate 2018-06-27 17:20:24 -07:00
Andy
fd8b7f3da5 Remove redundant checks in getNameOfDeclaration (#25244) 2018-06-27 13:56:31 -07:00
Daniel Rosenwasser
63a52cd21e Give a better message up-front for incompatible equality errors. 2018-06-26 15:11:41 -07:00
Nathan Shively-Sanders
9025bc7c69 Fix control flow loop in yield expression (#25228)
* Fix control flow loop in yield expression

Yet again, the fix is to stop using checkExpressionCached.

* Update lib in test to reduce number of errors
2018-06-26 12:50:29 -07:00
Nathan Shively-Sanders
9044589377 Fix duplicate errors in js special assignments (#24508)
* Fix duplicate errors in js special assignments

* Simplify checkExpressionCached call to checkExpression

* Accept baselines after merge

* Use Map for deferredNodes and improve NoDeferredCheck comment

I added an assert when a duplicate was added, but it caused 18 failures
in our test suite.

* Remove NoDeferredCheck
2018-06-26 12:40:58 -07:00
Anders Hejlsberg
70975cd08f Merge pull request #24897 from Microsoft/restTuples
Tuples in rest parameters and spread expressions
2018-06-25 19:26:35 -07:00
Anders Hejlsberg
d7443f04fd Contextual typing by tuple rest elements 2018-06-25 10:45:02 -10:00
Andy
e8e80d2bbd Don't crash on property access with type (#25170)
* Don't crash on property access with type

* Move test
2018-06-25 11:25:52 -07:00
Anders Hejlsberg
28c9f5933a Complete support for rest elements in tuples 2018-06-24 14:32:41 -10:00
Wesley Wigham
c441451f83 Cache specifier resolutions for speed when emitting many types from the same place (#25112)
* Cache specifier resolutions for speed when emitting many types from the same place

* I swear I accepted this once already
2018-06-22 14:05:07 -07:00
Anders Hejlsberg
b650d7d06b Fix issue 2018-06-22 06:26:52 -10:00
Anders Hejlsberg
b0d8c6551e Merge branch 'master' into restTuples
# Conflicts:
#	src/compiler/checker.ts
2018-06-22 06:10:50 -10:00
Anders Hejlsberg
ae859d6303 Update destructuring to support optional and rest elements in tuples 2018-06-21 17:01:46 -10:00
Daniel Rosenwasser
b4cf51365d Merge pull request #25136 from Microsoft/useGetObjectFlags
Use `getObjectFlags` as suggested in previous PR.
2018-06-21 14:30:59 -07:00
Daniel Rosenwasser
a5b9a4c5ea Use getObjectFlags as suggested in previous PR. 2018-06-21 13:52:06 -07:00
Daniel Rosenwasser
72068e22af Merge pull request #25115 from Microsoft/matchingTypeRefs
Improved errors using type reference targets
2018-06-21 13:46:21 -07:00
Wenlu Wang
51e7ae0813 provide spelling suggestion for indexed access (#22225)
* provide spelling suggestion for indexed access

* update merge

* accept baseline

* fix suggession return type

* allow string or identifier on getSuggestionForNonexistentProperty

* fix lint
2018-06-21 13:40:41 -07:00
Daniel Rosenwasser
9df95fee79 Expand better error messages to anonymous object types with identical type aliases. 2018-06-21 13:13:26 -07:00
Andy
662ca71efc Add 'withContext' helper in createNodeBuilder (#24994) 2018-06-21 12:17:38 -07:00
Nathan Shively-Sanders
a7af92eb63 check return tag in getTypePredicateOfSignature (#25130) 2018-06-21 11:30:37 -07:00
Andy
2b9166b2f9 Don't recommend to install '@types/foo' if that already exists (#24815)
* Don't recommend to install '@types/foo' if that already exists

* Add different extra diagnostic text if the @types package exists

* Update API (#24966)
2018-06-21 10:19:14 -07:00
Nathan Shively-Sanders
43d0794ba3 Fix crash when binding jsdoc-style inner namepaths (#25106)
* getDeclarationIdentifier handles undefined name

getNameOfDeclaration actually doesn't handle all declarations, only
those that produce names that could be reasonably used as an identifier.
Until now, getDeclarationIdentifier assumed that getNameOfDeclaration
always returned a name. This caused crashes whenever we tried to get the
name of something like a Constructor.

* Add test and baselines

* getNameOfDeclaration can return undefined

This requires all callers to handle it, which turns out now to be too
disruptive.

* Fix lint
2018-06-21 10:01:39 -07:00