Commit Graph
9624 Commits
Author SHA1 Message Date
Nathan Shively-SandersandGitHub d892fd408f Fix expando handling in getTypeReferenceType (#34712)
* Fix expando handling in getTypeReferenceType

getExpandoSymbol looks for the initialiser of a symbol when it is an
expando value (IIFEs, function exprs, class exprs and empty object
literals) and returns the symbol.

Previously, however, it returned the symbol of the initialiser without
merging with the declaration symbol itself. This missed, in particular,
the prototype assignment in the following pattern:

```js
var x = function x() {
  this.y = 1
}
x.prototype = {
  z() { }
}

/** @type {x} */
var xx;
xx.z // missed!
```

getJSDocValueReference had weird try-again code that relied on calling
getTypeOfSymbol, which *does* correctly merge the symbols. This PR
re-removes that code and instead makes getExpandoSymbol call
mergeJSSymbols itself.

* Remove extra newline
2019-10-24 13:12:44 -07:00
Nathan Shively-SandersandGitHub 969634b97c Restore delayed merge check to getTypeFromJSDocValueReference (#34706)
* Restore delayed merge check to getTypeFromJSDocValueReference

This is needed when a function merges with a prototype assignment. The
resulting *merged* symbol is a constructor function marked with
SymbolFlags.Class. However, the merge doesn't happen until
getTypeOfFuncClassEnumModule is called, which, in the
getTypeReferenceType code path, doesn't happen until
getTypeFromJSDocValueReference. That means the check for
SymbolFlags.Class is missed.

Previously, getTypeFromJSDocValueReference had a weird check
`symbol !== getTypeOfSymbol(symbol).symbol`, which, if true, ran
getTypeReferenceType again on `getTypeOfSymbol(symbol).symbol`. For
JS "aliases", this had the effect of dereferencing the alias, and for
function-prototype merges, this had the effect of ... just trying again
after the merge had happened.

This is a confusing way to run things. getTypeReferenceType should
instead detect a function-prototype merge, cause it to happen, and
*then* run the rest of its code instead of relying on try-again logic at
the very end. However, for the RC, I want to fix this code by restoring
the old check, with an additional check to make sure that #33106 doesn't
break again:

```ts
const valueType = getTypeOfSymbol(symbol)
symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol
```

I'll work on the real fix afterwards and put it into 3.8.

* Add bug number
2019-10-24 09:24:58 -07:00
Wesley WighamandGitHub 07d3a2ec7e Do not consider element accesses which are neither statically bindable nor late bound as special assignments (#34679) 2019-10-23 16:01:25 -07:00
Nathan Shively-SandersandGitHub 8223c07527 getTypeFromJSDocValueReference: handle import types (#34683)
Previously it only handled types whose declaration was from `require`,
but now it handles types whose reference is an import type as well.
2019-10-23 15:53:38 -07:00
Andrew CaseyandGitHub 6f04f526d4 Merge pull request #34659 from amcasey/FARGlobalThis
Don't assume that all symbols have declarations
2019-10-22 16:26:19 -07:00
Andrew Casey 590fd3f2a2 Don't assume that all symbols have declarations
...in Find All References.  For example, global `this` doesn't in
modules.

Part of #34404
2019-10-22 15:00:30 -07:00
Kārlis GaņģisandNathan Shively-Sanders 479d30646f Fix crash in assigning function with this ref to alias (#34650) 2019-10-22 14:33:45 -07:00
Nathan Shively-SandersandGitHub 1cbbe288ac Treat any mix of element/prop access as declaration in JS (#34649)
Fixes #34642 but, notably, doesn't actually make the assignment into a
working declaration. It just fixes the crash.
2019-10-22 11:28:28 -07:00
Andrew CaseyandGitHub 159b6262ea Merge pull request #34631 from amcasey/ComputedPropName
Handle undefined from getPropertyNameForPropertyNameNode
2019-10-22 10:17:05 -07:00
Andrew Casey 7862e58354 Handle undefined from getPropertyNameForPropertyNameNode
...which can be returned when the property name is computed.

Part of #34404
2019-10-21 17:41:06 -07:00
Anders HejlsbergandGitHub f84fd300b8 Merge pull request #34607 from microsoft/fix33490
Fix type inference regression
2019-10-21 12:50:38 -07:00
Anders HejlsbergandGitHub ff6626f869 Merge pull request #34597 from microsoft/optionalChainControlFlow
More optional chaining control flow analysis
2019-10-21 12:36:07 -07:00
Andrew BranchandGitHub 1d3ecc0610 Ensure export= symbol from JavaScript always has a valueDeclaration (#34553) 2019-10-21 09:56:02 -07:00
Anders Hejlsberg 56520da6f0 Add regression tests 2019-10-20 18:00:08 -07:00
Anders Hejlsberg d218a31a7d Add tests 2019-10-19 10:51:59 -07:00
Daniel RosenwasserandGitHub b845800bdf Add option to configure automatic optional chain completions (#34552)
Add option to configure automatic optional chain completions
2019-10-18 17:35:59 -07:00
Andrew BranchandGitHub 91196fc53f Ensure functions that have prototype properties assigned by Object.defineProperty get marked as classes (#34577)
* Ensure functions that have prototype properties assigned by Object.defineProperty get marked as classes

* Revert unneeded change
2019-10-18 16:31:43 -07:00
Nathan Shively-SandersandGitHub cdf1ab2dec Bind @class in the right place -- bindWorker not bindChildrenWorker (#34575)
Also add an assert to make future mismatches fail in an obvious place
instead of in a while loop.
2019-10-18 14:13:14 -07:00
Nathan Shively-SandersandGitHub fa1884ed1b Fix crash in expando assignment to alias (#34566)
* Fix crash in expando assignment to alias

This PR disallows expando assignments

Fixes #34493, but disallows the prototype assignment nonetheless.

* Revert mistaken changes
2019-10-18 13:31:44 -07:00
Nathan Shively-SandersandGitHub 1d5add528d Emit computed property temps even w/o init w/useDefineForClassFields (#34406)
Fixes #33857
2019-10-18 13:23:38 -07:00
Nathan Shively-SandersandGitHub 82f927f8dd Fix stack overflow in circular assignment declaration (#34543)
* Fix stack overflow in circular assignment declaration

It also needs to have multiple assignments so that it has a ValueModule
flag.

Fixes #33006

* remove errant comment

* Remove other possible circularity

* Restore fallback with additional condition
2019-10-18 09:01:21 -07:00
Tim SuchanekandAndrew Branch 9ff9c41a9a Add completion test for partial generic object (#34559) 2019-10-18 08:59:49 -07:00
Daniel Rosenwasser d2fab65df6 Added test. 2019-10-17 17:04:45 -07:00
Andrew BranchandGitHub 454a3a0b0f Fix auto-imports from auto type acquisition definitions (#33766)
* Fix auto-imports from ATA typings

* Compare canonical filenames in isImportablePath
2019-10-17 13:59:09 -07:00
Nathan Shively-SandersandGitHub f5dbcb78af Resolve more jsdoc value references as types (#34515)
* Resolve more jsdoc value references as types

* add test
2019-10-17 11:21:34 -07:00
Andrew BranchandGitHub f41b7b59ce Fix quick info for methods whose contextual type is a mapped type property (#33930) 2019-10-17 10:54:01 -07:00
Andrew BranchandGitHub a95a25b9a7 Fix completions of optional properties in generic positions (#33937)
* fixes #30507

* Add test case for generic Partial type

* Fixes #28470

* Simplify contextFlags binary check

* Add string literal completion test

* Fix ContextFlags typings

* Speed up inference expression for completion

* Fix baseline merge

* Make contextFlags internal

* Reapply readonly array changes

* accept baselines

* Fix generic completion tests

* Re-merge ContextFlags

* Don’t change type during inference

* Fix typos and superfluous undefined arguments

* Add test for completions in unconstrained generic object literal
2019-10-17 10:45:40 -07:00
Klaus MeinhardtandRyan Cavanaugh 45d0ef9441 factory: parenthesize for-of expression when necessary (#34229)
Fixes: #33856
2019-10-17 10:17:33 -07:00
OrtaandGitHub 5d20c573a6 Merge pull request #34524 from orta/fix_32675
Does not add a duplicate completion when offering an export which was re-declared as a global
2019-10-17 13:08:32 -04:00
Orta Therox 85010fa6fe Make sure that global module re-exports are short-cutted to be added to completions 2019-10-17 12:33:01 -04:00
Nathan Shively-SandersandGitHub f3a234caac Dedupe inherited jsdoc comments (#34522)
JSDoc on own properties was already deduped, but inherited jsdoc was
incorrectly not deduped.

Fixes #32708
2019-10-16 15:56:01 -07:00
Orta Therox c40ddb183e Does not add a duplicate completion when offering an export which was re-declared as a global - fixes #32675 2019-10-16 17:02:35 -04:00
Klaus MeinhardtandRyan Cavanaugh 178417f431 factory: correctly parenthesize conditional head (#34227)
Fixes: #34109
2019-10-16 10:41:52 -07:00
Nathan Shively-SandersandGitHub 29f9493d87 Fix crash when exporting+aliasing globalThis inside declare global (#34408)
* global module:Fix crash when exporting+aliasing globalThis

* Fix another globalThis crash

find-all-refs assumed that an export inside a `declare x` was always an
ambient module, but it is not -- `declare global` does not allow
`export`, so find-all-refs shouldn't return any refs for this error case.
2019-10-15 14:05:39 -07:00
Anders HejlsbergandGitHub a685ac426c Merge pull request #34212 from microsoft/fix34021
Fix control flow analysis for --noFallthroughCasesInSwitch
2019-10-15 12:10:53 -07:00
Andrew BranchandGitHub e146f0d13d Allow inferFromUsage to do auto-imports (#33915)
* Add test

* Auto-import instead of using ImportTypeNodes

* Write more tests and fix namespace case

* Remove unused enum memmber

* Update API baselines

* Lint

* Style nits and util consolidation
2019-10-14 10:33:00 -07:00
Anders Hejlsberg cc817bc63e Add tests 2019-10-13 09:45:56 -07:00
Sheetal NandiandGitHub 57d7edb7bd Merge pull request #33883 from microsoft/revert-32887-incrementalNoEmit
Revert "Disallow incremental with noEmit"
2019-10-10 13:08:35 -07:00
Wesley WighamandGitHub 114329ade8 Handle when import alias has to parent (therefore is synthetic module symbol) (#33813) 2019-10-10 04:29:33 -07:00
Andrew Casey 87c905f423 Handle string literals in merge conflict regions
Check for undefined, like the other code paths in the same function.
2019-10-09 14:46:19 -07:00
Anders HejlsbergandGitHub 6104f746ad Merge pull request #33831 from microsoft/falseAssertions
Code following truthiness assertion with false argument is unreachable
2019-10-09 13:23:05 -07:00
Klaus MeinhardtandRyan Cavanaugh e48cd3a101 Fix noImplicitAny check on ambient private getters (#33896) 2019-10-09 10:05:26 -07:00
Sheetal NandiandGitHub 8032984de2 Revert "Disallow incremental with noEmit" 2019-10-08 13:41:40 -07:00
Wenlu WangandWesley Wigham 3d8252c70e avoid space before dot question (#33840) 2019-10-07 17:11:54 -07:00
Anders Hejlsberg e0bd810176 Update tests 2019-10-05 18:58:51 -07:00
Anders Hejlsberg eeaa752833 Add tests 2019-10-05 18:33:00 -07:00
Anders HejlsbergandGitHub afe6f4c95c Merge pull request #33821 from microsoft/fix33806
Reflect control flow effects of optional chains in equality checks
2019-10-05 17:48:53 -07:00
Anders Hejlsberg f88518187b Add tests 2019-10-05 13:08:31 -07:00
Anders Hejlsberg 42500d0606 Add tests 2019-10-04 16:12:44 -07:00
Anders Hejlsberg 2447bd775f Update tests 2019-10-04 16:01:09 -07:00