Commit Graph

3458 Commits

Author SHA1 Message Date
Daniel Rosenwasser 9edf9ecc4b Cherry-pick PR #38395 into release-3.9 (#38402)
Component commits:
6fe4be21e4 Exclude arrays and tuples from full intersection property check

9019e399e5 Add regression test

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
2020-05-07 23:56:33 -07:00
TypeScript Bot d906a471dd Cherry-pick PR #38398 into release-3.9 (#38400)
Component commits:
99c5c096c5 Properly finalize evolving array type in getTypeAtFlowCall

b355cd4da4 Add regression test

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
2020-05-07 23:50:20 -07:00
Daniel Rosenwasser b7d34594ba Properly handle private/protected members in unions of object types (#38277) (#38334)
* Property handle private/protected properties in unions of object types

* Add regression test

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
2020-05-07 13:18:27 -07:00
Anders Hejlsberg 9d6f126c78 Cherry-pick PR #38395 into release-3.9
Component commits:
6fe4be21e4 Exclude arrays and tuples from full intersection property check

9019e399e5 Add regression test
2020-05-07 20:15:20 +00:00
TypeScript Bot 90570dfe09 Cherry-pick PR #38278 into release-3.9 (#38330)
Component commits:
d905cede25 Add missing getApparentType call

c635e43ccc Add regression tests

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
2020-05-04 17:12:58 -07:00
TypeScript Bot 391a1596be Cherry-pick PR #38272 into release-3.9 (#38274)
Component commits:
d6477f9167 Fix crash on duplicate default exports

Co-authored-by: Andrew Branch <andrew@wheream.io>
2020-04-30 13:46:59 -07:00
TypeScript Bot f2c93987c2 🤖 Pick PR #38101 (Skip comparing optional property fl...) into release-3.9 (#38199)
* Cherry-pick PR #38101 into release-3.9

Component commits:
f0aeef14bf Skip comparing optional property flag when comparing against discriminant properties

* Update LKG

Co-authored-by: Wesley Wigham <t-weswig@microsoft.com>
Co-authored-by: typescript-bot <typescript@microsoft.com>
2020-04-26 15:30:00 -07:00
Daniel Rosenwasser 1b8c68d746 Revert "Add check for delete expression must be optional (#37921)" (#38154)
This reverts commit 39beb1d011.
2020-04-24 16:05:18 -07:00
Daniel Rosenwasser d28e38f573 Revert "make splice deleteCount required in es5.d.ts (#32643)" (#38169)
This reverts commit ddcf139668.
2020-04-24 14:30:28 -07:00
Andrew Branch ce95d9ca6b Fix values and types merging in JS module exports (#37896)
* Fix values and types merging in JS module exports

* Fix everything

* Share `setValueDeclaration` between binder (local merge) and checker (cross-file merge)

* Revert accidental changes to baselines

* Update baseline from master merge
2020-04-24 13:49:48 -07:00
Wesley Wigham 1785d6c707 Special-case export assigned namespaces in getSpecifierForModuleSymbol so they behave like their containing module symbol (#38151) 2020-04-24 13:10:34 -07:00
Andrew Branch fe140acc09 Fix truthiness call check for this-property access (#38163) 2020-04-24 13:02:17 -07:00
Nathan Shively-Sanders 032aa90289 Filter undefined from binding elements with initialisers without undefined in the type (#38122)
* Filter undefined from binding elts w/o undefined-containing inits

* use getTypeOfInitializer instead

* improve comment based on Wesleys suggestion
2020-04-22 15:45:15 -07:00
Nathan Shively-Sanders f248567dab Filter undefined only in binding patterns in params (#38116)
initialiser. But this is only correct when the initialiser is for a
parameter. For example:

```ts
declare let x: { s: string } | undefined;
const { s } = x;
```

This PR removes undefined from the type of a binding pattern only when
the binding pattern's parent is a parameter. This fixes the regression
from 3.8. However, it's still not the ideal fix; we should be able to
use control flow to solve this problem. Consider:

```ts
const { s }: { s: string } | undefined = { s: 'hi' }
declare function f({ s }: { s: string } | undefined = { s: 'hi' }): void
```

Neither line should have an error, but the first does in 3.8 and after
this change.
2020-04-22 09:56:32 -07:00
Wenlu Wang 39beb1d011 Add check for delete expression must be optional (#37921)
* Add check for delete expression must be optional

* Add more tests
2020-04-22 03:12:01 -07:00
Wesley Wigham a72e49e875 Delay pulling on signature contextual type until absolutely needed (#37851) 2020-04-21 13:29:45 -07:00
Sheetal Nandi e7774c6144 Handle non literal computed name when trying to get the name for object literal property name in json object (#37988)
Fixes #37984
2020-04-20 12:58:38 -07:00
Anders Hejlsberg 5d78cbdbbd Propagate nonInferrableType in &&, || and ?? operators (#38035)
* Propagate nonInferrableType in &&, || and ?? operators

* Add regression test

* Simpler solution: getTypeFacts(neverType) should return TypeFacts.None
2020-04-20 11:04:24 -07:00
Wesley Wigham deb5bac520 Use string representation for negative numeric property names (#37936) 2020-04-15 21:11:05 -07:00
Wesley Wigham cdc384006c Fix crash on declaration emit for globalThis (#37992) 2020-04-15 13:37:51 -07:00
Anders Hejlsberg 92cd3ae299 No iteration type errors during CFA (#37965)
* No iteration type errors during CFA

* Add regression test
2020-04-15 10:34:07 -07:00
Ashley Claymore 4538640d8a Added error when Enum member initaliser references itself (#34655)
Fixes #34606
2020-04-14 15:20:19 -04:00
Wesley Wigham edd4e0a42b Add fastpath to isRelatedTo for type references (#37481)
* Add fastpath to isRelatedTo for type references

* Do not check intersections or unions to ignore propegating reference flags, properly set comparing jsx flag

* Re-remove unneeded check

* Just check for TypeFlags.Object

* Remove else clause
2020-04-13 15:54:37 -07:00
Wesley Wigham 141ee01c8c Retain imports in declaration emit if they augment an export of the importing file (#37820)
* Retain imports in declaration emit if they augment an export of the importing file

* (sp)

* Check that a merge occurs, just because
2020-04-13 12:31:14 -07:00
Alexander T 795a5c83fe fix(37150): ignore private fields in string index type checking (#37183) 2020-04-10 12:53:53 -04:00
Andrew Branch 95cc1c279e Fix crash from missing valueDeclaration on intersection property (#37696)
* Add crashing test

* Fix missing valueDeclaration on intersection symbol property

* Remove assertion from serializeAsClass
2020-04-09 14:00:21 -07:00
Wesley Wigham 3d3854c93d Set contextual type on elaborated error node rather than passing it, so its discriminated (#37828) 2020-04-09 02:55:39 -07:00
Eli Barzilay e4babd40e0 Skip isBlockScopedNameDeclaredBeforeUse error in interface or type declarations
Fixes #35947.
2020-04-07 16:12:18 -04:00
Andrew Branch 3e86f15f51 Disambiguate types with same name from different namespaces in mapToTypeNodes (#37543)
* Disambiguate types with same name from different namespaces in mapToTypeNodes

* Update baseline with additional example

* Fix typo
2020-04-07 10:55:56 -07:00
Anders Hejlsberg a2609b1f1b Extra check in assignment of intersections with generic constituents (#37537)
* Consolidated extra property check with intersections

* Fix comment

* Add tests

* Properly propagate intersectionState

* Route property check through recursive type tracking logic

* Accept new baselines

* Skip check when apparent type of source is never

* Accept new baselines

* Only check when apparent type of source is a structured type
2020-04-06 13:36:20 -07:00
Anders Hejlsberg 5a4024dd9d Generic functions are never context sensitive (#37811)
* Functions with type parameters are never contextsensitive

* Add tests
2020-04-06 11:55:39 -07:00
Wesley Wigham 7317292782 Consider arrays and tuples within one another as possibly requiring deferral (#37776) 2020-04-03 14:14:13 -07:00
Wesley Wigham 6d25c01d09 Cache the regularized form of union types (#37749)
* Cache the regularized form of union types

* Inline function because why not

* Introduce two fastpasths into isRelatedTo
2020-04-02 23:54:24 -07:00
Anders Hejlsberg 349ae45a2c Reduce intersections with conflicting privates, elaborate on reasons (#37762)
* Elaborate on reasons for 'never' intersections

* Accept new API baselines

* Accept new baselines

* Add tests

* Accept new baselines

* Address CR feedback
2020-04-02 18:00:59 -07:00
Wesley Wigham 15aff05ff6 Explicitly merge module augmentation members into the exports added by export * declarations (#37691)
* Explicitly merge module augmentation members into the exports added by export * declarations

* Use ?., add namespace merge test

* Add missing merged symbol call to handle enum/ns merges during entity name lookup

* Add test with error case

* Handle missing value declarations in more places, unify duplicate declaration error handling to improve assignment declaration duplicate errors
2020-04-01 16:36:28 -07:00
Wesley Wigham 326e1c9ff8 Disallow partial matches for discriminant properties when generating error messages (#37589) 2020-04-01 15:39:12 -07:00
Alexander T 697d1042eb fix(37519): forbid trailing comma in a index signature (#37535) 2020-04-01 15:38:10 -07:00
Nathan Shively-Sanders 95a124f802 Fix crash on bad namespace parse (#37626)
* Fix crash on bad namespace parse

`global` inside a class body is parsed as a module declaration, and in
the following example has no body:

```ts
class C {
  global x
}
```

`x` is parsed as a separate ExpressionStatement. This caused a crash in
emit because the code didn't expect a module declaration with no body.

* inline node.body variable

* fix missed references to body
2020-04-01 15:05:49 -07:00
Simon Jaeger 9c4cbd64fb fix #32843 : evaluate right scope when checked if all type parameter are unused for jsdoc @template (#33320)
Co-authored-by: magierjones <simon.jaeger@magierjones.de>
2020-03-31 15:32:15 -07:00
pizzacat83 a46e9aea10 support 'in' type guard of intersections (#37106) 2020-03-31 13:37:08 -07:00
Anders Hejlsberg 2b0f351005 Fix narrow-by-constructor logic (#37698)
* Fix narrow-by-constructor logic

* Add regression test
2020-03-30 19:31:16 -07:00
Titian Cernicova-Dragomir 3433434142 Fixed issue where missing method call went unreported if the call target symbol did no have an id assigned or if the called property was used inside the if block on a different target. (#35862) 2020-03-30 14:45:32 -07:00
Jack Williams 0e15b9f245 Make never rest type top-like (#35438)
* Make never rest type top-like

* Add higher-order test

* properly support types which reduce to never

Co-authored-by: Wesley Wigham <wwigham@gmail.com>
2020-03-30 14:16:07 -07:00
Wesley Wigham 2f0cc51fee Fix contextual types for maybe-async callbacks (#37205)
* Fix contextual types for maybe-async callbacks

* Remove comment
2020-03-30 14:15:51 -07:00
uhyo 1f56ab02f0 Improve error message for invalid return type of JSX component (#32702)
* New diagnostic message for wrong JSX function component

* Component and Mixed type

* fix existing tests

* add new test for JSX component return type error

* fix tslint error

* update diagnostic message to include component name

* accept baseline

* update tests

* missing semicolon

* accept baseline

Co-authored-by: Wesley Wigham <wwigham@gmail.com>
2020-03-30 13:04:33 -07:00
Jack Williams 4c440e5e5b Fix #31319 : Narrow unit-unit inequality tests using comparability (#33071)
* Narrow unit-unit inequality tests using comparability

* Accept updated baselines

Co-authored-by: Wesley Wigham <wwigham@gmail.com>
2020-03-30 12:49:53 -07:00
Alexander T d8170faee1 fix(33054): allow variables starting with an underscore in for/of statement (#36739) 2020-03-30 11:18:18 -07:00
Alexander T 96f01227d4 fix(36909): wrong error message when trying to named-import an export (#36925) 2020-03-28 12:16:50 -07:00
Wesley Wigham 4567fc4f1a Ensure computed property names are always checked (#37307) 2020-03-25 15:16:54 -07:00
Sheetal Nandi 11043b0951 Check JSDocPropetyTag (#37544)
Fixes #37040
2020-03-23 17:20:35 -07:00