mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
merge with origin/master
This commit is contained in:
@@ -306,7 +306,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
|
||||
handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning));
|
||||
handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true));
|
||||
recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ namespace ts {
|
||||
const jsDocComments = getJsDocCommentsFromText(declaration, currentText);
|
||||
emitNewLineBeforeLeadingComments(currentLineMap, writer, declaration, jsDocComments);
|
||||
// jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
emitComments(currentText, currentLineMap, writer, jsDocComments, /*trailingSeparator*/ true, newLine, writeCommentRange);
|
||||
emitComments(currentText, currentLineMap, writer, jsDocComments, /*leadingSeparator*/ false, /*trailingSeparator*/ true, newLine, writeCommentRange);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,12 +655,13 @@ namespace ts {
|
||||
function emitModuleElementDeclarationFlags(node: Node) {
|
||||
// If the node is parented in the current source file we need to emit export declare or just export
|
||||
if (node.parent.kind === SyntaxKind.SourceFile) {
|
||||
const modifiers = getModifierFlags(node);
|
||||
// If the node is exported
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (modifiers & ModifierFlags.Export) {
|
||||
write("export ");
|
||||
}
|
||||
|
||||
if (node.flags & NodeFlags.Default) {
|
||||
if (modifiers & ModifierFlags.Default) {
|
||||
write("default ");
|
||||
}
|
||||
else if (node.kind !== SyntaxKind.InterfaceDeclaration && !noDeclare) {
|
||||
@@ -669,21 +670,21 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitClassMemberDeclarationFlags(flags: NodeFlags) {
|
||||
if (flags & NodeFlags.Private) {
|
||||
function emitClassMemberDeclarationFlags(flags: ModifierFlags) {
|
||||
if (flags & ModifierFlags.Private) {
|
||||
write("private ");
|
||||
}
|
||||
else if (flags & NodeFlags.Protected) {
|
||||
else if (flags & ModifierFlags.Protected) {
|
||||
write("protected ");
|
||||
}
|
||||
|
||||
if (flags & NodeFlags.Static) {
|
||||
if (flags & ModifierFlags.Static) {
|
||||
write("static ");
|
||||
}
|
||||
if (flags & NodeFlags.Readonly) {
|
||||
if (flags & ModifierFlags.Readonly) {
|
||||
write("readonly ");
|
||||
}
|
||||
if (flags & NodeFlags.Abstract) {
|
||||
if (flags & ModifierFlags.Abstract) {
|
||||
write("abstract ");
|
||||
}
|
||||
}
|
||||
@@ -692,7 +693,7 @@ namespace ts {
|
||||
// note usage of writer. methods instead of aliases created, just to make sure we are using
|
||||
// correct writer especially to handle asynchronous alias writing
|
||||
emitJsDocComments(node);
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
write("export ");
|
||||
}
|
||||
write("import ");
|
||||
@@ -731,7 +732,7 @@ namespace ts {
|
||||
|
||||
function writeImportDeclaration(node: ImportDeclaration) {
|
||||
emitJsDocComments(node);
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
write("export ");
|
||||
}
|
||||
write("import ");
|
||||
@@ -926,7 +927,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isPrivateMethodTypeParameter(node: TypeParameterDeclaration) {
|
||||
return node.parent.kind === SyntaxKind.MethodDeclaration && (node.parent.flags & NodeFlags.Private);
|
||||
return node.parent.kind === SyntaxKind.MethodDeclaration && hasModifier(node.parent, ModifierFlags.Private);
|
||||
}
|
||||
|
||||
function emitTypeParameters(typeParameters: TypeParameterDeclaration[]) {
|
||||
@@ -976,7 +977,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (node.parent.flags & NodeFlags.Static) {
|
||||
if (hasModifier(node.parent, ModifierFlags.Static)) {
|
||||
diagnosticMessage = Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
|
||||
}
|
||||
else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
@@ -1055,7 +1056,7 @@ namespace ts {
|
||||
function emitParameterProperties(constructorDeclaration: ConstructorDeclaration) {
|
||||
if (constructorDeclaration) {
|
||||
forEach(constructorDeclaration.parameters, param => {
|
||||
if (param.flags & NodeFlags.ParameterPropertyModifier) {
|
||||
if (hasModifier(param, ModifierFlags.ParameterPropertyModifier)) {
|
||||
emitPropertyDeclaration(param);
|
||||
}
|
||||
});
|
||||
@@ -1064,7 +1065,7 @@ namespace ts {
|
||||
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
if (node.flags & NodeFlags.Abstract) {
|
||||
if (hasModifier(node, ModifierFlags.Abstract)) {
|
||||
write("abstract ");
|
||||
}
|
||||
|
||||
@@ -1114,7 +1115,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
emitJsDocComments(node);
|
||||
emitClassMemberDeclarationFlags(node.flags);
|
||||
emitClassMemberDeclarationFlags(getModifierFlags(node));
|
||||
emitVariableDeclaration(<VariableDeclaration>node);
|
||||
write(";");
|
||||
writeLine();
|
||||
@@ -1141,7 +1142,7 @@ namespace ts {
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) {
|
||||
emitTypeOfVariableDeclarationFromTypeLiteral(node);
|
||||
}
|
||||
else if (!(node.flags & NodeFlags.Private)) {
|
||||
else if (!hasModifier(node, ModifierFlags.Private)) {
|
||||
writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError);
|
||||
}
|
||||
}
|
||||
@@ -1158,7 +1159,7 @@ namespace ts {
|
||||
// This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit
|
||||
else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) {
|
||||
// TODO(jfreeman): Deal with computed properties in error reporting.
|
||||
if (node.flags & NodeFlags.Static) {
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
@@ -1269,9 +1270,9 @@ namespace ts {
|
||||
if (node === accessors.firstAccessor) {
|
||||
emitJsDocComments(accessors.getAccessor);
|
||||
emitJsDocComments(accessors.setAccessor);
|
||||
emitClassMemberDeclarationFlags(node.flags | (accessors.setAccessor ? 0 : NodeFlags.Readonly));
|
||||
emitClassMemberDeclarationFlags(getModifierFlags(node) | (accessors.setAccessor ? 0 : ModifierFlags.Readonly));
|
||||
writeTextOfNode(currentText, node.name);
|
||||
if (!(node.flags & NodeFlags.Private)) {
|
||||
if (!hasModifier(node, ModifierFlags.Private)) {
|
||||
accessorWithTypeAnnotation = node;
|
||||
let type = getTypeAnnotationFromAccessor(node);
|
||||
if (!type) {
|
||||
@@ -1302,7 +1303,7 @@ namespace ts {
|
||||
let diagnosticMessage: DiagnosticMessage;
|
||||
if (accessorWithTypeAnnotation.kind === SyntaxKind.SetAccessor) {
|
||||
// Setters have to have type named and cannot infer it so, the type should always be named
|
||||
if (accessorWithTypeAnnotation.parent.flags & NodeFlags.Static) {
|
||||
if (hasModifier(accessorWithTypeAnnotation.parent, ModifierFlags.Static)) {
|
||||
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
|
||||
Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
|
||||
Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1;
|
||||
@@ -1320,7 +1321,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
else {
|
||||
if (accessorWithTypeAnnotation.flags & NodeFlags.Static) {
|
||||
if (hasModifier(accessorWithTypeAnnotation, ModifierFlags.Static)) {
|
||||
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
|
||||
@@ -1356,7 +1357,7 @@ namespace ts {
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.Constructor) {
|
||||
emitClassMemberDeclarationFlags(node.flags);
|
||||
emitClassMemberDeclarationFlags(getModifierFlags(node));
|
||||
}
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
write("function ");
|
||||
@@ -1387,7 +1388,7 @@ namespace ts {
|
||||
|
||||
if (node.kind === SyntaxKind.IndexSignature) {
|
||||
// Index signature can have readonly modifier
|
||||
emitClassMemberDeclarationFlags(node.flags);
|
||||
emitClassMemberDeclarationFlags(getModifierFlags(node));
|
||||
write("[");
|
||||
}
|
||||
else {
|
||||
@@ -1428,7 +1429,7 @@ namespace ts {
|
||||
emitType(node.type);
|
||||
}
|
||||
}
|
||||
else if (node.kind !== SyntaxKind.Constructor && !(node.flags & NodeFlags.Private)) {
|
||||
else if (node.kind !== SyntaxKind.Constructor && !hasModifier(node, ModifierFlags.Private)) {
|
||||
writeReturnTypeAtSignature(node, getReturnTypeVisibilityError);
|
||||
}
|
||||
|
||||
@@ -1468,7 +1469,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (node.flags & NodeFlags.Static) {
|
||||
if (hasModifier(node, ModifierFlags.Static)) {
|
||||
diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
|
||||
@@ -1534,7 +1535,7 @@ namespace ts {
|
||||
node.parent.parent.kind === SyntaxKind.TypeLiteral) {
|
||||
emitTypeOfVariableDeclarationFromTypeLiteral(node);
|
||||
}
|
||||
else if (!(node.parent.flags & NodeFlags.Private)) {
|
||||
else if (!hasModifier(node.parent, ModifierFlags.Private)) {
|
||||
writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError);
|
||||
}
|
||||
|
||||
@@ -1570,7 +1571,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (node.parent.flags & NodeFlags.Static) {
|
||||
if (hasModifier(node.parent, ModifierFlags.Static)) {
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
|
||||
|
||||
Reference in New Issue
Block a user