10608 Commits

Author SHA1 Message Date
Anders Hejlsberg
9d9dea0e77 Merge branch 'master' into fix41581 2020-12-03 17:27:10 -10:00
Anders Hejlsberg
cd37a327a7
Fix non-homomorphic mapped type constraint issues (#41807)
* Less aggressive wildcard check, 'keyof any' constraint for 'infer T' in mapped type constraint position

* Accept new baselines

* Add regression tests
2020-12-03 16:36:45 -10:00
Armando Aguirre
143d1104ab
Merge pull request #41703 from a-tarasyuk/fix/41653
fix(41653): Enum Keys in Destructure Prevents ES6 Function Convert with --target ES5
2020-12-03 16:10:51 -08:00
Ron Buckton
324f0469c0
Merge pull request #41791 from microsoft/fix40643
Reuse temp variable scope for converted loop body
2020-12-03 13:33:09 -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
Ron Buckton
27dc177f29 Reuse temp variable scope for converted loop body 2020-12-02 18:11:45 -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
Wesley Wigham
9f9eed400c
Read the base construct signature from the static base type, not the instance base (#41767) 2020-12-02 13:30:46 -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
Wesley Wigham
0da5a7e4ba
Add missing BinaryExpression source side cases to isMatchingReference (#41765) 2020-12-01 14:47:14 -08:00
Anders Hejlsberg
4d6947ae14
Check nested conditional types for non-distributiveness in mapped types with 'as' clauses (#41713)
* Check nested conditional types for non-distributiveness

* Rename to maybeNonDistributiveNameType

* Add regression test
2020-12-01 12:07:47 -10:00
Anders Hejlsberg
4782c74b75
Propagate wildcard types in non-homomorphic mapped types (#41622)
* Propagate wildcard types in non-homomorphic mapped types

* Add regression test

* Accept new baselines

* Accept new baselines
2020-12-01 11:57:00 -10:00
Wesley Wigham
2a3f5508ec
addImplementationSuccessElaboration admits declarations with no symbol (#41758) 2020-12-01 12:19:12 -08:00
Toan Nguyen
0c76803854
Fix typos in comments (#41307)
* Fix typo fuction -> function

* Fix typo assignement -> assignment
2020-11-30 15:02:07 -08:00
Nathan Shively-Sanders
06fb724cd1
Improve uncalled function checks (#41599)
Fixes #41586
Fixes #41588

1. For binary expressions, if the immediate parent is an IfStatement,
then check the body of the if statement. I didn't walk upward to find an
IfStatement because in my experimentation I found that binary expression
uncalled-function errors are only issued when the expression is on the left of the
top-most binary expression.

2. For property accesses with interspersed calls, I added a
CallExpression case. In fact, any expression could appear here, but I
only want to fix calls for now since that's all we've observed in
Definitely Typed, and we didn't see anything else in the user tests or RWC
tests. I also didn't examine parameters of the intermediate call
expressions, but I don't think it's needed since the intent is to avoid
false positives.
2020-11-30 14:27:19 -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
Oleksandr T
3a903b8a28 fix(41653): convert arrow function to function expression that used as destructure initializer 2020-11-26 21:19:15 +02:00
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
Oleksandr T
5adb55eb18
feat(41216): show JSDoc for aliases (#41452) 2020-11-24 14:40:51 -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
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
Anders Hejlsberg
bf1ac8ae49 Update fourslash test 2020-11-23 08:35:50 -10: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
Martin Probst
6b04f50394
Do not parse template arguments in JavaScript files. (#36673)
Fixes #36662.
2020-11-19 11:41:35 -08:00
Anders Hejlsberg
d787239ad9 Add tests 2020-11-18 14:57:39 -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
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
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 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
Nathan Shively-Sanders
64be2a8d16
Revert "Revert "feat(40197): handle uncalled function checks in binary expressions (#40260)"" (#41462)
This reverts commit cf3e28ea66bdfb4e438f86bd7d7860b66dae0ed8.
2020-11-09 11:34:41 -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
45b698b3f6
fix(40632): skip emitting abstract members (#40699) 2020-11-04 16:02:17 -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
Oleksandr T
e4c1568c5d
fix(41078): add element access expressions support in convertFunctionToEs6Class (#41089) 2020-11-02 15:49:22 -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