Commit Graph

15402 Commits

Author SHA1 Message Date
Anders Hejlsberg
411c6d04c6 Fix getTypeFacts for pattern template literal types (#41693)
* Normalize `${string}` to just string, fix getTypeFacts

* Add tests

* Accept new baselines
2020-11-26 06:55:01 -10:00
Anders Hejlsberg
ec1490fb44 Properly cache types for shared control flow nodes (#41665)
* Properly cache shared flow node types

* Add test
2020-11-25 14:51:38 -10: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 Casey
a6ebf5d79a Trace checkDeferredNode to cover JSX elements (#41572) 2020-11-24 14:33:15 -08:00
Andrew Casey
4c8418ee19 Use stricter types for tracing event arguments (#41217)
* Use stricter types for tracing event arguments

In local development, I've routinely passed the wrong local and ended up
having JSON.stringify throw.

* Make the type recursive

Courtesy of @rbuckton

* Fix lint error
2020-11-24 14:33:00 -08:00
Oleksandr T
03877260f8 fix(41194): ignore jsxFrag identifier in import declarations (#41441) 2020-11-24 14:29:47 -08:00
Guerric Phalippou
d338c20c15 Add a comment to clarify the #private field (#41547)
* add a comment to clarify the #private field

* small fix
2020-11-23 22:34:27 -08:00
Oleksandr T
d163ab67c8 fix(41240): allow emitting numeric with underscored separators as-is in esnext target (#41435) 2020-11-23 17:01:42 -08:00
Andrew Casey
669305b914 Pass throwIfNoEntry to fs.statSync (#41604)
Future versions of node will be able to return undefined, rather than
allocating and throwing an exception, when a file is not found.

See https://github.com/nodejs/node/pull/33716
2020-11-23 12:43:00 -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
Martin Probst
6b04f50394 Do not parse template arguments in JavaScript files. (#36673)
Fixes #36662.
2020-11-19 11:41:35 -08:00
Oleksandr T
9bbbe5c0c7 fix(41227): change message about incorrect property access with possible replacement with static access (#41275) 2020-11-18 12:50:32 -08:00
Mateusz Burzyński
09eb3d3b9c Fix/jsx global preferred over config implicit (#41476)
* Add actual baselines for a problem with global namespace being preferred over config & pragma implicit ones

* Fixed an issue with global React namespace being preferred over config & pragma implicit ones

* Do not try to mark JSX classic runtime symbols as used when automatic runtime is used
2020-11-17 17:52:32 -08:00
Oleksandr T
6369d89711 fix(41492): make more friendly handling the missing call function in binary expressions (#41502) 2020-11-17 09:42:27 -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
Ron Buckton
54e54f4f19 Fix definition of ts.Iterator 2020-11-11 18:42:12 -08:00
Andrew Casey
f79a78cd54 Merge pull request #41498 from amcasey/RemoveBeginEnd
Fold tracing.begin and end into push and pop
2020-11-11 15:23:11 -08:00
Andrew Casey
e8996a34a9 Remove redundant type annotation 2020-11-11 13:56:27 -08:00
Wesley Wigham
44595042b2 Comment position feedback 2020-11-11 13:02:09 -08:00
Wesley Wigham
2c7c62d7fa Merge branch 'master' into fix-incremental-jsx-crash 2020-11-11 13:00:47 -08:00
Andrew Casey
116000e548 Fold tracing.begin and end into push and pop
Storing the arguments on the stack will make it possible to forego
try-finally blocks when we start tracing in server scenarios, which have
to handle cancellation.
2020-11-11 12:58:00 -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
Nathan Shively-Sanders
9fb6acf1e1 Add missed resolveSymbol in commonjs import resolution (#41479)
Fixes resolution of export aliases in the postfix-property-access case
of commonjs require:

```js
const { x } = require('./foo').nested
x
```

This program would previously fail if `x` was an export alias.

Fixes #41422
2020-11-10 11:28:49 -08:00
Wesley Wigham
dc7d997e4a Fix crash on attempting to suggest a ts import for a synthetic js resolution 2020-11-09 14:05:17 -08:00
Nathan Shively-Sanders
64be2a8d16 Revert "Revert "feat(40197): handle uncalled function checks in binary expressions (#40260)"" (#41462)
This reverts commit cf3e28ea66.
2020-11-09 11:34:41 -08:00
Oleksandr T
45b698b3f6 fix(40632): skip emitting abstract members (#40699) 2020-11-04 16:02:17 -08:00
Sheetal Nandi
76cf8fd78b Add way to exclude files and directories to watch (#39243)
* Parse excludeDirectories and excludeFiles

* Use watch factory in typings installer

* Some refactoring for watchFactory

* Create Noop watcher if file or directory being watched is excluded

* Baselines without using exclude watch options

* Baselines including exclude option

* Handle exclude options in the system watches

* Add test without exclude option for recursive directory watching

* Test baselines with exclude option

* Always set sysLog

* Test for exclude option in server

* Add exclude options in the config file and fix the test

* Fix host configuration for server

* Handle host configuration for watch options

* Fix sysLog time log so baselines can be clean

* Handle reloadProjects to reload the project from scratch

* Ensure that file updates are reflected

* Feedback

* Feedback
2020-11-04 13:30:06 -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
Sheetal Nandi
9c60d5a4d3 Dont look for properties of Object and Function type when looking to resolve named import from module with export= (#37964)
* Add tests

* Dont look at object or function type when looking for members of `export=` type to be resolved by named imports
Fixes #37165

* Create separate cache when skipping function and object property augmentation

* Lookup in both cache if not skipObjectFunctionPropertyAugment
2020-11-03 12:22:30 -08:00
Daniel Rosenwasser
4d19d98ca1 Bump 4.2 (#41377)
* Bump version to 4.2.

* Accepted baselines.
2020-11-02 23:02:03 -08:00
Thomas Williamson
8ed251d0c7 Support xml namespace prefix for JSX elements and attributes (#37421)
* Support xml namespace prefix for JSX elements and attributes

Just as with the `-` character, `:` is now also treated specially in JSX
element and attribute names, but is only allowed a single time, and not
at the beginning or end of the name, as is specified in the JSX spec.
All tests in jsxInvalidEsprimaTestSuite still fail, but for slightly
different reasons now. Two lines in jsxEsprimaFbTestSuite were
uncommented as they included elements with namespaces, and they now pass
without error.

* Add case for colons at ends of identifier

* Add case for jsx namepsace intrinsics

* Add cases with upcase idents for jsx namespaces

* Add case for jsx namespaces with react option

* Always consider jsx names with colon to be intrinsics

* Adjust comment about chars valid in jsx names but not js idents

* Fix minor typo in namespace prefix test case variable name

* Remove misleading comments on isUnhyphenatedJsxName
2020-11-02 15:34:36 -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
Oleksandr T
056d01afda fix(38283): fix incorrect parsing of static modifier (#41127) 2020-11-02 14:45:26 -08:00
okmttdhr
7db5f68144 Add index signature for anonymous object literal type (#37903)
* Use ts.map for stylistic consistency

* Show error only if noImplicitAny is set

* Accept baseline for noImplicitAnyIndexing

* Fix lint error

* Add test cases for indexedAccessWithFreshObjectLiteral
2020-11-02 14:35:56 -08:00
Oleksandr T
f646ec87fc fix(40901): skip checking custom arguments name in a constructor (#40912) 2020-11-02 14:35:07 -08:00
Daniel Rosenwasser
373b352333 Rename 'compat' to 'deprecatedCompat'. (#41000) 2020-11-02 14:25:12 -08:00
Oleksandr T
075477f9cf fix(35779): emit comments after trailing comma (#37887) 2020-11-02 14:24:55 -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
Wesley Wigham
816af71d58 Fix incremental emit issue where dependency relations implied by synthesized imports would not be detected (#41346)
* Fix incremental emit issue where dependency relations implies by synthesized imports would not be detected

* Update src/compiler/program.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-11-01 16:05:49 -08:00
Wesley Wigham
479105090d Merge pull request #41330 from weswigham/jsx-import-source-as-auto-import
Auto-include types for the jsx import source in the new jsx transforms
2020-10-30 16:51:04 -07:00
Wesley Wigham
1e1ae3034b Update src/compiler/program.ts
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2020-10-30 16:21:36 -07:00
Wesley Wigham
fe94a2180c Use same metho as importHelpers to add synthetic import 2020-10-30 16:16:23 -07:00
Wesley Wigham
8493ee8824 Add mroe incremental-affecting affixes to compiler options, add incremental test for changing jsxImportSource 2020-10-30 16:01:27 -07:00
Wesley Wigham
fe3b3436e6 Add affectsModuleResolution: true ot jsx and jsxImportSource options 2020-10-30 15:38:20 -07:00
Wesley Wigham
e044b56d7f Merge pull request #40985 from weswigham/static-decl-ref
Adjust typeof import name lookup to better match type query lookup
2020-10-30 11:13:23 -07:00
Ron Buckton
f944afd053 Fix double alias of complex export/import/default/namespace combination 2020-10-29 18:42:36 -07:00
Ron Buckton
bcbe1d7638 Merge pull request #41094 from microsoft/destructuringEvaluationOrder
Fix destructuring evaluation order for initializers
2020-10-29 17:12:18 -07:00
Wesley Wigham
6714998e01 Auto-include types for the jsx import source in the new jsx transforms 2020-10-29 14:17:24 -07:00
Ron Buckton
2b7e790732 Update control flow for nested binary exprs 2020-10-29 13:32:32 -07:00