8931 Commits

Author SHA1 Message Date
Collins Abitekaniza
7b55d1846b Giving too many arguments should error on the first argument that exceeds arity (#27982)
* span on first arg that exceeds arity

* refactor baseline

* handle cases for spread arguments

* refactor + add coverage for tuple spread cases

* create diagnostic on NodeArray of exceeding args

* test function overloading
2019-03-12 15:57:12 -07:00
Matt McCutchen
ab8153602a Fix mixin logic to preserve at least one constructor type even when the (#27701)
intersection also contains non-constructor types.

Fixes #17388.
2019-03-12 14:30:43 -07:00
Matt McCutchen
6c6f216d0d Handle generic mapped types in getTypeOfPropertyOfContextualType. (#27586)
* Handle generic mapped types in getTypeOfPropertyOfContextualType.

The changes to existing baselines look acceptable to me.

Fixes #24694.

* Minor reorganization, add test case from @yortus
2019-03-12 14:13:32 -07:00
Wenlu Wang
d2476759e2 add related error span for default exports (#25396)
* add related error span for default exports

* accept baseline

* stash

* accept baseline and fix lint

* update testcase

* Add missing semicolon
2019-03-12 13:15:14 -07:00
Wenlu Wang
bd27296ba6 improve stripInternal with inline comments (#23611)
* improve stripInternal with inline comments

* fix lint

* stash

* simptify StripInternal

* fix internal type declaration

* fix internal type declaration again

* accept baseline

* refactor inline

* simply prev check

* remove getTrailingCommentRangesOfNode

* Merge implementation with new isInternalDeclaration method, accept lkg-based baseline
2019-03-12 13:14:47 -07:00
Anders Hejlsberg
ba95fcac87
Merge pull request #30334 from Microsoft/inferenceContextCleanup
Revise InferenceContext implementation
2019-03-12 10:13:55 -07:00
Anders Hejlsberg
7f90ad1155 Add tests 2019-03-12 06:29:33 -07:00
Wesley Wigham
3ba5aa9f60
Add regression test for #29692 (#30325) 2019-03-11 15:41:05 -07:00
Wesley Wigham
ca9566fcde
Forbid contravariant inferences to conditional type branches (#30287) 2019-03-11 15:21:03 -07:00
Sheetal Nandi
97fbc87e98
Merge pull request #29813 from Microsoft/incrementalBuildInfo
Build .tsbuildinfo file when building using tsc --b
2019-03-08 15:49:44 -08:00
Wesley Wigham
a9ad94ab3c
Conditional type simplifications & Globally cached conditional type instances (#29437)
* Introduce simpliciations for extract/exclude-like conditional types and fix restrictive instantiations

* Add test for the common simplifications

* unify true branch constraint generation logic and true branch simplification

* Use identical check on instantiated types

* Add late-instantiate conditionals to test

* Globally cache conditional type instantiations ala indexed access types

* Handle `any` simplifications

* Factor empty intersection check into function

* Modifify conditional type constraints to better handle single-branch `any` and restrictive type parameters

* Add test case motivating prior commit

* Fix lint

* Factor logic into worker vs cacheing function

* Remove now unneeded casts
2019-03-08 15:33:12 -08:00
Wesley Wigham
58e847abb5
Add assignability rule relaxing the assignability of partial mapped types (#30112)
* Add assignability rule relaxing the assignability of partial mapped types

* Update comment
2019-03-08 14:01:27 -08:00
Wesley Wigham
45a6cb7066
Reset toplevel flag when higher priority inference takes place (#30265) 2019-03-08 13:57:43 -08:00
Sheetal Nandi
990b199ebd Merge branch 'master' into incrementalBuildInfo 2019-03-08 11:42:19 -08:00
Anders Hejlsberg
d59e51b063
Merge pull request #30215 from Microsoft/higherOrderFunctionTypeInference
Higher order function type inference
2019-03-08 10:41:32 -08:00
Wesley Wigham
e982240500
Instantiating a signature in the context of another should infer from return type predicates if they match up (#30242)
* Instantiating a signature in the context of another should infer from return type predicates if they match up

* Invert condition per PR feedback
2019-03-07 17:39:58 -08:00
Wesley Wigham
4c9ad08610
Add fix for webpack history merge bug (#29339)
* Add fix for webpack history merge bug

* Add test case
2019-03-07 13:34:28 -08:00
Sheetal Nandi
fe9f42480a Handle error when type parameter of mapped type uses private type
Fixes #30201
2019-03-06 13:30:48 -08:00
Gabriela Britto
d2364f555f
Merge pull request #30089 from Microsoft/convert-to-named-parameters
Convert to named parameters
2019-03-06 09:33:01 -08:00
Sheetal Nandi
6e1e1e7bd5 Merge branch 'master' into incrementalBuildInfo 2019-03-05 12:02:27 -08:00
Anders Hejlsberg
22c934a065 Add tests 2019-03-04 11:07:02 -08:00
Gabriela Araujo Britto
8c4ab69d09 add test for non-transient symbol 2019-03-04 09:34:04 -08:00
Anders Hejlsberg
304e25cf69 Add tests 2019-03-02 11:59:33 -08:00
Anders Hejlsberg
8794ebdff5
Merge pull request #30179 from Microsoft/fixGetParameterNameAtPosition2
Fix out-of-bounds issue in getParameterNameAtPosition
2019-03-02 05:17:36 -10:00
Anders Hejlsberg
d9bb869341 Add regression test 2019-03-01 16:34:23 -08:00
Sheetal Nandi
223d42847b Merge branch 'master' into incrementalBuildInfo 2019-03-01 11:39:44 -08:00
Sheetal Nandi
cd195c91c6 Add options tsBuildInfoFile to provide name for the buildinfo file 2019-03-01 10:28:57 -08:00
Sheetal Nandi
df9da15abb Incremental false with composite not allowed 2019-03-01 09:39:58 -08:00
Jack Williams
5bef1aa13c Add regressions for conditional types that affect parameter variance (#30146) 2019-02-28 16:14:16 -08:00
Wesley Wigham
b1a73ab560
Resolve aliases to jsx namespace symbol (#30160) 2019-02-28 13:52:57 -08:00
Anders Hejlsberg
7f5052bf7b
Merge pull request #30114 from Microsoft/contextualGenericRestParameter
Improve contextual typing by generic rest parameters
2019-02-28 11:00:12 -10:00
Anders Hejlsberg
237c33b444
Merge pull request #30109 from Microsoft/circularConstraintErrors
Consistently error on circular constraints
2019-02-28 10:57:01 -10:00
Wesley Wigham
a6a3ae00a6
Only collect inferences which actually have inferences into the returnMapper (#30111) 2019-02-28 12:46:24 -08:00
Nathan Shively-Sanders
be2db9db12
Add globalThis (#29332)
* Restore original code from bind-toplevel-this

With one or two additional comments

* Working in JS, but the symbol is not right.

Still need to

1. Make it work in Typescript.
2. Add test (and make them work) for the other uses of GlobalThis:
window, globalThis, etc.

* Check in TS also; update some tests

Lots of tests still fail, but all but 1 change so far has been correct.

* Update baselines

A couple of tests still fail and need to be fixed.

* Handle type references to globalThis

The type reference must be `typeof globalThis`. Just `globalThis` will
be treated as a value reference in type position -- an error.

* Restore former behaviour of implicitThis errors

I left the noImplicitThis rule for captured use of global this in an
arrow function, even though technically it isn't `any` any more --
it's typeof globalThis.  However, you should still use some other method
to access globals inside an arrow, because captured-global-this is super
confusing there.

* Test values with type globalThis

I ran into a problem with intersecting `Window & typeof globalThis`:

1. This adds a new index signature to Window, which is probably not
desired. In fact, with noImplicitAny, it's not desired on globalThis
either I think.
2. Adding this type requires editing TSJS-lib-generator, not this repo.

So I added the test cases and will probably update them later, when
those two problems are fixed.

* Add esnext declaration for globalThis

* Switch to symbol-based approach

I decided I didn't like the import-type-based approach.

Update baselines to reflect the difference.

* Do not suggest globals for completions at toplevel

* Add tests of element and property access

* Look up globalThis using normal resolution

globalThis is no longer constructed lazily. Its synthetic Identifier
node is also now more realistic.

* Update fourslash tests

* Add missed fourslash test update

* Remove esnext.globalthis.d.ts too

* Add chained globalThis self-lookup test

* Attempt at making globalThis readonly

In progress, had to interrupt for other work.

* Add/update tests

* Addres PR comments:

1. Add parameter to tryGetThisTypeAt to exclude globalThis.
2. Use combined Module flag instead combining them in-place.
3. SymbolDisplay doesn't print 'module globalThis' for this expressions
anymore.
2019-02-27 14:14:34 -08:00
Wesley Wigham
13c08ab32b
Use identity with the permissive instantation to detect nongenric instances and disable variance probing on nongeneric instances (#29981)
* Use identity with the restrictive instantation to detect nongenric instances and disable variance probing on nongeneric instances

* Generalize to also include interfaces, add test case, still perform argument comparisons for postive comparisons if possible

* Actually accept baselines, lol

* Reduce deep nesting limit just a bit so yargs still builds

* Handle circular identities in isNonGeneric

* Use a simple traversal of the types rather than the restrictive instantiation

* Cache the bits using an existing field to further reduce any time nongeneric check takes

* Revert to using an existing mapper, use permissive > restrictive

* Revert constant change

* And revert the comment, too
2019-02-27 14:12:30 -08:00
Nathan Shively-Sanders
aedffe049d Revert "Merge pull request #27697 from mattmccutchen/issue-27118"
This reverts commit 2dfb6202ed03e04ba1dcc330eea219c50fe48c66, reversing
changes made to bbf559b9c7fd21b984d7cb538140c74e3d6a6b45.
2019-02-27 11:50:04 -08:00
Daniel Rosenwasser
e8e7e88b2a
Merge pull request #30094 from Kingwl/improve_completions_for_optional_props
check completions with assignable rather than identity
2019-02-26 16:19:50 -08:00
Anders Hejlsberg
0716b87b75 Merge branch 'master' into contextualGenericRestParameter 2019-02-26 14:00:41 -08:00
Wesley Wigham
288851066b
Dont create a union type to infer conditional type branches (#30010) 2019-02-26 13:43:41 -08:00
Wesley Wigham
2533d8294e
Make a fresh empty object literal not a subtype of a type with an index signaure (#29975)
* Forbid inferable index checkign during subtype relationship checking

* Merge object.values and object.entries overloads to work around subtype change

* Invert subtype relationship between fresh empty objects and non-empty object types

* Remvoe comment

* Revert lib change

* Remove trailing whitespace ffs
2019-02-26 13:43:22 -08:00
Anders Hejlsberg
2212f4777a Add regression test 2019-02-26 12:44:12 -08:00
王文璐
4d7ec380a9 check completions with assignable rather than identity 2019-02-26 10:54:01 +08:00
Wesley Wigham
c5061486a9
Retain substitution types through instantiation if possible (#30059) 2019-02-25 17:10:03 -08:00
Gabriela Araujo Britto
a5153a94ab add tests 2019-02-25 14:14:28 -08:00
Gabriela Araujo Britto
365967d484 Merge branch 'master' into convert-to-named-parameters 2019-02-25 10:54:58 -08:00
Gabriela Araujo Britto
f571866f47 add new tests for bad class references 2019-02-25 10:32:56 -08:00
Gabriela Araujo Britto
bc3611d1dd update failing tests 2019-02-25 10:32:28 -08:00
Joseph Wunderlich
21ab39649c remove any annotation from declare method quickfix 2019-02-22 17:24:21 -08:00
Gabriela Araujo Britto
6b53489a4a Merge branch 'master' into convert-to-named-parameters 2019-02-20 13:24:09 -08:00
Daniel Rosenwasser
4e3efc2e90
fix no space before equal operator in type parameter (#29990)
fix no space before equal operator in type parameter
2019-02-20 12:16:18 -08:00