Commit graph

511 commits

Author SHA1 Message Date
Mohamed Hegazy ce16f0af03 Update version 2016-09-01 14:35:41 -07:00
Kanchalai Tanglertsampan 3ed8bca8db Merge branch 'master' into release-2.0 2016-08-25 16:15:30 -07:00
Nathan Shively-Sanders c0309fa78e Fix crash when checking module exports for export=
Also make maxNodeModuleJsDepth default to 0 so that incorrect tsconfigs
now let the compiler spend less time compiling JS that is found in
node_modules (especially since most people will already have the d.ts
and want ignore the JS anyway). jsconfig still defaults to 2.
2016-08-25 09:21:31 -07:00
Yui 234b3bb9ff Merge master 08/22 (#10487)
* Add test case for #8229

* Do not report errors during contextual typecheck
Fixes #8229

* Handle the scenario when let [a=undefined]=[]

* Instantiate contextual this parameters if needed

* Test that contextually typed generic this parameters are instantiated

* Don't allow `.ts` to appear in an import

* Add specific error message for unwanted '.ts' extension

* Allow `await` in a simple unary expression

* More tests

* Forbid `await await`

* Allow `await await`

* Improve error message

* Don't allow ".d.ts" extension in an import either.

* Rename 'find' functions

* Assign and instantiate contextual this type if not present

* JSDoc supports null, undefined and never types

* Update baselines in jsDocParsing unit tests

* Return non-JsDocComment children
... to make syntactic classification work

* Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeScriptExtensions and rename

* Fix comment

* Treat special property access symbol differently
... when retriving documentation

* Fix tests

* Update shim version to be 2.1 (#10424)

* Check return code paths on getters (#10102)

* Check return paths on getters

* Remove TODO comment

* Remove extraneous arguments from harness's runBaseline (#10419)

* Remove extraneous arguments from runBaseline

* Address comments from @yuit

* Remove needless call to basename

* Refactor baseliners out of compiler runner (#10440)

* CR feedback

* fix broken tests

* Pass in baselineOpts into types baselines so that RWC baselines can be written to internal folder (#10443)

* Add more test for 10426

* routine update of dom libs

* Add test for jsdoc syntactic classification for function declaration

* Simplify implementation

* Tolerate certain errors in tsconfig.json

* Add test for configFile error tolerance

* Use TS parser to tolerate more errors in tsconfig.json

* Implement tuple types as type references to synthesized generic types

* Add comments + minor changes

* Accept new baselines

* Add .types extension

* Properly guard for undefined in getTypeReferenceArity

* Add jsdoc nullable union test case to fourslash

* Fix class/interface merging issue + lint error

* Allow "typings" in a package.json to be missing its extension (but also allow it to have an extension)

* Contextually type this in getDeclFromSig, not checkThisExpr

* Update parser comment with es7 grammar (#10459)

* Use ES7 term of ExponentiationExpression

* Update timeout for mac OS

* Address PR: add space

* allowSyntheticDefaultImports resolves to modules instead of variables

Fixes #10429 by improving the fix in #10096

* Rename getContextuallyTypedThisParameter to getContextualThisParameter

* Fix 10472: Invalid emitted code for await expression (#10483)

* Properly emit await expression with yield expression

* Add tests and update baselines

* Move parsing await expression into parse unary-expression

* Update incorrect comment
2016-08-22 17:04:49 -07:00
Andy Hanson 92eb8df68c Allow "typings" in a package.json to be missing its extension (but also allow it to have an extension) 2016-08-22 13:03:49 -07:00
Yui 7b6846d1c1 Merge master to release-2.0 on 08/19 (#10444)
* Add test case for #8229

* Do not report errors during contextual typecheck
Fixes #8229

* Handle the scenario when let [a=undefined]=[]

* Don't allow `.ts` to appear in an import

* Add specific error message for unwanted '.ts' extension

* Allow `await` in a simple unary expression

* More tests

* Forbid `await await`

* Allow `await await`

* Improve error message

* Don't allow ".d.ts" extension in an import either.

* Rename 'find' functions

* Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeScriptExtensions and rename

* Fix comment

* Treat special property access symbol differently
... when retriving documentation

* Fix tests

* Update shim version to be 2.1 (#10424)

* Check return code paths on getters (#10102)

* Check return paths on getters

* Remove TODO comment

* Remove extraneous arguments from harness's runBaseline (#10419)

* Remove extraneous arguments from runBaseline

* Address comments from @yuit

* Remove needless call to basename

* Refactor baseliners out of compiler runner (#10440)

* CR feedback

* fix broken tests

* Pass in baselineOpts into types baselines so that RWC baselines can be written to internal folder (#10443)
2016-08-19 17:55:27 -07:00
Andy Hanson 297cb50cbf Merge branch 'master' into no_ts_extension 2016-08-19 06:11:46 -07:00
Mohamed Hegazy 78f259340a Merge branch 'master' into release-2.0 2016-08-18 16:17:18 -07:00
Mohamed Hegazy b10c2baaf3 Update version to 2.0.2 2016-08-18 14:53:04 -07:00
Yui 1d9124eb7c [Release-2.0] Merge master into Release-2.0 (#10347)
* Change getUnionType to default to no subtype reduction

* Remove unnecessary subtype reduction operations

* Use binary searching in union types to improve performance

* Optimize type inference

* Fixed broken singleAsteriskRegex. Fixes #9918 (#9920)

* Lock ts-node to 1.1.0 while perf issue is investigated (#9933)

* Fix typo in comment for MAX_SAFE_INTEGER

* In ts.performance.now, bind window.performance.now

Using an arrow function. Previously, it was set directly to
window.performance.now, which fails when used on Chrome.

* Add lint enforcing line endings (#9942)

* Add servicesSources to the list of prerequisites for running tests

* Support emitting static properties for classes with no name

* Add assertion whitespace lint rule (#9931)

* Add assertion whitespace lint rule

* Fix typo

* Add the word `Rule` to Jakefile

* Limit travis build matrix (#9968)

* Convert getErrorBaseline to use canonical diagnostic formatting (#9708)

* Convert getErrorBaseline to use canonical diagnostic formatting

* Fix lint

* Found another clone of format diagnostic - consolidate

* Fully declone

* Unify nodeKind implementations for navigationBar and navigateTo

* Fix test and rename a function

* Fix lint errors

* Remove hardcoded port, use the custom port

* Unlock ts-node version (#9960)

* Allow an abstract class to appear in a local scope

* JSDoc understands string literal types

Unfortunately, I didn't find a way to reuse the normal string literal
type, so I had to extend the existing JSDoc type hierarchy. Otherwise,
this feature is very simple.

* Update baselines to be current

* Add find and findIndex to ReadonlyArray

* The optional this should be readonly too.

* Update baseline source location

* Re-add concat overload to support inferring tuples

* Update baselines with new concat overload

* Update LastJSDoc[Tag]Node

* Display enum member types using qualified names

* Accept new baselines

* Fix lint error

* null/undefined are allowed as index expressions

`null` and `undefined` are not allowed with `--strictNullChecks` turned
on. Previously, they were disallowed whether or not it was on.

* Use correct nullable terminology

* Get rid of port parameter

* Remove [port] in usage message

* Properly reset type guards in loops

* Add regression test

* Introduce the `EntityNameExpression` type

* Allow `export =` and `export default` to alias any EntityNameExpression, not just identifiers.

* Lint tests helper files

* recreate program if baseUrl or paths changed in tsconfig

* Simplify some code

* Have travis use a newer image for the OSX build (#10034)

Suggested by travis support for stopping the randomly-halting-builds issue.

* Correctly check for ambient class flag

* Use "best choice type" for || and ?: operators

* jsx opening element formatting

* change error message for unused parameter property

fix

* Fix issue related to this and #8383

* Add additional tests

* Accept new baselines

* Provide `realpath` for module resolution in LSHost

* Add test

* Add test baselines

* Accept new baselines

* CR feedback

* Remove `SupportedExpressionWithTypeArguments` type; just check that the expression of each `ExpressionWithTypeArguments` is an `EntityNameExpression`.

* Fix bug

* Fix #10083 - allowSyntheticDefaultImports alters getExternalModuleMember (#10096)

* Use recursion, and fix error for undefined node

* Rename function

* Fix lint error

* 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.

* Add a helper function `getOrUpdateProperty` to prevent unprotected access to Maps.

* Limit type guards as assertions to incomplete types in loops

* Accept new baselines

* Fix linting error

* 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.

* Use {} type facts for unconstrained type params

Previously it was using TypeFacts.All. But the constraint of an
unconstrained type parameter is actually {}.

* Fix newline lint

* Test that declares conflicting method first

* [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

* Remove unused reference files: these tests produce erros so they will not produce these files (#9233)

* Add string-literal completion test for jsdoc

* Support other (new) literal types in jsdoc

* Don't allow properties inherited from Object to be automatically included in TSX attributes

* Add new test baseline and delete else in binder

The extra `else` caused a ton of test failures!

* Fix lint

* Port PR #10016 to Master (#10100)

* Treat namespaceExportDeclaration as declaration

* Update baselines

* wip - add tests

* Add tests

* Show "export namespace" for quick-info

* Fix more lint

* Try using runtests-parallel for CI (#9970)

* Try using runtests-parallel for CI

* Put worker count setting into .travis.yml

* Reduce worker count to 4 - 8 wasnt much different from 4-6 but had contention issues causing timeouts

* Fix lssl task (#9967)

* Surface noErrorTruncation option

* Stricter check for discriminant properties in type guards

* Add tests

* 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

* Fix instanceof operator narrowing issues

* Accept new baselines

* Add regression test

* Improve naming and documentation from PR

* Update comment

* Add more tests

* Accept new baselines

* Reduce worker count to 3 (#10210)

Since we saw a starvation issue on one of @sandersn's PRs.

* Speed up fourslash tests

* Duh

* Make baselines faster by not writing out unneeded files

* Fix non-strict-compliant test

* Fix 10076: Fix Tuple Destructing with "this" (#10208)

* Call checkExpression eventhough there is no appropriate type from destructuring of array

* Add tests and baselines

* use transpileModule

* Remove use strict

* Improve instanceof for structurally identical types

* Introduce isTypeInstanceOf function

* Add test

* Accept new baselines

* Fix loop over array to use for-of instead of for-in

* Use correct this in tuple type parameter constraints

Instantiate this in tuple types used as type parameter constraints

* Add explanatory comment to resolveTupleTypeMembers

* Ignore null, undefined, void when checking for discriminant property

* Add regression test

* Delay tuple type constraint resolution

Create a new tuple that stores the this-type.

* Always use thisType when generating tuple id

* Optimize format of type list id strings used in maps

* Make ReadonlyArray iterable.

* Allow OSX to fail while we investigate (#10255)

The random test timeouts are an issue.

* avoid using the global name

* Fix single-quote lint

* Optimize performance of maps

* Update API sample

* Fix processDiagnosticMessages script

* Have travis take shallow clones of the repo (#10275)

Just cloning TS on travis takes 23 seconds on linux (68 seconds on mac), hopefully having it do a shallow clone will help.

We don't rely on any tagging/artifacts from the travis servers which clone depth could impact, so this shouldn't impact anything other than build speed.

* Add folds to travis log (#10269)

* Optimize filterType to only call getUnionType if necessary

* Add shorthand types declaration for travis-fold (#10293)

* Optimize getTypeWithFacts

* Filter out nullable and primitive types in isDiscriminantProperty

* Fix typo

* Add regression tests

* Optimize core filter function to only allocate when necessary

* Address CR comments + more optimizations

* Faster path for creating union types from filterType

* Allow an @types direcotry to have a package.json which specifies `"typings": null` to disclude it from automatically included typings.

* Lint

* Collect timing information for commands running on travis (#10308)

* Simplifies performance API

* Use 'MapLike' instead of 'Map' in 'preferConstRule.ts'.

* narrow from 'any' in most situations

instanceof and user-defined typeguards narrow from 'any' unless the narrowed-to type is exactly 'Object' or 'Function'. This is a breaking change.

* Update instanceof conformance tests

* accept new baselines

* add tests

* accept new baselines

* Use lowercase names for type reference directives

* Use proper response codes in web tests

* Treat ambient shorthand declarations as explicit uses of the `any` type

* Parallel linting (#10313)

* A perilous thing, a parallel lint

* Use work queue rather than scheduling work

* Dont read files for lint on main thread

* Fix style

* Fix the style fix (#10344)

* Aligned mark names with values used by ts-perf.

* Use an enum in checkClassForDuplicateDeclarations to aid readability

* Rename to Accessor

* Correctly update package.json version

* Migrated more MapLikes to Maps

* Add ES2015 Date constructor signature that accepts another Date (#10353)

* Parameters with no assignments implicitly considered const

* Add tests

* Migrate additional MapLikes to Maps.

* Fix 10625: JSX Not validating when index signature is present  (#10352)

* Check for type of property declaration before using index signature

* Add tests and baselines

* fix linting error

* Adding more comments

* Clean up/move some Map helper functions.

* Revert some formatting changes.

* Improve ReadonlyArray<T>.concat to match Array<T>

The Array-based signature was incorrect and also out-of-date.

* Fix link to blog

* Remove old assertion about when we're allowed to use fileExists

* Set isNewIdentifierLocation to true for JavaScript files

* Update error message for conflicting type definitions

Fixes #10370

* Explain why we lower-case type reference directives

* Correctly merge bindThisPropertyAssignment

Also simply it considerably after noticing that it's *only* called for
Javascript files, so there was a lot of dead code for TS cases that
never happened.

* Fix comment

* Property handle imcomplete control flow types in nested loops

* Update due to CR suggestion

* Add regression test

* Fix 10289: correctly generate tsconfig.json with --lib (#10355)

* Separate generate tsconfig into its own function and implement init with --lib

# Conflicts:
#	src/compiler/tsc.ts

* Add tests and baselines; Update function name

Add unittests and baselines
Add unittests and baselines for generating tsconfig

Move unittest into harness folder

Update harness tsconfig.json

USe correct function name

* Use new MapLike interstead. Update unittest

# Conflicts:
#	src/compiler/commandLineParser.ts

* Update JakeFile

* Add tests for incorrect cases

* Address PR : remove explicity write node_modules

* Add more tests for `export = foo.bar`.

* Output test baselines to tests/baselines/local instead of root
2016-08-18 14:49:09 -07:00
Yui da8fc5d5a9 Fix 10289: correctly generate tsconfig.json with --lib (#10355)
* Separate generate tsconfig into its own function and implement init with --lib

# Conflicts:
#	src/compiler/tsc.ts

* Add tests and baselines; Update function name

Add unittests and baselines
Add unittests and baselines for generating tsconfig

Move unittest into harness folder

Update harness tsconfig.json

USe correct function name

* Use new MapLike interstead. Update unittest

# Conflicts:
#	src/compiler/commandLineParser.ts

* Update JakeFile

* Add tests for incorrect cases

* Address PR : remove explicity write node_modules
2016-08-17 15:23:28 -07:00
Andy Hanson c42f1cb0d0 Explain why we lower-case type reference directives 2016-08-17 06:21:49 -07:00
Andy ef4fefc197 Merge pull request #10340 from Microsoft/lower_case_types
Use lowercase names for type reference directives
2016-08-17 06:04:14 -07:00
Ron Buckton 11c5c4ee8e Merge pull request #10359 from Microsoft/optimizeMoreMaps
Migrate more MapLikes to Maps
2016-08-16 20:11:35 -07:00
Ryan Cavanaugh a36e15558e Update error message for conflicting type definitions
Fixes #10370
2016-08-16 14:04:02 -07:00
Ron Buckton 7f0a02ff02 Migrated more MapLikes to Maps 2016-08-15 15:03:55 -07:00
Ron Buckton 4e04b75d4b Aligned mark names with values used by ts-perf. 2016-08-15 11:07:49 -07:00
Andy Hanson 54735edc72 Use lowercase names for type reference directives 2016-08-15 07:40:25 -07:00
Andy Hanson 3de8c22196 Merge branch 'master' into no_ts_extension 2016-08-15 07:18:34 -07:00
Ron Buckton c81624435a Simplifies performance API 2016-08-12 16:34:35 -07:00
Anders Hejlsberg 87393e026e Merge branch 'master' into optimizeMaps 2016-08-12 13:31:37 -07:00
Andy Hanson df739fdd50 Allow an @types direcotry to have a package.json which specifies "typings": null to disclude it from automatically included typings. 2016-08-12 08:13:39 -07:00
Anders Hejlsberg 65e1293b2e Optimize performance of maps 2016-08-10 16:47:06 -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
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 359c8b12ef Don't allow ".d.ts" extension in an import either. 2016-08-03 07:18:48 -07:00
Andy Hanson 2821d98265 Merge branch 'master' into no_ts_extension 2016-08-02 06:18:53 -07:00
Yuichi Nukiyama 7224f22975 throw error when paths option mapping empty array
fix
2016-07-23 15:05:36 +09:00
Yui a0406c777f Port Fix 9894 to master (#9896)
* Add tests and baselines

* Addess PR: get the first non-ambient external module file

* Rename test file and update baseline

* Add tests and baselines

* Update baselines
2016-07-22 15:41:52 -07:00
Yui bd6d2c0251 [Release-2.0] Fix 9829 : do not report error using import, export, module augmentation in d.t.s (#9894)
* Only error in non-declaration file

* Add tests and baselines

* Addess PR: get the first non-ambient external module file

* Rename test file and update baseline

* Add tests and baselines

* Update baselines
2016-07-22 10:16:00 -07:00
Andy Hanson 448a480aa8 Don't allow .ts to appear in an import 2016-07-21 13:42:49 -07:00
Wesley Wigham 2a26beb9d8 Add performance framework from transforms branch (#9536)
* Port performance tools from transforms branch

* Use friendlier names, add compiler option to print all recorded measures

* Always print total time

* + -> .getTime
2016-07-19 15:10:29 -07:00
Vladimir Matveev af0c548312 Merge pull request #9750 from Microsoft/fixFormatDiagnostics
use sys based host for formatting diagnostics
2016-07-15 12:35:03 -07:00
Vladimir Matveev 2da6846557 use sys based host for formatting diagnostics 2016-07-14 23:02:56 -07:00
Alex Eagle 62f49c3b7e use getNewLine from host rather than sys 2016-07-13 15:25:31 -07:00
Alex Eagle 05fbe7cddd use getNewLine from host rather than sys 2016-07-13 15:25:15 -07:00
Alex Eagle e28acd3c1f Add formatDiagnostics utility 2016-07-13 14:22:16 -07:00
Andy 1546974ea6 Merge pull request #9676 from Microsoft/relative_module
Treat "." and ".." as relative module names
2016-07-13 12:18:14 -07:00
Alex Eagle 34e81f2805 Add formatDiagnostics utility 2016-07-13 11:15:09 -07:00
Andy Hanson c90897ccdd Treat "." and ".." as relative module names 2016-07-13 06:51:00 -07:00
Yui 48ab0ce07f Change version to 2.1.0 (#9615) 2016-07-11 20:53:12 -07:00
Nathan Shively-Sanders f19844fbe9 Merge pull request #9580 from Microsoft/compile-with-noImplicitThis
Compile with --noImplicitThis
2016-07-11 15:25:44 -07:00
Nathan Shively-Sanders 6414a5721c Remove another use of this, in program.ts 2016-07-11 13:49:36 -07:00
Bill Ticehurst 5f6eb5bb12 Removed duplicate logic
(cherry picked from commit 21bf801c6c)
2016-07-11 09:11:48 -07:00
Bill Ticehurst 5eba2e09fb Fixed the node tracking and a harness bug
(cherry picked from commit 2ab1143f1c)
2016-07-11 09:11:46 -07:00
Bill Ticehurst b360ad5f3c Fix module tracking
(cherry picked from commit ca874bdd17)
2016-07-11 09:11:45 -07:00
Bill Ticehurst 21bf801c6c Removed duplicate logic 2016-07-10 23:07:45 -07:00
Bill Ticehurst 2ab1143f1c Fixed the node tracking and a harness bug 2016-07-10 20:54:07 -07:00
Bill Ticehurst ca874bdd17 Fix module tracking 2016-07-10 16:12:42 -07:00
Nathan Shively-Sanders b543074861 Compile with --noImplicitThis
1. Add to various tsconfig.json
2. Add to Jakefile
3. Add annotations where needed.
4. Add workaround to shims.ts, which uses toplevel `this`.
2016-07-08 15:13:32 -07:00