Skip to content

Commit cec3a37

Browse files
committed
Merge branch 'master' into object-spread
2 parents 57850ec + a67ad06 commit cec3a37

265 files changed

Lines changed: 28293 additions & 1097 deletions

File tree

Some content is hidden

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

Gulpfile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,16 +725,16 @@ declare module "convert-source-map" {
725725
}
726726

727727
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
728-
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "built/local/bundle.js" }, /*useBuiltCompiler*/ true));
728+
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "../../built/local/bundle.js" }, /*useBuiltCompiler*/ true));
729729
return testProject.src()
730730
.pipe(newer("built/local/bundle.js"))
731731
.pipe(sourcemaps.init())
732-
.pipe(testProject)
732+
.pipe(testProject())
733733
.pipe(through2.obj((file, enc, next) => {
734734
const originalMap = file.sourceMap;
735735
const prebundledContent = file.contents.toString();
736736
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
737-
originalMap.sources = originalMap.sources.map(s => path.resolve("src", s));
737+
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
738738
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
739739
originalMap.file = "built/local/_stream_0.js";
740740

scripts/processDiagnosticMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
8686
'/// <reference path="types.ts" />\r\n' +
8787
'/* @internal */\r\n' +
8888
'namespace ts {\r\n' +
89-
' export var Diagnostics = {\r\n';
89+
' export const Diagnostics = {\r\n';
9090
var names = Utilities.getObjectKeys(messageTable);
9191
for (var i = 0; i < names.length; i++) {
9292
var name = names[i];

scripts/tslint/typeOperatorSpacingRule.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ class TypeOperatorSpacingWalker extends Lint.RuleWalker {
1818
for (let i = 1; i < types.length; i++) {
1919
const currentType = types[i];
2020
if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) {
21-
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
22-
this.addFailure(failure);
21+
const sourceFile = currentType.getSourceFile();
22+
const previousTypeEndPos = sourceFile.getLineAndCharacterOfPosition(types[i - 1].end);
23+
const currentTypeStartPos = sourceFile.getLineAndCharacterOfPosition(currentType.pos);
24+
if (previousTypeEndPos.line === currentTypeStartPos.line) {
25+
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
26+
this.addFailure(failure);
27+
}
2328
}
2429
expectedStart = currentType.end + 2;
2530
}

src/compiler/binder.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,24 @@ namespace ts {
355355
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
356356
: Diagnostics.Duplicate_identifier_0;
357357

358-
forEach(symbol.declarations, declaration => {
359-
if (hasModifier(declaration, ModifierFlags.Default)) {
358+
if (symbol.declarations && symbol.declarations.length) {
359+
// If the current node is a default export of some sort, then check if
360+
// there are any other default exports that we need to error on.
361+
// We'll know whether we have other default exports depending on if `symbol` already has a declaration list set.
362+
if (isDefaultExport) {
360363
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
361364
}
362-
});
365+
else {
366+
// This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration.
367+
// Error on multiple export default in the following case:
368+
// 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default
369+
// 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers)
370+
if (symbol.declarations && symbol.declarations.length &&
371+
(isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(<ExportAssignment>node).isExportEquals))) {
372+
message = Diagnostics.A_module_cannot_have_multiple_default_exports;
373+
}
374+
}
375+
}
363376

364377
forEach(symbol.declarations, declaration => {
365378
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));
@@ -1114,7 +1127,7 @@ namespace ts {
11141127
}
11151128
else {
11161129
forEachChild(node, bind);
1117-
if (node.operator === SyntaxKind.PlusEqualsToken || node.operator === SyntaxKind.MinusMinusToken) {
1130+
if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) {
11181131
bindAssignmentTargetFlow(node.operand);
11191132
}
11201133
}
@@ -1363,7 +1376,7 @@ namespace ts {
13631376
function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean {
13641377
const body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
13651378
if (body && (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock)) {
1366-
for (const stat of (<Block>body).statements) {
1379+
for (const stat of (<BlockLike>body).statements) {
13671380
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
13681381
return true;
13691382
}
@@ -1948,12 +1961,15 @@ namespace ts {
19481961
bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node));
19491962
}
19501963
else {
1964+
// An export default clause with an expression exports a value
1965+
// We want to exclude both class and function here, this is necessary to issue an error when there are both
1966+
// default export-assignment and default export function and class declaration.
19511967
const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(<ExportAssignment>node)
19521968
// An export default clause with an EntityNameExpression exports all meanings of that identifier
19531969
? SymbolFlags.Alias
19541970
// An export default clause with any other expression exports a value
19551971
: SymbolFlags.Property;
1956-
declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
1972+
declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.Property | SymbolFlags.AliasExcludes | SymbolFlags.Class | SymbolFlags.Function);
19571973
}
19581974
}
19591975

@@ -2436,8 +2452,7 @@ namespace ts {
24362452
}
24372453

24382454
// If the parameter's name is 'this', then it is TypeScript syntax.
2439-
if (subtreeFlags & TransformFlags.ContainsDecorators
2440-
|| (name && isIdentifier(name) && name.originalKeywordKind === SyntaxKind.ThisKeyword)) {
2455+
if (subtreeFlags & TransformFlags.ContainsDecorators || isThisIdentifier(name)) {
24412456
transformFlags |= TransformFlags.AssertTypeScript;
24422457
}
24432458

0 commit comments

Comments
 (0)