Skip to content

[Transforms] Merge master 06/14/2016 #9169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 239 commits into from
Jun 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
239 commits
Select commit Hold shift + click to select a range
20d8a94
Remove check narrowing only certain types, add test showing issues wi…
weswigham Feb 25, 2016
a2feb0e
string literal case test
weswigham Mar 11, 2016
92bf91d
Reconcile fix with CFA work
weswigham Apr 26, 2016
73d4aae
Defaultable -> NotNarrowable to align with use
weswigham Apr 26, 2016
70733da
Missed a defaultable in comments
weswigham Apr 26, 2016
a80529b
Add test for narrowing to unions of string literals
weswigham Apr 26, 2016
21587aa
Rewrite isInStringLiteral to accomodate for unterminated strings
mhegazy May 2, 2016
0a277a1
Refactor signatureHelp to expose helper functions
mhegazy May 2, 2016
060f2a8
Add support for completion in string literals
mhegazy May 2, 2016
7b0d664
Remove unused check
mhegazy May 2, 2016
4464a41
Merge branch 'master' into stringLiteralCompletions
mhegazy May 3, 2016
291ad33
Use const instead of let
mhegazy May 3, 2016
e5a32b7
Fix error
mhegazy May 3, 2016
02f30ff
Formatting changes
mhegazy May 3, 2016
b9ab4d3
Use shorthand properties
mhegazy May 3, 2016
f657e3c
Merge branch 'master' into stringLiteralCompletions
mhegazy May 8, 2016
81ee968
Add failing test for #8738
evansb May 22, 2016
63291d1
Sort baseline reference identifier by name
evansb May 22, 2016
9a4b6ab
Detects assignment to internal module export clause, fixes #8738
evansb May 22, 2016
4e415eb
add SharedArrayBuffer
YuichiNukiyama May 23, 2016
269ebda
Factor out assignment op check
evansb May 23, 2016
ec60ac9
Add test for composite assignment
evansb May 23, 2016
ebd4ce6
Factor out the behaviour and handles x++ and ++x
evansb May 23, 2016
f1ac06f
Handles ES3 default as identifier name
evansb May 23, 2016
eca9437
Fix missing else statement
evansb May 23, 2016
47eac4f
isNameOfExportedDeclarationInNonES6Module
evansb May 24, 2016
3b7814b
Reorder options alphabetically
mhegazy May 27, 2016
5d9c871
Mark diagnostics, and skipDefaultLibCheck as internal
mhegazy May 27, 2016
fa16a99
Allow an import of "foo.js" to be matched by a file "foo.ts"
May 31, 2016
a0546a9
Improve loadModuleFromFile code
May 31, 2016
f4d6b67
Respond to PR comments
May 31, 2016
d4b8889
Respond to more PR comments
May 31, 2016
9179f4c
Fix test
Jun 1, 2016
d111a0f
Merge branch 'master' into narrow-all-types
sandersn Jun 1, 2016
9a620bf
Actually merge from master
sandersn Jun 1, 2016
9575b3c
Revert to old tryLoad implementation
Jun 1, 2016
0e96c5e
Run fixupParentReferences when parsing isolated jsDocComment
zhengbli Jun 2, 2016
92177be
initial revision of unit test support for project system in tsserver
vladima Jun 2, 2016
3b19825
Allow wildcard ("*") patterns in ambient module declarations
Jun 2, 2016
2517238
Add non-widening forms of null and undefined
ahejlsberg Jun 2, 2016
5f3f2d3
Create separate control flows for property declarations with initiali…
ahejlsberg Jun 2, 2016
706683d
Add regression test
ahejlsberg Jun 2, 2016
4281bf5
Allow trailing commas in function parameter and argument lists
Jun 2, 2016
9f087cb
Merge pull request #8941 from Microsoft/controlFlowPropertyDeclarations
ahejlsberg Jun 2, 2016
20bab14
Add tests
ahejlsberg Jun 2, 2016
ef0f6c8
Merge pull request #7235 from weswigham/narrow-all-types
sandersn Jun 2, 2016
fb2df77
Remove unused variable
ahejlsberg Jun 2, 2016
7e00d7e
Merge pull request #8931 from Microsoft/tsserver-projectsystem-tests
vladima Jun 2, 2016
d41ac8a
Add null check and CR feedback
zhengbli Jun 2, 2016
7e9cb46
Support shorthand ambient module declarations
Jun 2, 2016
fc3e040
Revert "Merge pull request #7235 from weswigham/narrow-all-types"
sandersn Jun 2, 2016
e2a1a78
reuse the fixupParentReferences function
zhengbli Jun 2, 2016
24f15a4
Merge pull request #8946 from Microsoft/revert-narrow-all-types
sandersn Jun 2, 2016
131f759
Merge pull request #8930 from zhengbli/i8676
zhengbli Jun 2, 2016
3853555
Merge pull request #8944 from Microsoft/reviseWidening
ahejlsberg Jun 2, 2016
bcc9220
Improve typing of && operator with --strictNullChecks
ahejlsberg Jun 3, 2016
13698a9
Add test
ahejlsberg Jun 3, 2016
094f97e
Respond to PR comments
Jun 3, 2016
1541ebe
Respond to PR comments
Jun 3, 2016
ed6bfcd
Add merging tests
Jun 3, 2016
c8ced67
Use a function `stringify` to simplify calls to `JSON.stringify(xyz, …
Jun 3, 2016
8b0974a
Update tests
Jun 3, 2016
2bed32d
Fix mistake
Jun 3, 2016
e412f52
Include indent in navigation bar protocol
Jun 3, 2016
baebf2b
Merge pull request #8959 from Microsoft/stringify
Jun 3, 2016
3aaa4ea
Merge pull request #8957 from Microsoft/navbar_indent
Jun 3, 2016
39c4e8a
Remove unnecessary restrictions in property access narrowing
ahejlsberg Jun 4, 2016
a5e9071
Fix fourslash test
ahejlsberg Jun 4, 2016
87ee72b
Add regression test
ahejlsberg Jun 4, 2016
6dcd587
Merge pull request #8962 from Microsoft/propertyAccessNarrowing
ahejlsberg Jun 4, 2016
bb7818b
Consider property declarations to be control flow containers
ahejlsberg Jun 4, 2016
3b1effb
Adding regression test
ahejlsberg Jun 4, 2016
18a8758
Remove restriction on --target es5 and --module es6
mhegazy Jun 5, 2016
f5ab9d7
change type definition for Object.create
plantain-00 Jun 5, 2016
2fc2f5c
Fix signature help
Jun 6, 2016
f832488
Add "implicit any" warning for shorthand ambient modules
Jun 6, 2016
543b484
Remove trailing whitespace
Jun 3, 2016
13ddc34
Merge pull request #8979 from Microsoft/trailing_whitespace
Jun 6, 2016
447e583
Merge pull request #8974 from plantain-00/change_type_definition_for_…
mhegazy Jun 6, 2016
d9ec512
Support using string values in enums for CompilerOptions in transpile…
Jun 6, 2016
e05e112
Remove trailing whitespace in jakefile
Jun 6, 2016
52138e0
Make `jake runtests-browser` support test regexes with spaces
Jun 6, 2016
f215ac9
Add another test
Jun 6, 2016
a918730
factor out isJsxOrTsxExtension
Jun 6, 2016
cd1b9f0
Merge pull request #8989 from Microsoft/jakefile_whitespace
Jun 6, 2016
704f987
Move to a conformance test
Jun 6, 2016
9761c3b
Revert "Revert "Merge pull request #7235 from weswigham/narrow-all-ty…
weswigham Jun 6, 2016
26b1ab4
Use inclusive flag, as originally done, but include almost everything
weswigham Jun 6, 2016
693cb9c
Add additional tests
Jun 6, 2016
2918c18
Merge pull request #8992 from Microsoft/runtests-browser-spaces
Jun 6, 2016
1fe8a08
Respond to PR comments
Jun 6, 2016
941c863
Fix typo
Jun 6, 2016
bfafecc
Merge pull request #8993 from weswigham/refix-primitive-narrowing
sandersn Jun 6, 2016
52d8a78
Merge pull request #8970 from Microsoft/propertyControlFlow
ahejlsberg Jun 7, 2016
3052913
add tests for tsserver project system
zhengbli Jun 7, 2016
53a5b42
Merge pull request #8994 from Microsoft/typo
Jun 7, 2016
ed48e58
Fix test
Jun 7, 2016
849ab7c
Merge pull request #8942 from Microsoft/param_trailing_commas
Jun 7, 2016
843aa6c
Allow case comparison to undefined and null in strict null checking mode
sandersn Jun 7, 2016
b4f1214
Remove incorrectly added tests
sandersn Jun 7, 2016
5fef080
Merge pull request #9003 from Microsoft/caseUndefinedAndNull
sandersn Jun 7, 2016
d941177
check if moduleResolution when verifying that program can be reused
vladima Jun 7, 2016
6913c32
Merge pull request #9009 from Microsoft/reusing-program-missing-check
vladima Jun 7, 2016
37949a3
more tests for module resolution change and exclude
zhengbli Jun 7, 2016
78792df
Fix linting issues
zhengbli Jun 7, 2016
17cc206
Merge JSDoc of assignments from function expressions
sandersn Jun 7, 2016
8b7fb8e
Merge pull request #8739 from evansb/fix-8738
vladima Jun 7, 2016
6a243e3
Allow nested assignments in type guards
ahejlsberg Jun 8, 2016
cdf5b7a
Add tests
ahejlsberg Jun 8, 2016
cdf4cde
Merge pull request #9002 from zhengbli/moreTsserverTests
zhengbli Jun 8, 2016
6bf5f11
Improve order of parameter's merged jsdoc
sandersn Jun 8, 2016
65bbeb1
Force LF newlines for LKG builds/non debug builds
DickvdBrink Jun 8, 2016
83971d0
Create intersection types in type guards for unrelated types
ahejlsberg Jun 8, 2016
9832f62
Split commentsFunction test into expr/decl
sandersn Jun 8, 2016
1fe6626
Remove TODO comments
sandersn Jun 8, 2016
ea1bdff
Accept new baselines
ahejlsberg Jun 8, 2016
a57ee29
Add tests
ahejlsberg Jun 8, 2016
404650d
Merge pull request #9026 from DickvdBrink/lkg-newlines
mhegazy Jun 8, 2016
97270ce
Merge branch 'master' into reorderOptions
mhegazy Jun 8, 2016
7eb5f4b
Remove comments
mhegazy Jun 8, 2016
179d423
Merge pull request #9010 from Microsoft/merge-jsdoc-of-assignment-and…
sandersn Jun 8, 2016
d8667ae
Fix test helper
Jun 8, 2016
9027da4
Merge branch 'master' into stringLiteralCompletions
mhegazy Jun 8, 2016
899f667
Recognize relative path using in outDir property (#9025)
yuit Jun 8, 2016
cc5dd5b
Add comments
mhegazy Jun 8, 2016
d36d2b3
Merge pull request #8771 from YuichiNukiyama/fix8505
mhegazy Jun 8, 2016
6b8109a
Merge pull request #8850 from Microsoft/reorderOptions
mhegazy Jun 8, 2016
9fac99e
Add test case
sandersn Jun 8, 2016
17b5415
Merge pull request #8428 from Microsoft/stringLiteralCompletions
mhegazy Jun 8, 2016
de8ddd6
Return trace when exception happens
zhengbli Jun 8, 2016
5a0ae4a
Remove Long-Done TODO
weswigham Jun 8, 2016
8f39f05
Merge pull request #9032 from zhengbli/printTrace
zhengbli Jun 8, 2016
7c1b28f
Allow primitive type guards with typeof on right
sandersn Jun 8, 2016
11377f9
Primitive type guards are now order independent
sandersn Jun 8, 2016
454ab50
Merge pull request #9035 from weswigham/patch-6
weswigham Jun 8, 2016
aeb1d97
Merge pull request #8949 from Microsoft/strictNullLogicalAnd
ahejlsberg Jun 8, 2016
b3c5c1d
Merge pull request #9013 from Microsoft/typeGuardNestedAssignment
ahejlsberg Jun 8, 2016
d182a59
Fix comments in tests
ahejlsberg Jun 8, 2016
8360bc7
Add handleing for classes
mhegazy Jun 8, 2016
33137f6
Add more tests for target=es5 module=es6
mhegazy Jun 8, 2016
6446827
addExportToArgumentListKind
mhegazy Jun 8, 2016
f42d8b8
Accept baseline
mhegazy Jun 9, 2016
475c1c2
Add more tests
mhegazy Jun 9, 2016
82505ea
Merge pull request #9040 from Microsoft/addExportToArgumentListKind
mhegazy Jun 9, 2016
19baf1f
Adds progress indicators to the runtests-parallel build task.
rbuckton Jun 9, 2016
8fc3422
Fixed typo
rbuckton Jun 9, 2016
b1a7498
Fix comment
ahejlsberg Jun 9, 2016
c14d711
Merge pull request #9043 from Microsoft/parallelTestProgress
rbuckton Jun 9, 2016
9e12290
Merge pull request #9031 from Microsoft/typeGuardIntersectionTypes
ahejlsberg Jun 9, 2016
0aa2fe3
Add test for out-of-range error
Jun 9, 2016
b08fe6f
Use proper method of not resolving alias
Jun 9, 2016
9ef9b74
Fix module loading error
Jun 9, 2016
75b8293
Merge pull request #8988 from Microsoft/transpile_options
Jun 9, 2016
3ab1e27
Update tests
Jun 9, 2016
7a2ef42
Contextually type return statement in async function
Jun 9, 2016
3492542
Remove stale files
mhegazy Jun 9, 2016
5e72b8a
Undo change
Jun 9, 2016
03371c0
Improve perf
Jun 9, 2016
559b49b
Improve tests
Jun 9, 2016
3954e99
Merge pull request #9056 from Microsoft/async_function_return_type
Jun 9, 2016
512c671
Merge pull request #8895 from Microsoft/strip_extension
Jun 9, 2016
75c1d77
Merge branch 'master' into shorthand_ambient_module
Jun 9, 2016
88be1ac
Fix sourcemaps for debugging tests
weswigham Jun 9, 2016
b521fd5
Allow --sourceRoot with --inlineSources option
sheetalkamat Jun 9, 2016
0c64b0c
this in parameter initializers resolves to class
sandersn Jun 9, 2016
302cea8
Merge pull request #9054 from Microsoft/quick_info_meaning
Jun 9, 2016
9fa9710
Add tests for more kinds of import/export
Jun 9, 2016
a88366d
Merge branch 'master' into shorthand_ambient_module
Jun 9, 2016
9ffd00d
Merge pull request #8939 from Microsoft/pattern_ambient_modules
Jun 9, 2016
d0f669e
Merge pull request #9059 from Microsoft/remove-tsservicesinbrowser
weswigham Jun 9, 2016
574a64d
Fix7334 Disallow async in functionExpression and ArrowFunction (#9062)
yuit Jun 9, 2016
e307295
Resolve function-this in parameter initialisers when explicitly provided
sandersn Jun 9, 2016
a4991b9
Merge pull request #9057 from Microsoft/sourceRootWithInlineSources
sheetalkamat Jun 9, 2016
a1e4b31
Allow null/undefined guard with null/undefined on left
sandersn Jun 9, 2016
f0a430a
Code review comments
mhegazy Jun 9, 2016
86a6959
Merge branch 'master' into primitive-type-guards-are-order-independent
sandersn Jun 9, 2016
2b46656
Merge pull request #9061 from Microsoft/fix-this-resolution-in-parame…
sandersn Jun 9, 2016
6923cba
Update more diagnostic messages ES6->2015
texastoland Jun 10, 2016
5af8ba8
Fixes an issue with runtests-parallel when global mocha is not instal…
rbuckton Jun 10, 2016
a1e4135
Merge pull request #9066 from Microsoft/fixRuntestsParallel
rbuckton Jun 10, 2016
6687f2c
Merge pull request #9065 from AppShipIt/8996-es6-diagnostic-messages
mhegazy Jun 10, 2016
e6eb36e
Update LKG
mhegazy Jun 10, 2016
ff6e025
Merge branch 'master' into shorthand_ambient_module
Jun 10, 2016
d973f4d
Merge branch 'master' into shorthand_ambient_module
Jun 10, 2016
077dfff
Add tests
Jun 10, 2016
71b7d44
Merge pull request #8945 from Microsoft/shorthand_ambient_module
Jun 10, 2016
97d7aa5
Merge pull request #9042 from Microsoft/ES6ModulesES5Target
mhegazy Jun 10, 2016
5ae0602
fix baselines
vladima Jun 10, 2016
72d64e1
Merge pull request #9084 from Microsoft/fixBaselines
vladima Jun 10, 2016
6425837
Salsa: get members of variables whose initialisers are functions
sandersn Jun 10, 2016
4a9b120
Test adding members to JS variables whose initialisers are functions
sandersn Jun 10, 2016
b027b4f
Recommend runtests-parallel in CONTRIBUTING
sandersn Jun 10, 2016
a3a1c49
Allow empty lists on command line
weswigham Jun 10, 2016
d204596
Remove single-comma empty array form
weswigham Jun 10, 2016
ccd4552
Merge pull request #9089 from Microsoft/recommend-runtests-parallel-i…
sandersn Jun 10, 2016
8d83cd1
Remove trailing whitespace
weswigham Jun 10, 2016
9827b63
Implicit type inclusion changes
RyanCavanaugh Jun 10, 2016
576f09f
Merge
RyanCavanaugh Jun 10, 2016
81d1ccf
Only inlineSourceMap when debugging through jake-browser (#9080)
yuit Jun 11, 2016
6153422
minor fix: add missing return clause
plantain-00 Jun 13, 2016
fb050f1
Use camel-case instead of snake-case (#9134)
yuit Jun 13, 2016
e8ac1ab
Baseline fix, CR comments, lint
RyanCavanaugh Jun 13, 2016
6702e65
CR changes
RyanCavanaugh Jun 13, 2016
6f63799
Merge pull request #9129 from plantain-00/minor_fix_add_missing_retur…
mhegazy Jun 13, 2016
8b09312
Merge pull request #9036 from Microsoft/primitive-type-guards-are-ord…
sandersn Jun 13, 2016
89488f8
Add test for jsdoc in navigation bar
Jun 13, 2016
3dca09b
Fixes runtests-parallel not reporting failure for failed tests.
rbuckton Jun 13, 2016
c0c707c
Fix decorator metadata emit for rest arg with no type
Jun 13, 2016
5a7f746
Add isDefinition to ReferenceEntry
sandersn Jun 13, 2016
ac9e617
Test isDefinition
sandersn Jun 13, 2016
7d31bcf
Add option to bail out of `jake runtests` when one test fails
Jun 13, 2016
b10d932
Absolute-ify paths in both places
RyanCavanaugh Jun 13, 2016
29f5291
Refactor
RyanCavanaugh Jun 13, 2016
236351d
Add unit test
RyanCavanaugh Jun 13, 2016
90b319f
lint
RyanCavanaugh Jun 13, 2016
f9923ef
Merge pull request #9095 from RyanCavanaugh/implicitTypeReferences
RyanCavanaugh Jun 13, 2016
318e957
Added tests.
DanielRosenwasser Jun 14, 2016
d54094c
Accepted baselines.
DanielRosenwasser Jun 14, 2016
eae289c
Emit 'exports.' if the shorthand is a general export.
DanielRosenwasser Jun 14, 2016
e8a7e0c
Accepted baselines.
DanielRosenwasser Jun 14, 2016
9d023a8
Merge pull request #9090 from weswigham/allow-empty-lists-command-line
weswigham Jun 14, 2016
6eaf7fa
Merge pull request #9146 from Microsoft/runtests_bail_2.0
Jun 14, 2016
b92a8f2
Merge pull request #9144 from Microsoft/decorator_metadata_rest_param…
Jun 14, 2016
29b1e79
Merge pull request #9140 from Microsoft/navbar_jsdoc
Jun 14, 2016
f6cee27
Emit 'Promise' decorator metadata return type for async methods
Jun 14, 2016
33e4c7a
Respond to PR comment
Jun 14, 2016
1b4b01e
Unescape identifiers used in code completion
Jun 14, 2016
c33df01
Merge pull request #9156 from Microsoft/decorator_metadata_async
Jun 14, 2016
792b23e
Make isDefinition required.
sandersn Jun 14, 2016
7bf40c4
Add more isDefinition tests and fix computed property bug
sandersn Jun 14, 2016
6b05eca
Fix bug: do unescaping in the right place, so that it only affects es…
Jun 14, 2016
13a0f59
Merge pull request #9159 from Microsoft/code_completion_escaping
Jun 14, 2016
102a890
Use `isLiteralComputedPropertyDeclarationName`
sandersn Jun 14, 2016
8917ddf
Merge pull request #9151 from Microsoft/commonjsShorthands
DanielRosenwasser Jun 14, 2016
57f66b8
Merge pull request #9148 from Microsoft/add-isDefinition-to-references
sandersn Jun 14, 2016
7890fd5
Merge pull request #9088 from Microsoft/add-members-to-variable-decla…
sandersn Jun 14, 2016
3632d36
Merge branch 'master' into transforms_mergemaster_0614
Jun 14, 2016
9853724
Merge branch 'master' into transforms_mergemaster_0614
Jun 14, 2016
e67a16d
Merge branch 'transforms_mergemaster_0614' of https://github.com/Micr…
Jun 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,13 +794,14 @@ function runConsoleTests(defaultReporter, runInParallel) {
colors = process.env.colors || process.env.color;
colors = colors ? ' --no-colors ' : ' --colors ';
reporter = process.env.reporter || process.env.r || defaultReporter;
var bail = (process.env.bail || process.env.b) ? "--bail" : "";
var lintFlag = process.env.lint !== 'false';

// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
if(!runInParallel) {
tests = tests ? ' -g "' + tests + '"' : '';
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run;
console.log(cmd);

var savedNodeEnv = process.env.NODE_ENV;
Expand Down Expand Up @@ -865,7 +866,7 @@ task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], functio
runConsoleTests('min', /*runInParallel*/ true);
}, {async: true});

desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false lint=true dirty=false.");
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false lint=true bail=false dirty=false.");
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
runConsoleTests('mocha-fivemat-progress-reporter', /*runInParallel*/ false);
}, {async: true});
Expand Down
5 changes: 2 additions & 3 deletions scripts/mocha-parallel.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ function runTests(taskConfigsFolder, run, options, cb) {
counter--;

if (counter <= 0) {
var failed = 0;
var reporter = new Base(),
stats = reporter.stats,
failures = reporter.failures;
Expand Down Expand Up @@ -224,8 +223,8 @@ function runTests(taskConfigsFolder, run, options, cb) {
reporter.epilogue();
}

if (failed) {
return cb(new Error("Test failures reported: " + failed));
if (stats.failures) {
return cb(new Error("Test failures reported: " + stats.failures));
}
else {
return cb();
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1985,7 +1985,7 @@ namespace ts {
classPrototype.parent = leftSideOfAssignment;

const funcSymbol = container.locals[constructorFunction.text];
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function)) {
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
return;
}

Expand Down
8 changes: 6 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11497,8 +11497,12 @@ namespace ts {
// When resolved signature is a call signature (and not a construct signature) the result type is any, unless
// the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations
// in a JS file
const funcSymbol = checkExpression(node.expression).symbol;
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function)) {
// Note:JS inferred classes might come from a variable declaration instead of a function declaration.
// In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration.
const funcSymbol = node.expression.kind === SyntaxKind.Identifier ?
getResolvedSymbol(node.expression as Identifier) :
checkExpression(node.expression).symbol;
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
return getInferredClassType(funcSymbol);
}
else if (compilerOptions.noImplicitAny) {
Expand Down
31 changes: 23 additions & 8 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,13 @@ namespace ts {
}
},
{
name: "typesRoot",
type: "string"
name: "typeRoots",
type: "list",
element: {
name: "typeRoots",
type: "string",
isFilePath: true
}
},
{
name: "types",
Expand Down Expand Up @@ -493,13 +498,20 @@ namespace ts {
}

/* @internal */
export function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] {
const values = trimString((value || "")).split(",");
export function parseListTypeOption(opt: CommandLineOptionOfListType, value = "", errors: Diagnostic[]): (string | number)[] | undefined {
value = trimString(value);
if (startsWith(value, "-")) {
return undefined;
}
if (value === "") {
return [];
}
const values = value.split(",");
switch (opt.element.type) {
case "number":
return ts.map(values, parseInt);
return map(values, parseInt);
case "string":
return ts.map(values, v => v || "");
return map(values, v => v || "");
default:
return filter(map(values, v => parseCustomTypeOption(<CommandLineOptionOfCustomType>opt.element, v, errors)), v => !!v);
}
Expand Down Expand Up @@ -560,8 +572,11 @@ namespace ts {
i++;
break;
case "list":
options[opt.name] = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i], errors);
i++;
const result = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i], errors);
options[opt.name] = result || [];
if (result) {
i++;
}
break;
// If not a primitive, the possible types are specified in what is effectively a map of options.
default:
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,10 @@
"category": "Error",
"code": 2687
},
"Cannot find type definition file for '{0}'.": {
"category": "Error",
"code": 2688
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
Expand Down
104 changes: 50 additions & 54 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@

namespace ts {
/** The version of the TypeScript compiler release */
export const version = "1.9.0";

const emptyArray: any[] = [];

const defaultLibrarySearchPaths = [
"types/",
"node_modules/",
"node_modules/@types/",
];

export const version = "1.9.0";
const defaultTypeRoots = ["node_modules/@types"];

export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string {
while (true) {
Expand Down Expand Up @@ -178,6 +173,11 @@ namespace ts {

const typeReferenceExtensions = [".d.ts"];

function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) {
return options.typeRoots ||
defaultTypeRoots.map(d => combinePaths(options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d));
}

/**
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
Expand All @@ -192,39 +192,36 @@ namespace ts {
traceEnabled
};

// use typesRoot and fallback to directory that contains tsconfig or current directory if typesRoot is not set
const rootDir = options.typesRoot || (options.configFilePath ? getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory()));

const typeRoots = getEffectiveTypeRoots(options, host);
if (traceEnabled) {
if (containingFile === undefined) {
if (rootDir === undefined) {
if (typeRoots === undefined) {
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
}
else {
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, rootDir);
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
}
}
else {
if (rootDir === undefined) {
if (typeRoots === undefined) {
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
}
else {
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, rootDir);
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
}
}
}

const failedLookupLocations: string[] = [];

// Check primary library paths
if (rootDir !== undefined) {
const effectivePrimarySearchPaths = options.typesSearchPaths || defaultLibrarySearchPaths;
for (const searchPath of effectivePrimarySearchPaths) {
const primaryPath = combinePaths(rootDir, searchPath);
if (traceEnabled) {
trace(host, Diagnostics.Resolving_with_primary_search_path_0, primaryPath);
}
const candidate = combinePaths(primaryPath, typeReferenceDirectiveName);
if (typeRoots.length) {
if (traceEnabled) {
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
}
const primarySearchPaths = typeRoots;
for (const typeRoot of primarySearchPaths) {
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
const candidateDirectory = getDirectoryPath(candidate);
const resolvedFile = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations,
!directoryProbablyExists(candidateDirectory, host), moduleResolutionState);
Expand All @@ -251,9 +248,6 @@ namespace ts {
if (containingFile) {
initialLocationForSecondaryLookup = getDirectoryPath(containingFile);
}
else {
initialLocationForSecondaryLookup = rootDir;
}

if (initialLocationForSecondaryLookup !== undefined) {
// check secondary locations
Expand Down Expand Up @@ -932,19 +926,6 @@ namespace ts {
}
}

function getDefaultTypeDirectiveNames(rootPath: string): string[] {
const localTypes = combinePaths(rootPath, "types");
const npmTypes = combinePaths(rootPath, "node_modules/@types");
let result: string[] = [];
if (sys.directoryExists(localTypes)) {
result = result.concat(sys.getDirectories(localTypes));
}
if (sys.directoryExists(npmTypes)) {
result = result.concat(sys.getDirectories(npmTypes));
}
return result;
}

function getDefaultLibLocation(): string {
return getDirectoryPath(normalizePath(sys.getExecutingFilePath()));
}
Expand All @@ -953,7 +934,6 @@ namespace ts {
const realpath = sys.realpath && ((path: string) => sys.realpath(path));

return {
getDefaultTypeDirectiveNames,
getSourceFile,
getDefaultLibLocation,
getDefaultLibFileName: options => combinePaths(getDefaultLibLocation(), getDefaultLibFileName(options)),
Expand All @@ -967,7 +947,8 @@ namespace ts {
trace: (s: string) => sys.write(s + newLine),
directoryExists: directoryName => sys.directoryExists(directoryName),
realpath,
getEnvironmentVariable: name => getEnvironmentVariable(name, /*host*/ undefined)
getEnvironmentVariable: name => getEnvironmentVariable(name, /*host*/ undefined),
getDirectories: (path: string) => sys.getDirectories(path),
};
}

Expand Down Expand Up @@ -1030,21 +1011,35 @@ namespace ts {
return resolutions;
}

export function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
function getInferredTypesRoot(options: CompilerOptions, rootFiles: string[], host: CompilerHost) {
return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
}

/**
* Given a set of options and a set of root files, returns the set of type directive names
* that should be included for this program automatically.
* This list could either come from the config file,
* or from enumerating the types root + initial secondary types lookup location.
* More type directives might appear in the program later as a result of loading actual source files;
* this list is only the set of defaults that are implicitly included.
*/
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
// Use explicit type list from tsconfig.json
if (options.types) {
return options.types;
}

// or load all types from the automatic type import fields
if (host && host.getDefaultTypeDirectiveNames) {
const commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
if (commonRoot) {
return host.getDefaultTypeDirectiveNames(commonRoot);
// Walk the primary type lookup locations
let result: string[] = [];
if (host.directoryExists && host.getDirectories) {
const typeRoots = getEffectiveTypeRoots(options, host);
for (const root of typeRoots) {
if (host.directoryExists(root)) {
result = result.concat(host.getDirectories(root));
}
}
}

return undefined;
return result;
}

export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
Expand Down Expand Up @@ -1096,11 +1091,13 @@ namespace ts {
if (!tryReuseStructureFromOldProgram()) {
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));

// load type declarations specified via 'types' argument
const typeReferences: string[] = getDefaultTypeDirectiveNames(options, rootNames, host);
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, rootNames, host);

if (typeReferences) {
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined);
const inferredRoot = getInferredTypesRoot(options, rootNames, host);
const containingFilename = combinePaths(inferredRoot, "__inferred type names__.ts");
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
for (let i = 0; i < typeReferences.length; i++) {
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
}
Expand Down Expand Up @@ -1208,10 +1205,9 @@ namespace ts {
(oldOptions.jsx !== options.jsx) ||
(oldOptions.allowJs !== options.allowJs) ||
(oldOptions.rootDir !== options.rootDir) ||
(oldOptions.typesSearchPaths !== options.typesSearchPaths) ||
(oldOptions.configFilePath !== options.configFilePath) ||
(oldOptions.baseUrl !== options.baseUrl) ||
(oldOptions.typesRoot !== options.typesRoot) ||
!arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) ||
!arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
!mapIsEqualTo(oldOptions.paths, options.paths)) {
return false;
Expand Down Expand Up @@ -1967,7 +1963,7 @@ namespace ts {
}
}
else {
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, Diagnostics.Cannot_find_name_0, typeReferenceDirective));
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
}

if (saveResolution) {
Expand Down
5 changes: 3 additions & 2 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2630,9 +2630,9 @@ namespace ts {
target?: ScriptTarget;
traceResolution?: boolean;
types?: string[];
/* @internal */ typesRoot?: string;
/** Paths used to used to compute primary types search locations */
typeRoots?: string[];
typesSearchPaths?: string[];
/* @internal */ useLegacyEmitter?: boolean;
/*@internal*/ version?: boolean;
/*@internal*/ watch?: boolean;

Expand Down Expand Up @@ -2940,6 +2940,7 @@ namespace ts {
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
getCanonicalFileName(fileName: string): string;
useCaseSensitiveFileNames(): boolean;
getNewLine(): string;
Expand Down
12 changes: 12 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,18 @@ namespace ts {
return charCode === CharacterCodes.singleQuote || charCode === CharacterCodes.doubleQuote;
}

/**
* Returns true if the node is a variable declaration whose initializer is a function expression.
* This function does not test if the node is in a JavaScript file or not.
*/
export function isDeclarationOfFunctionExpression(s: Symbol) {
if (s.valueDeclaration && s.valueDeclaration.kind === SyntaxKind.VariableDeclaration) {
const declaration = s.valueDeclaration as VariableDeclaration;
return declaration.initializer && declaration.initializer.kind === SyntaxKind.FunctionExpression;
}
return false;
}

/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
/// assignments we treat as special in the binder
export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind {
Expand Down
Loading