779 Commits

Author SHA1 Message Date
Sheetal Nandi
15f9ea3d14 Merge branch 'master' into requireJson 2018-05-03 15:35:54 -07:00
Wesley Wigham
23b9a23455
Ensure properties with computed names are visited (#23787) 2018-05-03 11:21:29 -07:00
Nathan Shively-Sanders
7cda045d52
Always export typedefs (#23723)
* Always export typedefs

This actually just required deleting a check in declareModuleMembers
and checking for external AND commonjs modules in a couple of places.

However, while experimenting with this feature, I discovered that even
previously-exported typedefs would only be exported if they came after a
commonjs export node. So I added a commonjs check to the pass in the
parser. It will not catch nested module.exports, but it will catch
top-level assignments.

The new test tests both changes.

* Post-bind typedef instead of pre-checking for commonjs

* Duplicate identifier errors

* Fix class type reference resolution+update baselines

* Move to a type-based check for duplicate identifiers
2018-04-30 14:55:26 -07:00
Sheetal Nandi
579748bc2b Merge branch 'master' into requireJson 2018-04-30 11:44:09 -07:00
Nathan Shively-Sanders
905f9a02ad
module.exports = Entity is an alias, just like export = Entity (#23570)
* Make `module.export =` an alias like `export=` is

This breaks a couple of tests for previous workarounds. Fix in upcoming
commits.

* Basically fixes all the breaks, but needs cleanup

* More notes to myself

* Clean up TODOs

* Call mergeSymbolTable and delete export= afterward

instead of basically copying the code myself.

* More cleanup

* Remove unnecessary check in import type checking

* Revert to DIY code.

It is more correct and will go away in a few days.

* Exported class expressions can be used as type

In both JS and TS

* Do not require named class expressions
2018-04-23 15:24:31 -07:00
Klaus Meinhardt
4827728b16 binder: don't inline generator function's control flow
Fixes: #23565
2018-04-20 16:26:53 +02:00
Sheetal Nandi
ce08af4dfe Merge branch 'master' into requireJson 2018-04-13 15:26:16 -07:00
Ryan Cavanaugh
8294259ec2 Remove all reference comments from compiler/ 2018-04-11 15:38:26 -07:00
Sheetal Nandi
9f724156be Merge branch 'master' into requireJson 2018-04-05 15:18:21 -07:00
TravCav
42d226ca42 isDefaultExport is always false here. 2018-04-05 10:38:51 -04:00
Wesley Wigham
9b987eb947
Dont bind a local symbol for a default export without a name (#23152) 2018-04-04 15:26:10 -07:00
Nathan Shively-Sanders
d3e0929b14
Mark js-assignment functions' symbols as methods (#23078)
This make display more accurate:
1. The functions now print as methods
2. When the type of the function references the class, the type of the
function itself is now printed correctly instead of as `any`.
2018-04-02 12:17:35 -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
61aad4c7b8
Handle toplevel this-assignment (#22913)
Do nothing now. Someday we might handle it correctly.
2018-03-27 12:24:37 -07:00
Wesley Wigham
7721cc45c8
Improve assertion violation message (#22522) 2018-03-22 11:46:52 -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
Anders Hejlsberg
9083f6cf18 Revise binder logic to correctly find 'infer T' containers 2018-03-21 13:23:58 -07:00
Sheetal Nandi
b4e0062b41 Merge branch 'master' into requireJson 2018-03-16 14:46:34 -07:00
Andy
28ff6b6ef3
Store import nodes in SourceFile.imports instead of StringLiteral nodes (#22495)
* Store import nodes in SourceFile.imports instead of StringLiteral nodes

* Change SourceFile#imports storage back

* Code review

* StringLiteral -> StringLiteralLike
2018-03-16 14:01:00 -07:00
Andy
99d5058568
Add 'isPrototypeAccess' helper (#22648)
* Add 'isPrototypeAccess' helper

* Fix type error
2018-03-16 13:27:47 -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
Sheetal Nandi
2071466420 Merge branch 'master' into requireJson 2018-03-08 13:24:59 -08:00
Nathan Shively-Sanders
f8134d0b45 Merge branch 'master' into js-object-literal-assignments-as-declarations 2018-03-08 10:40:55 -08:00
Andy
55bffba5fd
Use getTextOfNode over getTextOfNodeFromSourceText(getSourceFileOfNode(node)) (#22387) 2018-03-08 07:52:35 -08:00
Andy
2676786e7f
Add 'isNamedDeclaration' helper to reduce casts (#22089)
* Add 'isNamedDeclaration' helper to reduce casts

* Add assertion

* Remove assertion
2018-03-08 07:50:25 -08:00
Nathan Shively-Sanders
239f214b1c Address PR comments
1. Add documentation
2. Better organisation of concerns in utility functions
3. Better handling of module.exports and exports in the binder's new
code.
2018-03-07 16:26:29 -08:00
Nathan Shively-Sanders
d86440f94f Merge branch 'master' into js-object-literal-assignments-as-declarations 2018-03-07 14:51:55 -08:00
Andy
5e593acad9
Avoid cast by providing type predicate to isExternalModuleAugmentation (#22119)
* Avoid cast by providing type predicate to isExternalModuleAugmentation

* Break into isExternalModuleAugmentation and isModuleAugmentationExternal
2018-03-06 07:27:36 -08:00
Wesley Wigham
10e3b73330
Debug assert on parent rebind, mitigate circularity in symbol access checking (#22282)
* Assert that symbol parents are never rebound to different parents

* mitigate circularities in symbol accessibility checking
2018-03-01 16:49:42 -08:00
Wesley Wigham
7a31192ecb
Stop binding type predicate types twice (#22210) 2018-02-28 15:43:13 -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
Sheetal Nandi
3572fad981 Bind and resolve the module for json file 2018-02-23 13:59:54 -08:00
Nathan Shively-Sanders
aa6b76fb6f Merge branch 'master' into js-object-literal-assignments-as-declarations 2018-02-23 09:24:32 -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
d55aa22d15 Code cleanup 2018-02-22 11:19:44 -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
Andy
8a52eade2e
Make getTextOfIdentifierOrLiteral and getEscapedTextOfIdentifierOrLiteral only accept Identifier | StringLiteralLike | NumericLiteral (#22002) 2018-02-21 11:05:43 -08:00
Nathan Shively-Sanders
01f2ee3d1f Set up structure of prototype assignments
No actual binding happens yet though
2018-02-20 16:03:54 -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
ad43240ff0 Merge branch 'master' into js-object-literal-assignments-as-declarations 2018-02-20 09:14:36 -08:00
Nathan Shively-Sanders
518f651656 Remove assert hit by chrome devtools+update baselines
Just return undefined instead. Gets rid of many errors in chrome
devtools
2018-02-20 08:48:04 -08:00
Andy
b3edc8f9f4
Apply 'no-unnecessary-type-assertion' lint rule (#22005)
* Apply 'no-unnecessary-type-assertion' lint rule

* Fix type error

* Fix tsconfig.json

* Add --format back
2018-02-16 18:38:00 -08:00
Nathan Shively-Sanders
54a89ac026 Simplify bindPropertyAssignment inner loop 2018-02-15 12:25:55 -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
0191b70d62 Further cleanup 2018-02-15 09:54:55 -08:00
Nathan Shively-Sanders
d2b933e0d6 Cleanup in binder: rename and move 2018-02-15 09:36:48 -08:00
Nathan Shively-Sanders
4fdef85608 Naming and duplication cleanup 2018-02-15 09:13:06 -08:00