Commit Graph

3477 Commits

Author SHA1 Message Date
Anders Hejlsberg
c5b8f4fcd4 Fix relation between generic mapped types and types with index signatures (#38761)
* Fix relation between generic mapped type and type with index signature(s)

* Add tests
2020-05-25 09:55:41 -07:00
Nathan Shively-Sanders
fc83d10388 Merge branch 'master' into diagnose-accidental-accessor-call 2020-05-20 16:46:34 -07:00
Nathan Shively-Sanders
3340142dda Merge pull request #38607 from a-tarasyuk/bug/38295
fix(38295): Duplicated object key in const not detected when the key is a number preceded by `-` or `+`
2020-05-20 14:52:09 -07:00
Alexander T
4e945fbc98 fix(38299): use string literals as keys to creating rest result (#38600) 2020-05-20 13:52:52 -07:00
Alexander T
bbf56b044b Merge branch 'master' of https://github.com/microsoft/TypeScript into bug/38295 2020-05-20 20:13:50 +03:00
Alexander T
e04ab6938a fix(38295): handle duplicate object literal keys which contain '+' and '-' tokens 2020-05-20 14:32:41 +03:00
Anders Hejlsberg
7ba0a6592d No contextual types from circular mapped type properties (#38653)
* No contextual types from circular mapped type properties

* Add regression test
2020-05-19 13:42:30 -07:00
Anders Hejlsberg
3c1f37e913 Use control flow analysis to check 'super(...)' call before 'this' access (#38612)
* Use CFA graph to check this/super accesses are preceded by super() call

* Accept cleaned-up API baselines

* Accept new baselines

* Add tests
2020-05-16 19:58:17 -07:00
Eli Barzilay
33c3e9e2c6 Make processTaggedTemplateExpression visit a returned node
This problem was introduced in 70399e146e (from PR #23801), which added
a `visitTaggedTemplateExpression` case for `TaggedTemplateExpression`,
before that, it would fallback to the default of `visitNode`.  So re-add
that happen in `processTaggedTemplateExpression`.

Since it doesn't hurt, I left a `Debug.checkDefined(property.name)`
instead of `!`-ing it.

Fixes #38558.
2020-05-15 19:46:45 -04:00
Wesley Wigham
7fc456f2d7 Include unknown in spread prop override check (#38577) 2020-05-14 14:36:38 -07:00
Anders Hejlsberg
0091fd6c64 Exclude arrays and tuples from full intersection property check (#38395)
* Exclude arrays and tuples from full intersection property check

* Add regression test
2020-05-07 15:03:51 -07:00
Anders Hejlsberg
7798f532df Fix crash caused by assertion with evolving array type (#38398)
* Properly finalize evolving array type in getTypeAtFlowCall

* Add regression test
2020-05-07 14:05:57 -07:00
Jack Williams
05d59a1f1a Unify logic in typeof narrowing (#33434) 2020-05-06 15:15:24 -07:00
Josh Goldberg
be2eb8a2e1 Allowed comment directives to be multiline (#38228)
* Allowed comment directives to be multiline

* Added tests, and perhaps fixed a test runner bug?

* I think it's going to need a consistent variable to loop over

* Used dynamically computed indexes in verifies

* Added multiline tests

* Increased flexibility for multiline comment parsing

* Undid a couple of formatting changes; removed backslashes from multiline regexp

* Added baseline tests for multiline comment skipping

Co-authored-by: Orta Therox <orta.therox@gmail.com>
2020-05-06 13:09:29 -07:00
Anders Hejlsberg
2524fb164a Consistent narrowing by discriminant (#38311)
* Consistent requirements for narrowing by discriminant

* Add tests
2020-05-05 20:06:07 -07:00
Anders Hejlsberg
e6390efb01 Properly handle private/protected members in unions of object types (#38277)
* Property handle private/protected properties in unions of object types

* Add regression test
2020-05-04 15:28:00 -07:00
Anders Hejlsberg
a09470f013 Fix index signatures on unions of intersections (#38278)
* Add missing getApparentType call

* Add regression tests
2020-05-04 12:46:14 -07:00
Leko
275ed548df disallows exponentials with BigInts for targets lower than ES2016 2020-05-04 13:14:48 -04:00
Andrew Branch
53320f59a4 Fix crash on duplicate default exports (#38272) 2020-04-30 12:21:02 -07:00
Jacob Bandes-Storch
fd4eccee6c Merge remote-tracking branch 'upstream/master' into diagnose-accidental-accessor-call 2020-04-29 23:00:16 -07:00
Orta
0258db2210 Adds support for looking up past Blocks in expando objects (#38031)
* Adds support for looking up past Blocks in expando objects

* Adds JS tests to validate the JS parsing also works

* Get the top level block expando tests green
2020-04-29 10:35:33 -04:00
Anders Hejlsberg
a0ebd2c26e Guard against recursion in inferTypeForHomomorphicMappedType (#38224)
* Guard against recursion in inferTypeForHomomorphicMappedType

* Add regression test
2020-04-28 16:56:35 -07:00
Anders Hejlsberg
16d2eb7075 Error on this.xxx access of previously declared but uninitialized property (#38030)
* Error on this.xxx access of previously declared but uninitialized property

* Add tests

* Accept new baselines
2020-04-28 12:52:14 -07:00
Daniel Rosenwasser
6a6c83cf9a Revert "Revert "Add check for delete expression must be optional (#37921)" (#38154)" (#38173)
This reverts commit 1b8c68d746.
2020-04-27 13:23:45 -07:00
Wesley Wigham
4a5eeb0bb2 Skip comparing optional property flag when comparing against discriminant properties (#38101) 2020-04-24 18:33:30 -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
Jacob Bandes-Storch
61f60057f1 Better error message for accidental calls to get-accessors 2020-04-11 15:52:17 -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