Merge remote-tracking branch 'Microsoft/master'

This commit is contained in:
SaschaNaz
2015-09-12 16:16:53 +09:00
119 changed files with 2148 additions and 257 deletions
View File
+23 -10
View File
@@ -4640,7 +4640,9 @@ namespace ts {
// and intersection types are further deconstructed on the target side, we don't want to
// make the check again (as it might fail for a partial target type). Therefore we obtain
// the regular source type and proceed with that.
source = getRegularTypeOfObjectLiteral(source);
if (target.flags & TypeFlags.UnionOrIntersection) {
source = getRegularTypeOfObjectLiteral(source);
}
}
let saveErrorInfo = errorInfo;
@@ -5111,8 +5113,8 @@ namespace ts {
function abstractSignatureRelatedTo(source: Type, sourceSig: Signature, target: Type, targetSig: Signature) {
if (sourceSig && targetSig) {
let sourceDecl = source.symbol && getDeclarationOfKind(source.symbol, SyntaxKind.ClassDeclaration);
let targetDecl = target.symbol && getDeclarationOfKind(target.symbol, SyntaxKind.ClassDeclaration);
let sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
let targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
// If the source object isn't itself a class declaration, it can be freely assigned, regardless
@@ -5126,8 +5128,8 @@ namespace ts {
let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration);
let targetReturnDecl = targetReturnType && targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration);
let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
let targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract;
let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract;
@@ -5511,6 +5513,7 @@ namespace ts {
regularType.constructSignatures = (<ResolvedType>type).constructSignatures;
regularType.stringIndexType = (<ResolvedType>type).stringIndexType;
regularType.numberIndexType = (<ResolvedType>type).numberIndexType;
(<FreshObjectLiteralType>type).regularType = regularType;
}
return regularType;
}
@@ -8879,7 +8882,7 @@ namespace ts {
// Note, only class declarations can be declared abstract.
// In the case of a merged class-module or class-interface declaration,
// only the class declaration node will have the Abstract flag set.
let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration);
let valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & NodeFlags.Abstract) {
error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -12631,6 +12634,10 @@ namespace ts {
return s.flags & SymbolFlags.Instantiated ? getSymbolLinks(s).target : s;
}
function getClassLikeDeclarationOfSymbol(symbol: Symbol): Declaration {
return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined);
}
function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: ObjectType): void {
// TypeScript 1.0 spec (April 2014): 8.2.3
@@ -12668,14 +12675,20 @@ namespace ts {
if (derived === base) {
// derived class inherits base without override/redeclaration
let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration);
let derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
// It is an error to inherit an abstract member without implementing it or being declared abstract.
// If there is no declaration for the derived class (as in the case of class expressions),
// then the class cannot be declared abstract.
if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) {
error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2,
typeToString(type), symbolToString(baseProperty), typeToString(baseType));
if (baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) {
if (derivedClassDecl.kind === SyntaxKind.ClassExpression) {
error(derivedClassDecl, Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1,
symbolToString(baseProperty), typeToString(baseType));
}
else {
error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2,
typeToString(type), symbolToString(baseProperty), typeToString(baseType));
}
}
}
else {
@@ -427,6 +427,7 @@ namespace ts {
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
+6 -1
View File
@@ -1692,11 +1692,16 @@
"A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": {
"category": "Error",
"code": 2651
},
},
"Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": {
"category": "Error",
"code": 2652
},
"Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.": {
"category": "Error",
"code": 2653
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
+97 -52
View File
@@ -186,6 +186,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
/** Sourcemap data that will get encoded */
let sourceMapData: SourceMapData;
/** If removeComments is true, no leading-comments needed to be emitted **/
let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker;
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -1292,8 +1295,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) {
function emitJsxAttribute(node: JsxAttribute) {
emit(node.name);
write("=");
emit(node.initializer);
if (node.initializer) {
write("=");
emit(node.initializer);
}
}
function emitJsxSpreadAttribute(node: JsxSpreadAttribute) {
@@ -2352,7 +2357,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
operand.kind !== SyntaxKind.PostfixUnaryExpression &&
operand.kind !== SyntaxKind.NewExpression &&
!(operand.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.NewExpression) &&
!(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression)) {
!(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression) &&
!(operand.kind === SyntaxKind.NumericLiteral && node.parent.kind === SyntaxKind.PropertyAccessExpression)) {
emit(operand);
return;
}
@@ -3666,7 +3672,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitFunctionDeclaration(node: FunctionLikeDeclaration) {
if (nodeIsMissing(node.body)) {
return emitOnlyPinnedOrTripleSlashComments(node);
return emitCommentsOnNotEmittedNode(node);
}
// TODO (yuisu) : we should not have special cases to condition emitting comments
@@ -4143,7 +4149,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
else if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) {
if (!(<MethodDeclaration>member).body) {
return emitOnlyPinnedOrTripleSlashComments(member);
return emitCommentsOnNotEmittedNode(member);
}
writeLine();
@@ -4210,7 +4216,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitMemberFunctionsForES6AndHigher(node: ClassLikeDeclaration) {
for (let member of node.members) {
if ((member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) && !(<MethodDeclaration>member).body) {
emitOnlyPinnedOrTripleSlashComments(member);
emitCommentsOnNotEmittedNode(member);
}
else if (member.kind === SyntaxKind.MethodDeclaration ||
member.kind === SyntaxKind.GetAccessor ||
@@ -4267,7 +4273,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// Emit the constructor overload pinned comments
forEach(node.members, member => {
if (member.kind === SyntaxKind.Constructor && !(<ConstructorDeclaration>member).body) {
emitOnlyPinnedOrTripleSlashComments(member);
emitCommentsOnNotEmittedNode(member);
}
// Check if there is any non-static property assignment
if (member.kind === SyntaxKind.PropertyDeclaration && (<PropertyDeclaration>member).initializer && (member.flags & NodeFlags.Static) === 0) {
@@ -5166,7 +5172,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitInterfaceDeclaration(node: InterfaceDeclaration) {
emitOnlyPinnedOrTripleSlashComments(node);
emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node: EnumDeclaration) {
@@ -5288,7 +5294,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
let shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
return emitOnlyPinnedOrTripleSlashComments(node);
return emitCommentsOnNotEmittedNode(node);
}
let hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
let emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -6718,7 +6724,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitNodeConsideringCommentsOption(node: Node, emitNodeConsideringSourcemap: (node: Node) => void): void {
if (node) {
if (node.flags & NodeFlags.Ambient) {
return emitOnlyPinnedOrTripleSlashComments(node);
return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
@@ -6985,22 +6991,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
return leadingComments;
}
/**
* Removes all but the pinned or triple slash comments.
* @param ranges The array to be filtered
* @param onlyPinnedOrTripleSlashComments whether the filtering should be performed.
*/
function filterComments(ranges: CommentRange[], onlyPinnedOrTripleSlashComments: boolean): CommentRange[] {
// If we're removing comments, then we want to strip out all but the pinned or
// triple slash comments.
if (ranges && onlyPinnedOrTripleSlashComments) {
ranges = filter(ranges, isPinnedOrTripleSlashComment);
if (ranges.length === 0) {
return undefined;
}
}
function isPinnedComments(comment: CommentRange) {
return currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
}
return ranges;
/**
* Determine if the given comment is a triple-slash
*
* @return true if the comment is a triple-slash comment else false
**/
function isTripleSlashComment(comment: CommentRange) {
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
// so that we don't end up computing comment string and doing match for all // comments
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash &&
comment.pos + 2 < comment.end &&
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash) {
let textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
return textSubStr.match(fullTripleSlashReferencePathRegEx) ||
textSubStr.match(fullTripleSlashAMDReferencePathRegEx) ?
true : false;
}
return false;
}
function getLeadingCommentsToEmit(node: Node) {
@@ -7028,28 +7040,53 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
function emitOnlyPinnedOrTripleSlashComments(node: Node) {
emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true);
/**
* Emit comments associated with node that will not be emitted into JS file
*/
function emitCommentsOnNotEmittedNode(node: Node) {
emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false);
}
function emitLeadingComments(node: Node) {
return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true);
}
function emitLeadingCommentsWorker(node: Node, onlyPinnedOrTripleSlashComments: boolean) {
// If the caller only wants pinned or triple slash comments, then always filter
// down to that set. Otherwise, filter based on the current compiler options.
let leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
function emitLeadingCommentsWorker(node: Node, isEmittedNode: boolean) {
if (compilerOptions.removeComments) {
return;
}
let leadingComments: CommentRange[];
if (isEmittedNode) {
leadingComments = getLeadingCommentsToEmit(node);
}
else {
// If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node,
// unless it is a triple slash comment at the top of the file.
// For Example:
// /// <reference-path ...>
// declare var x;
// /// <reference-path ...>
// interface F {}
// The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted
if (node.pos === 0) {
leadingComments = filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
}
}
emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment);
}
function emitTrailingComments(node: Node) {
if (compilerOptions.removeComments) {
return;
}
// Emit the trailing comments only if the parent's end doesn't match
let trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
let trailingComments = getTrailingCommentsToEmit(node);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
@@ -7061,13 +7098,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
* ^ => pos; the function will emit "comment1" in the emitJS
*/
function emitTrailingCommentsOfPosition(pos: number) {
let trailingComments = filterComments(getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
if (compilerOptions.removeComments) {
return;
}
let trailingComments = getTrailingCommentRanges(currentSourceFile.text, pos);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
function emitLeadingCommentsOfPosition(pos: number) {
function emitLeadingCommentsOfPositionWorker(pos: number) {
if (compilerOptions.removeComments) {
return;
}
let leadingComments: CommentRange[];
if (hasDetachedComments(pos)) {
// get comments without detached comments
@@ -7078,7 +7123,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
leadingComments = getLeadingCommentRanges(currentSourceFile.text, pos);
}
leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
@@ -7086,7 +7130,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitDetachedComments(node: TextRange) {
let leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos);
let leadingComments: CommentRange[];
if (compilerOptions.removeComments) {
// removeComments is true, only reserve pinned comment at the top of file
// For example:
// /*! Pinned Comment */
//
// var x = 10;
if (node.pos === 0) {
leadingComments = filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
}
}
else {
// removeComments is false, just get detached as normal and bypass the process to filter comment
leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos);
}
if (leadingComments) {
let detachedComments: CommentRange[] = [];
let lastComment: CommentRange;
@@ -7136,20 +7195,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write(shebang);
}
}
function isPinnedOrTripleSlashComment(comment: CommentRange) {
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
}
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
// so that we don't end up computing comment string and doing match for all // comments
else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash &&
comment.pos + 2 < comment.end &&
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash &&
currentSourceFile.text.substring(comment.pos, comment.end).match(fullTripleSlashReferencePathRegEx)) {
return true;
}
}
}
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
+13 -17
View File
@@ -1058,11 +1058,11 @@ namespace ts {
}
function parseIdentifierName(): Identifier {
return createIdentifier(isIdentifierOrKeyword());
return createIdentifier(tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName(): boolean {
return isIdentifierOrKeyword() ||
return tokenIsIdentifierOrKeyword(token) ||
token === SyntaxKind.StringLiteral ||
token === SyntaxKind.NumericLiteral;
}
@@ -1086,7 +1086,7 @@ namespace ts {
}
function isSimplePropertyName() {
return token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || isIdentifierOrKeyword();
return token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName(): ComputedPropertyName {
@@ -1213,9 +1213,9 @@ namespace ts {
case ParsingContext.HeritageClauses:
return isHeritageClause();
case ParsingContext.ImportOrExportSpecifiers:
return isIdentifierOrKeyword();
return tokenIsIdentifierOrKeyword(token);
case ParsingContext.JsxAttributes:
return isIdentifierOrKeyword() || token === SyntaxKind.OpenBraceToken;
return tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.OpenBraceToken;
case ParsingContext.JsxChildren:
return true;
case ParsingContext.JSDocFunctionParameters:
@@ -1254,7 +1254,7 @@ namespace ts {
function nextTokenIsIdentifierOrKeyword() {
nextToken();
return isIdentifierOrKeyword();
return tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword(): boolean {
@@ -1824,7 +1824,7 @@ namespace ts {
// the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword".
// In the first case though, ASI will not take effect because there is not a
// line terminator after the identifier or keyword.
if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
if (scanner.hasPrecedingLineBreak() && tokenIsIdentifierOrKeyword(token)) {
let matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
if (matchesPattern) {
@@ -2282,7 +2282,7 @@ namespace ts {
}
}
if (isIdentifierOrKeyword()) {
if (tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -4101,13 +4101,9 @@ namespace ts {
}
}
function isIdentifierOrKeyword() {
return token >= SyntaxKind.Identifier;
}
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
return tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
@@ -4117,7 +4113,7 @@ namespace ts {
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
return (isIdentifierOrKeyword() || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak();
return (tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration(): boolean {
@@ -4170,7 +4166,7 @@ namespace ts {
case SyntaxKind.ImportKeyword:
nextToken();
return token === SyntaxKind.StringLiteral || token === SyntaxKind.AsteriskToken ||
token === SyntaxKind.OpenBraceToken || isIdentifierOrKeyword();
token === SyntaxKind.OpenBraceToken || tokenIsIdentifierOrKeyword(token);
case SyntaxKind.ExportKeyword:
nextToken();
if (token === SyntaxKind.EqualsToken || token === SyntaxKind.AsteriskToken ||
@@ -4777,7 +4773,7 @@ namespace ts {
// It is very important that we check this *after* checking indexers because
// the [ token can start an index signature or a computed property name
if (isIdentifierOrKeyword() ||
if (tokenIsIdentifierOrKeyword(token) ||
token === SyntaxKind.StringLiteral ||
token === SyntaxKind.NumericLiteral ||
token === SyntaxKind.AsteriskToken ||
@@ -5320,7 +5316,7 @@ namespace ts {
return true;
}
return isIdentifierOrKeyword();
return tokenIsIdentifierOrKeyword(token);
}
export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) {
+44 -34
View File
@@ -358,7 +358,8 @@ namespace ts {
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
let program: Program;
let files: SourceFile[] = [];
let diagnostics = createDiagnosticCollection();
let fileProcessingDiagnostics = createDiagnosticCollection();
let programDiagnostics = createDiagnosticCollection();
let commonSourceDirectory: string;
let diagnosticsProducingTypeChecker: TypeChecker;
@@ -428,6 +429,7 @@ namespace ts {
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
getFileProcessingDiagnostics: () => fileProcessingDiagnostics
};
return program;
@@ -460,6 +462,7 @@ namespace ts {
// check if program source files has changed in the way that can affect structure of the program
let newSourceFiles: SourceFile[] = [];
let modifiedSourceFiles: SourceFile[] = [];
for (let oldSourceFile of oldProgram.getSourceFiles()) {
let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target);
if (!newSourceFile) {
@@ -499,6 +502,7 @@ namespace ts {
}
// pass the cache of module resolutions from the old source file
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
modifiedSourceFiles.push(newSourceFile);
}
else {
// file has no changes - use it as is
@@ -515,7 +519,11 @@ namespace ts {
}
files = newSourceFiles;
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
for (let modifiedFile of modifiedSourceFiles) {
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
}
oldProgram.structureIsReused = true;
return true;
@@ -645,9 +653,10 @@ namespace ts {
Debug.assert(!!sourceFile.bindDiagnostics);
let bindDiagnostics = sourceFile.bindDiagnostics;
let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
let fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
let programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile);
});
}
@@ -664,7 +673,8 @@ namespace ts {
function getOptionsDiagnostics(): Diagnostic[] {
let allDiagnostics: Diagnostic[] = [];
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics())
addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics());
return sortAndDeduplicateDiagnostics(allDiagnostics);
}
@@ -772,10 +782,10 @@ namespace ts {
if (diagnostic) {
if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) {
diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument));
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument));
}
else {
diagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument));
fileProcessingDiagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument));
}
}
}
@@ -797,11 +807,11 @@ namespace ts {
// We haven't looked for this file, do so now and cache result
let file = host.getSourceFile(fileName, options.target, hostErrorMessage => {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
else {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
});
filesByName.set(canonicalName, file);
@@ -837,11 +847,11 @@ namespace ts {
let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
if (canonicalName !== sourceFileName) {
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
else {
diagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
}
}
}
@@ -877,7 +887,7 @@ namespace ts {
return;
function findModuleSourceFile(fileName: string, nameLiteral: Expression) {
return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end);
return findSourceFile(fileName, /* isDefaultLib */ false, file, skipTrivia(file.text, nameLiteral.pos), nameLiteral.end);
}
}
@@ -902,7 +912,7 @@ namespace ts {
for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
if (commonPathComponents[i] !== sourcePathComponents[i]) {
if (i === 0) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
return;
}
@@ -931,7 +941,7 @@ namespace ts {
if (!isDeclarationFile(sourceFile)) {
let absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
allFilesBelongToPath = false;
}
}
@@ -944,52 +954,52 @@ namespace ts {
function verifyCompilerOptions() {
if (options.isolatedModules) {
if (options.declaration) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
}
if (options.noEmitOnError) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
}
if (options.out) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
}
if (options.outFile) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
}
}
if (options.inlineSourceMap) {
if (options.sourceMap) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
}
if (options.mapRoot) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
}
if (options.sourceRoot) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
}
}
if (options.inlineSources) {
if (!options.sourceMap && !options.inlineSourceMap) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
}
}
if (options.out && options.outFile) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
}
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
// Error to specify --mapRoot or --sourceRoot without mapSourceFiles
if (options.mapRoot) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
}
if (options.sourceRoot) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
}
return;
}
@@ -1000,24 +1010,24 @@ namespace ts {
let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
if (options.isolatedModules) {
if (!options.module && languageVersion < ScriptTarget.ES6) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
}
let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
if (firstNonExternalModuleSourceFile) {
let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}
// Cannot specify module gen target when in es6 or above
if (options.module && languageVersion >= ScriptTarget.ES6) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
}
// there has to be common source directory if user specified --outdir || --sourceRoot
@@ -1046,30 +1056,30 @@ namespace ts {
if (options.noEmit) {
if (options.out) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
}
if (options.outFile) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
}
if (options.outDir) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
}
if (options.declaration) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
}
}
if (options.emitDecoratorMetadata &&
!options.experimentalDecorators) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
}
if (options.experimentalAsyncFunctions &&
options.target !== ScriptTarget.ES6) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
}
}
}
+6 -1
View File
@@ -6,6 +6,11 @@ namespace ts {
(message: DiagnosticMessage, length: number): void;
}
/* @internal */
export function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean {
return token >= SyntaxKind.Identifier;
}
export interface Scanner {
getStartPos(): number;
getToken(): SyntaxKind;
@@ -1590,7 +1595,7 @@ namespace ts {
// Scans a JSX identifier; these differ from normal identifiers in that
// they allow dashes
function scanJsxIdentifier(): SyntaxKind {
if (token === SyntaxKind.Identifier) {
if (tokenIsIdentifierOrKeyword(token)) {
let firstCharPosition = pos;
while (pos < end) {
let ch = text.charCodeAt(pos);
+3
View File
@@ -1359,6 +1359,7 @@ namespace ts {
/* @internal */ getSymbolCount(): number;
/* @internal */ getTypeCount(): number;
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
// For testing purposes only.
/* @internal */ structureIsReused?: boolean;
}
@@ -2322,5 +2323,7 @@ namespace ts {
// operation caused diagnostics to be returned by storing and comparing the return value
// of this method before/after the operation is performed.
getModificationCount(): number;
/* @internal */ reattachFileDiagnostics(newFile: SourceFile): void;
}
}
+13 -1
View File
@@ -435,6 +435,7 @@ namespace ts {
}
export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
export let fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
export function isTypeNode(node: Node): boolean {
if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) {
@@ -1507,12 +1508,23 @@ namespace ts {
add,
getGlobalDiagnostics,
getDiagnostics,
getModificationCount
getModificationCount,
reattachFileDiagnostics
};
function getModificationCount() {
return modificationCount;
}
function reattachFileDiagnostics(newFile: SourceFile): void {
if (!hasProperty(fileDiagnostics, newFile.fileName)) {
return;
}
for (let diagnostic of fileDiagnostics[newFile.fileName]) {
diagnostic.file = newFile;
}
}
function add(diagnostic: Diagnostic): void {
let diagnostics: Diagnostic[];
+7 -41
View File
@@ -213,27 +213,11 @@ namespace ts.formatting {
public NoSpaceBetweenYieldKeywordAndStar: Rule;
public SpaceBetweenYieldOrYieldStarAndOperand: Rule;
// Async-await
// Async functions
public SpaceBetweenAsyncAndFunctionKeyword: Rule;
public NoSpaceBetweenAsyncAndFunctionKeyword: Rule;
public SpaceAfterAwaitKeyword: Rule;
public NoSpaceAfterAwaitKeyword: Rule;
// Type alias declaration
public SpaceAfterTypeKeyword: Rule;
public NoSpaceAfterTypeKeyword: Rule;
// Tagged template string
public SpaceBetweenTagAndTemplateString: Rule;
public NoSpaceBetweenTagAndTemplateString: Rule;
// Type operation
public SpaceBeforeBar: Rule;
public NoSpaceBeforeBar: Rule;
public SpaceAfterBar: Rule;
public NoSpaceAfterBar: Rule;
public SpaceBeforeAmpersand: Rule;
public SpaceAfterAmpersand: Rule;
constructor() {
///
@@ -315,7 +299,7 @@ namespace ts.formatting {
this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space));
this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete));
this.SpaceAfterFunctionInFuncDecl = new Rule(RuleDescriptor.create3(SyntaxKind.FunctionKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space));
@@ -348,7 +332,7 @@ namespace ts.formatting {
this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// Add a space around certain TypeScript keywords
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
@@ -384,25 +368,9 @@ namespace ts.formatting {
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// Type alias declaration
this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// template string
this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// type operation
this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceBeforeAmpersand = new Rule(RuleDescriptor.create3(SyntaxKind.AmpersandToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.SpaceAfterAmpersand = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AmpersandToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
@@ -430,12 +398,8 @@ namespace ts.formatting {
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand,
this.SpaceBetweenAsyncAndFunctionKeyword,
this.SpaceBetweenTagAndTemplateString,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
@@ -539,6 +503,8 @@ namespace ts.formatting {
case SyntaxKind.ConditionalExpression:
case SyntaxKind.AsExpression:
case SyntaxKind.TypePredicate:
case SyntaxKind.UnionType:
case SyntaxKind.IntersectionType:
return true;
// equals in binding elements: function foo([[x, y] = [1, 2]])
@@ -7,6 +7,11 @@ declare var a;
(<any>[1,3,]);
(<any>"string");
(<any>23.0);
(<any>1);
(<any>1.);
(<any>1.0);
(<any>12e+34);
(<any>0xff);
(<any>/regexp/g);
(<any>false);
(<any>true);
@@ -23,6 +28,12 @@ declare var a;
declare var A;
// should keep the parentheses in emit
(<any>1).foo;
(<any>1.).foo;
(<any>1.0).foo;
(<any>12e+34).foo;
(<any>0xff).foo;
(<any>(1.0));
(<any>new A).foo;
(<any>typeof A).x;
(<any>-A).x;
@@ -46,6 +57,11 @@ new (<any>A());
[1, 3,];
"string";
23.0;
1;
1.;
1.0;
12e+34;
0xff;
/regexp/g;
false;
true;
@@ -59,6 +75,12 @@ a[0];
a.b["0"];
a().x;
// should keep the parentheses in emit
(1).foo;
(1.).foo;
(1.0).foo;
(12e+34).foo;
(0xff).foo;
(1.0);
(new A).foo;
(typeof A).x;
(-A).x;
@@ -10,6 +10,11 @@ declare var a;
(<any>[1,3,]);
(<any>"string");
(<any>23.0);
(<any>1);
(<any>1.);
(<any>1.0);
(<any>12e+34);
(<any>0xff);
(<any>/regexp/g);
(<any>false);
(<any>true);
@@ -33,36 +38,42 @@ declare var a;
>a : Symbol(a, Decl(castExpressionParentheses.ts, 0, 11))
declare var A;
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
// should keep the parentheses in emit
(<any>1).foo;
(<any>1.).foo;
(<any>1.0).foo;
(<any>12e+34).foo;
(<any>0xff).foo;
(<any>(1.0));
(<any>new A).foo;
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
(<any>typeof A).x;
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
(<any>-A).x;
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
new (<any>A());
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
(<Tany>()=> {})();
>Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 28, 2))
>Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 39, 2))
(<any>function foo() { })();
>foo : Symbol(foo, Decl(castExpressionParentheses.ts, 29, 6))
>foo : Symbol(foo, Decl(castExpressionParentheses.ts, 40, 6))
(<any><number><any>-A).x;
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
// nested cast, should keep one pair of parenthese
(<any><number>(<any>-A)).x;
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
// nested parenthesized expression, should keep one pair of parenthese
(<any>(A))
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
@@ -28,6 +28,31 @@ declare var a;
><any>23.0 : any
>23.0 : number
(<any>1);
>(<any>1) : any
><any>1 : any
>1 : number
(<any>1.);
>(<any>1.) : any
><any>1. : any
>1. : number
(<any>1.0);
>(<any>1.0) : any
><any>1.0 : any
>1.0 : number
(<any>12e+34);
>(<any>12e+34) : any
><any>12e+34 : any
>12e+34 : number
(<any>0xff);
>(<any>0xff) : any
><any>0xff : any
>0xff : number
(<any>/regexp/g);
>(<any>/regexp/g) : any
><any>/regexp/g : any
@@ -104,6 +129,47 @@ declare var A;
>A : any
// should keep the parentheses in emit
(<any>1).foo;
>(<any>1).foo : any
>(<any>1) : any
><any>1 : any
>1 : number
>foo : any
(<any>1.).foo;
>(<any>1.).foo : any
>(<any>1.) : any
><any>1. : any
>1. : number
>foo : any
(<any>1.0).foo;
>(<any>1.0).foo : any
>(<any>1.0) : any
><any>1.0 : any
>1.0 : number
>foo : any
(<any>12e+34).foo;
>(<any>12e+34).foo : any
>(<any>12e+34) : any
><any>12e+34 : any
>12e+34 : number
>foo : any
(<any>0xff).foo;
>(<any>0xff).foo : any
>(<any>0xff) : any
><any>0xff : any
>0xff : number
>foo : any
(<any>(1.0));
>(<any>(1.0)) : any
><any>(1.0) : any
>(1.0) : number
>1.0 : number
(<any>new A).foo;
>(<any>new A).foo : any
>(<any>new A) : any
@@ -0,0 +1,14 @@
tests/cases/compiler/classExpressionExtendingAbstractClass.ts(5,9): error TS2653: Non-abstract class expression does not implement inherited abstract member 'foo' from class 'A'.
==== tests/cases/compiler/classExpressionExtendingAbstractClass.ts (1 errors) ====
abstract class A {
abstract foo(): void;
}
var C = class extends A { // no error reported!
~~~~~
!!! error TS2653: Non-abstract class expression does not implement inherited abstract member 'foo' from class 'A'.
};
@@ -0,0 +1,28 @@
//// [classExpressionExtendingAbstractClass.ts]
abstract class A {
abstract foo(): void;
}
var C = class extends A { // no error reported!
};
//// [classExpressionExtendingAbstractClass.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var A = (function () {
function A() {
}
return A;
})();
var C = (function (_super) {
__extends(class_1, _super);
function class_1() {
_super.apply(this, arguments);
}
return class_1;
})(A);
@@ -1,7 +1,12 @@
//// [tests/cases/compiler/commentOnAmbientClass1.ts] ////
//// [a.ts]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare class C {
}
@@ -15,6 +20,9 @@ declare class E extends C {
}
//// [a.js]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
//// [b.js]
///<reference path="a.ts"/>
@@ -5,13 +5,18 @@ declare class E extends C {
>C : Symbol(C, Decl(a.ts, 0, 0))
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare class C {
>C : Symbol(C, Decl(a.ts, 0, 0))
}
// Don't keep this comment.
declare class D {
>D : Symbol(D, Decl(a.ts, 2, 1))
>D : Symbol(D, Decl(a.ts, 7, 1))
}
@@ -5,7 +5,12 @@ declare class E extends C {
>C : C
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare class C {
>C : C
}
@@ -1,7 +1,12 @@
//// [tests/cases/compiler/commentOnAmbientEnum.ts] ////
//// [a.ts]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare enum C {
a,
b,
@@ -18,6 +23,9 @@ declare enum E {
}
//// [a.js]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
//// [b.js]
///<reference path="a.ts"/>
@@ -4,22 +4,27 @@ declare enum E {
>E : Symbol(E, Decl(b.ts, 0, 0))
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare enum C {
>C : Symbol(C, Decl(a.ts, 0, 0))
a,
>a : Symbol(C.a, Decl(a.ts, 1, 16))
>a : Symbol(C.a, Decl(a.ts, 6, 16))
b,
>b : Symbol(C.b, Decl(a.ts, 2, 6))
>b : Symbol(C.b, Decl(a.ts, 7, 6))
c
>c : Symbol(C.c, Decl(a.ts, 3, 6))
>c : Symbol(C.c, Decl(a.ts, 8, 6))
}
// Don't keep this comment.
declare enum D {
>D : Symbol(D, Decl(a.ts, 5, 1))
>D : Symbol(D, Decl(a.ts, 10, 1))
}
@@ -4,7 +4,12 @@ declare enum E {
>E : E
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare enum C {
>C : C
@@ -1,7 +1,12 @@
//// [tests/cases/compiler/commentOnAmbientModule.ts] ////
//// [a.ts]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare module C {
function foo();
}
@@ -20,6 +25,9 @@ declare module E {
}
//// [a.js]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
//// [b.js]
///<reference path="a.ts"/>
@@ -5,28 +5,33 @@ declare module E {
class foobar extends D.bar {
>foobar : Symbol(foobar, Decl(b.ts, 1, 18))
>D.bar : Symbol(D.bar, Decl(a.ts, 6, 18))
>D : Symbol(D, Decl(a.ts, 3, 1))
>bar : Symbol(D.bar, Decl(a.ts, 6, 18))
>D.bar : Symbol(D.bar, Decl(a.ts, 11, 18))
>D : Symbol(D, Decl(a.ts, 8, 1))
>bar : Symbol(D.bar, Decl(a.ts, 11, 18))
foo();
>foo : Symbol(foo, Decl(b.ts, 2, 32))
}
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare module C {
>C : Symbol(C, Decl(a.ts, 0, 0))
function foo();
>foo : Symbol(foo, Decl(a.ts, 1, 18))
>foo : Symbol(foo, Decl(a.ts, 6, 18))
}
// Don't keep this comment.
declare module D {
>D : Symbol(D, Decl(a.ts, 3, 1))
>D : Symbol(D, Decl(a.ts, 8, 1))
class bar { }
>bar : Symbol(bar, Decl(a.ts, 6, 18))
>bar : Symbol(bar, Decl(a.ts, 11, 18))
}
@@ -14,7 +14,12 @@ declare module E {
}
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare module C {
>C : typeof C
@@ -1,9 +1,17 @@
//// [commentOnAmbientVariable1.ts]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare var v: number;
// Don't keep this comment.
declare var y: number;
//// [commentOnAmbientVariable1.js]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
@@ -1,9 +1,14 @@
=== tests/cases/compiler/commentOnAmbientVariable1.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare var v: number;
>v : Symbol(v, Decl(commentOnAmbientVariable1.ts, 1, 11))
>v : Symbol(v, Decl(commentOnAmbientVariable1.ts, 6, 11))
// Don't keep this comment.
declare var y: number;
>y : Symbol(y, Decl(commentOnAmbientVariable1.ts, 4, 11))
>y : Symbol(y, Decl(commentOnAmbientVariable1.ts, 9, 11))
@@ -1,5 +1,10 @@
=== tests/cases/compiler/commentOnAmbientVariable1.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare var v: number;
>v : number
@@ -1,7 +1,12 @@
//// [tests/cases/compiler/commentOnAmbientfunction.ts] ////
//// [a.ts]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare function foo();
// Don't keep this comment.
@@ -12,6 +17,9 @@ declare function bar();
declare function foobar(a: typeof foo): typeof bar;
//// [a.js]
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
//// [b.js]
///<reference path="a.ts"/>
@@ -4,14 +4,19 @@ declare function foobar(a: typeof foo): typeof bar;
>foobar : Symbol(foobar, Decl(b.ts, 0, 0))
>a : Symbol(a, Decl(b.ts, 1, 24))
>foo : Symbol(foo, Decl(a.ts, 0, 0))
>bar : Symbol(bar, Decl(a.ts, 1, 23))
>bar : Symbol(bar, Decl(a.ts, 6, 23))
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare function foo();
>foo : Symbol(foo, Decl(a.ts, 0, 0))
// Don't keep this comment.
declare function bar();
>bar : Symbol(bar, Decl(a.ts, 1, 23))
>bar : Symbol(bar, Decl(a.ts, 6, 23))
@@ -7,7 +7,12 @@ declare function foobar(a: typeof foo): typeof bar;
>bar : () => any
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare function foo();
>foo : () => any
@@ -1,7 +1,12 @@
//// [tests/cases/compiler/commentOnElidedModule1.ts] ////
//// [a.ts]
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
module ElidedModule {
}
@@ -15,6 +20,9 @@ module ElidedModule3 {
}
//// [a.js]
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
//// [b.js]
///<reference path="a.ts"/>
@@ -4,13 +4,18 @@ module ElidedModule3 {
>ElidedModule3 : Symbol(ElidedModule3, Decl(b.ts, 0, 0))
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
module ElidedModule {
>ElidedModule : Symbol(ElidedModule, Decl(a.ts, 0, 0))
}
// Don't keep this comment.
module ElidedModule2 {
>ElidedModule2 : Symbol(ElidedModule2, Decl(a.ts, 2, 1))
>ElidedModule2 : Symbol(ElidedModule2, Decl(a.ts, 7, 1))
}
@@ -4,7 +4,12 @@ module ElidedModule3 {
>ElidedModule3 : any
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
module ElidedModule {
>ElidedModule : any
}
@@ -1,7 +1,12 @@
//// [tests/cases/compiler/commentOnInterface1.ts] ////
//// [a.ts]
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
interface I {
}
@@ -15,6 +20,9 @@ interface I3 {
}
//// [a.js]
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
//// [b.js]
///<reference path='a.ts'/>
@@ -4,13 +4,18 @@ interface I3 {
>I3 : Symbol(I3, Decl(b.ts, 0, 0))
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
interface I {
>I : Symbol(I, Decl(a.ts, 0, 0))
}
// Don't keep this comment.
interface I2 {
>I2 : Symbol(I2, Decl(a.ts, 2, 1))
>I2 : Symbol(I2, Decl(a.ts, 7, 1))
}
@@ -4,7 +4,12 @@ interface I3 {
>I3 : I3
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
interface I {
>I : I
}
@@ -1,7 +1,12 @@
//// [tests/cases/compiler/commentOnSignature1.ts] ////
//// [a.ts]
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
function foo(n: number): void;
// Don't keep this comment.
function foo(s: string): void;
@@ -33,14 +38,15 @@ function foo2(a: any): void {
}
//// [a.js]
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
function foo(a) {
}
var c = (function () {
/*! keep this pinned comment */
function c(a) {
}
/*! keep this pinned comment */
c.prototype.foo = function (a) {
};
return c;
@@ -14,49 +14,54 @@ function foo2(a: any): void {
>a : Symbol(a, Decl(b.ts, 4, 14))
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
function foo(n: number): void;
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30))
>n : Symbol(n, Decl(a.ts, 1, 13))
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30))
>n : Symbol(n, Decl(a.ts, 6, 13))
// Don't keep this comment.
function foo(s: string): void;
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30))
>s : Symbol(s, Decl(a.ts, 3, 13))
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30))
>s : Symbol(s, Decl(a.ts, 8, 13))
function foo(a: any): void {
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30))
>a : Symbol(a, Decl(a.ts, 4, 13))
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30))
>a : Symbol(a, Decl(a.ts, 9, 13))
}
class c {
>c : Symbol(c, Decl(a.ts, 5, 1))
>c : Symbol(c, Decl(a.ts, 10, 1))
// dont keep this comment
constructor(a: string);
>a : Symbol(a, Decl(a.ts, 9, 16))
>a : Symbol(a, Decl(a.ts, 14, 16))
/*! keep this pinned comment */
constructor(a: number);
>a : Symbol(a, Decl(a.ts, 11, 16))
>a : Symbol(a, Decl(a.ts, 16, 16))
constructor(a: any) {
>a : Symbol(a, Decl(a.ts, 12, 16))
>a : Symbol(a, Decl(a.ts, 17, 16))
}
// dont keep this comment
foo(a: string);
>foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19))
>a : Symbol(a, Decl(a.ts, 16, 8))
>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19))
>a : Symbol(a, Decl(a.ts, 21, 8))
/*! keep this pinned comment */
foo(a: number);
>foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19))
>a : Symbol(a, Decl(a.ts, 18, 8))
>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19))
>a : Symbol(a, Decl(a.ts, 23, 8))
foo(a: any) {
>foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19))
>a : Symbol(a, Decl(a.ts, 19, 8))
>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19))
>a : Symbol(a, Decl(a.ts, 24, 8))
}
}
@@ -14,7 +14,12 @@ function foo2(a: any): void {
>a : any
}
=== tests/cases/compiler/a.ts ===
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
function foo(n: number): void;
>foo : { (n: number): void; (s: string): void; }
>n : number
@@ -0,0 +1,33 @@
//// [doNotEmitDetachedComments.ts]
/*
multi line
comment
*/
var x = 10;
// Single Line comment
function foo() { }
/*
multi-line comment
*/
//========================
function bar() { }
//========================
//// [doNotEmitDetachedComments.js]
var x = 10;
function foo() { }
function bar() { }
@@ -0,0 +1,31 @@
=== tests/cases/compiler/doNotEmitDetachedComments.ts ===
/*
multi line
comment
*/
var x = 10;
>x : Symbol(x, Decl(doNotEmitDetachedComments.ts, 6, 3))
// Single Line comment
function foo() { }
>foo : Symbol(foo, Decl(doNotEmitDetachedComments.ts, 6, 11))
/*
multi-line comment
*/
//========================
function bar() { }
>bar : Symbol(bar, Decl(doNotEmitDetachedComments.ts, 10, 18))
//========================
@@ -0,0 +1,32 @@
=== tests/cases/compiler/doNotEmitDetachedComments.ts ===
/*
multi line
comment
*/
var x = 10;
>x : number
>10 : number
// Single Line comment
function foo() { }
>foo : () => void
/*
multi-line comment
*/
//========================
function bar() { }
>bar : () => void
//========================
@@ -0,0 +1,64 @@
//// [doNotEmitDetachedCommentsAtStartOfConstructor.ts]
class A {
constructor() {
// Single Line Comment
var x = 10;
}
}
class B {
constructor() {
/*
Multi-line comment
*/
var y = 10;
}
}
class C {
constructor() {
// Single Line Comment with more than one blank line
var x = 10;
}
}
class D {
constructor() {
/*
Multi-line comment with more than one blank line
*/
var y = 10;
}
}
//// [doNotEmitDetachedCommentsAtStartOfConstructor.js]
var A = (function () {
function A() {
var x = 10;
}
return A;
})();
var B = (function () {
function B() {
var y = 10;
}
return B;
})();
var C = (function () {
function C() {
var x = 10;
}
return C;
})();
var D = (function () {
function D() {
var y = 10;
}
return D;
})();
@@ -0,0 +1,50 @@
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts ===
class A {
>A : Symbol(A, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 0, 0))
constructor() {
// Single Line Comment
var x = 10;
>x : Symbol(x, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 4, 11))
}
}
class B {
>B : Symbol(B, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 6, 1))
constructor() {
/*
Multi-line comment
*/
var y = 10;
>y : Symbol(y, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 14, 11))
}
}
class C {
>C : Symbol(C, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 16, 1))
constructor() {
// Single Line Comment with more than one blank line
var x = 10;
>x : Symbol(x, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 23, 11))
}
}
class D {
>D : Symbol(D, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 25, 1))
constructor() {
/*
Multi-line comment with more than one blank line
*/
var y = 10;
>y : Symbol(y, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 34, 11))
}
}
@@ -0,0 +1,54 @@
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts ===
class A {
>A : A
constructor() {
// Single Line Comment
var x = 10;
>x : number
>10 : number
}
}
class B {
>B : B
constructor() {
/*
Multi-line comment
*/
var y = 10;
>y : number
>10 : number
}
}
class C {
>C : C
constructor() {
// Single Line Comment with more than one blank line
var x = 10;
>x : number
>10 : number
}
}
class D {
>D : D
constructor() {
/*
Multi-line comment with more than one blank line
*/
var y = 10;
>y : number
>10 : number
}
}
@@ -0,0 +1,48 @@
//// [doNotEmitDetachedCommentsAtStartOfFunctionBody.ts]
function foo1() {
// Single line comment
return 42;
}
function foo2() {
/*
multi line
comment
*/
return 42;
}
function foo3() {
// Single line comment with more than one blank line
return 42;
}
function foo4() {
/*
multi line comment with more than one blank line
*/
return 42;
}
//// [doNotEmitDetachedCommentsAtStartOfFunctionBody.js]
function foo1() {
return 42;
}
function foo2() {
return 42;
}
function foo3() {
return 42;
}
function foo4() {
return 42;
}
@@ -0,0 +1,42 @@
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts ===
function foo1() {
>foo1 : Symbol(foo1, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 0, 0))
// Single line comment
return 42;
}
function foo2() {
>foo2 : Symbol(foo2, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 4, 1))
/*
multi line
comment
*/
return 42;
}
function foo3() {
>foo3 : Symbol(foo3, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 14, 1))
// Single line comment with more than one blank line
return 42;
}
function foo4() {
>foo4 : Symbol(foo4, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 21, 1))
/*
multi line comment with more than one blank line
*/
return 42;
}
@@ -0,0 +1,46 @@
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts ===
function foo1() {
>foo1 : () => number
// Single line comment
return 42;
>42 : number
}
function foo2() {
>foo2 : () => number
/*
multi line
comment
*/
return 42;
>42 : number
}
function foo3() {
>foo3 : () => number
// Single line comment with more than one blank line
return 42;
>42 : number
}
function foo4() {
>foo4 : () => number
/*
multi line comment with more than one blank line
*/
return 42;
>42 : number
}
@@ -0,0 +1,45 @@
//// [doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts]
() => {
// Single line comment
return 0;
}
() => {
/*
multi-line comment
*/
return 0;
}
() => {
// Single line comment with more than one blank line
return 0;
}
() => {
/*
multi-line comment with more than one blank line
*/
return 0;
}
//// [doNotEmitDetachedCommentsAtStartOfLambdaFunction.js]
(function () {
return 0;
});
(function () {
return 0;
});
(function () {
return 0;
});
(function () {
return 0;
});
@@ -0,0 +1,32 @@
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts ===
() => {
No type information for this code. // Single line comment
No type information for this code.
No type information for this code. return 0;
No type information for this code.}
No type information for this code.
No type information for this code.() => {
No type information for this code. /*
No type information for this code. multi-line comment
No type information for this code. */
No type information for this code.
No type information for this code. return 0;
No type information for this code.}
No type information for this code.
No type information for this code.() => {
No type information for this code. // Single line comment with more than one blank line
No type information for this code.
No type information for this code.
No type information for this code. return 0;
No type information for this code.}
No type information for this code.
No type information for this code.() => {
No type information for this code. /*
No type information for this code. multi-line comment with more than one blank line
No type information for this code. */
No type information for this code.
No type information for this code.
No type information for this code. return 0;
No type information for this code.}
No type information for this code.
No type information for this code.
@@ -0,0 +1,43 @@
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts ===
() => {
>() => { // Single line comment return 0;} : () => number
// Single line comment
return 0;
>0 : number
}
() => {
>() => { /* multi-line comment */ return 0;} : () => number
/*
multi-line comment
*/
return 0;
>0 : number
}
() => {
>() => { // Single line comment with more than one blank line return 0;} : () => number
// Single line comment with more than one blank line
return 0;
>0 : number
}
() => {
>() => { /* multi-line comment with more than one blank line */ return 0;} : () => number
/*
multi-line comment with more than one blank line
*/
return 0;
>0 : number
}
@@ -0,0 +1,14 @@
//// [doNotEmitPinnedCommentNotOnTopOfFile.ts]
var x = 10;
/*!
multi line
comment
*/
var x = 10;
//// [doNotEmitPinnedCommentNotOnTopOfFile.js]
var x = 10;
var x = 10;
@@ -0,0 +1,13 @@
=== tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts ===
var x = 10;
>x : Symbol(x, Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 0, 3), Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 8, 3))
/*!
multi line
comment
*/
var x = 10;
>x : Symbol(x, Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 0, 3), Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 8, 3))
@@ -0,0 +1,15 @@
=== tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts ===
var x = 10;
>x : number
>10 : number
/*!
multi line
comment
*/
var x = 10;
>x : number
>10 : number
@@ -0,0 +1,21 @@
//// [doNotEmitPinnedCommentOnNotEmittedNode.ts]
class C {
/*! remove pinned comment anywhere else */
public foo(x: string, y: any)
public foo(x: string, y: number) { }
}
var x = 10;
/*! remove pinned comment anywhere else */
declare var OData: any;
//// [doNotEmitPinnedCommentOnNotEmittedNode.js]
var C = (function () {
function C() {
}
C.prototype.foo = function (x, y) { };
return C;
})();
var x = 10;
@@ -0,0 +1,24 @@
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts ===
class C {
>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 0, 0))
/*! remove pinned comment anywhere else */
public foo(x: string, y: any)
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33))
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 15))
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 25))
public foo(x: string, y: number) { }
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33))
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 15))
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 25))
}
var x = 10;
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 7, 3))
/*! remove pinned comment anywhere else */
declare var OData: any;
>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 10, 11))
@@ -0,0 +1,25 @@
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts ===
class C {
>C : C
/*! remove pinned comment anywhere else */
public foo(x: string, y: any)
>foo : (x: string, y: any) => any
>x : string
>y : any
public foo(x: string, y: number) { }
>foo : (x: string, y: any) => any
>x : string
>y : number
}
var x = 10;
>x : number
>10 : number
/*! remove pinned comment anywhere else */
declare var OData: any;
>OData : any
@@ -0,0 +1,18 @@
//// [doNotEmitPinnedCommentOnNotEmittedNodets.ts]
class C {
/*! remove pinned comment anywhere else */
public foo(x: string, y: any)
public foo(x: string, y: number) { }
}
/*! remove pinned comment anywhere else */
declare var OData: any;
//// [doNotEmitPinnedCommentOnNotEmittedNodets.js]
var C = (function () {
function C() {
}
C.prototype.foo = function (x, y) { };
return C;
})();
@@ -0,0 +1,21 @@
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts ===
class C {
>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 0, 0))
/*! remove pinned comment anywhere else */
public foo(x: string, y: any)
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 33))
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 15))
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 25))
public foo(x: string, y: number) { }
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 33))
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 4, 15))
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 4, 25))
}
/*! remove pinned comment anywhere else */
declare var OData: any;
>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 8, 11))
@@ -0,0 +1,21 @@
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts ===
class C {
>C : C
/*! remove pinned comment anywhere else */
public foo(x: string, y: any)
>foo : (x: string, y: any) => any
>x : string
>y : any
public foo(x: string, y: number) { }
>foo : (x: string, y: any) => any
>x : string
>y : number
}
/*! remove pinned comment anywhere else */
declare var OData: any;
>OData : any
@@ -0,0 +1,42 @@
//// [doNotEmitPinnedDetachedComments.ts]
var x = 10;
/*! Single Line comment */
function baz() { }
/*!
multi-line comment
*/
//========================
function bar() {
/*!
Remove this comment
*/
}
function foo() {
/*! Remove this */
return 0;
}
//========================
//// [doNotEmitPinnedDetachedComments.js]
var x = 10;
function baz() { }
function bar() {
}
function foo() {
return 0;
}
@@ -0,0 +1,39 @@
=== tests/cases/compiler/doNotEmitPinnedDetachedComments.ts ===
var x = 10;
>x : Symbol(x, Decl(doNotEmitPinnedDetachedComments.ts, 0, 3))
/*! Single Line comment */
function baz() { }
>baz : Symbol(baz, Decl(doNotEmitPinnedDetachedComments.ts, 0, 11))
/*!
multi-line comment
*/
//========================
function bar() {
>bar : Symbol(bar, Decl(doNotEmitPinnedDetachedComments.ts, 4, 18))
/*!
Remove this comment
*/
}
function foo() {
>foo : Symbol(foo, Decl(doNotEmitPinnedDetachedComments.ts, 21, 1))
/*! Remove this */
return 0;
}
//========================
@@ -0,0 +1,41 @@
=== tests/cases/compiler/doNotEmitPinnedDetachedComments.ts ===
var x = 10;
>x : number
>10 : number
/*! Single Line comment */
function baz() { }
>baz : () => void
/*!
multi-line comment
*/
//========================
function bar() {
>bar : () => void
/*!
Remove this comment
*/
}
function foo() {
>foo : () => number
/*! Remove this */
return 0;
>0 : number
}
//========================
@@ -0,0 +1,15 @@
//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts] ////
//// [file0.ts]
//// [file1.ts]
//// [file2.ts]
/// <reference path="file0.ts" />
/// <reference path="file1.ts" />
/// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
//// [file0.js]
//// [file1.js]
//// [file2.js]
@@ -0,0 +1,10 @@
=== tests/cases/compiler/file2.ts ===
/// <reference path="file0.ts" />
No type information for this code./// <reference path="file1.ts" />
No type information for this code./// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
No type information for this code.=== tests/cases/compiler/file0.ts ===
No type information for this code.
No type information for this code.=== tests/cases/compiler/file1.ts ===
No type information for this code.
@@ -0,0 +1,10 @@
=== tests/cases/compiler/file2.ts ===
/// <reference path="file0.ts" />
No type information for this code./// <reference path="file1.ts" />
No type information for this code./// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
No type information for this code.=== tests/cases/compiler/file0.ts ===
No type information for this code.
No type information for this code.=== tests/cases/compiler/file1.ts ===
No type information for this code.
@@ -0,0 +1,15 @@
//// [tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts] ////
//// [file0.ts]
/// <reference path="file1.ts" />
declare var OData: any;
//// [file1.ts]
/// <reference path="file0.ts" />
interface F { }
//// [file0.js]
//// [file1.js]
@@ -0,0 +1,12 @@
=== tests/cases/compiler/file1.ts ===
/// <reference path="file0.ts" />
interface F { }
>F : Symbol(F, Decl(file1.ts, 0, 0))
=== tests/cases/compiler/file0.ts ===
/// <reference path="file1.ts" />
declare var OData: any;
>OData : Symbol(OData, Decl(file0.ts, 2, 11))
@@ -0,0 +1,12 @@
=== tests/cases/compiler/file1.ts ===
/// <reference path="file0.ts" />
interface F { }
>F : F
=== tests/cases/compiler/file0.ts ===
/// <reference path="file1.ts" />
declare var OData: any;
>OData : any
@@ -0,0 +1,46 @@
//// [tests/cases/compiler/doNotemitTripleSlashComments.ts] ////
//// [file0.ts]
/// <reference path="file1.ts" />
/// <reference path="file2.ts" />
/// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
var x = 10;
/// <reference path="file1.ts" />
var y = "hello";
/// <reference path="file2.ts" />
//// [file1.ts]
/// <reference path="file0.ts" />
function foo() { }
/// <reference path="file0.ts" />
var z = "world";
//// [file2.ts]
/// <reference path="file1.ts" />
/// ====================================
function bar() { }
//// [file0.js]
var x = 10;
var y = "hello";
//// [file1.js]
function foo() { }
var z = "world";
//// [file2.js]
function bar() { }
@@ -0,0 +1,40 @@
=== tests/cases/compiler/file2.ts ===
/// <reference path="file1.ts" />
/// ====================================
function bar() { }
>bar : Symbol(bar, Decl(file2.ts, 0, 0))
=== tests/cases/compiler/file0.ts ===
/// <reference path="file1.ts" />
/// <reference path="file2.ts" />
/// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
var x = 10;
>x : Symbol(x, Decl(file0.ts, 4, 3))
/// <reference path="file1.ts" />
var y = "hello";
>y : Symbol(y, Decl(file0.ts, 7, 3))
/// <reference path="file2.ts" />
=== tests/cases/compiler/file1.ts ===
/// <reference path="file0.ts" />
function foo() { }
>foo : Symbol(foo, Decl(file1.ts, 0, 0))
/// <reference path="file0.ts" />
var z = "world";
>z : Symbol(z, Decl(file1.ts, 8, 3))
@@ -0,0 +1,43 @@
=== tests/cases/compiler/file2.ts ===
/// <reference path="file1.ts" />
/// ====================================
function bar() { }
>bar : () => void
=== tests/cases/compiler/file0.ts ===
/// <reference path="file1.ts" />
/// <reference path="file2.ts" />
/// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
var x = 10;
>x : number
>10 : number
/// <reference path="file1.ts" />
var y = "hello";
>y : string
>"hello" : string
/// <reference path="file2.ts" />
=== tests/cases/compiler/file1.ts ===
/// <reference path="file0.ts" />
function foo() { }
>foo : () => void
/// <reference path="file0.ts" />
var z = "world";
>z : string
>"world" : string
@@ -0,0 +1,16 @@
//// [emitPinnedCommentsOnTopOfFile.ts]
/*!
multi line
comment
*/
var x = 10;
//// [emitPinnedCommentsOnTopOfFile.js]
/*!
multi line
comment
*/
var x = 10;
@@ -0,0 +1,10 @@
=== tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts ===
/*!
multi line
comment
*/
var x = 10;
>x : Symbol(x, Decl(emitPinnedCommentsOnTopOfFile.ts, 6, 3))
@@ -0,0 +1,11 @@
=== tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts ===
/*!
multi line
comment
*/
var x = 10;
>x : number
>10 : number
@@ -0,0 +1,20 @@
//// [tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts] ////
//// [file0.ts]
var x = 10
//// [file1.ts]
/// <reference path="file0.ts" />
declare var OData: any;
/// <reference path="file0.ts" />
interface F { }
//// [file0.js]
var x = 10;
//// [file1.js]
/// <reference path="file0.ts" />
@@ -0,0 +1,16 @@
=== tests/cases/compiler/file1.ts ===
/// <reference path="file0.ts" />
declare var OData: any;
>OData : Symbol(OData, Decl(file1.ts, 1, 11))
/// <reference path="file0.ts" />
interface F { }
>F : Symbol(F, Decl(file1.ts, 1, 23))
=== tests/cases/compiler/file0.ts ===
var x = 10
>x : Symbol(x, Decl(file0.ts, 1, 3))
@@ -0,0 +1,17 @@
=== tests/cases/compiler/file1.ts ===
/// <reference path="file0.ts" />
declare var OData: any;
>OData : any
/// <reference path="file0.ts" />
interface F { }
>F : F
=== tests/cases/compiler/file0.ts ===
var x = 10
>x : number
>10 : number
@@ -0,0 +1,7 @@
//// [jsxEmitAttributeWithPreserve.tsx]
declare var React: any;
<foo data/>
//// [jsxEmitAttributeWithPreserve.jsx]
<foo data/>;
@@ -0,0 +1,8 @@
=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx ===
declare var React: any;
>React : Symbol(React, Decl(jsxEmitAttributeWithPreserve.tsx, 1, 11))
<foo data/>
>data : Symbol(unknown)
@@ -0,0 +1,10 @@
=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx ===
declare var React: any;
>React : any
<foo data/>
><foo data/> : any
>foo : any
>data : any
@@ -47,9 +47,9 @@ a / > ;
< a;
b > ;
b > ;
<a b= c=></a>;
<a b c></a>;
b.c > ;
<a.b c=></a.b>;
<a.b c></a.b>;
c > ;
<a.b.c></a>;
< .a > ;
@@ -67,7 +67,7 @@ var x = <div>one</div><div>two</div>;;
var x = <div>one</div> /* intervening comment */ /* intervening comment */ <div>two</div>;;
<a>{"str"}}</a>;
<span className="a"/> id="b" />;
<div className=/>>;
<div className/>>;
<div {...props}/>;
<div>stuff</div>...props}>;
@@ -158,14 +158,14 @@ var x = <div attr1={"foo" + "bar"} attr2={"foo" + "bar" +
<Component constructor="foo"/>;
<Namespace.Component />;
<Namespace.DeepNamespace.Component />;
<Component {...x} y={2} z=/>;
<Component {...x} y={2} z/>;
<Component {...this.props} sound="moo"/>;
<font-face />;
<Component x={y}/>;
<x-component />;
<Component {...x}/>;
<Component {...x} y={2}/>;
<Component {...x} y={2} z=/>;
<Component {...x} y={2} z/>;
<Component x={1} {...y}/>;
<Component x={1} y="2" {...z} {...z}><Child /></Component>;
<Component x="1" {...(z = { y: 2 }, z)} z={3}>Text</Component>;
@@ -0,0 +1,14 @@
//// [keywordInJsxIdentifier.tsx]
declare var React: any;
<foo class-id/>;
<foo class/>;
<foo class-id="1"/>;
<foo class="1"/>;
//// [keywordInJsxIdentifier.js]
React.createElement("foo", {"class-id": true});
React.createElement("foo", {"class": true});
React.createElement("foo", {"class-id": "1"});
React.createElement("foo", {"class": "1"});
@@ -0,0 +1,17 @@
=== tests/cases/compiler/keywordInJsxIdentifier.tsx ===
declare var React: any;
>React : Symbol(React, Decl(keywordInJsxIdentifier.tsx, 1, 11))
<foo class-id/>;
>class-id : Symbol(unknown)
<foo class/>;
>class : Symbol(unknown)
<foo class-id="1"/>;
>class-id : Symbol(unknown)
<foo class="1"/>;
>class : Symbol(unknown)
@@ -0,0 +1,25 @@
=== tests/cases/compiler/keywordInJsxIdentifier.tsx ===
declare var React: any;
>React : any
<foo class-id/>;
><foo class-id/> : any
>foo : any
>class-id : any
<foo class/>;
><foo class/> : any
>foo : any
>class : any
<foo class-id="1"/>;
><foo class-id="1"/> : any
>foo : any
>class-id : any
<foo class="1"/>;
><foo class="1"/> : any
>foo : any
>class : any
+9 -2
View File
@@ -1,12 +1,19 @@
//// [pinnedComments1.ts]
/*!=========
Keep this pinned comment
=========
*/
/* unpinned comment */
/*! pinned comment */
/*! pinned comment that need to be removed */
class C {
}
//// [pinnedComments1.js]
/*! pinned comment */
/*!=========
Keep this pinned comment
=========
*/
var C = (function () {
function C() {
}
@@ -1,7 +1,11 @@
=== tests/cases/compiler/pinnedComments1.ts ===
/*!=========
Keep this pinned comment
=========
*/
/* unpinned comment */
/*! pinned comment */
/*! pinned comment that need to be removed */
class C {
>C : Symbol(C, Decl(pinnedComments1.ts, 0, 0))
}
@@ -1,7 +1,11 @@
=== tests/cases/compiler/pinnedComments1.ts ===
/*!=========
Keep this pinned comment
=========
*/
/* unpinned comment */
/*! pinned comment */
/*! pinned comment that need to be removed */
class C {
>C : C
}
@@ -20,10 +20,10 @@ declare module JSX {
//// [tsxAttributeResolution6.jsx]
// Error
<test1 s=/>;
<test1 s/>;
<test1 n='true'/>;
<test2 />;
// OK
<test1 n=/>;
<test1 n/>;
<test1 n={false}/>;
<test2 n=/>;
<test2 n/>;
@@ -42,5 +42,5 @@ x3();
var x4 = <T extends={true}>() => </T>;
x4.isElement;
// This is an element
var x5 = <T extends=>() => </T>;
var x5 = <T extends>() => </T>;
x5.isElement;
@@ -6,6 +6,11 @@ declare var a;
(<any>[1,3,]);
(<any>"string");
(<any>23.0);
(<any>1);
(<any>1.);
(<any>1.0);
(<any>12e+34);
(<any>0xff);
(<any>/regexp/g);
(<any>false);
(<any>true);
@@ -22,6 +27,12 @@ declare var a;
declare var A;
// should keep the parentheses in emit
(<any>1).foo;
(<any>1.).foo;
(<any>1.0).foo;
(<any>12e+34).foo;
(<any>0xff).foo;
(<any>(1.0));
(<any>new A).foo;
(<any>typeof A).x;
(<any>-A).x;
@@ -0,0 +1,7 @@
abstract class A {
abstract foo(): void;
}
var C = class extends A { // no error reported!
};
@@ -1,5 +1,10 @@
//@filename: a.ts
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare class C {
}
+6 -1
View File
@@ -1,5 +1,10 @@
//@filename: a.ts
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare enum C {
a,
b,
@@ -1,5 +1,10 @@
//@filename: a.ts
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare module C {
function foo();
}
@@ -1,4 +1,9 @@
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare var v: number;
// Don't keep this comment.
@@ -1,5 +1,10 @@
//@filename: a.ts
/*! Keep this pinned comment */
/*!=========
Keep this pinned comment
=========
*/
/*! Don't keep this pinned comment */
declare function foo();
// Don't keep this comment.
@@ -1,5 +1,10 @@
//@filename: a.ts
/*! Keep this pinned comment */
/*!=================
Keep this pinned
=================
*/
/*! Don't keep this pinned comment */
module ElidedModule {
}

Some files were not shown because too many files have changed in this diff Show More