9234 Commits

Author SHA1 Message Date
Nathan Shively-Sanders
7e115bbbef Use correct this in tuple type parameter constraints
Instantiate this in tuple types used as type parameter constraints
2016-08-09 12:44:08 -07:00
Andy Hanson
4f54c6c228 Fix loop over array to use for-of instead of for-in 2016-08-09 06:55:21 -07:00
Anders Hejlsberg
3f1ec7ad4b Merge pull request #10216 from Microsoft/structurallyIdenticalInstanceof
Improve instanceof with structurally identical types
2016-08-08 22:14:50 -07:00
Anders Hejlsberg
5ebfad6e4a Introduce isTypeInstanceOf function 2016-08-08 17:40:27 -07:00
Anders Hejlsberg
624e52e834 Improve instanceof for structurally identical types 2016-08-08 16:40:59 -07:00
Ryan Cavanaugh
40f0c6018d use transpileModule 2016-08-08 15:36:38 -07:00
Yui
3f6aa3f3f0 Fix 10076: Fix Tuple Destructing with "this" (#10208)
* Call checkExpression eventhough there is no appropriate type from destructuring of array

* Add tests and baselines
2016-08-08 14:45:29 -07:00
Yui
0cfeaaffb5 [Release 2.0] fix10179: 2.0 emits optional class properties defined in constructors, which breaks compatibility (#10212)
* Do not emit "?" for in property declaration in .d.ts when the property is declared as optional parameter property declaration

* Update baselines
2016-08-08 14:45:01 -07:00
Ryan Cavanaugh
53d54c2b28 Make baselines faster by not writing out unneeded files 2016-08-08 14:30:27 -07:00
Ryan Cavanaugh
e724e883e6 Duh 2016-08-08 13:31:45 -07:00
Ryan Cavanaugh
ce7f554090 Speed up fourslash tests 2016-08-08 13:15:25 -07:00
Anders Hejlsberg
8ea90ab28b Merge pull request #10194 from Microsoft/fixInstanceofNarrowing
Fix instanceof narrowing
2016-08-08 11:51:34 -07:00
Anders Hejlsberg
f6a850b988 Merge pull request #10188 from Microsoft/discriminantPropertyCheck
Discriminant property checks
2016-08-08 11:49:33 -07:00
Anders Hejlsberg
a0c5608770 Update comment 2016-08-08 09:44:24 -07:00
Nathan Shively-Sanders
acfdfe0560 Merge pull request #10103 from Microsoft/narrowing-a-type-parameter-intersects-concrete-types
Correctly narrow unconstrained type parameters
2016-08-08 09:22:32 -07:00
Nathan Shively-Sanders
5f665ad353 Merge pull request #9996 from joshaber/patch-1
Add `find` and `findIndex` to ReadonlyArray
2016-08-08 09:11:09 -07:00
Nathan Shively-Sanders
2845d2f8b8 Improve naming and documentation from PR 2016-08-08 09:04:46 -07:00
Nathan Shively-Sanders
e25db39ab4 Merge branch 'master' into narrowing-a-type-parameter-intersects-concrete-types 2016-08-08 08:42:28 -07:00
Anders Hejlsberg
01f865dee7 Fix instanceof operator narrowing issues 2016-08-07 07:48:40 -07:00
Godfrey Chan
cc2dc3acb0 Emit more efficient/concise "empty" ES6 ctor
When there are property assignments in a the class body of an inheriting
class, tsc current emit the following compilation:

```ts
class Foo extends Bar {
  public foo = 1;
}
```

```js
class Foo extends Bar {
  constructor(…args) {
    super(…args);
    this.foo = 1;
  }
}
```

This introduces an unneeded local variable and might force a reification
of the `arguments` object (or otherwise reify the arguments into an
array).

This is particularly bad when that output is fed into another transpiler
like Babel. In Babel, you get something like this today:


```js
var Foo = (function (_Bar) {
  _inherits(Foo, _Bar);

  function Foo() {
    _classCallCheck(this, Foo);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _Bar.call.apply(_Bar, [this].concat(args));
    this.foo = 1;
  }

  return Foo;
})(Bar);
```

This causes a lot of needless work/allocations and some very strange
code (`.call.apply` o_0).

Admittedly, this is not strictly tsc’s problem; it could have done a
deeper analysis of the code and optimized out the extra dance. However,
tsc could also have emitted this simpler, more concise and semantically
equivalent code in the first place:


```js
class Foo extends Bar {
  constructor() {
    super(…arguments);
    this.foo = 1;
  }
}
```

Which compiles into the following in Babel:

```js
var Foo = (function (_Bar) {
  _inherits(Foo, _Bar);

  function Foo() {
    _classCallCheck(this, Foo);

    _Bar.apply(this, arguments);
    this.foo = 1;
  }

  return Foo;
})(Bar);
```

Which is well-optimized (today) in most engines and much less confusing
to read.

As far as I can tell, the proposed compilation has exactly the same
semantics as before.

Fixes #10175
2016-08-06 23:24:44 -07:00
Anders Hejlsberg
37e96b3a06 Stricter check for discriminant properties in type guards 2016-08-06 09:01:35 -07:00
gcnew
46f5e5fad1 Surface noErrorTruncation option 2016-08-06 01:23:31 +03:00
Wesley Wigham
269b828538 Fix lssl task (#9967) 2016-08-05 14:16:29 -07:00
Yui
8830d7691e Port PR#9867 to Release-2.0 (#10147)
* Change the shape of the shim layer to support getAutomaticTypeDirectives

* Change the key for looking up automatic type-directives

* Update baselines from change look-up name of type-directives

* Add @currentDirectory into the test

* Update baselines

* Fix linting error

* Address PR: fix spelling mistake

* Instead of return path of the type directive names just return type directive names
2016-08-05 14:00:40 -07:00
Nathan Shively-Sanders
cabd276ddc Fix more lint 2016-08-05 10:28:03 -07:00
Yui
ceab31cf0d Port PR #10016 to Master (#10100)
* Treat namespaceExportDeclaration as declaration

* Update baselines

* wip - add tests

* Add tests

* Show "export namespace" for quick-info
2016-08-05 10:12:01 -07:00
Nathan Shively-Sanders
8f638f7ecd Fix lint 2016-08-05 09:58:30 -07:00
Nathan Shively-Sanders
798be6f4f9 Add new test baseline and delete else in binder
The extra `else` caused a ton of test failures!
2016-08-04 15:17:08 -07:00
Vladimir Matveev
0a1ec43de0 addref in all configured projects that contain the file 2016-08-04 14:46:00 -07:00
Andy Hanson
9947ac2ece Don't allow properties inherited from Object to be automatically included in TSX attributes 2016-08-04 14:13:07 -07:00
Nathan Shively-Sanders
3c32478b8f Support other (new) literal types in jsdoc 2016-08-04 13:01:17 -07:00
Nathan Shively-Sanders
4c3529680d Merge branch 'master' into jsdoc-string-literal-types 2016-08-04 09:52:15 -07:00
Yui
10b36abc8f [Release-2.0] Fix 9662: Visual Studio 2015 with TS2.0 gives incorrect @types path resolution errors (#9867)
* Change the shape of the shim layer to support getAutomaticTypeDirectives

* Change the key for looking up automatic type-directives

* Update baselines from change look-up name of type-directives

* Add @currentDirectory into the test

* Update baselines

* Fix linting error

* Address PR: fix spelling mistake

* Instead of return path of the type directive names just return type directive names
2016-08-04 07:43:54 -07:00
Andy Hanson
0aaec56b8f Add a helper function getOrUpdateProperty to prevent unprotected access to Maps. 2016-08-04 06:04:41 -07:00
Andy
0a8afc91f6 Merge pull request #10115 from Microsoft/export_specifiers_map
Add a helper function `getOrUpdateProperty` to prevent unprotected access to Maps.
2016-08-04 05:54:34 -07:00
Anders Hejlsberg
14f0aa0ace Merge pull request #10118 from Microsoft/limitTypeGuardAssertions
Limit "type guards as assertions" behavior
2016-08-03 14:59:19 -07:00
Nathan Shively-Sanders
38ee13cc32 Fix newline lint 2016-08-03 14:38:05 -07:00
Nathan Shively-Sanders
045b51a8ef Use {} type facts for unconstrained type params
Previously it was using TypeFacts.All. But the constraint of an
unconstrained type parameter is actually {}.
2016-08-03 14:36:05 -07:00
Vladimir Matveev
c0bcf8f10c release cached tree in compilation settings change 2016-08-03 14:02:37 -07:00
Nathan Shively-Sanders
8c01efba04 Allow JS multiple declarations of ctor properties
When a property is declared in the constructor and on the prototype of
an ES6 class, the property's symbol is discarded in favour of the
method's symbol. That because the usual use for this pattern is to bind
an instance function: `this.m = this.m.bind(this)`. In this case the
type you want really is the method's type.
2016-08-03 10:33:10 -07:00
Anders Hejlsberg
12eb57c4d0 Fix linting error 2016-08-03 10:15:00 -07:00
Anders Hejlsberg
7ab6e11aaf Limit type guards as assertions to incomplete types in loops 2016-08-03 10:00:37 -07:00
Andy Hanson
204f2c16c0 Add a helper function getOrUpdateProperty to prevent unprotected access to Maps. 2016-08-03 09:01:40 -07:00
Andy Hanson
359c8b12ef Don't allow ".d.ts" extension in an import either. 2016-08-03 07:18:48 -07:00
Nathan Shively-Sanders
4189b4d718 Narrowing type parameter intersects w/narrowed types
This makes sure that a union type that includes a type parameter is
still usable as the actual type that the type guard narrows to.
2016-08-02 16:10:20 -07:00
Andy Hanson
7908257ab7 Fix lint error 2016-08-02 13:18:46 -07:00
Yui
126c1eeb59 [Release-2.0] fix 9802: fix language service for UMD module alias (#10016)
* Treat namespaceExportDeclaration as declaration

* Update baselines

* wip - add tests

* Add tests

* Show "export namespace" for quick-info
2016-08-02 13:01:05 -07:00
Andy Hanson
6814a9fac6 Rename function 2016-08-02 12:41:22 -07:00
Andy Hanson
dc192238cc Use recursion, and fix error for undefined node 2016-08-02 12:37:30 -07:00
Wesley Wigham
0eeb9cbd0c Fix #10083 - allowSyntheticDefaultImports alters getExternalModuleMember (#10096) 2016-08-02 12:34:23 -07:00