Commit graph

49 commits

Author SHA1 Message Date
Klaus Meinhardt 24dd93fc2b
Fix access of protected members on generic this-type (#36928)
Fixes: #36926
2020-02-21 09:33:21 -08:00
Ron Buckton a47ac63738
Fix for incorrect 'this' type for optional call (#33799) 2019-10-04 13:39:42 -07:00
Andrew Branch 3d09010dc8
Intersect 'this' types in union signatures (#32538)
* Intersect this types in union signatures

* Actually update baselines
2019-07-26 14:56:03 -07:00
Nathan Shively-Sanders cc3d011333
Infer this parameters (#26800)
Previously we didn't. I can't remember why, probably because I
overlooked it in the initial PR.
2018-08-31 07:45:34 -07:00
Matt McCutchen f72193eedc Report a semantic error for an arrow function with a "this" parameter.
Fixes #9744.
2018-07-23 10:42:56 -04:00
王文璐 0bcbbbdd58 disallow static field access 2018-06-05 18:42:21 +08:00
王文璐 9767fbba09 allow access protected member in this parameter context 2018-06-04 15:16:59 +08:00
Nathan Shively-Sanders 154ac342cb
Allow extending any, with noImplicitAny errors (#23153)
Allow extending any, without noImplicitAny errors
2018-04-05 08:52:56 -07:00
Nathan Shively-Sanders 11eabc0946
Skip parens and non-null assertions when looking for this-context (#23097)
* Skip parens and ! for getting this-context of call

* Add test and improve code a bit

* Use skipOuterExpressions instead
2018-04-03 06:23:59 -07:00
Nathan Shively-Sanders e0e1a3b078 Test:this instantiation in type parameters
Make sure that `this` gets instantiated when it's used as a constraint
of a type parameter, and nowhere else in a signature.
2017-11-01 09:17:52 -07:00
Nathan Shively-Sanders a59f77ffb4 Test:type predicate uses correct index to report errors 2017-08-09 15:45:28 -07:00
Nathan Shively-Sanders 95f5bc1ee0 Add unknown property to test of contextual this type 2017-07-18 10:01:22 -07:00
Nathan Shively-Sanders 08ae02263a Contextually type this in object literals in JS
Previously, `this` would only get a contextual type inside object
literals with `--noImplicitThis` turned on in Typescript files.
2017-07-17 15:59:18 -07:00
Anders Hejlsberg 0ac92b4706 Add tests 2017-03-07 09:07:53 -08:00
Anders Hejlsberg 25738a8e41 Update tests 2017-02-28 16:09:42 -08:00
Anders Hejlsberg ff2cfd2af5 Update test 2017-02-28 09:49:54 -08:00
Anders Hejlsberg 5bda48ba8d Add tests 2017-02-27 10:19:26 -08:00
Anders Hejlsberg 6fdd929a66 Update test 2017-02-24 19:52:50 -08:00
Anders Hejlsberg ec292c92e2 Update test 2017-02-22 19:25:19 -08:00
Anders Hejlsberg e512376b0c Update tests 2017-02-16 17:42:22 -08:00
Nathan Shively-Sanders 3d3bcb4a5b Correctly copy annotated this getter -> setter
Previously it only went the other direction.
2016-05-04 13:35:35 -07:00
Nathan Shively-Sanders ff1b083ac3 Add tests+baselines for accessor this parameters 2016-05-04 11:03:52 -07:00
Daniel Rosenwasser fa67cb86b3 Merge remote-tracking branch 'origin/master' into thisTypesInBasePropAndContainer 2016-05-01 20:52:51 -07:00
Nathan Shively-Sanders c12cb83fb7 Type 'this' in object literal function properties
Previously, methods of object literals would give a type to 'this'.
Now function properties of object literals also give a type to 'this'.
2016-04-29 10:31:01 -07:00
Nathan Shively-Sanders 9f7621c7e2 Contextual signatures without thisType return anyType
If a contextual signature is found, if its thisType is undefined, then the contextual type of `this` is now `any`.
Previously `checkThisExpression` would keep looking for a different type for `this`.

Also update tests to show this new behaviour.
2016-04-28 14:17:11 -07:00
Nathan Shively-Sanders 3a74f483ba this in object literals intersects contextual type and literal type 2016-04-28 10:09:04 -07:00
Nathan Shively-Sanders 6c735b5cbf Add contextual typing test with this specified 2016-04-07 07:59:46 -07:00
Nathan Shively-Sanders 921d5f83e9 Fix == typo and add object literal 'this' test 2016-04-01 16:13:57 -07:00
Nathan Shively-Sanders 2a9f39b132 Forbid ConstructType as part of 'no this in constructors' 2016-04-01 13:06:55 -07:00
Nathan Shively-Sanders e4ed7f904e Address PR comments 2016-03-30 15:01:16 -07:00
Nathan Shively-Sanders c9f5f3d67e Remove --strictThisChecks 2016-03-25 15:41:37 -07:00
Nathan Shively-Sanders 1032cc5408 Rename --strictThis to --strictThisChecks
Use the upcoming naming scheme for --strict.*Checks and --strictChecks
flags.
2016-03-11 13:24:31 -08:00
Nathan Shively-Sanders 7b531fcd05 Check this expressions in object literal methods
Add a test and baseline
2016-03-09 13:06:06 -08:00
Nathan Shively-Sanders 482acccada Union this-types of unioned call signatures
And and tests and baselines
2016-03-08 13:05:00 -08:00
Daniel Rosenwasser 0abb4c907e Added tests. 2016-02-28 19:57:12 -08:00
Nathan Shively-Sanders a014edf55a Address more comments and remove temp test.
I added the temp test by mistake.
2016-02-16 13:00:21 -08:00
Nathan Shively-Sanders 41bb446865 Revert unioning of this argument types
The right solution is to not instantiate this-types of unions, which is a
separate problem more to do with this-class types.
2016-02-08 16:39:19 -08:00
Nathan Shively-Sanders 738713b146 Improve error reporting
1. Fix bug in error reporting in compareSignaturesRelated.
2. When the this-argument is a union type, allow assignability when the
method's signature is assignable to *any* member of the union.
2016-02-08 14:01:51 -08:00
Nathan Shively-Sanders 2f74da112d Add specific error messages for out-of-place this
Also remove lint in checker.
2016-02-04 16:01:10 -08:00
Nathan Shively-Sanders 8c87da523b First round of review comments addressed.
Only major thing is a bug fix in
`isContextSensitiveFunctionLikeDeclaration`, and turning on context
sensitivity to `this` even with `--strictThis` off.
2016-02-04 15:43:43 -08:00
Nathan Shively-Sanders 04e7d81105 Add tests and baselines for this-function types. 2016-01-29 14:49:52 -08:00
Anders Hejlsberg a234497004 Updating existing test 2015-11-06 08:55:26 -08:00
Anders Hejlsberg 870e96e525 Adding test 2015-11-06 08:55:08 -08:00
Nathan Shively-Sanders 67b9647069 Add a variable of type this in constructor body
The test already had a reference to the `this` value, but that doesn't
show that the *type* is allowed.
2015-11-02 10:47:56 -08:00
Nathan Shively-Sanders e609047b78 Add tests based on #5449 2015-10-30 14:02:07 -07:00
Anders Hejlsberg 82c010e12a Adding contextual typing test 2015-09-29 15:26:27 -07:00
Anders Hejlsberg 1c9fae8e0c Add tuple type test 2015-09-27 09:05:17 -07:00
Anders Hejlsberg 19319b2208 Adding test for declaration files 2015-09-26 15:56:00 -07:00
Anders Hejlsberg abd2a8526d Adding tests 2015-09-26 12:58:53 -07:00