Skip to content

Commit a399e8d

Browse files
committed
Fix merge conflict
2 parents def9ed4 + ab98dcf commit a399e8d

File tree

81 files changed

+664
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+664
-335
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ internal/
5454
!tests/cases/projects/projectOption/**/node_modules
5555
!tests/cases/projects/NodeModulesSearch/**/*
5656
!tests/baselines/reference/project/nodeModules*/**/*
57+
.idea

CONTRIBUTING.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ In general, things we find useful when reviewing suggestions are:
4040

4141
# Instructions for Contributing Code
4242

43-
## Code of Conduct
44-
45-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
46-
4743
## Contributing bug fixes
4844

4945
TypeScript is currently accepting contributions in the form of bug fixes. A bug must have an issue tracking it in the issue tracker that has been approved ("Milestone == Community") by the TypeScript team. Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.

Gulpfile.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Error.stackTraceLimit = 1000;
4343

4444
const cmdLineOptions = minimist(process.argv.slice(2), {
4545
boolean: ["debug", "light", "colors", "lint", "soft"],
46-
string: ["browser", "tests", "host", "reporter"],
46+
string: ["browser", "tests", "host", "reporter", "stackTraceLimit"],
4747
alias: {
4848
d: "debug",
4949
t: "tests",
@@ -561,6 +561,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
561561
const debug = cmdLineOptions["debug"];
562562
const tests = cmdLineOptions["tests"];
563563
const light = cmdLineOptions["light"];
564+
const stackTraceLimit = cmdLineOptions["stackTraceLimit"];
564565
const testConfigFile = "test.config";
565566
if (fs.existsSync(testConfigFile)) {
566567
fs.unlinkSync(testConfigFile);
@@ -580,7 +581,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done:
580581
}
581582

582583
if (tests || light || taskConfigsFolder) {
583-
writeTestConfigFile(tests, light, taskConfigsFolder, workerCount);
584+
writeTestConfigFile(tests, light, taskConfigsFolder, workerCount, stackTraceLimit);
584585
}
585586

586587
if (tests && tests.toLocaleLowerCase() === "rwc") {
@@ -759,8 +760,8 @@ function cleanTestDirs(done: (e?: any) => void) {
759760
}
760761

761762
// used to pass data from jake command line directly to run.js
762-
function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?: string, workerCount?: number) {
763-
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light: light, workerCount: workerCount, taskConfigsFolder: taskConfigsFolder });
763+
function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?: string, workerCount?: number, stackTraceLimit?: string) {
764+
const testConfigContents = JSON.stringify({ test: tests ? [tests] : undefined, light, workerCount, stackTraceLimit, taskConfigsFolder });
764765
console.log("Running tests with config: " + testConfigContents);
765766
fs.writeFileSync("test.config", testConfigContents);
766767
}
@@ -890,7 +891,7 @@ gulp.task(loggedIOJsPath, false, [], (done) => {
890891
const temp = path.join(builtLocalDirectory, "temp");
891892
mkdirP(temp, (err) => {
892893
if (err) { console.error(err); done(err); process.exit(1); };
893-
exec(host, [LKGCompiler, "--outdir", temp, loggedIOpath], () => {
894+
exec(host, [LKGCompiler, "--types --outdir", temp, loggedIOpath], () => {
894895
fs.renameSync(path.join(temp, "/harness/loggedIO.js"), loggedIOJsPath);
895896
del(temp).then(() => done(), done);
896897
}, done);
@@ -911,8 +912,8 @@ gulp.task(instrumenterJsPath, false, [servicesFile], () => {
911912
.pipe(gulp.dest("."));
912913
});
913914

914-
gulp.task("tsc-instrumented", "Builds an instrumented tsc.js", [loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => {
915-
exec(host, [instrumenterJsPath, "record", "iocapture", builtLocalDirectory, compilerFilename], done, done);
915+
gulp.task("tsc-instrumented", "Builds an instrumented tsc.js", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => {
916+
exec(host, [instrumenterJsPath, "record", "iocapture", builtLocalCompiler], done, done);
916917
});
917918

918919
gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", serverFile], () => {

Jakefile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ var loggedIOJsPath = builtLocalDirectory + 'loggedIO.js';
10551055
file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function () {
10561056
var temp = builtLocalDirectory + 'temp';
10571057
jake.mkdirP(temp);
1058-
var options = "--outdir " + temp + ' ' + loggedIOpath;
1058+
var options = "--types --outdir " + temp + ' ' + loggedIOpath;
10591059
var cmd = host + " " + LKGDirectory + compilerFilename + " " + options + " ";
10601060
console.log(cmd + "\n");
10611061
var ex = jake.createExec([cmd]);

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob
3030
* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
3131
* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
3232
* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
33-
* Read the language specification ([docx](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.docx?raw=true), [pdf](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.pdf?raw=true), [md](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md)).
33+
* Read the language specification ([docx](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.docx?raw=true),
34+
[pdf](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.pdf?raw=true), [md](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md)).
3435

36+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see
37+
the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected])
38+
with any additional questions or comments.
3539

3640
## Documentation
3741

@@ -91,4 +95,4 @@ node built/local/tsc.js hello.ts
9195

9296
## Roadmap
9397

94-
For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap).
98+
For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap).

src/compiler/checker.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,11 +1313,10 @@ namespace ts {
13131313
else if (namespace === unknownSymbol) {
13141314
return namespace;
13151315
}
1316-
13171316
symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning);
13181317
if (!symbol) {
13191318
if (!ignoreErrors) {
1320-
error(right, Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), declarationNameToString(right));
1319+
error(right, Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(namespace), declarationNameToString(right));
13211320
}
13221321
return undefined;
13231322
}
@@ -2931,7 +2930,7 @@ namespace ts {
29312930
// undefined or any type of the parent.
29322931
if (!parentType || isTypeAny(parentType)) {
29332932
if (declaration.initializer) {
2934-
return getBaseTypeOfLiteralType(checkExpressionCached(declaration.initializer));
2933+
return checkDeclarationInitializer(declaration);
29352934
}
29362935
return parentType;
29372936
}
@@ -3102,8 +3101,7 @@ namespace ts {
31023101

31033102
// Use the type of the initializer expression if one is present
31043103
if (declaration.initializer) {
3105-
const exprType = checkExpressionCached(declaration.initializer);
3106-
const type = getCombinedNodeFlags(declaration) & NodeFlags.Const || getCombinedModifierFlags(declaration) & ModifierFlags.Readonly ? exprType : getBaseTypeOfLiteralType(exprType);
3104+
const type = checkDeclarationInitializer(declaration);
31073105
return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality);
31083106
}
31093107

@@ -3126,8 +3124,7 @@ namespace ts {
31263124
// pattern. Otherwise, it is the type any.
31273125
function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean, reportErrors?: boolean): Type {
31283126
if (element.initializer) {
3129-
const exprType = checkExpressionCached(element.initializer);
3130-
return getCombinedNodeFlags(element) & NodeFlags.Const ? exprType : getBaseTypeOfLiteralType(exprType);
3127+
return checkDeclarationInitializer(element);
31313128
}
31323129
if (isBindingPattern(element.name)) {
31333130
return getTypeFromBindingPattern(<BindingPattern>element.name, includePatternInType, reportErrors);
@@ -12099,7 +12096,7 @@ namespace ts {
1209912096
error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
1210012097
}
1210112098
else {
12102-
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
12099+
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType));
1210312100
}
1210412101
return resolveErrorCall(node);
1210512102
}
@@ -12261,7 +12258,7 @@ namespace ts {
1226112258
}
1226212259

1226312260
if (!callSignatures.length) {
12264-
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
12261+
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType));
1226512262
return resolveErrorCall(node);
1226612263
}
1226712264

@@ -12309,7 +12306,7 @@ namespace ts {
1230912306
const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
1231012307
if (!callSignatures.length) {
1231112308
let errorInfo: DiagnosticMessageChain;
12312-
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
12309+
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType));
1231312310
errorInfo = chainDiagnosticMessages(errorInfo, headMessage);
1231412311
diagnostics.add(createDiagnosticForNodeFromMessageChain(node, errorInfo));
1231512312
return resolveErrorCall(node);
@@ -13672,6 +13669,18 @@ namespace ts {
1367213669
return links.resolvedType;
1367313670
}
1367413671

13672+
function isTypeAssertion(node: Expression) {
13673+
node = skipParenthesizedNodes(node);
13674+
return node.kind === SyntaxKind.TypeAssertionExpression || node.kind === SyntaxKind.AsExpression;
13675+
}
13676+
13677+
function checkDeclarationInitializer(declaration: VariableLikeDeclaration) {
13678+
const type = checkExpressionCached(declaration.initializer);
13679+
return getCombinedNodeFlags(declaration) & NodeFlags.Const ||
13680+
getCombinedModifierFlags(declaration) & ModifierFlags.Readonly ||
13681+
isTypeAssertion(declaration.initializer) ? type : getBaseTypeOfLiteralType(type);
13682+
}
13683+
1367513684
function isLiteralContextualType(contextualType: Type) {
1367613685
if (contextualType) {
1367713686
if (contextualType.flags & TypeFlags.TypeParameter) {
@@ -13691,7 +13700,7 @@ namespace ts {
1369113700

1369213701
function checkExpressionForMutableLocation(node: Expression, contextualMapper?: TypeMapper): Type {
1369313702
const type = checkExpression(node, contextualMapper);
13694-
return isLiteralContextualType(getContextualType(node)) ? type : getBaseTypeOfLiteralType(type);
13703+
return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getBaseTypeOfLiteralType(type);
1369513704
}
1369613705

1369713706
function checkPropertyAssignment(node: PropertyAssignment, contextualMapper?: TypeMapper): Type {
@@ -18509,7 +18518,7 @@ namespace ts {
1850918518

1851018519
// When resolved as an expression identifier, if the given node references an exported entity, return the declaration
1851118520
// node of the exported entity's container. Otherwise, return undefined.
18512-
function getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration {
18521+
function getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration | undefined {
1851318522
node = getParseTreeNode(node, isIdentifier);
1851418523
if (node) {
1851518524
// When resolving the export container for the name of a module or enum
@@ -18531,10 +18540,11 @@ namespace ts {
1853118540
const parentSymbol = getParentOfSymbol(symbol);
1853218541
if (parentSymbol) {
1853318542
if (parentSymbol.flags & SymbolFlags.ValueModule && parentSymbol.valueDeclaration.kind === SyntaxKind.SourceFile) {
18543+
const symbolFile = <SourceFile>parentSymbol.valueDeclaration;
18544+
const referenceFile = getSourceFileOfNode(node);
1853418545
// If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined.
18535-
if (parentSymbol.valueDeclaration === getSourceFileOfNode(node)) {
18536-
return <SourceFile>parentSymbol.valueDeclaration;
18537-
}
18546+
const symbolIsUmdExport = symbolFile !== referenceFile;
18547+
return symbolIsUmdExport ? undefined : symbolFile;
1853818548
}
1853918549
for (let n = node.parent; n; n = n.parent) {
1854018550
if (isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) {
@@ -18544,8 +18554,6 @@ namespace ts {
1854418554
}
1854518555
}
1854618556
}
18547-
18548-
return undefined;
1854918557
}
1855018558

1855118559
// When resolved as an expression identifier, if the given node references an import, return the declaration of

src/compiler/diagnosticMessages.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@
10431043
"category": "Error",
10441044
"code": 2348
10451045
},
1046-
"Cannot invoke an expression whose type lacks a call signature.": {
1046+
"Cannot invoke an expression whose type lacks a call signature. Type '{0}' has no compatible call signatures.": {
10471047
"category": "Error",
10481048
"code": 2349
10491049
},
@@ -1951,10 +1951,15 @@
19511951
"category": "Error",
19521952
"code": 2693
19531953
},
1954-
"Left side of comma operator is unused and has no side effects.": {
1954+
"Namespace '{0}' has no exported member '{1}'.": {
19551955
"category": "Error",
19561956
"code": 2694
19571957
},
1958+
"Left side of comma operator is unused and has no side effects.": {
1959+
"category": "Error",
1960+
"code": 2695
1961+
},
1962+
19581963
"Import declaration '{0}' is using private name '{1}'.": {
19591964
"category": "Error",
19601965
"code": 4000

src/harness/fourslash.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ namespace FourSlash {
363363
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,
364364
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
365365
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false,
366+
InsertSpaceAfterTypeAssertion: false,
366367
PlaceOpenBraceOnNewLineForFunctions: false,
367368
PlaceOpenBraceOnNewLineForControlBlocks: false,
368369
};

src/harness/loggedIO.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/// <reference path="..\..\src\compiler\sys.ts" />
22
/// <reference path="..\..\src\harness\harness.ts" />
3+
/// <reference path="..\..\src\harness\harnessLanguageService.ts" />
34
/// <reference path="..\..\src\harness\runnerbase.ts" />
5+
/// <reference path="..\..\src\harness\typeWriter.ts" />
46

57
interface FileInformation {
68
contents: string;

src/harness/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,25 @@
2222
"../compiler/utilities.ts",
2323
"../compiler/binder.ts",
2424
"../compiler/checker.ts",
25+
"../compiler/factory.ts",
26+
"../compiler/visitor.ts",
27+
"../compiler/transformers/ts.ts",
28+
"../compiler/transformers/jsx.ts",
29+
"../compiler/transformers/es7.ts",
30+
"../compiler/transformers/es6.ts",
31+
"../compiler/transformers/generators.ts",
32+
"../compiler/transformers/destructuring.ts",
33+
"../compiler/transformers/module/module.ts",
34+
"../compiler/transformers/module/system.ts",
35+
"../compiler/transformers/module/es6.ts",
36+
"../compiler/transformer.ts",
37+
"../compiler/comments.ts",
2538
"../compiler/sourcemap.ts",
2639
"../compiler/declarationEmitter.ts",
2740
"../compiler/emitter.ts",
2841
"../compiler/program.ts",
2942
"../compiler/commandLineParser.ts",
43+
"../compiler/tsc.ts",
3044
"../compiler/diagnosticInformationMap.generated.ts",
3145
"../services/breakpoints.ts",
3246
"../services/navigateTo.ts",

0 commit comments

Comments
 (0)