Commit graph

59 commits

Author SHA1 Message Date
Nathan Shively-Sanders
5c442419dc
Include arrow functions as javascript initializers (#23068)
This means that they are treated as valid js containers, methods, etc.
2018-04-02 10:11:39 -07:00
Nathan Shively-Sanders
6d9a8250bd
Improve binding and jsdoc of chained special js assignments (#23038)
* Search for jsdoc on chained assignments

* Fix binding of chained binary expression js-assignments

* Test:chained jsdoc+chained prototype assignment

* Improve naming
2018-04-02 09:47:01 -07:00
Nathan Shively-Sanders
adf30dd694
isMethodLike recognises prototype-assignment methods (#22935)
* isMethodLike recognises prototype-assignment methods

* Require js prototype methods to be in JS files
2018-03-28 10:41:24 -07:00
Nathan Shively-Sanders
61aad4c7b8
Handle toplevel this-assignment (#22913)
Do nothing now. Someday we might handle it correctly.
2018-03-27 12:24:37 -07:00
Nathan Shively-Sanders
c9ac15ae56
In JS, this assignments in constructors are preferred and nullable initializers become any (#22882)
* First draft:in js, constructor declaration is preferred

* Add tests

* initializer of null|undefined gives any in JS

Also move this-assignment fixes out of binder. I'm going to put it in
the checker instead.

* In JS, initializer null|undefined: any, []: any[]

* First draft of js prefer-ctor-types overhaul

* Update tests, update baselines

* Improve readability of constructor-type preference

* Cleanup: Remove TODO and duplication

* Add noImplicitAny errors

* Add comment
2018-03-26 13:42:34 -07:00
Nathan Shively-Sanders
4462c159b1
Correctly track thisContainer for this-property-assignments in JS nested containers (#22779)
* Track thisContainer for this-property-assignments in JS

Previously it would update on every block, not just those that could
bind `this`.

In addition, if the constructor symbol still can't be found, then no
binding happens. This is usually OK because people don't add new
properties in methods too often.

* Update additional baselines

* Add lib:dom to new test

* Address PR comments

* Correct new name for saveThisParentContainer
2018-03-22 09:54:43 -07:00
Nathan Shively-Sanders
de4a69cb72
In source files and blocks, bind function declarations before other statements (#22766)
* Add test case and temporarily disable inference

(Inference of class members from this-assignments inside a
prototype-assigned function.)

* Update baselines

* In blocks and source files, bind functions first

* Add tests from other bugs

* Remove temporary failsafe

* Update tests to restore intent and clean up errors

* Restore intent even better

* Restore intent even better x2

* Add missed baselines
2018-03-21 14:22:09 -07:00
Nathan Shively-Sanders
1074819be3
Js constructor function fixes (#22721)
* Do not add undefined for this assignments in functions

* Test:constructor functions with --strict

* First draft -- works, but needs a stricter check added

* Update baselines

* Make undefined-skip stricter and more efficient

Symbol-based now instead of syntactic

* Exclude prototype function assignments

* Add explanatory comment
2018-03-20 11:24:09 -07:00
Andy
b9f60566d0
For f.prototype.m = function() { this.x = 0; } make x a member of f, not of the function expression (#22643) 2018-03-16 11:35:51 -07:00
Nathan Shively-Sanders
e4610e3418
Import types in JS with var x = require('./mod') (#22161) 2018-03-08 11:11:51 -08:00
Nathan Shively-Sanders
04ceb3d9bd Disallow JS/non-JS merge without crashing
Note that the error location is misleading because it's reported inside
the merge step for the js initializer.
2018-03-08 09:49:23 -08:00
Nathan Shively-Sanders
c31808922d Remove assert for undeclared js-nested-exports
Previously, this would assert:

```ts
exports.undeclared.n = 1;
```

Because undeclared was never declared in any recognised way. Now it no
longer asserts, but does not bind. That's because the full pattern
starts with the line `exports = require('./x')` and assumes that x.js
declares `undeclared`. I am not sure how to bind this. The new test
contains this pattern in case I figure it out.
2018-02-27 15:04:10 -08:00
Nathan Shively-Sanders
c3143d2e47 Support js nested namespace decls on exports
and module.exports.
2018-02-27 10:20:16 -08:00
Nathan Shively-Sanders
dd2523650e Fix nested js-containers+proto assignment in types space
1. The actual symbols needed to be marked as containers.
2. Type node resolution needed to understand prototype assignments.
2018-02-23 09:16:01 -08:00
Nathan Shively-Sanders
aa88f71c2e Fix js-prototype-assignment on declarations 2018-02-22 12:52:50 -08:00
Nathan Shively-Sanders
41fba6f34b Incremental prototype+prototype assignment work
Had to fix nested incremental prototype detection, so I'll probably
merge this branch back into the PR branch.
2018-02-22 11:04:29 -08:00
Nathan Shively-Sanders
b14cf4ef9a First draft of prototype assignment
* Still misses incremental additions to the prototype.
* Not tested with {} or class initalizers.
* Code needs a cleanup pass.
2018-02-22 09:25:42 -08:00
Nathan Shively-Sanders
116a8a8cff Support nested prototype declarations
And add a test for them
2018-02-20 12:23:00 -08:00
Nathan Shively-Sanders
8f98c77217 Merge branch 'master' into js-object-literal-assignments-as-declarations 2018-02-15 10:28:25 -08:00
Nathan Shively-Sanders
0cadfcf6df Clean up js decl code in checker+utilities 2018-02-14 15:48:20 -08:00
Nathan Shively-Sanders
88c67fa777 Refactor binder and update baselines.
Also improve assert message in fourslash.
2018-02-13 15:44:15 -08:00
Nathan Shively-Sanders
fc08e20da8 Correctly merge JS decls
Turns out merging was incorrect even for non-nested declarations, but
tests didn't catch it before.
2018-02-13 14:17:46 -08:00
Ron Buckton
c84b7caa25 Fix emit when binder treats exported const as namespace 2018-02-12 13:02:47 -08:00
Nathan Shively-Sanders
03d155f622 Update tests and baselines 2018-02-09 16:20:44 -08:00
Nathan Shively-Sanders
61ea026b3c Allow window. prefix in default-assignment JS decl 2018-02-09 14:53:34 -08:00
Nathan Shively-Sanders
8ac94f5dec Support function/class in JS nested decls
This required fixing the predicates and the avoiding of contextual
typing loops. This is now done right, in
getContextualTypeOfBinaryExpression.

The predicates still need work.
2018-02-09 10:41:30 -08:00
Nathan Shively-Sanders
a09c2391a4 4-nested object-literal assignment works in JS 2018-02-08 16:07:22 -08:00
Nathan Shively-Sanders
b0aebb4c1e Recursive object-literal-assignment declarations 2018-02-08 15:43:10 -08:00
Nathan Shively-Sanders
7e3fdc29fa Test:o.x = o.x || {} assignments in JS 2018-02-07 14:55:23 -08:00
Nathan Shively-Sanders
a51bce0ab5 Test:basic var x = x || {} support in JS 2018-02-07 11:32:20 -08:00
Nathan Shively-Sanders
4f07f58c03 Merge branch 'master' into js-object-literal-assignments-as-declarations 2018-02-07 09:17:48 -08:00
Wesley Wigham
6c15fc6634
Fix devtools test (#20731)
* Fix devtools test

* Add small test case mimicing the issue from the user test
2017-12-18 14:47:45 -08:00
Nathan Shively-Sanders
c6a77514e8 Test:js object literal assignment as declaration 2017-11-29 11:37:35 -08:00
Nathan Shively-Sanders
74faa3d738 JS static properties:fix multi-file references+merging 2017-11-28 13:46:14 -08:00
Nathan Shively-Sanders
d338ecd6d0 Tests:more JS static property assignments
export default fails right now; I haven't got it to work and it's not in
dev tools, so I don't know if it's worth the effort.
2017-11-27 15:20:06 -08:00
Nathan Shively-Sanders
fa96bd4b01 More tests and update baselines 2017-11-21 15:03:44 -08:00
Nathan Shively-Sanders
b1c735fea6 Test:Type references to nested JS classes 2017-11-21 10:23:23 -08:00
Mohamed Hegazy
4221fb6a39 Check for initializer before using it (#18708) 2017-09-22 17:14:22 -07:00
Ron Buckton
115884aa30 Follow symbol through commonjs require for inferred class type 2017-06-21 18:20:46 -07:00
Ron Buckton
471e680ef0 Better types from jsdoc param tags 2017-06-06 18:10:00 -07:00
Ron Buckton
6e87078540 Added tests and improve type of new expression 2017-06-06 14:48:40 -07:00
Yui T
0cbfc79ca7 Rename test files to be more consistent and move them into jsdoc folder 2017-05-26 11:20:57 -07:00
Kanchalai Tanglertsampan
bd422e3a52 Add tests and update baselines 2017-05-23 16:11:23 -07:00
Mohamed Hegazy
19ada9719a Fix #14620: Lookup names in exports as well as locals when binding special properties 2017-03-23 10:26:05 -07:00
Mohamed Hegazy
3ac54e8a47 Infer class property declarations from assignments in nested arrow functions 2017-03-12 15:00:24 -07:00
Mohamed Hegazy
0fb415ac61 Merge pull request #14492 from Microsoft/anyInferences
Set inference result to `any` instead of `{}` for .js files if generic type parameter inference found no candidates
2017-03-08 16:15:50 -08:00
Mohamed Hegazy
89974bdaaf Merge pull request #14172 from Microsoft/moduleExportsAlias
Fix #14171: Recognize property assignements to `module.export` aliases as exports
2017-03-07 11:13:19 -08:00
Mohamed Hegazy
3705b87c5c Merge branch 'master' into infereClassPropertiesFromMethods 2017-03-06 16:53:51 -08:00
Mohamed Hegazy
b3161e365a Merge pull request #14222 from Microsoft/addAnyStringIndexerToJSObjects
Add a string indexer to any for object literals on a .js file
2017-03-06 16:44:30 -08:00
Mohamed Hegazy
8f7fd0918b Set inference result to any isntead of {} for .js files if generic type parameter inference found no candidates 2017-03-06 13:35:03 -08:00