8000 Merge pull request #1198 from Microsoft/usingShorthand · rbuckton/TypeScript@c85fcca · GitHub
[go: up one dir, main page]

Skip to content

Commit c85fcca

Browse files
author
Yui
committed
Merge pull request microsoft#1198 from Microsoft/usingShorthand
Using shorthand property assignment in compiler
2 parents a9cf216 + df54db7 commit c85fcca

21 files changed

+235
-297
lines changed

src/compiler/checker.ts

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -75,43 +75,43 @@ module ts {
7575

7676
var checker: TypeChecker = {
7777
getProgram: () => program,
78-
getDiagnostics: getDiagnostics,
79-
getGlobalDiagnostics: getGlobalDiagnostics,
8078
getNodeCount: () => sum(program.getSourceFiles(), "nodeCount"),
8179
getIdentifierCount: () => sum(program.getSourceFiles(), "identifierCount"),
8280
getSymbolCount: () => sum(program.getSourceFiles(), "symbolCount"),
8381
getTypeCount: () => typeCount,
84-
checkProgram: checkProgram,
85-
emitFiles: invokeEmitter,
86-
getParentOfSymbol: getParentOfSymbol,
87-
getNarrowedTypeOfSymbol: getNarrowedTypeOfSymbol,
88-
getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
89-
getPropertiesOfType: getPropertiesOfType,
90-
getPropertyOfType: getPropertyOfType,
91-
getSignaturesOfType: getSignaturesOfType,
92-
getIndexTypeOfType: getIndexTypeOfType,
93-
getReturnTypeOfSignature: getReturnTypeOfSignature,
94-
getSymbolsInScope: getSymbolsInScope,
95-
getSymbolInfo: getSymbolInfo,
96-
getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol,
97-
getTypeOfNode: getTypeOfNode,
98-
typeToString: typeToString,
99-
getSymbolDisplayBuilder: getSymbolDisplayBuilder,
100-
symbolToString: symbolToString,
101-
getAugmentedPropertiesOfType: getAugmentedPropertiesOfType,
102-
getRootSymbols: getRootSymbols,
103-
getContextualType: getContextualType,
104-
getFullyQualifiedName: getFullyQualifiedName,
105-
getResolvedSignature: getResolvedSignature,
106-
getEnumMemberValue: getEnumMemberValue,
107-
isValidPropertyAccess: isValidPropertyAccess,
108-
getSignatureFromDeclaration: getSignatureFromDeclaration,
109-
isImplementationOfOverload: isImplementationOfOverload,
110-
getAliasedSymbol: resolveImport,
11182
isUndefinedSymbol: symbol => symbol === undefinedSymbol,
11283
isArgumentsSymbol: symbol => symbol === argumentsSymbol,
113-
hasEarlyErrors: hasEarlyErrors,
114-
isEmitBlocked: isEmitBlocked
84+
getDiagnostics,
85+
getGlobalDiagnostics,
86+
checkProgram,
87+
invokeEmitter,
88+
getParentOfSymbol,
89+
getNarrowedTypeOfSymbol,
90+
getDeclaredTypeOfSymbol,
91+
getPropertiesOfType,
92+
getPropertyOfType,
93+
getSignaturesOfType,
94+
getIndexTypeOfType,
95+
getReturnTypeOfSignature,
96+
getSymbolsInScope,
97+
getSymbolInfo,
98+
getShorthandAssignmentValueSymbol,
99+
getTypeOfNode,
100+
typeToString,
101+
getSymbolDisplayBuilder,
102+
symbolToString,
103+
getAugmentedPropertiesOfType,
104+
getRootSymbols,
105+
getContextualType,
106+
getFullyQualifiedName,
107+
getResolvedSignature,
108+
getEnumMemberValue,
109+
isValidPropertyAccess,
110+
getSignatureFromDeclaration,
111+
isImplementationOfOverload,
112+
getAliasedSymbol: resolveImport,
113+
hasEarlyErrors,
114+
isEmitBlocked,
115115
};
116116

117117
var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined");
@@ -953,7 +953,7 @@ module ts {
953953
if (forEach(symbol.declarations, declaration => !getIsDeclarationVisible(declaration))) {
954954
return undefined;
955955
}
956-
return { aliasesToMakeVisible: aliasesToMakeVisible };
956+
return { aliasesToMakeVisible };
957957

958958
function getIsDeclarationVisible(declaration: Declaration) {
959959
if (!isDeclarationVisible(declaration)) {
@@ -9118,22 +9118,22 @@ module ts {
91189118
function invokeEmitter(targetSourceFile?: SourceFile) {
91199119
var resolver: EmitResolver = {
91209120
getProgram: () => program,
9121-
getLocalNameOfContainer: getLocalNameOfContainer,
9122-
getExpressionNamePrefix: getExpressionNamePrefix,
9123-
getExportAssignmentName: getExportAssignmentName,
9124-
isReferencedImportDeclaration: isReferencedImportDeclaration,
9125-
getNodeCheckFlags: getNodeCheckFlags,
9126-
getEnumMemberValue: getEnumMemberValue,
9127-
isTopLevelValueImportWithEntityName: isTopLevelValueImportWithEntityName,
9128-
hasSemanticErrors: hasSemanticErrors,
9129-
isEmitBlocked: isEmitBlocked,
9130-
isDeclarationVisible: isDeclarationVisible,
9131-
isImplementationOfOverload: isImplementationOfOverload,
9132-
writeTypeAtLocation: writeTypeAtLocation,
9133-
writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration,
9134-
isSymbolAccessible: isSymbolAccessible,
9135-
isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile,
9136-
getConstantValue: getConstantValue,
9121+
getLocalNameOfContainer,
9122+
getExpressionNamePrefix,
9123+
getExportAssignmentName,
9124+
isReferencedImportDeclaration,
9125+
getNodeCheckFlags,
9126+
getEnumMemberValue,
9127+
isTopLevelValueImportWithEntityName,
9128+
hasSemanticErrors,
9129+
isEmitBlocked,
9130+
isDeclarationVisible,
9131+
isImplementationOfOverload,
9132+
writeTypeAtLocation,
9133+
writeReturnTypeOfSignatureDeclaration,
9134+
isSymbolAccessible,
9135+
isImportDeclarationEntityNameReferenceDeclarationVisibile,
9136+
getConstantValue,
91379137
};
91389138
checkProgram();
91399139
return emitFiles(resolver, targetSourceFile);

src/compiler/commandLineParser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ module ts {
153153

154154
parseStrings(commandLine);
155155
return {
156-
options: options,
157-
filenames: filenames,
158-
errors: errors
156+
options,
157+
filenames,
158+
errors
159159
};
160160

161161
function parseStrings(args: string[]) {

src/compiler/core.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ module ts {
258258
}
259259

260260
return {
261-
file: file,
262-
start: start,
263-
length: length,
261+
file,
262+
start,
263+
length,
264264

265265
messageText: text,
266266
category: message.category,
@@ -335,12 +335,12 @@ module ts {
335335
}
336336

337337
return {
338-
file: file,
339-
start: start,
340-
length: length,
341-
code: code,
342-
category: category,
343-
messageText: messageText
338+
file,
339+
start,
340+
length,
341+
code,
342+
category,
343+
messageText
344344
};
345345
}
346346

src/compiler/emitter.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ module ts {
104104
}
105105
});
106106
return {
107-
firstAccessor: firstAccessor,
108-
getAccessor: getAccessor,
109-
setAccessor: setAccessor
107+
firstAccessor,
108+
getAccessor,
109+
setAccessor
110110
};
111111
}
112112

@@ -2787,7 +2787,7 @@ module ts {
27872787
Diagnostics.Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2 :
27882788
Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1;
27892789
return {
2790-
diagnosticMessage: diagnosticMessage,
2790+
diagnosticMessage,
27912791
errorNode: node,
27922792
typeName: node.name
27932793
};
@@ -2884,7 +2884,7 @@ module ts {
28842884
}
28852885

28862886
return {
2887-
diagnosticMessage: diagnosticMessage,
2887+
diagnosticMessage,
28882888
errorNode: node,
28892889
typeName: node.name
28902890
};
@@ -2949,7 +2949,7 @@ module ts {
29492949
}
29502950

29512951
return {
2952-
diagnosticMessage: diagnosticMessage,
2952+
diagnosticMessage,
29532953
errorNode: node,
29542954
typeName: (<Declaration>node.parent).name
29552955
};
@@ -3131,7 +3131,7 @@ module ts {
31313131
Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1;
31323132
}
31333133
return {
3134-
diagnosticMessage: diagnosticMessage,
3134+
diagnosticMessage,
31353135
errorNode: <Node>node.parameters[0],
31363136
// TODO(jfreeman): Investigate why we are passing node.name instead of node.parameters[0].name
31373137
typeName: node.name
@@ -3153,7 +3153,7 @@ module ts {
31533153
Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0;
31543154
}
31553155
return {
3156-
diagnosticMessage: diagnosticMessage,
3156+
diagnosticMessage,
31573157
errorNode: <Node>node.name,
31583158
typeName: undefined
31593159
};
@@ -3283,7 +3283,7 @@ module ts {
32833283
}
32843284

32853285
return {
3286-
diagnosticMessage: diagnosticMessage,
3286+
diagnosticMessage,
32873287
errorNode: <Node>node.name || node,
32883288
};
32893289
}
@@ -3368,7 +3368,7 @@ module ts {
33683368
}
33693369

33703370
return {
3371-
diagnosticMessage: diagnosticMessage,
3371+
diagnosticMessage,
33723372
errorNode: node,
33733373
typeName: node.name
33743374
};
@@ -3553,22 +3553,22 @@ module ts {
35533553
var hasEmitterError = forEach(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
35543554

35553555
// Check and update returnCode for syntactic and semantic
3556-
var returnCode: EmitReturnStatus;
3556+
var emitResultStatus: EmitReturnStatus;
35573557
if (isEmitBlocked) {
3558-
returnCode = EmitReturnStatus.AllOutputGenerationSkipped;
3558+
emitResultStatus = EmitReturnStatus.AllOutputGenerationSkipped;
35593559
} else if (hasEmitterError) {
3560-
returnCode = EmitReturnStatus.EmitErrorsEncountered;
3560+
emitResultStatus = EmitReturnStatus.EmitErrorsEncountered;
35613561
} else if (hasSemanticErrors && compilerOptions.declaration) {
3562-
returnCode = EmitReturnStatus.DeclarationGenerationSkipped;
3562+
emitResultStatus = EmitReturnStatus.DeclarationGenerationSkipped;
35633563
} else if (hasSemanticErrors && !compilerOptions.declaration) {
3564-
returnCode = EmitReturnStatus.JSGeneratedWithSemanticErrors;
3564+
emitResultStatus = EmitReturnStatus.JSGeneratedWithSemanticErrors;
35653565
} else {
3566-
returnCode = EmitReturnStatus.Succeeded;
3566+
emitResultStatus = EmitReturnStatus.Succeeded;
35673567
}
35683568

35693569
return {
3570-
emitResultStatus: returnCode,
3571-
errors: diagnostics,
3570+
emitResultStatus,
3571+
diagnostics,
35723572
sourceMaps: sourceMapDataList
35733573
};
35743574
}

src/compiler/parser.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -775,13 +775,12 @@ module ts {
775775
if (matchResult) {
776776
var start = commentRange.pos;
777777
var end = commentRange.end;
778-
var fileRef = {
779-
pos: start,
780-
end: end,
781-
filename: matchResult[3]
782-
};
783778
return {
784-
fileReference: fileRef,
779+
fileReference: {
780+
pos: start,
781+
end: end,
782+
filename: matchResult[3]
783+
},
785784
isNoDefaultLib: false
786785
};
787786
}
@@ -945,11 +944,11 @@ module ts {
945944
}
946945

947946
return {
948-
addLabel: addLabel,
949-
pushCurrentLabelSet: pushCurrentLabelSet,
950-
pushFunctionBoundary: pushFunctionBoundary,
951-
pop: pop,
952-
nodeIsNestedInLabel: nodeIsNestedInLabel,
947+
addLabel,
948+
pushCurrentLabelSet,
949+
pushFunctionBoundary,
950+
pop,
951+
nodeIsNestedInLabel,
953952
};
954953
})();
955954

@@ -1675,8 +1674,8 @@ module ts {
16751674
}
16761675

16771676
return {
1678-
typeParameters: typeParameters,
1679-
parameters: parameters,
1677+
typeParameters,
1678+
parameters,
16801679
type: type
16811680
};
16821681
}
@@ -4287,9 +4286,9 @@ module ts {
42874286
}
42884287
commentRanges = undefined;
42894288
return {
4290-
referencedFiles: referencedFiles,
4291-
amdDependencies: amdDependencies,
4292-
amdModuleName: amdModuleName
4289+
referencedFiles,
4290+
amdDependencies,
4291+
amdModuleName
42934292
};
42944293
}
42954294

src/compiler/scanner.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,13 +1167,13 @@ module ts {
11671167
hasPrecedingLineBreak: () => precedingLineBreak,
11681168
isIdentifier: () => token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord,
11691169
isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord,
1170-
reScanGreaterToken: reScanGreaterToken,
1171-
reScanSlashToken: reScanSlashToken,
1172-
reScanTemplateToken: reScanTemplateToken,
1173-
scan: scan,
1174-
setText: setText,
1175-
setTextPos: setTextPos,
1176-
tryScan: tryScan,
1170+
reScanGreaterToken,
1171+
reScanSlashToken,
1172+
reScanTemplateToken,
1173+
scan,
1174+
setText,
1175+
setTextPos,
1176+
tryScan,
11771177
};
11781178
}
11791179
}

src/compiler/sys.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ var sys: System = (function () {
9999
}
100100

101101
return {
102-
args: args,
102+
args,
103103
newLine: "\r\n",
104104
useCaseSensitiveFileNames: false,
105105
write(s: string): void {
106106
WScript.StdOut.Write(s);
107107
},
108-
readFile: readFile,
109-
writeFile: writeFile,
108+
readFile,
109+
writeFile,
110110
resolvePath(path: string): string {
111111
return fso.GetAbsolutePathName(path);
112112
},
@@ -191,8 +191,8 @@ var sys: System = (function () {
191191
// 1 is a standard descriptor for stdout
192192
_fs.writeSync(1, s);
193193
},
194-
readFile: readFile,
195-
writeFile: writeFile,
194+
readFile,
195+
writeFile,
196196
watchFile: (fileName, callback) => {
197197
// watchFile polls a file every 250ms, picking up file notifications.
198198
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);

0 commit comments

Comments
 (0)
0