Commit graph

664 commits

Author SHA1 Message Date
Andy Hanson
c958c47ef5 Merge branch 'master' into map4 2016-10-26 11:05:51 -07:00
Andy Hanson
9130fbd731 Merge branch 'master' into refactor_module_resolution 2016-10-26 08:27:34 -07:00
Andy Hanson
07bb2582b6 Don't require resolvedTsFileName and resolvedJsFileName, just resolvedFileName and extension. Also, change search order to do all TS searching before searching for JS. 2016-10-26 08:13:58 -07:00
Jason Ramsay
1b16c0b94b For JavaScript files, we report semantic errors for using TypeScript-only constructs from within a JavaScript file as syntactic errors. 2016-10-25 18:09:04 -07:00
Vladimir Matveev
7890f63250 use unresolved imports as a source of used typings (#11828) 2016-10-25 15:24:21 -07:00
Andy Hanson
040942f2b2 Merge branch 'master' into includes_glob 2016-10-25 08:19:37 -07:00
Andy Hanson
1b15646c41 Simplify isImplicitGlob test 2016-10-25 08:13:07 -07:00
Ryan Cavanaugh
95670c6251 Perform a useful comparison. Fixes #11805 2016-10-24 10:14:41 -07:00
Andy Hanson
5e7e5421fa Add noop, notImplemented, and notYetImplemented helpers 2016-10-19 14:21:48 -07:00
Andy Hanson
a11838215c Merge branch 'master' into map4 2016-10-19 13:16:55 -07:00
Andy Hanson
1d201c1add Merge branch 'master' into refactor_module_resolution 2016-10-19 09:20:45 -07:00
Andy Hanson
7c53a1deb2 Instead of getResolutionOrDiagnostic, use getResolutionDiagnostic and avoid using resolution.resolvedFileName if the diagnostic is defined. 2016-10-18 14:22:43 -07:00
Andy Hanson
7685e6af15 Forbid unused locals/parameters in compiler 2016-10-18 14:00:52 -07:00
Andy Hanson
64e8221a44 Use single concat call instead of repeated calls 2016-10-18 08:18:01 -07:00
Andy Hanson
b557211a37 Return both ts and js results from module resolution, and don't have moduleNameResolver responsible for omitting files based on compiler options 2016-10-18 07:09:43 -07:00
Andy Hanson
7292f9f67e Merge branch 'master' into map4 2016-10-17 06:49:53 -07:00
Andrej Baran
17d60d5d8f Merged master into es2017-target 2016-10-15 08:31:22 +02:00
Mohamed Hegazy
2920f82804 Add error reporting for using --noImplicitUseStrict with --options.alwaysStrict 2016-10-13 16:54:09 -07:00
Andrej Baran
a500fd9211 Merge branch 'master' into es2017-target 2016-10-13 14:02:54 +02:00
Andrej Baran
b871b5353c Favor use of ES2015 instead of ES6 2016-10-13 13:32:00 +02:00
Andy Hanson
e8c7224eac Merge branch 'master' into map4 2016-10-12 08:50:49 -07:00
Andy Hanson
14701e3067 Respond to some PR comments 2016-10-11 13:44:20 -07:00
Andy
d34916abf8 Merge pull request #11448 from Microsoft/fix_array_condition
Fix array conditional
2016-10-07 10:03:06 -07:00
Andy Hanson
a4f610df82 Inline calculation of resolvedPath 2016-10-07 08:41:23 -07:00
Andy Hanson
13a8dc11b0 Fix array conditional 2016-10-07 08:35:13 -07:00
Andy Hanson
aadcbcc083 Use native maps when they're available 2016-10-06 13:29:18 -07:00
Vladimir Matveev
bf98d23740 check lib command line option when deciding if program structure can be reused 2016-10-06 05:04:45 -07:00
Vladimir Matveev
8dabe33b32 fix linter (#11366) 2016-10-04 14:00:45 -07:00
Vladimir Matveev
3f2e3919b4 revert versions 2016-09-27 23:36:19 -07:00
Vladimir Matveev
833a46c091 merge with origin/master 2016-09-27 10:22:41 -07:00
Kanchalai Tanglertsampan
7fd5699511 Merge branch 'release-2.0' into release-2.0.5 2016-09-14 16:57:59 -07:00
Mohamed Hegazy
b6aeaab019 Update version 2016-09-14 13:13:34 -07:00
Andy Hanson
0f51bdbb4f Rename function and use directorySeparator variables 2016-09-14 06:21:07 -07:00
Vladimir Matveev
d14183c5a1 merge with origin/release-2.0.5 2016-09-13 15:59:04 -07:00
Andy Hanson
48c67cbdb5 Merge branch 'master' into import_directory 2016-09-13 08:46:49 -07:00
Kanchalai Tanglertsampan
4685646281 Merge branch 'master' of https://github.com/microsoft/TypeScript 2016-09-06 17:14:36 -07:00
Richard Knoll
8f0c7ef6c7 Pass the right host to getEffectiveTyperoots 2016-09-06 12:46:27 -07:00
Kanchalai Tanglertsampan
e1be0bcd4c Merge branch 'master' into mergeMaster_09/01 2016-09-06 11:26:21 -07:00
Richard Knoll
a26d3108c2 Merge remote-tracking branch 'origin/master' into import_completions_pr 2016-09-06 11:04:39 -07:00
Richard Knoll
ed69a8a161 Merge pull request #10692 from Microsoft/import_completions_pr
release 2.0.5 porting import completions pr
2016-09-02 17:55:47 -07:00
Andy Hanson
12ad9d0aaf Search for node_modules in parent directories when getting type roots. 2016-09-02 13:42:43 -07:00
Andy Hanson
2d60a20b6f Default type roots when host.directoryExists is not implemented should be node_modules/@types, not just node_modules 2016-09-02 13:29:51 -07:00
Andy Hanson
cbd00b9a92 Use undefined instead of empty array, and check for existence of "node_modules/@types" instead of just for "node_modules". 2016-09-02 07:31:14 -07:00
Andy Hanson
0e8e5ec3e5 Search up for all node_modules directories available 2016-09-02 07:07:43 -07:00
Kanchalai Tanglertsampan
b5f4c074d6 Merge branch 'master' into mergeMaster_09/01 2016-09-01 16:19:44 -07:00
Vladimir Matveev
852b1d2700 Merge remote-tracking branch 'origin/release-2.0.5' into tsserverVS-WIP 2016-09-01 15:25:40 -07:00
Mohamed Hegazy
ce16f0af03 Update version 2016-09-01 14:35:41 -07:00
Richard Knoll
c742d16ff1 Merge remote-tracking branch 'origin/master' into import_completions_pr 2016-09-01 10:46:21 -07:00
Andy Hanson
22ba111e66 Search for node_modules in parent directories when getting type roots. 2016-09-01 09:25:20 -07:00
Vladimir Matveev
38ce6279cd add tsserver specific resolution pass that will load typings from cache locations if auto discovery is enabled 2016-08-29 22:21:58 -07:00
Vladimir Matveev
7e979746bb merge with origin/release-2.0 2016-08-29 14:13:22 -07:00
Richard Knoll
fb6ff42b93 Reuse effective type roots code in language service 2016-08-26 18:03:20 -07:00
Yui
a370908421 [Transforms] Merge master 08/09 (#10263)
* Improve error message

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

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

* 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

* wip - fix error

* Make ReadonlyArray iterable.

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

The random test timeouts are an issue.

* Fix error from using merging master

* avoid using the global name

* Fix single-quote lint

* Update baselines

* Fix linting

* 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

* Rename 'find' functions

* 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

* 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

* Assign and instantiate contextual this type if not present

* 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

* JSDoc supports null, undefined and never types

* Update baselines in jsDocParsing unit tests

* Restored comments to explain spreading 'arguments' into calls to 'super'.

* Added test.

* Use the non-nullable type of the contextual type for object completions.

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

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

* Output test baselines to tests/baselines/local instead of root

* Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeScriptExtensions and rename

* Fix comment

* Fix RWC Runner (#10420)

* Use /// <reference types

* Don't report an errors if it comes from lib.d.ts

* 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 error message

Add error message when trying to relate primitives to the boxed/apparent
backing types.

* fix linting error

* follow advise

* remove extra code

* Add more test for 10426

* fix some errors

* 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

* change error message

* Fix broken build from merging with master

* Fix linting error
2016-08-26 15:51:10 -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
Zhengbo Li
a082857ae8 Add APIs for enabling CompileOnSave on tsserver (#9837)
* Add API to get only the emited declarations output

* Add nonModuleBuilder

* Add basic tests for CompileOnSaveAffectedFileList API

* Add API for compile single file

* Avoid invoking project.languageService directly

* Add API to query if compileOnSave is enabled for a project

* Seperate check and emit signatures

* Use Path type for internal file name matching and simplifying builder logic

* Always return cascaded affected list

* Correct the tsconfig file in compileOnSave tests
Also move the CompileOnSave option out of compilerOptions

* Reduce string to path conversion
2016-08-23 16:11:52 -07:00
Andy Hanson
0b71f5f661 An import ending in "/" is always an import of a directory. 2016-08-23 13:38:39 -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
Richard Knoll
473be82572 Merge remote-tracking branch 'origin/master' into import_completions_pr 2016-08-19 16:59:48 -07:00
Richard Knoll
cf7feb3faa Responding to PR feedback 2016-08-19 16:49:55 -07:00
Vladimir Matveev
9189846e43 move module resolution to core.ts 2016-08-19 15:44:56 -07:00
Vladimir Matveev
683d6ef6e1 merge with origin/master 2016-08-19 13:15:59 -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
Vladimir Matveev
27deb313cc Merge remote-tracking branch 'origin/master' into tsserver-typings 2016-08-18 14:57:34 -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
Vladimir Matveev
a2e5c2d2b5 merge with origin/master 2016-08-17 14:38:30 -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
Richard Knoll
cc35bd5dca Merge remote-tracking branch 'origin/master' into import_completions_pr 2016-08-15 15:20:22 -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
Vladimir Matveev
9a180122a5 merge with origin/master 2016-08-14 11:42:08 -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
2627e6f3fc [Transforms] Merge master on 08/05 (#10182)
* Fix #10083 - allowSyntheticDefaultImports alters getExternalModuleMember (#10096)

* 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

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

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

* Port PR #10016 to Master (#10100)

* Treat namespaceExportDeclaration as declaration

* Update baselines

* wip - add tests

* Add tests

* Show "export namespace" for quick-info

* Update baselines from merging
2016-08-05 21:45:13 -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
Ron Buckton
ed0a653515 Merge branch 'master' into transforms 2016-08-02 11:45:56 -07:00
Andy Hanson
2821d98265 Merge branch 'master' into no_ts_extension 2016-08-02 06:18:53 -07:00
Richard Knoll
4ca7e95706 Merge remote-tracking branch 'origin/master' into import_completions_feedback 2016-07-28 13:23:33 -07:00
Vladimir Matveev
91b0eea84e Merge remote-tracking branch 'origin/master' into tsserverVS-WIP-mixedcontent 2016-07-26 12:03:52 -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
Vladimir Matveev
c0f4fdd489 merge with origin/master 2016-07-21 10:38:15 -07:00
Ron Buckton
248953ec59 Explicit handling for more nodes in reduceEachChild/visitEachChild 2016-07-20 12:12:07 -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