Commit Graph

7996 Commits

Author SHA1 Message Date
Andy
7dc66e916a moduleSpecifiers: specifier from "rootDirs" should be treated as relative (#25369) 2018-07-02 11:14:49 -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
Andy
ded446573a ChangeTracker: Combine deleteDeclaration, deleteNode, and deleteNodeInList (#25276)
* ChangeTracker: Combine deleteDeclaration, deleteNode, and deleteNodeInList

* Change name

* Update API (#24966)
2018-06-29 19:53:32 -07: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
Benjamin Lichtman
f0e5056063 Add test 2018-06-29 11:34:58 -07:00
Wesley Wigham
30db30055f Fix module specifier case handling for declaration emit (#25110) 2018-06-29 11:02:43 -07:00
Mohamed Hegazy
c27dace3df Merge pull request #25182 from Kingwl/fix-missing-enum-member
add quick fix for add missing enum member
2018-06-29 10:19:23 -07:00
Daniel Rosenwasser
d46b54b639 Actually make the test file use '--strict'. 2018-06-28 22:36:59 -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
12a201c29e Added test case. 2018-06-28 15:30:10 -07:00
Wesley Wigham
297f12e92c Add bailout case to sourcemap searching code (#25212)
* Add bailout case to sourcemap searching code

* Also skip sourcemappy comments like sourceURL
2018-06-28 11:40:31 -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
王文璐
d8cdd7552e do not handle enum type member 2018-06-28 09:36:26 +08:00
Andy
c35cb86192 When renaming at a tsx opening/closing tag, just rename the current element (#25273) 2018-06-27 11:01:38 -07:00
Andy
d957b1c8c2 fixUnusedIdentifier: Remove arguments corresponding to unused parameters (#25011)
* fixUnusedIdentifier: Remove arguments corresponding to unused parameters

* Update API (#24966)

* Fix handling of deletions: Make a list of things to delete and don't delete until the end

* Remove dummy test

* Bug fixes

* Update API (#24966)

* Move code to textChanges
2018-06-27 09:26:47 -07:00
王文璐
d6f5fc6518 add Initializer if enum value is another enum 2018-06-27 21:03:50 +08:00
Andy
c8c547a706 Only add completion for a symbol if it is accessible (#25096) 2018-06-26 18:03:07 -07:00
Andy
ab9e913af3 getEditsForFileRename: Test both before and after the rename (#25074) 2018-06-26 16:55:51 -07:00
Mohamed Hegazy
b59824ad9f Merge pull request #25190 from mprobst/fix-generic-type-emit
Fix decorator design:types emit for type variables.
2018-06-26 14:04:37 -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
Wesley Wigham
38dab7417a Fix lint race when not running tests in parallel (#25235) 2018-06-26 12:27:49 -07:00
王文璐
a62a54df57 Merge branch 'master' into fix-missing-enum-member 2018-06-26 10:30:09 +08: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
王文璐
d5268c81e7 add quick fix for add missing enum member 2018-06-26 10:17:22 +08:00
Nathan Shively-Sanders
99ebcd788f Treat link tag as comment (#25206)
* First attempt at parsing. Doesn't work

But my machine is dying, so this is an emergency commit.

* Parsing sort of works

But it's not right yet; the test I added fails. See the TODO I added.

* Parse link tag as comment
2018-06-25 15:27:49 -07:00
Anders Hejlsberg
d869e56d33 Add tests 2018-06-25 10:45:38 -10:00
Andy
0b5b7ef547 Fix removal of default import (#25200) 2018-06-25 12:41:32 -07:00
Andy
6cd27a3217 Support doc comment template at function expression (#25050) 2018-06-25 11:40:45 -07:00
Andy
8923a01481 Fix test failure (#25199) 2018-06-25 11:34:04 -07:00
Andy
9aa60f27eb goToDefinition: Don't add duplicate definitions for PropertyAssignment and ArrowFunction at m: () => {} (#24995)
* goToDefinition: Don't add duplicate definitions for PropertyAssignment and ArrowFunction at `m: () => {}`

* Just use !isCallLikeExpression
2018-06-25 11:33:47 -07: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
Andy
b3a6428186 Fix completions trigger character on JSX opening tag (#25167) 2018-06-25 11:10:38 -07:00
Andy
806a661be3 Add refactor to convert named to default export and back (#24878)
* Add refactor to convert named to default export and back

* Support ambient module

* Handle declaration kinds that can't be default-exported

* Update API (#24966)
2018-06-25 10:34:24 -07:00
Martin Probst
55c3ec3e94 Fix decorator design:types emit for type variables.
Previously, TypeScript would resolve the reified types for the
`design:types` decorator emit in the regular `currentScope`. That scope
does not include class declaration bodies.

However when reifying types, class declarations do introduce a new scope
for any `TypeVariable`s declared on them. Because TS resolved the
EntityName for such types against the parent scope (e.g. the source
file), not the class scope, TypeScript would either fail to resolve the type (giving `TypeReferenceSerializationKind.Unknown`), or
incorrectly resolve to a different, accidentally matching symbol in the outer scope (giving `TypeWithConstructSignatureAndValue`).

This would result in an emit referencing an undeclared symbol, or
mis-referencing the wrong symbol.

    __metadata("design:type", typeof (_a = typeof TypeVariable !== "undefined" && TypeVariable) === "function" && _a || Object)
    __metadata("design:type", TypeVariable)

This change special cases `currentScope` for
`serializeTypeReferenceNode` to use a class scope, if present. This
changes the emit for a `TypeVariable` back to `Object`:

    __metadata("design:type", Object)
2018-06-25 17:24:05 +02:00
Anders Hejlsberg
9cd8eadfd2 Update tests 2018-06-24 14:32:50 -10:00
Wesley Wigham
bd97e12f76 Multifaceted approach to performantly enabling fileExists outside of the synchronize step in the emit host (#25107)
* Multifaceted approach to performantly enabling fileExists outside of the synchronize step in the emit host

* make cache undefinable and handle correctly

* Remove unneeded cast

* Readd assert

* More useful failure messager
2018-06-22 14:05:36 -07:00
Andy
42fc8431f7 getEditsForFileRename: Don't update import with non-relative path if the imported file didn't move (#25159) 2018-06-22 11:21:45 -07:00
Andy
cb9c3e0f6a Don't provide a path completion if a directory name was already typed (#25055) 2018-06-22 11:18:16 -07:00
Anders Hejlsberg
b0d8c6551e Merge branch 'master' into restTuples
# Conflicts:
#	src/compiler/checker.ts
2018-06-22 06:10:50 -10:00
Anders Hejlsberg
c2310009e1 Update tests 2018-06-21 17:02:35 -10:00
Nathan Shively-Sanders
0bb897273f Parse nested prop and param tags the same way (#25139)
That is, only nest them if their name matches the provided parent name.
Otherwise do not nest them.

Note that this commit changes the behaviour of an incorrect typedef that
contains both an `@type` child tag and `@property` child tags.

Previously, the `@type` would be incorrectly nested under a `@property`
tag with type `object`, just like `@property` tags would be. Now, the
`@type` tag causes the entire typedef to ignore the `@property` tags and
treat the typedef as if it were an instance of the
typedef-and-nested-type pattern:

```js
/**
 * @typedef {Object} name
 * @type {{ the, actual, type }}
 */
```
2018-06-21 16:12:55 -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
Andy
e3e4c5dd2e getEditsForFileRename: For directory rename, preserve casing of suffix (#24975) 2018-06-21 11:46:13 -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
Andy
e7b338e943 Don't treat a declaration as a type argument position (#25046) 2018-06-21 10:18:37 -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
Andy
40899eaf5b Error on 'const' in class expression (#25125) 2018-06-21 09:57:52 -07:00