Commit Graph

8966 Commits

Author SHA1 Message Date
Nathan Shively-Sanders
32054f1c31 Forbid accessing block-scoped variables on globalThis (#30510)
* Forbid accessing const & let on globalThis

It's just an error; you still get the type of the property.

* Disallow access of blockscoped vars on globalThis

Also change Array, Function, String, et al from `const` to `var` so that
they remain accessible via `globalThis.String`.

* Update baselines after lib.d.ts change

Note especially the change in redefineArray, which is now allowed as
long as you provide a type that is assignable to ArrayConstructor.

* Remove blockscoped vars from typeof globalThis

Unlike forbidding them, this removes the properties entirely.

Unfortunately, this means that accessing these properties is only an
error with noImplicitAny, and that error is quite confusing.

Let's discuss our options. I see 3:

1. Forbid access of block-scoped vars as properties (in all flag
settings), but leave them on the type. Simple to implement.
2. Remove block-scoped vars from the globalThis type. Has the bad
error/flag behaviour described above, but simple to implement.
3. Remove block-scoped vars from the globalThis type. Also, forbid
accessing them by executing another resolveName lookup for failed
property accesses on globalThisSymbol. If the second lookup returns a
blockscoped var, issue an error instead of falling back to the index
signature. This seems too complex to me.

* Update baselines

* Better error for block-scoped usage on globalThis

So that value-space references have as clear an error as type-space
references.

* Update fourslash tests

* Fix semi-colon lint

* Don't copy so much when filtering blockscoped vars
2019-03-25 14:07:48 -07:00
Gabriela Araujo Britto
0f6f3b79b5 Fix find all references of inherited constructor (#30514)
* recursively look for inherited constructor references

* add test

* remove outdated comment

* add tests

* move function

* improve tests

* minor refactor

* fix convert params refactoring to deal with inherited constructor calls

* simplify refactor test
2019-03-22 15:17:50 -07:00
Wesley Wigham
b86dea03f2 Fix crash caused by cyclic defaults (#30532) 2019-03-21 18:27:14 -07:00
Ron Buckton
2932421370 Merge pull request #30495 from Microsoft/fix29427
Adjust offset to account for 'this' parameter when emitting parameter decorators
2019-03-20 12:56:50 -07:00
Sheetal Nandi
800f7a3447 Merge pull request #30414 from Microsoft/jsSyntaxCompletions
Filter ts only keywords from js file completion
2019-03-20 10:38:11 -07:00
Ron Buckton
cfb0adeadf Merge pull request #28609 from ajafff/class-decorator-generics
resolve TypeReference in class decorator at parent of class
2019-03-19 15:46:58 -07:00
Ron Buckton
07bec2893f Adjust offset to account for 'this' parameter when emitting parameter decorators 2019-03-19 11:46:18 -07:00
Ron Buckton
e19c7f1a45 Prevent substitution of 'super' in async super helper 2019-03-19 11:35:18 -07:00
Ron Buckton
4e54f30fb4 Fix _superIndex emit when super access captured in async arrow 2019-03-19 10:20:08 -07:00
Gabriela Araujo Britto
84087d0e0a Use shorthand property assignment in convert parameters to object (#30468)
* create shorthand property assignment in argument object when possible

* add shorthand property assignment test

* don't offer refactor on jsdoc comment

* add jsdoc test

* improve jsdoc test

* use crlf
2019-03-19 09:28:09 -07:00
Gabriela Britto
10b9051624 Fix convert to named parameters rest parameter tuple (#30286)
* check if rest parameter is of tuple type in isOptionalParameter

* expose isArrayType and isTupleType in checker

* don't offer refactor if rest parameter type is neither array nor tuple type

* add tests for rest parameters

* fix tests for renamed refactor

* remove unnecessary conditional operator
2019-03-18 10:31:38 -07:00
Masahiro Wakame
18b8625ef8 fix error on globalThis type extend (#30460)
* Add test for extend globalThis

* Fix compile aborting
2019-03-18 09:18:27 -07:00
Anders Hejlsberg
d0646a629a Merge pull request #30084 from dragomirtitian/GH-26563
Improved argument description for parameters originating from tuples
2019-03-18 06:14:52 -10:00
Anders Hejlsberg
36cf12fe0a Merge pull request #30363 from Microsoft/fixTypeParameterPromotion
Higher order type parameter promotion fixes
2019-03-18 08:48:03 -07:00
Anders Hejlsberg
b6aff98fd7 Add test relating type predicates with and without this parameters 2019-03-17 17:39:08 -10:00
Nathan Shively-Sanders
658798032b Fix globalThis completions (#30441)
* Fix, but with test not quite right

* Add missing completions to test

* Remove out-of-date comment
2019-03-15 19:10:39 -07:00
Nathan Shively-Sanders
0f598db3e5 Fixes #29524, a merged UMD-global (#30403)
This kind of merged symbol causes crashes in two places because it's
marked BlockScoped, which makes us assume that it must be something that
is inside a SourceFile. However, block-scoped checks don't make sense
for this kind of symbol, so I exclude them by looking at the kind of
the valueDeclaration, as @mprobst suggested in the original bug.
2019-03-15 09:45:33 -07:00
Wesley Wigham
563593b8be Enable better error spans for async functions (#30413) 2019-03-14 17:10:42 -07:00
Sheetal Nandi
f829f958a2 Filter ts only keywords from js file completion
Fixes #29212
2019-03-14 15:52:50 -07:00
Gabriela Britto
1c8a359914 rename convert to named parameters (#30401) 2019-03-14 13:41:29 -07:00
Gabriela Britto
7824fbc395 Merge pull request #30383 from Microsoft/fixFindAllRefsOfDefaultExport
Fix find all refs of default export
2019-03-14 09:39:06 -07:00
Sheetal Nandi
8b04143675 Merge pull request #30380 from Microsoft/completionsWhileWritingSpread
Fix completions when writing spread expression
2019-03-14 09:38:50 -07:00
Sheetal Nandi
2961bc3fc0 Merge pull request #30384 from Microsoft/completionsInTypeParameter
Add extends of type parameter as type only location for completions
2019-03-13 18:07:31 -07:00
Gabriela Araujo Britto
b29ed70ddb Merge branch 'master' into fixFindAllRefsOfDefaultExport 2019-03-13 16:04:23 -07:00
Sheetal Nandi
342616781e Merge pull request #30381 from Microsoft/mapConstructor
Fix map constructor to accept readonly tuple
2019-03-13 15:24:22 -07:00
Sheetal Nandi
526eda8f18 Add extends of type parameter as type only location for completions
Fixes #28511
2019-03-13 15:22:33 -07:00
Wesley Wigham
5d08b68122 Fix react-redux break on DT (#30375)
* Forbid reentrancy in conditional type creation (force deferal on occurance)

* Add repro from react-redux, accept updated baselines
2019-03-13 15:21:46 -07:00
Gabriela Araujo Britto
66e2c54fe5 add tests for finding references of named and default exports 2019-03-13 15:11:33 -07:00
Sheetal Nandi
027d65a920 Fix map constructor to accept readonly tuple
Fixes #29721
2019-03-13 14:52:58 -07:00
Sheetal Nandi
12d736f0a4 Fix completions when writing spread expression
Fixes #29234
2019-03-13 14:25:43 -07:00
Anders Hejlsberg
fd0d477519 Add test 2019-03-13 06:51:13 -07:00
Anders Hejlsberg
4f4d9f6819 Add test 2019-03-12 17:29:44 -07:00
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
Titian Cernicova-Dragomir
88babf2a90 Merge remote-tracking branch 'remotes/origin/master' into GH-26563 2019-03-11 02:31:07 +02: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