Commit Graph

5891 Commits

Author SHA1 Message Date
Oleksandr T
2946318df0 fix(41526): add JSDoc type annotations before parameters (#41561) 2020-12-04 16:52:12 -08:00
kingwl
870f5b613a Merge branch 'master' into noPropertyAccessFromIndexSignature_fix 2020-12-04 12:47:38 +08:00
Andrew Branch
69bc3f3b0c Allow type-only imports on ImportEqualsDeclarations (#41573)
* Allow type-only ImportEqualsDeclarations

* Suppress CJS-in-ESM error when type-only

* Add grammar error on import type in import alias

* Update API baselines

* Fix importsNotUsedAsValues with ImportEqualsDeclarations

* Make bad error talk words more good for Daniel. Fixes #41603

* One more error message baseline update

* Update transformer and emitter
2020-12-03 13:27:15 -08:00
kingwl
501b69c61f respect quote Preference 2020-12-03 12:00:30 +08:00
Jack Works
0b6c9254a8 Fix import tracker for dynamic import (#41473)
* chore: migrate findAllRefs_importType_js to baseline

* fix: reference for dynamic import

* fix: find all reference for typeof import()

* fix: test

* refactor: addIndirectUser

* refactor: isExported

* refactor: isExported

* resolve review
2020-12-02 14:46:20 -08:00
Ryan Cavanaugh
9a957e7b9c Remove incorrect assert that triggers crash on completions of globalThis (#40278)
Fixes #39338
2020-12-02 11:47:32 -08:00
Armando Aguirre
fd50f1e3c9 Merge pull request #41543 from a-tarasyuk/fix/41534
fix(41534): Maximum call stack error while computing document symbol file
2020-12-01 18:03:11 -08:00
Wenlu Wang
55810095f4 Allow qualified name for convert namespace import (#41592) 2020-12-01 15:23:57 -08:00
inokawa
d57954345b Fix typos (#41723) 2020-12-01 13:46:41 -08:00
Oleksandr T
23b3eb685f fix(41621): fixUnusedIdentifier - allow deleting prefix/postfix unary operators (#41624) 2020-11-30 13:58:47 -08:00
Oleksandr T
1bd8e388ae fix(41688): completions with infer keyword (#41704) 2020-11-30 11:56:12 -08:00
Song Gao
d5779c75d3 replace whole path if directory separator appears for import completion. (#41412)
* replace whole path if directory separator appears.

* Fix.

* revert change.

* Fix test case.

* add test.

* fix as suggested.

* revert useless change

* adapt to code change.

* fix baseline for test file.
2020-11-25 09:37:08 -08:00
Andrew Branch
3fa30f4826 Remove obsolete go-to-definition code after CommonJS alias changes (#41522)
* Remove obsolete code

* Revert package-lock change
2020-11-25 09:01:56 -08:00
Oleksandr T
5adb55eb18 feat(41216): show JSDoc for aliases (#41452) 2020-11-24 14:40:51 -08:00
Oleksandr T
03877260f8 fix(41194): ignore jsxFrag identifier in import declarations (#41441) 2020-11-24 14:29:47 -08:00
Jean Pierre
71559a5c0c Fix show deprecated suggestion for alias (#41128)
* Fix show deprecated suggestion for alias

* Fix failing tests

* Avoid duplicated kind modifiers
2020-11-23 15:50:12 -08:00
Nathan Shively-Sanders
d057f7a992 Remove-unused-identifiers codefix skips assigned identifiers (#41168)
* Remove-all-unused-identifiers skips assigned identifiers

Previously, fixUnusedIdentifier worked the same in fix-all mode as for a
single fix: identifiers with assignments would be deleted:

```ts
function f(a) { }
f(1)
```

becomes

```ts
function f() { }
f()
```

But any kind of argument will be deleted, even one with side effects.
For a single codefix invocation, this is probably OK.
But for fix-all, this could lead to multiple changes
spread throughout a large file.

Now fix-all will only delete parameters and variable declarations with
no assignments:

```ts
function f(a) { }
function g(a) { }
f(1)
g
let x = 1
let y
```

becomes

```
function f(a) { }
function g() { }
f(1)
g
let x = 1
```

* Don't remove assigned parameters for single codefix either

* add optional parameter test case

* Skip initialised params and binding elements

Based on PR feedback from @amcasey

* fixAll removes unused binding patterns completely

* Fixes from comments

Thanks @amcasey for the thorough review

* fix trailing space lint

* correctly remove-all array binding
2020-11-21 09:57:17 -08:00
Oleksandr T
9bcbca4e6c fix(41534): fix children circular references 2020-11-20 22:41:12 +02:00
Nathan Shively-Sanders
d3abd35428 Unused Identifier codefix better understands constructors and methods (#41555)
* Unuse Identifier codefix understands constructors

Previously, it did not look for `super()` and `new this()` calls when
determining whether a constructor parameter could be deleted.

* better names, fix off-by-1 bug

* Codefix understands super methods now too

This unifies the code, changing it considerably.
2020-11-18 11:19:43 -08:00
Andrew Casey
79ffd03f8b Add tracing support to tsserver (#41374)
* Add tracing support to tsserver

Read the `TSS_TRACE` environment variable to determine which directory
trace files should be written to.

Notable changes from tsc tracing:
1) Drop all tracepoints that depend on type IDs
2) Write output to trace.PID.json
3) New, server-specific events (request/response, cancellation, etc)

* Drop try-finally blocks that aren't strictly necessary

* Fix lint error

* Trace background work (for diagnostics)

* Move try-finally blocks into session so tsc doesn't use them

* Add missing try-finally

* Use consistent capitalization

* Inline canPop call where underlying variable is available

* Clarify comments

* Include PID in build-mode file names

* Introduce more efficient popAll function

* Trace throwIfCancellationRequested rather than isCancellationRequested

* Remove unnecessary try-finally blocks

* Add a command-line argument for consistency with logging

* Fix rebase issues

* Address PR feedback

* Rename completionEvents to eventStack

* Drop assertStackEmpty as hard-to-maintain and marginally valuable

* Rename stepCancellation to stepCanceledEarly

* Rename stepEarlyCancellation to stepCanceled and use flag instead

* Check correct variable on exit
2020-11-16 09:26:28 -08:00
Andrew Branch
266d8de64a Proposal: importModuleSpecifierPreference: project-relative (#40637)
* Add new importModuleSpecifierPreference value

* Add second test

* Update API baselines

* Clean up and add some comments

* Rename option value
2020-11-11 11:48:32 -08:00
Wenlu Wang
ca7510ea05 String literal rename support (#39298)
* add basicly support for rename string literal type

* fix merge conflict

* fix some behavior

* Update package-lock.json

* Update package-lock.json

* do not break old behavior if not type checked

* fix cr issue

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2020-11-06 09:58:34 -08:00
Oleksandr T
899e2d00e9 fix(40469): suggest QF convert 'Convert to named function' to function expressions (#40476) 2020-11-05 10:25:24 -08:00
Oleksandr T
98aaeb7f48 fix(40610): handle template string concatenation (#40653) 2020-11-05 10:09:21 -08:00
Oleksandr T
09048656d2 feat(40750): add refactoring to infer a return type annotation to a function (#41052) 2020-11-03 16:22:13 -08:00
Oleksandr T
ad70313141 fix(39858): generate valid async/await code for imported functions (#40154) 2020-11-02 16:12:08 -08:00
Oleksandr T
5d81b17d02 fix(40042): add modifiers in correct position for decorated methods (#40050) 2020-11-02 15:52:57 -08:00
Oleksandr T
e4c1568c5d fix(41078): add element access expressions support in convertFunctionToEs6Class (#41089) 2020-11-02 15:49:22 -08:00
Oleksandr T
3f92a6498f fix(40257): fix type parameters range (#40265) 2020-11-02 15:20:13 -08:00
Wenlu Wang
ce8d702586 Add support for pedantic property access (#40171)
* Add support for pedantic property access

* accept baseline

* Update diag message

* Avoid pedantic

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-11-02 15:19:00 -08:00
Nathan Shively-Sanders
ae81add083 Separate delete-all-imports from other delete-all (#41105)
This fixes the first part of #32196
2020-11-02 14:18:50 -08:00
Oleksandr T
eb6ddf6b29 fix(40671): suggest ConvertStringToTemplateLiteral refactoring for string with property/element acceses elements (#40942) 2020-10-29 15:23:11 -07:00
Michael
71cd5d522d Fix two issues with ConvertToTypeOnlyExport codefix (#40490)
* Modify test case to reproduce error

* Fix TypeOnlyExport codefix to work with 3 or more type exports in the same declaration

The check to ensure that a fixed export declaration wasn't fixed again
was reversed. This only surfaced when 3 or more type exports existed in
the same declaration.

* Add failing test cases for comments being duplicated

* Fix convertToTypeOnlyExport codefix from duplicating leading comments

* Simplify convertToTypeOnlyExport when change is just inserting `type` keyword

Co-authored-by: Andrew Branch <andrew@wheream.io>
2020-10-27 15:08:20 -07:00
Oleksandr T
9ed608b439 fix(41244): ignore synthesized imports (#41267) 2020-10-27 13:22:02 -07:00
Oleksandr T
3754bb4455 fix(40994): change type for optional properties (#41011) 2020-10-27 10:05:40 -07:00
Alex T
417b8a9481 fix(29881): infer quote preference for property access conversion in completions (#41041) 2020-10-13 10:06:27 -07:00
Andrew Branch
83d02a5f05 Fix auto imports for export default edge cases (#41068) 2020-10-12 15:42:58 -07:00
Andrew Branch
4766a2e5a3 Fix overlapping changes when un-qualifying import use site within transformed export (#40987)
* Fix overlapping changes when un-qualifying import use site within transformed export

* Break long line
2020-10-09 13:24:18 -07:00
Alex T
23c5f9260c fix(3758): show completion for object literals in an assignment pattern (#40976) 2020-10-08 12:27:53 -07:00
Wesley Wigham
4dc7e59248 Merge pull request #40953 from weswigham/improve-completions-large-literal-perf
Improve the performance of requesting completions within a massive array literal
2020-10-07 12:44:20 -07:00
Wesley Wigham
d6af322287 Add comment 2020-10-07 12:27:43 -07:00
Wesley Wigham
3df8bc6a03 Rephrase to use binarySearchKey 2020-10-06 12:29:58 -07:00
Alex T
5c55fc0a21 fix(40817): suggest import for default exported alias (#40845) 2020-10-06 09:52:35 -07:00
Alex T
0c7d45a9ed fix: change deprecated FunctionLike type to SignatureDeclaration (#40795) 2020-10-06 07:51:01 -07:00
Alex T
1e49ad8370 fix(40685): fix generating docs for arrow functions (#40728) 2020-10-06 07:50:08 -07:00
Wesley Wigham
da57f9876e Improve the performance of requesting completions within a massive array literal 2020-10-05 14:42:10 -07:00
Andrew Branch
6ee4a6b7f0 Skip past module.exports = { Foo } in go-to-defintion on 'Foo' (#40835)
* Add test

* Skip shorthand property assignments of module.exports in go-to-definition

* Skip past shorthand property assignments in module.exports in go-to-definition

* Revert WIP change

* Fix comment typo

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-10-05 11:47:19 -07:00
Andrew Branch
736363b427 Use other files when necessary to determine import style in JS (#40879)
* Use other files when necessary to determine import style in JS

* Fix existing tests
2020-10-05 11:39:20 -07:00
Andrew Branch
a301001420 Use correct program when checking for reexports from AutoImportProviderProject (#40843) 2020-09-30 09:32:19 -07:00
Nathan Shively-Sanders
f615e229d3 Fix default property assigned prototype (#40836)
* Fix default-property-assignment decls+prototype property decls

The check in getAssignedClassSymbol forgot to allow for default-property
assignment declarations, in part because it wasn't using a utility
function to do so.

* small cleanup

* make allowDeclaration parameter required
2020-09-30 08:36:52 -07:00